/* Fvwm command input interface. Copyright 1996, Toshi Isogai. No guarantees or warantees or anything are provided. Use this program at your own risk. Permission to use this program for any purpose is given, as long as the copyright is kept intact. */ #include "FvwmConsole.h" char *MyName; int fd[2]; /* pipe to fvwm */ FILE *sp; int s,ns; /* socket handles */ char name[32]; /* name of this program in executable format */ int pid; /* server routine child process id */ void server(int *fd); void GetResponse(); void DeadPipe(); void CloseSocket(); void ErrMsg( char *msg ); void SigHandler(); #define XARGS (sizeof(xterm_a)/sizeof(char *)) void main(int argc, char **argv){ char *tmp, *s; static char client[120]; char **eargv; int i,j; char *xterm_a[] = {"-title", name,"-name",name, "-e",client,NULL }; /* initially no child */ pid = 0; /* Save the program name - its used for error messages and option parsing */ tmp = argv[0]; s=strrchr(argv[0], '/'); if (s != NULL) tmp = s + 1; strcpy( name, tmp ); MyName = safemalloc(strlen(tmp)+2); strcpy(MyName,"*"); strcat(MyName, tmp); /* construct client's name */ strcpy( client, argv[0] ); strcat( client, "C" ); if(argc < FARGS) { fprintf(stderr,"%s Version %s should only be executed by fvwm!\n", MyName, VERSION); exit(1); } if( ( eargv =(char **)safemalloc((argc-FARGS+XARGS)*sizeof(char *)) ) == NULL ) { ErrMsg( "allocation" ); } /* copy arguments */ eargv[0] = XTERM; j= 1; for ( i=FARGS ; i 0) { if(header[1] == M_PASS) { send( ns, (char *)&body[3], strlen((char *)&body[3]), 0 ); } free(body); } } /************************************/ /* print error message on stderr */ /************************************/ void ErrMsg( char *msg ) { fprintf( stderr, "%s server error in %s\n", name, msg ); CloseSocket(); exit(1); }