static gboolean channel_cb(GIOChannel *source, GIOCondition condition, gpointer data) { int rc; char buf[STDIN_BUF_SIZE+1]; //GsmSms *obj = (GsmSms *)data; if (condition != G_IO_IN) { return TRUE; } /* we've received something on stdin. */ printf("# "); rc = fscanf(stdin, "%s", buf); if (rc <= 0) { printf("NULL/n"); return TRUE; } if (!strcmp(buf, "h")) { shell_help(); } else if (!strcmp(buf, "?")) { shell_help(); } else if (!strcmp(buf, "s")) { //emit_signal(obj); } else if (!strcmp(buf, "q")) { exit(0); } else { printf("Unknown command `%s'/n", buf); } return TRUE; }
/** * execute internal command in child process * pipe_end: write end of pipe to notify parent of errnos * key: indicates the internal command * jman: job manager * args: array of args string to command * returns: status **/ _BOOL execute_internal(int pipe_end,short key,JMANAGER* jman,char **args){ if(jman == NULL || args == NULL){errno = EINVAL; return FALSE;} if(pipe_end != -1){ if(close(pipe_end) ==-1){ _exit(EXIT_FAILURE); } } _BOOL ret = FALSE; switch(key){ case JOBS: ret = shell_dump(jman,args); break; case FG: ret = shell_foreground(jman,args); break; case BG: ret = shell_background(jman,args); break; case SHEXIT: ret = shell_exit(FALSE,NULL,NULL); case ECHO: ret = shell_echo(jman,args); break; case HELP: ret = shell_help("\r%s\n",args); break; default: errno = EINVAL; return FALSE; break; if(ret) _exit(EXIT_SUCCESS); else return FALSE; } return TRUE; }