int main(void) { static char buf[100]; static char bufCNM[100]; int fd; // Assumes three file descriptors open. while((fd = open("console", O_RDWR)) >= 0){ if(fd >= 3){ close(fd); break; } } // Read and run input commands. while(getcmd(buf, sizeof(buf)) >= 0){ if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){ // Clumsy but will have to do for now. // Chdir has no effect on the parent if run in the child. buf[strlen(buf)-1] = 0; // chop \n if(chdir(buf+3) < 0) printf(2, "cannot cd %s\n", buf+3); else{ if((buf + 3)[0] == '.' && (buf + 3)[1] == '.' && (buf + 3)[2] == 0){ cutChild(currentDir); if(currentDir[0] == 0) isRootDir = 1; continue; } if(isRootDir){ catenate(currentDir, buf + 3); isRootDir = 0; } else{ append(currentDir, '/'); catenate(currentDir, buf + 3); } } continue; } if(fork1() == 0) { int i; int len = strlen(buf); for(i = len + 1; i > 0; i--) { bufCNM[i] = buf[i-1]; } bufCNM[0] = '/'; runcmd(parsecmd(buf)); if(buf[0] != '/') { runcmd(parsecmd(bufCNM)); } exit(); } wait(); } exit(); }
int main(int argc, char **argv) { bool succeed = false; char *redirout = (char*)stdout; char *redirerr = (char*)stderr; char *defs = NULL; con_init(); OPTS_OPTION_U16(OPTION_MEMDUMPCOLS) = 16; /* * Command line option parsing commences now We only need to support * a few things in the test suite. */ while (argc > 1) { ++argv; --argc; if (argv[0][0] == '-') { if (parsecmd("redirout", &argc, &argv, &redirout, 1, false)) continue; if (parsecmd("redirerr", &argc, &argv, &redirerr, 1, false)) continue; if (parsecmd("defs", &argc, &argv, &defs, 1, false)) continue; con_change(redirout, redirerr); if (!strcmp(argv[0]+1, "debug")) { OPTS_OPTION_BOOL(OPTION_DEBUG) = true; continue; } if (!strcmp(argv[0]+1, "memchk")) { OPTS_OPTION_BOOL(OPTION_MEMCHK) = true; continue; } if (!strcmp(argv[0]+1, "nocolor")) { con_color(0); continue; } con_err("invalid argument %s\n", argv[0]+1); return -1; } } con_change(redirout, redirerr); succeed = test_perform("tests", defs); stat_info(); return (succeed) ? EXIT_SUCCESS : EXIT_FAILURE; }
/* sed: perform a basic sed substitution command on input */ int sed(char *s, size_t max, const char *input, const char *sedcmd) { char cmd[MAX_MSG]; struct sedinfo sedbuf; std::regex pattern; auto type = std::regex_constants::format_sed; strncpy(cmd, sedcmd, MAX_MSG); if (!parsecmd(&sedbuf, cmd)) { puterr(s, max, &sedbuf); return 0; } try { if (!sedbuf.ignore) pattern = std::regex(sedbuf.regex); else pattern = std::regex(sedbuf.regex, std::regex::icase); } catch (std::regex_error) { snprintf(s, max, "sed: invalid regex"); return 0; } if (!sedbuf.global) type |= std::regex_constants::format_first_only; snprintf(s, max, "%s", std::regex_replace(input, pattern, sedbuf.replace, type).c_str()); return 1; }
static long dlwrite(Chan *c, void *a, long n, vlong voffset) { Cmdbuf *cmd; Cmdtab *ct; USED(voffset); switch((ulong)c->qid.path){ case Qdynld: cmd = parsecmd(a, n); qlock(&dllock); if(waserror()){ qunlock(&dllock); free(cmd); nexterror(); } ct = lookupcmd(cmd, dlcmd, nelem(dlcmd)); switch(ct->index){ case DLdev: devload(cmd->f[1]); break; case DLudev: devunload(cmd->f[1]); break; } poperror(); qunlock(&dllock); free(cmd); break; default: error(Egreg); } return n; }
int main(void) { static char buf[100]; int fd; // Assumes three file descriptors open. while((fd = open("console", O_RDWR)) >= 0) { if(fd >= 3){ close(fd); break; } } // Read and run input commands. while(getcmd(buf, sizeof(buf)) >= 0) { if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){ // Clumsy but will have to do for now. // Chdir has no effect on the parent if run in the child. buf[strlen(buf)-1] = 0; // chop \n if(chdir(buf+3) < 0) printf(2, "cannot cd %s\n", buf+3); continue; } else if(buf[0] == 'v' && buf[1] == 'e' && buf[2] == 'r' && buf[3] == 's' && buf[4] == 'i' && buf[5] == 'o' && buf[6] == 'n') printf(1, "uNIX Version 0-1 \n Build Version 3"); if(fork1() == 0) runcmd(parsecmd(buf)); wait(); } exit(); }
int main(void) { static char buf[100]; int fd, r; // Read and run input commands. while(getcmd(buf, sizeof(buf)) >= 0){ if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){ // Clumsy but will have to do for now. // Chdir has no effect on the parent if run in the child. buf[strlen(buf)-1] = 0; // chop \n if(chdir(buf+3) < 0) fprintf(stderr, "cannot cd %s\n", buf+3); continue; } if(strncmp(buf, "exit", 4) == 0) { fprintf(stdout, "Exit, good bye.\n"); exit(0); } if(fork1() == 0) runcmd(parsecmd(buf)); wait(&r); } exit(0); }
static int sysconwrite(void *va, ulong count) { Cmdbuf *cb; int e; cb = parsecmd(va, count); if(waserror()){ free(cb); nexterror(); } if(cb->nf == 0) error(Enoctl); if(strcmp(cb->f[0], "reboot") == 0){ osreboot(rebootargv[0], rebootargv); error("reboot not supported"); }else if(strcmp(cb->f[0], "halt") == 0){ if(cb->nf > 1) e = atoi(cb->f[1]); else e = 0; cleanexit(e); /* XXX ignored for the time being (and should be a string anyway) */ }else if(strcmp(cb->f[0], "broken") == 0) keepbroken = 1; else if(strcmp(cb->f[0], "nobroken") == 0) keepbroken = 0; else if(strcmp(cb->f[0], "exdebug") == 0) exdebug = !exdebug; else error(Enoctl); poperror(); free(cb); return count; }
void execute (char **args, char *command_line){ pid_t pid; pid = fork(); int status; if (pid == -1){ perror("Fork failed, ABORT!"); exit(1); } if (pid == 0){/*child process*/ parsecmd(command_line, args); if (execvp(args[0], args) < 0){ if (strcmp(strerror(errno), "No such file or directory") == 0) printf("Invalid command, n00b."); else printf("%s", strerror(errno)); printf("%c" , '\n'); } exit(0); } else{/* parent */ if(wait(&status) == -1) perror("Error while waiting for command to complete"); /*else check the status of the child*/ else{ if (WIFSIGNALED(status) != 0) printf("Error signal : %d\n",WTERMSIG(status)); else if (WIFEXITED(status) != 0) ;/*success!*/ else printf("Error in evaluating command."); } } }
static long regresswrite(struct chan *c, void *a, long n, int64_t unused) { ERRSTACK(1); uintptr_t pc; struct cmdbuf *cb; cb = parsecmd(a, n); if (waserror()) { kfree(cb); nexterror(); } switch((int)(c->qid.path)){ case Monitorctlqid: if(strncmp(a, "ktest", 5) == 0){ run_registered_ktest_suites(); } else { error(EFAIL, "regresswrite: only commands are %s", ctlcommands); } break; case Monitordataqid: if (onecmd(cb->nf, cb->f, NULL) < 0) n = -1; break; default: error(EBADFD, ERROR_FIXME); } kfree(cb); poperror(); return n; }
void cmdloop(int top) { union node *n; struct stackmark smark; int inter; int numeof = 0; enum skipstate skip; TRACE(("cmdloop(%d) called\n", top)); setstackmark(&smark); for (;;) { if (pendingsigs) dotrap(); inter = 0; if (iflag == 1 && top) { inter = 1; showjobs(out2, SHOW_CHANGED); chkmail(0); flushout(&errout); nflag = 0; } n = parsecmd(inter); TRACE(("cmdloop: "); showtree(n)); /* showtree(n); DEBUG */ if (n == NEOF) { if (!top || numeof >= 50) break; if (nflag) break; if (!stoppedjobs()) { if (!iflag || !Iflag) break; out2str("\nUse \"exit\" to leave shell.\n"); } numeof++; } else if (n != NULL && nflag == 0) { job_warning = (job_warning == 2) ? 1 : 0; numeof = 0; evaltree(n, EV_MORE); } popstackmark(&smark); setstackmark(&smark); /* * Any SKIP* can occur here! SKIP(FUNC|BREAK|CONT) occur when * a dotcmd is in a loop or a function body and appropriate * built-ins occurs in file scope in the sourced file. Values * other than SKIPFILE are reset by the appropriate eval*() * that contained the dotcmd() call. */ skip = current_skipstate(); if (skip != SKIPNONE) { if (skip == SKIPFILE) stop_skipping(); break; } } popstackmark(&smark); }
void Users::handle_command(char *buf, User *u){ netmsg m = parsecmd(buf); switch(m.cmd){ case CMD_NAME: if (u->name != NULL){ free(u->name); } u->name = strdup(m.arg); break; case CMD_SAY: char buf[MAXLEN]; sprintf(buf,"%s: %s",u->name,m.arg); this->u->messages->addMessage(Message(buf, 20000, 0xffffff ) ); send("say %s\n",buf); break; case CMD_KILL: //ignore break; case CMD_PING: send(u,"pong %s\n",m.arg); break; default: printf("unknown network command from user %s: %d '%s'\n",u->name,m.cmd,m.arg); } }
static int32_t iigwrite(Chan* c, void* a, int32_t n, int64_t off) { Proc *up = externup(); Cmdbuf *cb; switch((uint32_t)c->qid.path){ case Qdir: error(Eperm); case Qiigctl: if(off || n >= READSTR) error(Ebadarg); cb = parsecmd(a, n); if(waserror()){ free(cb); nexterror(); } iigctl(cb); poperror(); free(cb); return n; default: error(Egreg); break; } return 0; }
int main(int argc, char* argv[]) { static char buf[BUFSIZ]; int fd; whitespace = " \t\r\n\v"; symbols = "<|>&;()"; if (argc == 2 && !strcmp(argv[1], "-i")) interactive = 1; // Assumes three file descriptors open. while ((fd = open("/dev/console", O_RDWR)) >= 0) { if (fd >= 3) { close(fd); break; } } // Read and run input commands. while (getcmd(buf) >= 0) { if (!memcmp(buf, "cd ", 3)) { // Clumsy but will have to do for now. // Chdir has no effect on the parent if run in the child. if (chdir(buf + 3) < 0) dprintf(2, "cannot cd %s\n", buf + 3); continue; } else if (!strcmp(buf, "exit")) return 0; // XXX should allow return code (exit [n]) if (fork1() == 0) runcmd(parsecmd(buf)); wait(); } return 0; }
int executer(char *line) { /* Insert your code to execute the command line * identically to the standard execution scheme: * parsecmd, then fork+execvp, for a single command. * pipe and i/o redirection are not required. */ //printf("Not implemented: can not execute %s\n", line); struct cmdline *l; l = parsecmd( & line); if (l->err) { /* Syntax error, read another command */ printf("error: %s\n", l->err); return 1; } pid_t process = create_processes(l->seq, l->in, l->out, l->bg); if(!l->bg){ while(1){ waitpid(process, NULL, 0); if(waitpid(process, NULL, 0) == -1){ break; } } //waitpid(process, NULL, 0); } /* Remove this line when using parsecmd as it will free it */ //free(line); return 0; }
int main(void) { static char buf[100]; int fd, status; // Assumes three file descriptors open. while((fd = open("console", O_RDWR)) >= 0){ if(fd >= 3){ close(fd); break; } } // Read and run input commands. while(getcmd(buf, sizeof(buf)) >= 0){ if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){ // Clumsy but will have to do for now. // Chdir has no effect on the parent if run in the child. buf[strlen(buf)-1] = 0; // chop \n if(chdir(buf+3) < 0) printf(2, "cannot cd %s\n", buf+3); continue; } if(fork1() == 0) runcmd(parsecmd(buf)); wait(&status); } exit(0); }
void cmdloop(void) { Cmd *cmdp; File *ocurfile; int loaded; for(;;){ if(!downloaded && curfile && curfile->unread) load(curfile); if((cmdp = parsecmd(0))==0){ if(downloaded){ rescue(); exits("eof"); } break; } ocurfile = curfile; loaded = curfile && !curfile->unread; if(cmdexec(curfile, cmdp) == 0) break; freecmd(); cmdupdate(); update(); if(downloaded && curfile && (ocurfile!=curfile || (!loaded && !curfile->unread))) outTs(Hcurrent, curfile->tag); /* don't allow type ahead on files that aren't bound */ if(downloaded && curfile && curfile->rasp == 0) terminp = termoutp; } }
int main(void) { static char buf[100]; int fd, r; // Read and run input commands. while(getcmd(buf, sizeof(buf)) >= 0){ if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){ // Clumsy but will have to do for now. // Chdir has no effect on the parent if run in the child. buf[strlen(buf)-1] = 0; // chop \n if(chdir(buf+3) < 0) fprintf(stderr, "cannot cd %s\n", buf+3); continue; } /* also clumsy: can't use exit* programs, but ok since not traversing PATH anyway.*/ if(!strncmp(buf, "exit", 4)) { exit(0); } if(fork1() == 0) runcmd(parsecmd(buf)); wait(&r); } exit(0); }
void evalstring(char *s, int flags) { union node *n; struct stackmark smark; int flags_exit; flags_exit = flags & EV_EXIT; flags &= ~EV_EXIT; setstackmark(&smark); setinputstring(s, 1); while ((n = parsecmd(0)) != NEOF) { if (n != NULL) { if (flags_exit && preadateof()) evaltree(n, flags | EV_EXIT); else evaltree(n, flags); } popstackmark(&smark); } popfile(); popstackmark(&smark); if (flags_exit) exitshell(exitstatus); }
void evalstring(char *s, int flags) { union node *n; struct stackmark smark; int flags_exit; int any; flags_exit = flags & EV_EXIT; flags &= ~EV_EXIT; any = 0; setstackmark(&smark); setinputstring(s, 1); while ((n = parsecmd(0)) != NEOF) { if (n != NULL && !nflag) { if (flags_exit && preadateof()) evaltree(n, flags | EV_EXIT); else evaltree(n, flags); any = 1; } popstackmark(&smark); setstackmark(&smark); } popfile(); popstackmark(&smark); if (!any) exitstatus = 0; if (flags_exit) exraise(EXEXIT); }
void netlogctl(Fs *f, char* s, int n) { int i, set; Netlogflag *fp; Cmdbuf *cb; Cmdtab *ct; cb = parsecmd(s, n); if(waserror()){ free(cb); nexterror(); } if(cb->nf < 2) error(Ebadnetctl); ct = lookupcmd(cb, routecmd, nelem(routecmd)); SET(set); switch(ct->index){ case CMset: set = 1; break; case CMclear: set = 0; break; case CMonly: parseip(f->alog->iponly, cb->f[1]); if(ipcmp(f->alog->iponly, IPnoaddr) == 0) f->alog->iponlyset = 0; else f->alog->iponlyset = 1; free(cb); poperror(); return; default: cmderror(cb, "unknown netlog control message"); } for(i = 1; i < cb->nf; i++){ for(fp = flags; fp->name; fp++) if(strcmp(fp->name, cb->f[i]) == 0) break; if(fp->name == nil) continue; if(set) f->alog->logmask |= fp->mask; else f->alog->logmask &= ~fp->mask; } free(cb); poperror(); }
void netlogctl(struct Fs *f, char *s, int n) { ERRSTACK(1); int i, set = 0; Netlogflag *fp; struct cmdbuf *cb; struct cmdtab *ct; cb = parsecmd(s, n); if (waserror()) { kfree(cb); nexterror(); } if (cb->nf < 2) error(EINVAL, ERROR_FIXME); ct = lookupcmd(cb, routecmd, ARRAY_SIZE(routecmd)); switch (ct->index) { case CMset: set = 1; break; case CMclear: set = 0; break; case CMonly: parseip(f->alog->iponly, cb->f[1]); if (ipcmp(f->alog->iponly, IPnoaddr) == 0) f->alog->iponlyset = 0; else f->alog->iponlyset = 1; kfree(cb); poperror(); return; default: cmderror(cb, "unknown ip control message"); } for (i = 1; i < cb->nf; i++) { for (fp = flags; fp->name; fp++) if (strcmp(fp->name, cb->f[i]) == 0) break; if (fp->name == NULL) continue; if (set) f->alog->logmask |= fp->mask; else f->alog->logmask &= ~fp->mask; } kfree(cb); poperror(); }
/* pipestate -> parsecmd */ struct CmdGroup *pipestate(struct CmdGroup *cmdgroup){ int type; switch(type = yylex()){ case WORD: printparse(type, "command"); return parsecmd(cmdgroup); default: return cmderror(type, cmdgroup, "Pipe cannot be followed by '%s'\n", tokentext); } }
int main(void) { static char buf[100]; int fd; // Assumes three file descriptors open. while((fd = open("console", O_RDWR)) >= 0){ if(fd >= 3){ close(fd); break; } } // Read and run input commands. while(getcmd(buf, sizeof(buf)) >= 0){ if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){ // Clumsy but will have to do for now. // Chdir has no effect on the parent if run in the child. buf[strlen(buf)-1] = 0; // chop \n if(chdir(buf+3) < 0) printf(2, "cannot cd %s\n", buf+3); continue; } if(!strncmp(buf,"export PATH",11)){ //if export PATH was called //buf = buf+12; PATH = malloc(10*sizeof(char*)); //allocate memory for the PATH variable memset(PATH, 0, 10*sizeof(char*)); //clean alocated memory - 10 paths max int i; for(i=0;i<10;i++){ PATH[i] = malloc(100); //allocate memory for each path in PATH - 100 chars max memset(PATH[i],0,100); //clean allocated memory } pathInit = 1; //set flag to 1 - initialized int tempIndex = 0; int* beginIndex = &tempIndex; int length = strlen(&(buf[12])); //set the starting point to parse after "export PATH" char** temp = PATH; while(*beginIndex<length-1) //go over the command string and tokenize by delimiter { if(strtok(*temp,&(buf[12]),':',beginIndex)) //if tokenizer returned a string { (temp)++; } } continue; } if(fork1() == 0) { runcmd(parsecmd(buf)); } wait(); } exit(); }
int main(void) { signal(SIGCHLD, backgroundHandler); signal(SIGHUP, backgroundHandler); signal(SIGINT, foregroundHandler); signal(SIGQUIT, foregroundHandler); // Read and run input commands. char buf[100]; while(getcmd(buf, sizeof(buf)) >= 0){ buf[strlen(buf)-1] = 0; // chop \n if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){ if(chdir(buf+3) < 0) fprintf(stderr, "cannot cd %s\n", buf+3); } else { // see if it needs to run in the background bool runInBackground = isBackgroundProc(buf, sizeof(buf)); int pid = fork1(); if(!runInBackground) { if(pid == 0) { runcmd(parsecmd(buf)); } foregroundPid = pid; wait(&pid); foregroundPid = -1; } else { addPidToList(sizePidsList, pid); if(pid == 0) { setpgrp(); runcmd(parsecmd(buf)); } } } } return 0; }
static long segmentwrite(Chan *c, void *a, long n, vlong voff) { Cmdbuf *cb; Globalseg *g; ulong va, len, top; if(c->qid.type == QTDIR) error(Eperm); switch(TYPE(c)){ case Qctl: g = c->aux; cb = parsecmd(a, n); if(strcmp(cb->f[0], "va") == 0){ if(g->s != nil) error("already has a virtual address"); if(cb->nf < 3) error(Ebadarg); va = strtoul(cb->f[1], 0, 0); len = strtoul(cb->f[2], 0, 0); top = PGROUND(va + len); va = va&~(BY2PG-1); len = (top - va) / BY2PG; if(len == 0) error(Ebadarg); g->s = newseg(SG_SHARED, va, len); } else error(Ebadctl); break; case Qdata: g = c->aux; if(voff + n > g->s->top - g->s->base) error(Ebadarg); qlock(&g->l); g->off = voff + g->s->base; g->data = smalloc(n); if(waserror()){ free(g->data); qunlock(&g->l); nexterror(); } g->dlen = n; memmove(g->data, a, g->dlen); docmd(g, Cwrite); free(g->data); qunlock(&g->l); poperror(); return g->dlen; default: panic("segmentwrite"); } return 0; /* not reached */ }
int main (int argc,char **argv){ int rows,cols,color;char **a,wall; parsecmd (argc,argv,&rows,&cols,&color,&wall); /* printf("rows %d cols %d color %d wall %d\n",rows,cols,color,wall); */ initrand(); a= mazeinit (rows,cols,wall); mazewalk (a,rows,cols); mazeprint (a,rows,cols,color); mazefree (a,rows); return 0; }
int main () { char cmdline[MAXLINE]; char *argv[MAXARGS]; int bg; while (1) { printf("> "); //prompt fgets(cmdline, MAXLINE, stdin); //read bg = parsecmd(cmdline, argv, ' '); //parse evalcmd(argv, bg); //eval } }
static int32_t cecwrite(Chan *c, void *a, int32_t n, int64_t mm) { Proc *up = externup(); Cmdbuf *cb; Cmdtab *cp; if(c->qid.path == Qctl){ cb = parsecmd(a, n); if(waserror()){ free(cb); nexterror(); } cp = lookupcmd(cb, ceccmd, nelem(ceccmd)); switch(cp->index){ case CMsetname: strecpy(name, name+sizeof name-1, cb->f[1]); break; case CMtraceon: tflag = 1; break; case CMtraceoff: tflag = 0; break; case CMsetpasswd: strcpy(passwd, cb->f[1]); break; case CMcecon: cecon(cb->f[1]); break; case CMcecoff: cecoff(cb->f[1]); break; case CMsetshelf: shelf = atoi(cb->f[1]); break; case CMwrite: cecputs((char*)a+6,n-6); break; case CMreset: rst(connidx(atoi(cb->f[1]))); break; default: cmderror(cb, "bad control message"); break; } free(cb); poperror(); return n; } error(Egreg); return 0; }
static int cmdloop(int top) { union node *n; struct stackmark smark; int inter; int status = 0; int numeof = 0; TRACE(("cmdloop(%d) called\n", top)); #ifdef HETIO if(iflag && top) hetio_init(); #endif for (;;) { int skip; setstackmark(&smark); if (jobctl) showjobs(out2, SHOW_CHANGED); inter = 0; if (iflag && top) { inter++; chkmail(); } n = parsecmd(inter); /* showtree(n); DEBUG */ if (n == NEOF) { if (!top || numeof >= 50) break; if (!stoppedjobs()) { if (!Iflag) break; out2str("\nUse \"exit\" to leave shell.\n"); } numeof++; } else if (nflag == 0) { job_warning = (job_warning == 2) ? 1 : 0; numeof = 0; evaltree(n, 0); status = exitstatus; } popstackmark(&smark); skip = evalskip; if (skip) { evalskip &= ~(SKIPFUNC | SKIPFUNCDEF); break; } } return status; }
int main (int argc, const char * argv[]) #endif { talk_base::AutoThread auto_thread; talk_base::Thread* thread = talk_base::Thread::Current(); #if !defined(MAC_IPHONE) GoCast::ThreadSafeMessageQueue mq; #endif if (!parsecmd(argc, (char**)argv)) { std::cout << "Error parsing command line arguments." << endl; exit(-1); } #if(defined(GOCAST_ENABLE_VIDEO) && defined(GOCAST_LINUX)) gtk_init(&argc, (char***)&argv); #endif GoCast::SocketServer socket_server; thread->set_socketserver(&socket_server); //Declare client only after set_socketserver() #if(defined(GOCAST_ENABLE_VIDEO) && !defined(GOCAST_WINDOWS)) GoCast::PeerConnectionClient testClient(&mq, NULL, peername, mainserver, mainserver_port, false); #else GoCast::PeerConnectionClient testClient(&mq, NULL, peername, mainserver, mainserver_port); #endif socket_server.SetPeerConnectionClient(&testClient); #if !defined(MAC_IPHONE) //Run client shell TestClientShell shell(&mq); shell.startThread(); #endif //Run client thread->Run(); //Set thread's socket server to NULL before exiting thread->set_socketserver(NULL); #if !defined(MAC_IPHONE) //Stop shell thread shell.stopThread(); #endif return 0; }