Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

main.cpp

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2004 Michael 'Mickey' Lauer <mickey@vanille.de>
00003 ** All rights reserved.
00004 **
00005 ** This file may be distributed and/or modified under the terms of the
00006 ** GNU General Public License version 2 as published by the Free Software
00007 ** Foundation and appearing in the file LICENSE.GPL included in the
00008 ** packaging of this file.
00009 **
00010 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00011 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00012 **
00013 **********************************************************************/
00014 
00015 /* STD */
00016 #include <pwd.h>
00017 #include <sys/types.h>
00018 #include <fcntl.h>
00019 #include <unistd.h>
00020 #include <stdio.h>
00021 #include <string.h>
00022 #include <errno.h>
00023 
00024 int main( int argc, char** argv )
00025 {
00026     printf( "\nPyQuicklaunch Launcher (numargs=%d, arg[0]='%s', arg[1]='%s')\n", argc, argv[0], argv[1] );
00027 
00028     char fifoName[1024];
00029     sprintf( &fifoName[0], "/tmp/mickeys-quicklauncher-%s", ::getpwuid( ::getuid() )->pw_name );
00030 
00031 
00032     int fd = open( &fifoName[0], O_WRONLY | O_NONBLOCK );
00033     if ( fd == -1 )
00034     {
00035         perror( "Can't open fifo" );
00036         return -1;
00037     }
00038 
00039     char wdPath[1024];
00040     getcwd( &wdPath[0], sizeof( wdPath ) );
00041 
00042     char scriptPath[1024];
00043     if ( argv[1][0] == '/' )
00044     {
00045         strcpy( &scriptPath[0], argv[1] );
00046     }
00047     else
00048     {
00049         sprintf( &scriptPath[0], "%s/%s", wdPath, argv[1] );
00050     }
00051 
00052     printf( "\nInstructing the Quicklauncher to launch '%s'...", &scriptPath[0] );
00053 
00054     int res = write( fd, scriptPath, strlen( scriptPath ) );
00055     if ( res < 1 )
00056     {
00057         perror( "Can't write string to fifo" );
00058         return -1;
00059     }
00060 
00061     close( fd );
00062 
00063     return 0;
00064 }

Generated on Sat Nov 5 16:15:25 2005 for OPIE by  doxygen 1.4.2