summaryrefslogtreecommitdiff
path: root/library/quickexec.cpp
Unidiff
Diffstat (limited to 'library/quickexec.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/quickexec.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/library/quickexec.cpp b/library/quickexec.cpp
index f3b5089..fad5677 100644
--- a/library/quickexec.cpp
+++ b/library/quickexec.cpp
@@ -1,41 +1,61 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
1#include <stdio.h> 21#include <stdio.h>
2#include <sys/types.h> 22#include <sys/types.h>
3#include <sys/stat.h> 23#include <sys/stat.h>
4#include <unistd.h> 24#include <unistd.h>
5#include <fcntl.h> 25#include <fcntl.h>
6 26
7#define QUICKEXEC "/tmp/.quickexec" 27#define QUICKEXEC "/tmp/.quickexec"
8 28
9int quickexecv( const char *path, const char *argv[] ) 29int quickexecv( const char *path, const char *argv[] )
10{ 30{
11 int fd = open( QUICKEXEC, O_WRONLY ); 31 int fd = open( QUICKEXEC, O_WRONLY );
12 if ( fd == -1 ) { 32 if ( fd == -1 ) {
13 perror( "quickexec pipe" ); 33 perror( "quickexec pipe" );
14 return -1; 34 return -1;
15 } 35 }
16 write( fd, path, strlen( path )+1 ); 36 write( fd, path, strlen( path )+1 );
17 const char **s = argv; 37 const char **s = argv;
18 while( *s ) { 38 while( *s ) {
19 write( fd, *s, strlen( *s )+1 ); 39 write( fd, *s, strlen( *s )+1 );
20 ++s; 40 ++s;
21 } 41 }
22 close(fd); 42 close(fd);
23 return 0; 43 return 0;
24} 44}
25 45
26int quickexec( const char *path, const char *, ...) 46int quickexec( const char *path, const char *, ...)
27{ 47{
28 int fd = open( QUICKEXEC, O_WRONLY ); 48 int fd = open( QUICKEXEC, O_WRONLY );
29 if ( fd == -1 ) { 49 if ( fd == -1 ) {
30 perror( "quickexec pipe" ); 50 perror( "quickexec pipe" );
31 return -1; 51 return -1;
32 } 52 }
33 const char** s = &path; 53 const char** s = &path;
34 do { 54 do {
35 write( fd, *s, strlen( *s )+1 ); 55 write( fd, *s, strlen( *s )+1 );
36 } while ( *(++s) ); 56 } while ( *(++s) );
37 57
38 close( fd ); 58 close( fd );
39 59
40 return 0; 60 return 0;
41} 61}