ASTTree ParseCommand(char **cmdTokens, int tokenCnt) { if (tokenCnt <= 0) return NULL; int i; for (i = tokenCnt-1; i >= 0; i--) { char *token = cmdTokens[i]; if (strcmp(token, "|") == 0) { // Create a pipe node cmdTokens[i] = NULL; ASTNode *pipeNode = CreateASTNode(); pipeNode->type = PipeCommand; pipeNode->u.pipe.leftCommand = ParseCommand(cmdTokens, i); pipeNode->u.pipe.rightCommand = ParseCommand(cmdTokens+i+1, tokenCnt-i-1); return pipeNode; } else if (strcmp(token, ">") == 0) { // If > appears, must be > file in the end. Nothing more. // don't support > sth < sth2 if (cmdTokens[i+1] == NULL) { perror("Wrong syntax: > should be followed by a file name."); return NULL; } cmdTokens[i] = NULL; ASTNode *outNode = CreateASTNode(); outNode->type = OutRedirCommand; outNode->u.out.command = ParseCommand(cmdTokens, tokenCnt-2); outNode->u.out.outFile = cmdTokens[i+1]; return outNode; } else if (strcmp(token, ">>") == 0) { if (cmdTokens[i+1] == NULL) { perror("Wrong syntax: >> should be followed by a file name."); return NULL; } cmdTokens[i] = NULL; ASTNode *appNode = CreateASTNode(); appNode->type = OutAppendCommand; appNode->u.app.command = ParseCommand(cmdTokens, tokenCnt-2); appNode->u.app.appendFile = cmdTokens[i+1]; return appNode; } else if (strcmp(token, "<") == 0) { if (cmdTokens[i+1] == NULL) { perror("Wrong syntax: < should be followed by a file name."); return NULL; } cmdTokens[i] = NULL; ASTNode *inpNode = CreateASTNode(); inpNode->type = InpRedirCommand; inpNode->u.inp.command = ParseCommand(cmdTokens, tokenCnt-2); inpNode->u.inp.inpFile = cmdTokens[i+1]; return inpNode; } } // Prim Command ASTNode *primNode = CreateASTNode(); primNode->type = PrimCommand; primNode->u.prim.cmdTokens = cmdTokens; return primNode; }
int main( int argc, char **argv) { int x_argc; char **x_argv; Options options[] = {{"i","install",0,0,0}, {"r","remove",0,0,0}, {"p","port",1,0,0}, {0,0,0,0,0}}; ParseStdArgs(argc, argv, &x_argc, &x_argv); ParseCommand(x_argc,x_argv,options,1,&extra_argc,&extra_argv); if (options[2].present && options[2].value) SetPortname(options[2].value); else if (GetPortname() == 0) SetPortname("mdsip"); if (options[0].present) { InstallService(); exit(0); } else if (options[1].present) { RemoveService(); exit(0); } else { SERVICE_TABLE_ENTRY srvcTable[] = {{ServiceName(1),(LPSERVICE_MAIN_FUNCTION)ServiceMain},{NULL,NULL}}; WSADATA wsaData; WORD wVersionRequested; wVersionRequested = MAKEWORD(1,1); WSAStartup(wVersionRequested,&wsaData); StartServiceCtrlDispatcher(srvcTable); } return 1; }
bool CMakeParser::Parse(const wxString& content) { // Clear everything Clear(); Command command; IteratorPair context(content.begin(), content.end()); // Parse input into tokens while (ParseCommand(context, command, m_errors)) { // If command is 'set', store variable info if (command.name == "set") { if (!command.arguments.IsEmpty()) { m_variables.insert(command.arguments[0]); } else { Error error = {command.pos, ErrorSetMissingArguments}; m_errors.push_back(error); } } // Add command m_commands.push_back(command); } return true; }
/* * .KB_C_FN_DEFINITION_START * void ServicePrompt(char) * This private function process each character checking for valid commands. * This function is only executed if the character is considered valid. * Each command is terminated with NULL (0) or ''. * .KB_C_FN_DEFINITION_END */ static void ServicePrompt(char p_char) { if (p_char == '\r') p_char = 0; if (p_char == '\010') { if (buffCount) { /* handle backspace BS */ inputBuffer[--buffCount] = 0; printf(backspaceString); } return; } if (buffCount < MAX_INPUT_SIZE - 1) { inputBuffer[buffCount++] = p_char; putchar(p_char); } if (!p_char) { printf("\n"); ParseCommand(inputBuffer); p_memset(inputBuffer, 0, MAX_INPUT_SIZE); buffCount = 0; printf("\n>"); } }
//----------------------------------------------------------------------------- // ProcessMessage // Processes the input message //----------------------------------------------------------------------------- void CConsole::ProcessMessage( const TMessage& msg ) { switch( msg.nType ) { case mKeyPressed: switch( msg.nMessage ) { case KEY_ESCAPE: Engine::PostMsg( msg ); break; case KEY_TILDE: gnConsoleActive = !gnConsoleActive; break; case KEY_ENTER: m_szCurrCommand[ m_nCurrPos++ ] = 0; ParseCommand( m_szCurrCommand ); break; case KEY_BACKSPACE: if( m_nCurrPos > 0 ) { m_szCurrCommand[ --m_nCurrPos ] = 0; } break; default: m_szCurrCommand[ m_nCurrPos++ ] = (char)msg.nMessage; //printf( "%c", (char)msg.nMessage ); printf( "%s\n", m_szCurrCommand ); } break; default: break; } }
char *ParseCommandA(wchar_t *str, char *name) { wchar_t *tmp1, *tmp2; char *ret; // Validate arguments if (str == NULL) { return NULL; } if (name != NULL) { tmp1 = CopyStrToUni(name); } else { tmp1 = NULL; } tmp2 = ParseCommand(str, tmp1); if (tmp2 == NULL) { ret = NULL; } else { ret = CopyUniToStr(tmp2); Free(tmp2); } Free(tmp1); return ret; }
bool Kernel::Initialize(s32 argc, char **argv) { ParseCommand(argc, argv); return _logger.Initialize(); }
/*----------------------------------------------------------------------------------------------*/ void Commando::Import() { uint32_t bread; /* Wait for data from the serial port */ read(TLM_2_CMD_P[READ], &packet_header, sizeof(CCSDS_Packet_Header)); /* Decode the header */ DecodeCCSDSPacketHeader(&decoded_header, &packet_header); /* Get the body */ read(TLM_2_CMD_P[READ], &command_body, decoded_header.length); /* Get the start of execution */ IncStartTic(); /* Now execute the command */ ParseCommand(); /* Get the stop of execution */ IncStopTic(); /* Increment execution count */ IncExecTic(); }
int GentRedis::Process(const char *rbuf, uint64_t size, string &outstr) { string data(rbuf,size); int status = ParseCommand(data); if(status == -1) { outstr = REDIS_ERROR + " unknown command\r\n"; //Info("unknown command",outstr, REDIS_ERROR); return 0; }else if(status == -2) { outstr = REDIS_ERROR + " wrong number of arguments for 'keys' command\r\n"; //Info("wrong number of arguments for 'keys' command",outstr, REDIS_ERROR); return 0; }else if(status == -3) { outstr = REDIS_ERROR + " key is very very long\r\n"; //Info("key is very very long",outstr, REDIS_ERROR); return 0; }else if(status == AUTH_REQ_FAIL) { outstr = "- " + REDIS_AUTH_REQ + "\r\n"; //Info(REDIS_AUTH_REQ, outstr, "-"); return 0; }else if(status == AUTH_FAIL) { outstr = REDIS_ERROR + " " + REDIS_AUTH_FAIL + "\r\n"; //Info(REDIS_AUTH_FAIL,outstr, REDIS_ERROR); return 0; } return status; }
void ParseStdArgs(int argc, char **argv,int *extra_argc, char ***extra_argv) { Options options[] = {{"P","protocol",1,0,0}, {"h","hostfile",1,0,0}, {"s","server",0,0,0}, {"m","multi",0,0,0}, {"c","compression",1,0,0}, {0,0,0,0}}; ParseCommand(argc,argv,options,1,extra_argc,extra_argv); if (options[0].present && options[0].value) SetProtocol(options[0].value); if (options[1].present && options[1].value) SetHostfile(options[1].value); if (options[2].present) { if (options[3].present) { fprintf(stderr,"Cannot select both server mode and multi mode\n\n"); PrintHelp(0); } else { SetMulti(1); SetContextSwitching(0); } } if (options[3].present) { SetMulti(1); SetContextSwitching(1); } if (options[4].present && options[4].value) SetCompressionLevel(atoi(options[4].value)); }
bool InboundJSONCLIProtocol::SignalInputData(IOBuffer &buffer) { //1. Get the buffer and the length uint8_t *pBuffer = GETIBPOINTER(buffer); uint32_t length = GETAVAILABLEBYTESCOUNT(buffer); if (length == 0) return true; //2. Walk through the buffer and execute the commands string command = ""; for (uint32_t i = 0; i < length; i++) { if ((pBuffer[i] == 0x0d) || (pBuffer[i] == 0x0a)) { if (command != "") { if (!ParseCommand(command)) { FATAL("Unable to parse command\n`%s`", STR(command)); return false; } } command = ""; buffer.Ignore(i); pBuffer = GETIBPOINTER(buffer); length = GETAVAILABLEBYTESCOUNT(buffer); i = 0; continue; } command += (char) pBuffer[i]; if (command.length() >= MAX_COMMAND_LENGTH) { FATAL("Command too long"); return false; } } //3. Done return true; }
CDispToDispCommandPtr CDispToDispProtoSerializer::ParseCommand( const SmartPtr<IOService::IOPackage> &p) { if ( ! p.isValid() ) return CDispToDispCommandPtr(new CDispToDispUnknownCommand); return ParseCommand( (IDispToDispCommands)p->header.type, UTF8_2QSTR( p->buffers[0].getImpl() ) ); }
int Command(const char *input, ENGINE_STATE *stat) { char input_copy[2048], cmd_str[20]; strcpy(input_copy, input); sscanf(input, "%s", cmd_str); int cmd = ParseCommand(cmd_str); return uci_commands[cmd].cmd(input_copy, stat); }
Bool WINAPI EventTextCommand(char *str) { // Parse command, and don't pass it on if we handle it if (ParseCommand(str, commands)) return False; return True; }
bool AppInit(CNotification * Notify, const char * BaseDirectory, int argc, char **argv) { try { g_Notify = Notify; InitializeLog(); WriteTrace(TraceAppInit, TraceDebug, "Starting (BaseDirectory: %s)", BaseDirectory ? BaseDirectory : "null"); if (Notify == NULL) { WriteTrace(TraceAppInit, TraceError, "No Notification class passed"); return false; } WriteTrace(TraceAppInit, TraceDebug, "Settings up settings"); g_Settings = new CSettings; g_Settings->Initialize(BaseDirectory, AppName()); WriteTrace(TraceAppInit, TraceDebug, "Parse Commands"); if (!ParseCommand(argc, argv)) { WriteTrace(TraceAppInit, TraceError, "Failed to Parse Commands, exiting now"); return false; } #ifdef _WIN32 if (g_Settings->LoadBool(Setting_CheckEmuRunning) && pjutil::TerminatedExistingExe()) { delete g_Settings; g_Settings = new CSettings; g_Settings->Initialize(BaseDirectory, AppName()); } #endif SetupTrace(); FixDirectories(); #ifdef _WIN32 CMipsMemoryVM::ReserveMemory(); IncreaseThreadPriority(); #endif //Create the plugin container WriteTrace(TraceAppInit, TraceInfo, "Create Plugins"); g_Plugins = new CPlugins(Directory_Plugin); g_Lang = new CLanguage(); g_Lang->LoadCurrentStrings(); g_Notify->AppInitDone(); WriteTrace(TraceAppInit, TraceDebug, "Initialized Successfully"); return true; } catch (...) { g_Notify->DisplayError(stdstr_f("Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__).c_str()); WriteTrace(TraceAppInit, TraceError, "Exception caught, Init was not successfull"); return false; } }
void SSECallback(int sid, SocketServerEvent event, void* data, int data_len) { zlog_debug(gZlogCategories[ZLOG_MAIN], "SSECallback is called %d", event); switch (event) { case SSE_RECEIVE: { if (data != NULL) { #if 0 char response[256]; memset(response, 0, sizeof(response)); snprintf(response, sizeof(response), "received data: [%s]", (char*) data); SocketServerSend(sid, response, strlen(response)); int d = strncmp("exit", (char*)data, 4); if (d == 0) exit(0); #endif //0 //#define DEBUG 1 #if defined(DEBUG) int i; char* buf_str = (char*) malloc (3*data_len + 2); char* buf_ptr = buf_str; unsigned char* str = (unsigned char*) data; for (i = 0; i < data_len; i++) { buf_ptr += sprintf(buf_ptr, "|%2X", str[i]); } sprintf(buf_ptr,"|\0"); zlog_debug(gZlogCategories[ZLOG_SOCKET], "Receiving %d bytes of data [%s]", data_len, buf_str); #endif //defined(DEBUG) ParseCommand(data, data_len); } } break; case SSE_CONNECT: { _SetSocketId(sid); } break; case SSE_DISCONNECT: { _SetSocketId(0); } break; default: break; } }
bool P2PProxyServerSession::ProceesSystemCommand(const char *data, uint16 len) { ASSERT(signal_thread_->IsCurrent()); LOG_P2P(P2P_PROXY_SOCKET_DATA) << "process System command"; /////////////////////////////////////////////////////////////////////////// //BUSINESS LOGIC NOTE (GuangleiHe, 11/28/2013) //There didn't used P2PRTSPCommand to parse the data. //P2PRTSPCommand only known by P2PSystemCommandFactory /////////////////////////////////////////////////////////////////////////// //Step 1. Parse the system command. uint32 p2p_system_command_type; uint32 server_socket; uint32 client_socket; uint32 client_connection_ip; uint16 client_connection_port; if(!ParseCommand(data,len,&p2p_system_command_type,&server_socket, &client_socket,&client_connection_ip,&client_connection_port)){ LOG(LS_ERROR) << "Parse the p2p system command error"; return false; } ////////////////////////////////////////////////////////////////////////// if(p2p_system_command_type == P2P_SYSTEM_CREATE_CLIENT_SUCCEED){ LOG_P2P(P2P_PROXY_SOCKET_LOGIC) << "Client Socket Create Succeed"; socket_table_management_->AddNewLocalSocket(server_socket, client_socket,TCP_SOCKET); ////////////////////////////////////////////////////////////////////////// //there is normal business logic, some times proxsocketbegin closed. //so the second of socket begin map getting NULL pointer. ////////////////////////////////////////////////////////////////////////// P2PProxySocket *res = GetP2PProxySocket(server_socket); if(res != NULL) res->OnP2PSocketConnectSucceed(this,client_socket); } else if(p2p_system_command_type == P2P_SYSTEM_SOCKET_CONNECT_FAILURE){ P2PProxySocket *res = GetP2PProxySocket(server_socket); if(res != NULL) res->OnP2PSocketConnectFailure(this); } else if(p2p_system_command_type == P2P_SYSTEM_SOCKET_CLOSE){ LOG_P2P(P2P_PROXY_SOCKET_LOGIC) << "close server socket "; P2PProxySocket *res = GetP2PProxySocket(server_socket); if(res != NULL) res->OnP2PClose(this); } return true; }
static void Configure(InputParameters *p_Inp, int ac, char *av[]) { memset(p_Inp, 0, sizeof(InputParameters)); ParseCommand(p_Inp, ac, av); fprintf(stdout,"----------------------------- JM %s %s -----------------------------\n", VERSION, EXT_VERSION); if(!p_Inp->bDisplayDecParams) { fprintf(stdout,"--------------------------------------------------------------------------\n"); fprintf(stdout," Input H.264 bitstream : %s \n",p_Inp->infile); fprintf(stdout,"--------------------------------------------------------------------------\n"); } }
int CommandObject::Welcome() { int cmmd; // string scmd; LayerSetObject lso; char filename[50]; cout<<"****************\n* BitMagic 0.1 *\n****************\n请选择一项功能:\n[1]水印大师-设置向导\n[3]我要玩命令行~\n[0]退出\n"; cin>>cmmd; while( cmmd!=1 && cmmd!=2 && cmmd!=3 && cmmd!=4 && cmmd!=0 ) { cout<<"请选择一项功能!"<<endl; cin>>cmmd; } switch(cmmd) { case 1: Watermark(); break; case 3: cout<<"请输入要打开的BMP图像的路径和文件名:"; cin>>filename; while (lso.CreateLayer(filename)==-1) cin>>filename; if(IsType(filename,"bmp")) { cout<<"bmp图像打开完成,请输入命令。如需帮助,请输入HELP。"<<endl; string scmd; do{ getline(cin,scmd); char tscmd[MAX_LINE_LENGTH];//MAX_LINE_LENGTH定义在include.h strcpy(tscmd,scmd.c_str()); ParseCommand(lso,tscmd); }while(strcmp(parameter[0],"exit")!=0); } else cout<<"请打开bmp文件!"<<endl; break; default:cout<<"发生错误!"<<endl; } return 1; }
PresenceParams ParseCommand (QString cmd, const QString& marker, const QStringList& statuses = {}, Parse::Options opts = Parse::NoOptions) { cmd = cmd.trimmed (); cmd = cmd.mid (marker.size ()); if (cmd.startsWith (' ')) cmd = cmd.mid (1); const auto& unicode = cmd.toUtf8 (); std::vector<std::string> convertedStatuses; for (const auto& status : statuses) convertedStatuses.push_back (status.toUtf8 ().constData ()); return ParseCommand (unicode.begin (), unicode.end (), convertedStatuses, opts); }
tCommand tScriptState::GetNextCommand(CString& sLine, bool& bSilent) { tCommand cmd; ULONG step = ReadCommand(sLine); if (!sLine.IsEmpty()) { CString s; s = sLine; ParseCommand(s, cmd, step, bSilent); } else { cmd.cmdId = cmdComment; cmd.line = currentLine; cmd.lineDot = currentDot; } return cmd; }
static portTASK_FUNCTION(ShellTask, pvParameters) { static unsigned char cmd_buf[48]; (void)pvParameters; (void)FSSH1_ParseCommand((unsigned char*)FSSH1_CMD_HELP, FSSH1_GetStdio(), ParseCommand); /* print help and prints as well the prompt */ cmd_buf[0] = '\0'; for(;;) { #if PL_USE_USB_SCI static char_t usb_tx_buf[USB1_DATA_BUFF_SIZE]; (void)CDC1_App_Task(usb_tx_buf, sizeof(usb_tx_buf)); /* Call the USB application task */ #endif (void)FSSH1_ReadAndParseLine(cmd_buf, sizeof(cmd_buf), FSSH1_GetStdio(), ParseCommand); #if PL_HAS_QUEUE #if QUEUE_SINGLE_CHAR { unsigned char ch; FSSH1_StdIO_OutErr_FctType io = FSSH1_GetStdio()->stdOut; while((ch=QUEUE_ReceiveChar()) && ch!='\0') { io(ch); } } #else { const unsigned char *msg; msg = QUEUE_ReceiveMessage(); if (msg!=NULL) { FSSH1_SendStr(msg, FSSH1_GetStdio()->stdOut); FRTOS1_vPortFree((void*)msg); } } #endif #endif #if PL_HAS_I2C if (SHELL_i2Commands && I2C_ReceiveCommand(cmd_buf, sizeof(cmd_buf))==ERR_OK) { bool handled = FALSE; (void)ParseCommand(cmd_buf, &handled, FSSH1_GetStdio()); } #endif FRTOS1_vTaskDelay(50/portTICK_RATE_MS); } }
int CommandObject::Welcome(char* filename) { LayerSetObject lso; if(IsType(filename,"bmp")) { while (lso.CreateLayer(filename)==-1) cin>>filename; cout<<"bmp图像打开完成,请输入命令。如需帮助,请输入HELP。"<<endl; string scmd; do{ getline(cin,scmd); char tscmd[MAX_LINE_LENGTH]; strcpy(tscmd,scmd.c_str()); ParseCommand(lso,tscmd); }while(strcmp(parameter[0],"exit")!=0); } else
void ConsoleAPI::ExecuteCommand(const QString &command) { PROFILE(ConsoleAPI_ExecuteCommand); QString commandName; QStringList parameterList; ParseCommand(command, commandName, parameterList); if (commandName.isEmpty()) return; CommandMap::iterator iter = commands.find(commandName); if (iter == commands.end()) { LogError("Cannot find a console command \"" + commandName + "\"!"); return; } iter->second->Invoke(parameterList); }
bool P2PProxyClientSession::ProceesSystemCommand(const char *data, uint16 len) { ASSERT(signal_thread_->IsCurrent()); LOG_P2P(P2P_PROXY_SOCKET_DATA) << "process System command"; /////////////////////////////////////////////////////////////////////////// //BUSINESS LOGIC NOTE (GuangleiHe, 11/28/2013) //There didn't used P2PRTSPCommand to parse the data. //P2PRTSPCommand only known by P2PSystemCommandFactory /////////////////////////////////////////////////////////////////////////// //Step 1. Parse the system command. uint32 p2p_system_command_type; uint32 server_socket; uint32 client_socket; uint32 client_connection_ip; uint16 client_connection_port; if(!ParseCommand(data,len,&p2p_system_command_type,&server_socket, &client_socket,&client_connection_ip,&client_connection_port)){ LOG(LS_ERROR) << "Parse the p2p system command error"; return false; } ////////////////////////////////////////////////////////////////////////// if(p2p_system_command_type == P2P_SYSTEM_CREATE_CLIENT_SOCKET){ LOG_P2P(P2P_PROXY_SOCKET_LOGIC) << "Create New Client Socket"; //Step 1. Create AsyncSocket object. talk_base::AsyncSocket *int_socket = worker_thread_->socketserver()->CreateAsyncSocket(SOCK_STREAM); talk_base::SocketAddress server_addr(client_connection_ip,client_connection_port); new P2PProxyClientSocketBinding(new P2PProxyEndSocket(this,server_socket), int_socket,server_addr); } else if(p2p_system_command_type == P2P_SYSTEM_SOCKET_CLOSE){ LOG_P2P(P2P_PROXY_SOCKET_LOGIC) << "close server socket "; is_self_close = false; P2PProxySocket *res = GetP2PProxySocket(server_socket); if(res != NULL) res->OnP2PClose(this); } return true; }
/// %Thread start void CliRunnable::run() { ///- Init new SQL thread for the world database (one connection call enough) sDatabase.ThreadStart(); // let thread do safe mySQL requests char commandbuf[256]; ///- Display the list of available CLI functions then beep sLog.outString(""); /// \todo Shoudn't we use here also the sLog singleton? CliHelp(NULL,&printf); if(sConfig.GetIntDefault("BeepAtStart", 1) > 0) { printf("\a"); // \a = Alert } ///- As long as the World is running (no World::m_stopEvent), get the command line and handle it while (!World::m_stopEvent) { printf("mangos>"); fflush(stdout); char *command = fgets(commandbuf,sizeof(commandbuf),stdin); if (command != NULL) { for(int x=0;command[x];x++) if(command[x]=='\r'||command[x]=='\n') { command[x]=0; break; } //// \todo Shoudn't we use here also the sLog singleton? ParseCommand(&printf,command); } else if (feof(stdin)) { World::m_stopEvent = true; } } ///- End the database thread sDatabase.ThreadEnd(); // free mySQL thread resources }
void PipeDevice::UpdateInput() { // Read any pending characters off the pipe. If we hit a newline, // then dequeue a command off the front of m_buf and parse it. char buf[32]; ssize_t bytes_read = read(m_fd, buf, sizeof buf); while (bytes_read > 0) { m_buf.append(buf, bytes_read); bytes_read = read(m_fd, buf, sizeof buf); } std::size_t newline = m_buf.find("\n"); while (newline != std::string::npos) { std::string command = m_buf.substr(0, newline); ParseCommand(command); m_buf.erase(0, newline + 1); newline = m_buf.find("\n"); } }
/* Plugin processes console command. Return 0 if plugin handled the command, 1 if not handled. */ int ts3plugin_processCommand(uint64 serverConnectionHandlerID, const char* command) { size_t length = strlen(command); char* str = (char*)malloc(length+1); _strcpy(str, length+1, command); // Seperate the argument from the command char* arg = strchr(str, ' '); if(arg != NULL) { // Split the string by inserting a NULL-terminator *arg = (char)NULL; arg++; } ParseCommand(str, arg); free(str); return 0; /* Plugin did not handle command */ }
// вызывается, когда хост отправляет порцию данных к устройству; см. usbdrv.h uchar usbFunctionWrite(uchar *data, uchar len) { if (bytesRemaining == 0) // конец передачи return 1; if (len > bytesRemaining) len = bytesRemaining; uchar *buffer = (uchar*)&packet; uchar j; for (j = 0; j < len; j++) buffer[j + readIdx] = data[j]; readIdx += len; bytesRemaining -= len; if (bytesRemaining == 0) // Все данные получены ParseCommand(); return bytesRemaining == 0; // false означает, что есть еще данные }
int main(int argc, char *argv[]) { int error = 0; if ((argc == 2) && (strcmp(argv[1], "-v") == 0)) { ShowVersion(); return 0; } if ((InitClient()) || (ConnectToMiranda()) || (GetKnownCommands()) || (LoadLangPackModule())) { lpprintf("Could not create connection with Miranda or could not retrieve list of known commands.\n"); error = MIMRES_NOMIRANDA; } else{ if ((argc <= 1) || (argc > MAX_ARGUMENTS)) { PrintUsage(); } else{ PReply reply = ParseCommand(argv, argc); if (reply) { error = reply->code; lpprintf("%s\n", reply->message); } else{ lpprintf(Translate("Unknown command '%s'.\n"), argv[1]); } DestroyKnownCommands(); DisconnectFromMiranda(); DestroyClient(); } } return error; }