void *thread_run(void* client) { Client* newClient = (Client*) client; // client입니다. currentClient = newClient; // 클라이언트 타입에 따라 할 일을 처리합니다. if (newClient->isShell) doShell(newClient); else doClient(newClient); }
void *sessionThread(void *arg) { int sock; sock = *(int *)arg; free(arg); doClient(sock); close(sock); return NULL; }
int main(int ac, char **av) { int ch; int i; int serverMode = 0; while ((ch = getopt(ac, av, "aW:T:C:sv")) != -1) { switch(ch) { case 'a': /* auto tag / standard broadcast */ addTag(&AddrBase, NULL, 0); break; case 'W': /* specify working directory */ WorkDir = optarg; break; case 'T': TagDir = optarg; break; case 'C': /* specify server config file(s) (colon delimited) */ ConfigFiles = optarg; break; case 's': /* run as server using config file */ serverMode = 1; break; case 'v': VerboseOpt = 1; break; default: usage(1); /* not reached */ } } for (i = optind; i < ac; ++i) { if (strchr(av[i], '=')) addTag(&VarBase, av[i], 0); else addTag(&AddrBase, av[i], 0); } if (AddrBase == NULL) usage(1); if (AddrBase && AddrBase->name == NULL && AddrBase->next) { fprintf(stderr, "You cannot specify both -a AND a list of hosts. If you want\n" "to use auto-broadcast mode with a tag other than 'auto',\n" "just specify the tag without a host, e.g. ':<tag>'\n"); exit(1); } if (serverMode) doServer(); else doClient(); return(0); }
void TCParser::_parseClient(const std::vector<std::string> &args) { if (args.size() == 0) { _parserError(tcrec_cmd_version, "Empty client argument"); return; } std::string *text = createJoin(args, " "); doClient(*text); delete text; }
void acceptSocket(int fd) { struct sockaddr_in clientAddr; socklen_t len; for ( ; ;) { int clientfd = Accept(fd, (SADDR*)&clientAddr, &len); SocketAddr client; convert(clientAddr, client); fprintf(stdout, "Client: ip %s, port %d\n", client.ip, client.port); pid_t child; if ((child = fork()) == 0) { Close(fd); doClient(clientfd); } else Close(clientfd); } }
void newMessage() { new_message = oslLoadImageFilePNG("system/app/messenger/new_message.png", OSL_IN_RAM, OSL_PF_8888); if (!new_message) debugDisplay(); while (!osl_quit) { LowMemExit(); oslStartDrawing(); oslClearScreen(RGB(0,0,0)); controls(); oslDrawImageXY(new_message, 0, 0); navbarButtons(2); battery(330,2,0); digitaltime(381,4,0,hrTime); androidQuickSettings(); volumeController(); oslDrawImage(cursor); if (osl_keys->pressed.L) { oslPlaySound(Lock, 1); lockscreen(); } if (osl_keys->pressed.circle) { oslDeleteImage(new_message); messenger(); } if ((cursor->x >= 444 && cursor->x <= 480) && (cursor->y >= 157 && cursor->y <= 213) && (osl_keys->pressed.cross)) { oslPlaySound(KeypressStandard, 1); oslDeleteImage(messengerbg); messenger(); } if ((cursor->x >= 444 && cursor->x <= 480) && (cursor->y >= 76 && cursor->y <= 155) && (osl_keys->pressed.cross)) { oslPlaySound(KeypressStandard, 1); oslDeleteImage(messengerbg); home(); } if ((cursor->x >= 444 && cursor->x <= 480) && (cursor->y >= 19 && cursor->y <= 75) && (osl_keys->pressed.cross)) { oslPlaySound(KeypressStandard, 1); multitask(); } captureScreenshot(); if (cursor->x >= 7 && cursor->x <= 435 && cursor->y >= 55 && cursor->y <= 86 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); doServer(); } oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, INTRAFONT_ALIGN_LEFT); oslDrawString(14, 245, tempMessage); if (cursor->x >= 10 && cursor->x <= 362 && cursor->y >= 228 && cursor->y <= 270 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); openOSK("Enter Message", "", 128, -1); } if ((cursor->x >= 10 && cursor->x <= 405 && cursor->y >= 88 && cursor->y <= 118 && osl_keys->pressed.cross) && oslIsWlanPowerOn()) doClient(); else if ((cursor->x >= 410 && cursor->x <= 442 && cursor->y >= 92 && cursor->y <= 118 && osl_keys->pressed.cross) && oslIsWlanPowerOn()) doServer(); oslEndDrawing(); oslEndFrame(); oslSyncFrame(); } }
int main(int argc, char **argv) { int rank = 0; command_name = argv[0]; parse_opt(argc, argv); if (arg_version) { printVersion(); return 0; } if (arg_cp) { unsigned int slen = strlen(copy_command_src) + strlen(arg_cp) + 1000; char *icmd = malloc(slen); snprintf(icmd, slen,"%s %s", copy_command_src, arg_cp); arg_icmd = icmd; arg_ocmd = copy_command_dest; fprintf(stderr, " input command: %s\n", arg_icmd); } if (arg_icmd && arg_ifile) { fprintf(stderr, "Warning: Ignoring -icmd %s, because -i is set\n", arg_icmd); arg_icmd = NULL; } if (arg_ocmd && arg_ofile) { fprintf(stderr, "Warning: Ignoring -ocmd %s, because -o is set\n", arg_ocmd); arg_ocmd = NULL; } if (PSP_Init() != PSP_OK) { fprintf(stderr, "PSP_Init() failed!\n"); exit(1); } if (!arg_manual) { /* HACK HACK HACK */ setenv("__PSI_MASTERNODE", "-1", 0); setenv("__PSI_MASTERPORT", "-1", 0); PSE_initialize(); rank = PSE_getRank(); } else if (arg_server) { rank = 1; } if (rank < 0) { /* original process, let's spawn rank 0 and become logger */ setenv("PSI_NOMSGLOGGERDONE", "", 1); PSE_spawnAdmin(-1, 0, argc, argv, 0); } else if (rank == 0) { /* server */ if (arg_progress) set_timer(1, 1 ,timer); doServer(); } else { /* client */ if (arg_progress && arg_manual) set_timer(1, 1 ,timer); doClient(); } if (!arg_manual) { PSI_release(PSC_getMyTID()); } if ((!rank || arg_manual) && arg_progress) { print_stat(1); } return 0; }