您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ trim函数代码示例

51自学网 2021-06-03 08:58:46
  C++
这篇教程C++ trim函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中trim函数的典型用法代码示例。如果您正苦于以下问题:C++ trim函数的具体用法?C++ trim怎么用?C++ trim使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了trim函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: fopen

bool LexicsCutter::Read_Innormative_Words(std::string& FileName){    FILE *ma_file;    char line[1024];    unsigned int pos;    std::string line_s;    std::string lchar;    ma_file = fopen(FileName.c_str(), "rb");    if (!ma_file)    {        sLog.outError("Chat lexics cutter disabled. Reason: LexicsCutterWordsFile file does not exist in the server directory.");        return false;    }    while (!feof(ma_file))    {        line[0] = 0x0;        fgets(line, 1020, ma_file);        // check for UTF8 prefix and comment        if (strlen(line) >= 3)        {            if (line[0] == '/xEF' && line[1] == '/xBB' && line[2] == '/xBF')            {                strncpy(&line[0], &line[3], strlen(line) - 3);            }        }        if (strlen(line) >= 2)        {            if (line[0] == '/' && line[1] == '/') continue;        }        // check for empty string        line_s = line;        line_s = trim(line_s, "/x0A/x0D/x20");        if (line_s == "") continue;        // process line without CR/LF        line_s = line;        line_s = trim(line_s, "/x0A/x0D");        // create word vector of vectors        LC_WordVector vw;        pos = 0;        while (ReadUTF8(line_s, lchar, pos))        {            // create letter set            LC_LetterSet vl;            // initialize letter set with letter read            vl.insert(lchar);            // find letter analogs and push them onto the vector            LC_AnalogMap::iterator itr = AnalogMap.find(lchar);            if (itr != AnalogMap.end())            {                // analogs present, iterate                for (LC_AnalogVector::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); itr2++)                {                    vl.insert(*itr2);                }            }            // add letter vector to word vector            vw.push_back(vl);        }        // push new word to words list        WordList.push_back(vw);    }    fclose(ma_file);    return true;}
开发者ID:xXNembiXx,项目名称:mangos_335,代码行数:78,


示例2: login_mmo_auth

/** * Check/authentication of a connection. * @param sd: string (atm:md5key or dbpass) * @param isServer: string (atm:md5key or dbpass) * @return : *	-1: success *	0: unregistered id; *	1: incorrect pass; *	2: expired id *	3: blacklisted (or registration limit exceeded if new acc); *	5: invalid client_version|hash; *	6: banned *	x: acc state (TODO document me deeper) */int login_mmo_auth(struct login_session_data* sd, bool isServer) {	struct mmo_account acc;	int len;	char ip[16];	ip2str(session[sd->fd]->client_addr, ip);	// DNS Blacklist check	if( login_config.use_dnsbl ) {		char r_ip[16];		char ip_dnsbl[256];		char* dnsbl_serv;		uint8* sin_addr = (uint8*)&session[sd->fd]->client_addr;		sprintf(r_ip, "%u.%u.%u.%u", sin_addr[0], sin_addr[1], sin_addr[2], sin_addr[3]);		for( dnsbl_serv = strtok(login_config.dnsbl_servs,","); dnsbl_serv != NULL; dnsbl_serv = strtok(NULL,",") ) {			sprintf(ip_dnsbl, "%s.%s", r_ip, trim(dnsbl_serv));			if( host2ip(ip_dnsbl) ) {				ShowInfo("DNSBL: (%s) Blacklisted. User Kicked./n", r_ip);				return 3;			}		}	}	//Client Version check	if( login_config.check_client_version && sd->version != login_config.client_version_to_connect ){		ShowNotice("Invalid version (account: '%s', auth_vers: '%d', received version: '%d', ip: %s)/n",			sd->userid, login_config.client_version_to_connect, sd->version, ip);		return 5;	}	len = strnlen(sd->userid, NAME_LENGTH);	// Account creation with _M/_F	if( login_config.new_account_flag ) {		if( len > 2 && strnlen(sd->passwd, NAME_LENGTH) > 0 && // valid user and password lengths			sd->passwdenc == 0 && // unencoded password			sd->userid[len-2] == '_' && memchr("FfMm", sd->userid[len-1], 4) ) // _M/_F suffix		{			int result;			// remove the _M/_F suffix			len -= 2;			sd->userid[len] = '/0';			result = login_mmo_auth_new(sd->userid, sd->passwd, TOUPPER(sd->userid[len+1]), ip);			if( result != -1 )				return result;// Failed to make account. [Skotlex].		}	}	if( !accounts->load_str(accounts, &acc, sd->userid) ) {		ShowNotice("Unknown account (account: %s, received pass: %s, ip: %s)/n", sd->userid, sd->passwd, ip);		return 0; // 0 = Unregistered ID	}	if( !login_check_password(sd->md5key, sd->passwdenc, sd->passwd, acc.pass) ) {		ShowNotice("Invalid password (account: '%s', pass: '%s', received pass: '%s', ip: %s)/n", sd->userid, acc.pass, sd->passwd, ip);		return 1; // 1 = Incorrect Password	}	if( acc.expiration_time != 0 && acc.expiration_time < time(NULL) ) {		ShowNotice("Connection refused (account: %s, pass: %s, expired ID, ip: %s)/n", sd->userid, sd->passwd, ip);		return 2; // 2 = This ID is expired	}	if( acc.unban_time != 0 && acc.unban_time > time(NULL) ) {		char tmpstr[24];		timestamp2string(tmpstr, sizeof(tmpstr), acc.unban_time, login_config.date_format);		ShowNotice("Connection refused (account: %s, pass: %s, banned until %s, ip: %s)/n", sd->userid, sd->passwd, tmpstr, ip);		return 6; // 6 = Your are Prohibited to log in until %s	}	if( acc.state != 0 ) {		ShowNotice("Connection refused (account: %s, pass: %s, state: %d, ip: %s)/n", sd->userid, sd->passwd, acc.state, ip);		return acc.state - 1;	}	if( login_config.client_hash_check && !isServer ) {		struct client_hash_node *node = NULL;		bool match = false;		for( node = login_config.client_hash_nodes; node; node = node->next ) {			if( acc.group_id < node->group_id )				continue;//.........这里部分代码省略.........
开发者ID:Akheon23,项目名称:rathena,代码行数:101,


示例3: server

 static intserver(char **argv, char *pname[2], int p[2]){	Engine *ep;	FILE *f;	char buf[4096], buf1[4096], *msg, *s, *t;	int rc;#if 0/*def SERVER_DEBUG*/	printf("Server got/tpname[0] = /"%s/"/nand/t/tpname[1] = /"%s/"/n",		pname[0], pname[1]);	if (*argv) {		int i;		printf("Args for MATLAB to interpret:/n");		for(i = 0; argv[i]; i++)			printf("/t/"%s/"/n", argv[i]);		}#endif	if (exists(pname[0], 1) || exists(pname[1], 1))		return 1;	if (mkfifo(pname[0], 0600))		return mkfifo_fail(pname[0]);	if (mkfifo(pname[1], 0600)) {		unlink(pname[0]);		return mkfifo_fail(pname[1]);		}	s = *argv;        //if(s){ printf("%s/n",s); fflush(stdout);}	ep = engOpen(s ? s : "matlab -logfile engine.log");	if (!ep) {		Squawk("could not start MATLAB/n");		return 1;		}	/*DEBUG*/engOutputBuffer(ep, mbuf, sizeof(mbuf)-1);	if (s)		while(s = *++argv)			engEvalString(ep, s);	if (p[1] >= 0) {		close(p[0]);		write(p[1], "OK/n", 3);		close(p[1]);		}	rc = 1;	for(;;) {		f = fopen(pname[0], "r");		if (!f)			break;		s = fgets(buf, sizeof(buf), f);		if (!s) {			fclose(f);			break;			}		trim(s);		if (!*s) {			Squawk("server: empty parameters_file name/n");/ bailout:			fclose(f);			break;			}		if (!strcmp(s,"quit")) {			rc = 0;			goto bailout;			}		t = fgets(buf1, sizeof(buf1), f);		fclose(f);		if (!t) {			Squawk("server expected 2 lines from /"%s/"; only got 1./n",				pname[0]);			break;			}		trim(t);		msg = process(ep, s, t) ? "evaluation error" : "results_file written";		f = fopen(pname[1],"w");		if (!f) {			Squawk("Could not open pipe2 file /"%s/"/n", pname[1]);			break;			}		fprintf(f, "%s/n", msg);		fclose(f);		}	engClose(ep);	unlink(pname[0]);	unlink(pname[1]);	return rc;	}
开发者ID:ImageGuidedTherapyLab,项目名称:DakotaApplications,代码行数:84,


示例4: handleClient

void RequestHandler :: handleClient( int fd ){	Connection conn( fd );	HttpMessage request, response;		std::string content;	std::vector< std::string > parts;	std::string body;			bool done = false;		size_t request_counter = 0;		conn.set_timeout( 15 );		while( !done ){				try{			//std::cerr << "Handler " << *ptr_fd << " receiving..." << std::endl;			while( content.find( "/r/n/r/n" ) == std::string::npos ){				content += conn.receive( 1024 );				}			} catch( std::string error ){				//std::cerr << "RH: ERROR: " << error << std::endl;				done = true;				continue;				}		//std::cerr << "Handler " << *ptr_fd << " done receiving..." << std::endl;					//std::cerr << "content: '" << content << "'" << std::endl;		parts = split_string( content, "/r/n/r/n" );		if( parts.size() > 1 ){			for( size_t i = 1 ; i < parts.size() - 1 ; ++i ){				body += parts[i] + std::string( "/r/n/r/n" );				}			body += parts[parts.size()-1];			}		content.clear();		std::vector<std::string> header_lines = split_string( parts[0], "/r/n" );		std::vector< std::string > request_line = split_string( header_lines[0], " " );		//std::cerr << "request_line: '" << header_lines[0] << "' and header_lines.size() = " << header_lines.size() << "request_line.size() = " <<  << std::endl;		if( header_lines.size() < 2 || request_line.size() != 3 ){			// return error response			//conn.disconnect();			std::cerr << "RH: ERROR: " << "Invalid request line!" << std::endl;			done = true;			continue;			}				request.set_method( request_line[0] );		request.set_path( request_line[1] );		request.set_version( request_line[2] );		for( size_t i = 1 ; i < header_lines.size() ; ++i ){			std::vector<std::string> tmp = split_string( header_lines[i], ":" );			if( tmp.size() > 2 ){				std::string str;				for( size_t i = 1 ; i < tmp.size() - 1 ; ++i ){					str += tmp[i] + std::string( ":" );					}				str += tmp[tmp.size()-1];				request.set_header_field( trim(tmp[0] ), trim( str ) );				}			else{				request.set_header_field( trim( tmp[0] ), trim( tmp[1] ) );				}			}						if( ( request_line[0] == "PUT" ) || ( request_line[0] == "POST" ) ){			size_t content_length = 0;						if( request.has_header_field( "Content-Length" ) ){				content_length = string_to_integer( request.get_header_field( "Content-Length" ) );				}			if( request.has_header_field( "Transfer-Encoding" ) ){				if( request.get_header_field( "Transfer-Encoding" ) == "chunked" ){					bool chunks_done = false;					size_t chunk_size = 0, pos;					content = body;					body.clear();										while( !chunks_done ){						pos = content.find( "/r/n" );						if( pos != std::string::npos ){							std::string hex = content.substr( 0, pos );							chunk_size = hex_string_to_integer( trim( hex ) );							content = content.substr( pos+2 );							if( chunk_size == 0 ){ chunks_done = true; continue; }							}												try{							while( content.size() < chunk_size+2 ){								content += conn.receive( chunk_size - content.size() + 2 );								}							} catch( std::string error ){								//std::cerr << "RH: ERROR: " << error << std::endl;								 								done = true;								continue;//.........这里部分代码省略.........
开发者ID:mgronhol,项目名称:Saiga,代码行数:101,


示例5: mme_app_config_init

//.........这里部分代码省略.........                  && config_setting_lookup_string(subsetting,                          PGW_CONFIG_STRING_PGW_INTERFACE_NAME_FOR_SGI,                          (const char **)&pgw_interface_name_for_SGI)                  && config_setting_lookup_string(subsetting,                          PGW_CONFIG_STRING_PGW_IPV4_ADDR_FOR_SGI,                          (const char **)&pgw_ipv4_address_for_SGI)                )            ) {              config_pP->pgw_config.ipv4.pgw_interface_name_for_S5_S8 = strdup(pgw_interface_name_for_S5_S8);              cidr = strdup(pgw_ipv4_address_for_S5_S8);              address = strtok(cidr, "/");              mask    = strtok(NULL, "/");              IPV4_STR_ADDR_TO_INT_NWBO ( address, config_pP->pgw_config.ipv4.pgw_ipv4_address_for_S5_S8, "BAD IP ADDRESS FORMAT FOR S5_S8 !/n" )              config_pP->pgw_config.ipv4.pgw_ip_netmask_for_S5_S8 = atoi(mask);              free(cidr);              config_pP->pgw_config.ipv4.pgw_interface_name_for_SGI = strdup(pgw_interface_name_for_SGI);              cidr = strdup(pgw_ipv4_address_for_SGI);              address = strtok(cidr, "/");              mask    = strtok(NULL, "/");              IPV4_STR_ADDR_TO_INT_NWBO ( address, config_pP->pgw_config.ipv4.pgw_ipv4_address_for_SGI, "BAD IP ADDRESS FORMAT FOR SGI !/n" )              config_pP->pgw_config.ipv4.pgw_ip_netmask_for_SGI = atoi(mask);              free(cidr);          }      }      subsetting = config_setting_get_member (setting_pgw, PGW_CONFIG_STRING_IP_ADDRESS_POOL);      if(subsetting != NULL) {          sub2setting = config_setting_get_member (subsetting, PGW_CONFIG_STRING_IPV4_ADDRESS_LIST);          if(sub2setting != NULL) {              num     = config_setting_length(sub2setting);              for (i = 0; i < num; i++) {                  astring = config_setting_get_string_elem(sub2setting,i);                  if (astring != NULL) {                      trim(astring, strlen(astring)+1);                      if (inet_pton(AF_INET, astring, buf_in_addr) < 1) {                          // failure, test if there is a range specified in the string                          atoken = strtok(astring, PGW_CONFIG_STRING_IP_ADDRESS_RANGE_DELIMITERS);                          if (inet_pton(AF_INET, astring, buf_in_addr) == 1) {                              memcpy (&addr_start, buf_in_addr, sizeof(struct in_addr));                              // valid address                              atoken2 = strtok(NULL, PGW_CONFIG_STRING_IP_ADDRESS_RANGE_DELIMITERS);                              if (inet_pton(AF_INET, atoken2, buf_in_addr) == 1) {                                  memcpy (&addr_end, buf_in_addr, sizeof(struct in_addr));                                  // valid address                                  for (jh = ntohl(addr_start.s_addr); jh <= ntohl(addr_end.s_addr); jh++) {                                      DevAssert(PGW_MAX_ALLOCATED_PDN_ADDRESSES > config_pP->pgw_config.pool_pdn_addresses.num_ipv4_addresses);                                      jn = htonl(jh);                                      if (IN_CLASSA(addr_start.s_addr)) {                                          if ((jh & 0xFF) && (jh & 0xFF) != 0xFF) {                                              config_pP->pgw_config.pool_pdn_addresses.ipv4_addresses[config_pP->pgw_config.pool_pdn_addresses.num_ipv4_addresses++].s_addr = jn;                                          }                                      } else if (IN_CLASSB(addr_start.s_addr)) {                                          if ((jh & 0xFF) && (jh & 0xFF) != 0xFF) {                                              config_pP->pgw_config.pool_pdn_addresses.ipv4_addresses[config_pP->pgw_config.pool_pdn_addresses.num_ipv4_addresses++].s_addr = jn;                                          }                                      } else if (IN_CLASSC(addr_start.s_addr)) {                                          if ((jh & 0xFF) && (jh & 0xFF) != 0xFF) {                                              config_pP->pgw_config.pool_pdn_addresses.ipv4_addresses[config_pP->pgw_config.pool_pdn_addresses.num_ipv4_addresses++].s_addr = jn;                                          }                                      } else {                                          printf("ERROR ON ADDRESS CLASS %d.%d.%d.%d/n", NIPADDR(jn));                                      }                                  }                              }                          }                      } else {
开发者ID:ppenumarthi,项目名称:openair,代码行数:67,


示例6: trim

stringNancyBot::askNancy(string msg_input){	string msg_out = "PCManX-NancyBot";  // init msg_out	if( (BOT_RUN_LEVEL & USE_TEACH )&& (BOT_RUN_LEVEL & USE_AUTO_LEARN))	{		unsigned int get_here;		if( (get_here = msg_input.find_first_of('=')) != string::npos ) // found		{			string str_first = msg_input.substr(0,get_here);			string str_second = msg_input.substr(get_here+1);			str_first = trim(str_first);			str_second = trim(str_second);			if(!(str_first.empty() || str_second.empty()))			{				pMyMsgData->learning(str_first, str_second);				return "Got it!";			}		}	}	if (BOT_RUN_LEVEL & USE_USER_DEFINED_USAGES)	{		unsigned int get_here;		if( (get_here = msg_input.find_first_of('|')) != string::npos ) // found		{			string str_first = msg_input.substr(0,get_here);			string str_second = msg_input.substr(get_here+1);			str_first = trim(str_first);			str_second = trim(str_second);			if(!(str_first.empty() || str_second.empty()))			{				if(pMyMsgData->getUserDefinedUsages(str_first, str_second, msg_out ))					return msg_out;			}		}	}	BOT_STATUS = 0;	add_to_unknow = true;	string unknow_msg;	if(level__add_to_unknow_msg_changed)	{		pMyMsgData->setLevel__AddToUnknowMsg(LEVEL__ADD_TO_UNKNOW_MSG);		level__add_to_unknow_msg_changed = false;	}	if(level__re_learning_changed)	{		pMyMsgData->setLevel__ReLearning(LEVEL__RE_LEARNING);		level__re_learning_changed = false;	}		if(just_asked) // AUTO_LEARN	{		pMyMsgData->learning(just_asked_unknow_msg, msg_input);		just_asked = false;		add_to_unknow = false;	}		if( BOT_RUN_LEVEL & USE_AUTO_LEARN)	{		if( (unsigned int) (rand()%100 ) < LEVEL__ASK_UNKNOW_MSG )			BOT_STATUS = 3; // Auto learn;		if(BOT_STATUS == 3)		{			if(pMyMsgData->getSpecialMsg(BOT_STATUS, msg_out ) == 0){				// should not here			}			else			{				// get a msg that bot unknow to ask								if(pMyMsgData->getUnknowMsgToAsk(unknow_msg)) // got it				{					replaceString(msg_out, ask_flag, unknow_msg);					just_asked = true;					just_asked_unknow_msg = unknow_msg;										if( BOT_RUN_LEVEL & USE_LOG )					{						writeLog(msg_input, msg_out);					}					return msg_out;					}			}		} // end (BOT_STATUS = 3)	} // end (USE_AUTO_LEARN)			if( BOT_RUN_LEVEL & USE_ANGRY )	{		if( checkMsgRepeat(msg_input) > 3)		{			BOT_STATUS = 1;   // anacy is angry			if(pMyMsgData->getSpecialMsg(BOT_STATUS, msg_out ) == 0){				//should not run here			}		}	}		//.........这里部分代码省略.........
开发者ID:ShchaTyaGrokhnU,项目名称:pcmanx-gtk2,代码行数:101,


示例7: steps

SimulateOptions::SimulateOptions(const std::string &fname):steps(50),start(0),duration(5),absolute(MaxAbsolute),relative(MaxRelative),flags(0),integrator(CVODE),integratorOpt(0){    if(!fname.size())    {        Log(lError)<<"Empty file name for setings file";    }    else    {        map<string, string> settings;        map<string, string>::iterator it;        //Read each line in the settings file        vector<string> lines = getLinesInFile(fname);        for(int i = 0; i < lines.size(); i++)        {            vector<string> line = splitString(lines[i], ":");            if(line.size() == 2)            {                settings.insert( pair<string, string>(line[0], line[1]));            }            else            {                Log(lDebug2)<<"Empty line in settings file: "<<lines[i];            }        }        Log(lDebug3)<<"Settings File =============";        for (it = settings.begin() ; it != settings.end(); it++ )        {            Log(lDebug) << (*it).first << " => " << (*it).second;        }        Log(lDebug)<<"===========================";        //Assign values        it = settings.find("start");        start = (it != settings.end())   ? toDouble((*it).second) : 0;        it = settings.find("duration");        duration = (it != settings.end())    ? toDouble((*it).second) : 0;        it = settings.find("steps");        steps = (it != settings.end())       ? toInt((*it).second) : 50;        it = settings.find("absolute");        absolute = (it != settings.end())    ? toDouble((*it).second) : 1.e-7;        it = settings.find("relative");        relative = (it != settings.end())    ? toDouble((*it).second) : 1.e-4;        it = settings.find("variables");        if(it != settings.end())        {            vector<string> vars = splitString((*it).second, ",");            for(int i=0; i < vars.size(); i++)            {                variables.push_back(trim(vars[i]));            }        }        it = settings.find("amount");        if(it != settings.end())        {            vector<string> vars = splitString((*it).second, ",");            for(int i=0; i < vars.size(); i++)            {                string rec = trim(vars[i]);                if(rec.size())                {                    amounts.push_back(rec);                }            }        }        it = settings.find("concentration");        if(it != settings.end())        {            vector<string> vars = splitString((*it).second, ",");            for(int i=0; i < vars.size(); i++)            {                string rec = trim(vars[i]);                if(rec.size())                {                    concentrations.push_back(rec);                }            }        }    }    if (absolute > MaxAbsolute) {        absolute = MaxAbsolute;    }//.........这里部分代码省略.........
开发者ID:Alcibiades586,项目名称:roadrunner,代码行数:101,


示例8: on_xiphos_web_listener_ready_callback

void on_xiphos_web_listener_ready_callback (SoupSession *session, SoupMessage *msg, gpointer user_data){	if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {		// Get the response body.		string body (msg->response_body->data);		body = trim (body);		// Log it.    //printf ("%s/n", body.c_str());    //fflush (stdout);    ParseLine parseline (body);    if (parseline.lines.size() >= 3) {      // It retrieves the message ID and uses this to ask for a higher ID next poll.      // Update GUI.      last_message_id = parseline.lines[0];      gtk_label_set_text (GTK_LABEL (label_id), last_message_id.c_str());      string command = parseline.lines[1];      gtk_label_set_text (GTK_LABEL (label_command), command.c_str());      string body = parseline.lines[2];      gtk_label_set_text (GTK_LABEL (label_body), body.c_str());      // Handle "quit" command.      if (command == "quit") {        gtk_main_quit ();      }      // Handle "focus" command.      if (command == "focus") {        Parse parse (body, false, ".");        if (parse.words.size() == 3) {          string book;          switch (convert_to_int (parse.words[0])) {            case 1: book = "Gen"; break;            case 2: book = "Exod"; break;            case 3: book = "Lev"; break;            case 4: book = "Num"; break;            case 5: book = "Deut"; break;            case 6: book = "Josh"; break;            case 7: book = "Judg"; break;            case 8: book = "Ruth"; break;            case 9: book = "1Sam"; break;            case 10: book = "2Sam"; break;            case 11: book = "1Kgs"; break;            case 12: book = "2Kgs"; break;            case 13: book = "1Chr"; break;            case 14: book = "2Chr"; break;            case 15: book = "Ezra"; break;            case 16: book = "Neh"; break;            case 17: book = "Esth"; break;            case 18: book = "Job"; break;            case 19: book = "Ps"; break;            case 20: book = "Prov"; break;            case 21: book = "Eccl"; break;            case 22: book = "Song"; break;            case 23: book = "Isa"; break;            case 24: book = "Jer"; break;            case 25: book = "Lam"; break;            case 26: book = "Ezek"; break;            case 27: book = "Dan"; break;            case 28: book = "Hos"; break;            case 29: book = "Joel"; break;            case 30: book = "Amos"; break;            case 31: book = "Obad"; break;            case 32: book = "Jonah"; break;            case 33: book = "Mic"; break;            case 34: book = "Nah"; break;            case 35: book = "Hab"; break;            case 36: book = "Zeph"; break;            case 37: book = "Hag"; break;            case 38: book = "Zech"; break;            case 39: book = "Mal"; break;            case 40: book = "Matt"; break;            case 41: book = "Mark"; break;            case 42: book = "Luke"; break;            case 43: book = "John"; break;            case 44: book = "Acts"; break;            case 45: book = "Rom"; break;            case 46: book = "1Cor"; break;            case 47: book = "2Cor"; break;            case 48: book = "Gal"; break;            case 49: book = "Eph"; break;            case 50: book = "Phil"; break;            case 51: book = "Col"; break;            case 52: book = "1Thess"; break;            case 53: book = "2Thess"; break;            case 54: book = "1Tim"; break;            case 55: book = "2Tim"; break;            case 56: book = "Titus"; break;            case 57: book = "Phlm"; break;            case 58: book = "Heb"; break;            case 59: book = "Jas"; break;            case 60: book = "1Pet"; break;            case 61: book = "2Pet"; break;            case 62: book = "1John"; break;            case 63: book = "2John"; break;            case 64: book = "3John"; break;            case 65: book = "Jude"; break;            case 66: book = "Rev"; break;          }          if (!book.empty()) {            string reference = "sword://" + book + "." + parse.words[1] + "." + parse.words[2];            send_to_xiphos (xiphos_dbus_object (), xiphos_dbus_interface (), "setCurrentReference", reference);            reference.insert (0, "setCurrentReference ");//.........这里部分代码省略.........
开发者ID:alerque,项目名称:bibledit,代码行数:101,


示例9: setStartPosition

void PathInfo::Update(const float destX, const float destY, const float destZ){    float x, y, z;    // update start and end    m_sourceObject->GetPosition(x, y, z);    setStartPosition(x, y, z);    setEndPosition(destX, destY, destZ);    // make sure navMesh works    if(!m_navMesh)    {        m_sourceObject->GetPosition(x, y, z);        m_navMesh = m_sourceObject->GetMap()->GetNavMesh();        if(!m_navMesh)        {            // can't pathfind if navmesh doesn't exist            shortcut();            return;        }    }    if(!m_pathPolyRefs)    {        // path was not built before, most likely because navmesh wasn't working        // start from scratch, then return        Build();        return;    }    // should be safe to update path now    bool startOffPath = false;    bool endOffPath = false;    // find start and end poly    // navMesh.findNearestPoly is expensive, so first we check just the current path    getStartPosition(x, y, z);    dtPolyRef startPoly = getPathPolyByPosition(x, y, z);    getEndPosition(x, y, z);    dtPolyRef endPoly = getPathPolyByPosition(x, y, z);    if(startPoly != 0 && endPoly != 0)        trim(startPoly, endPoly);    else    {        // start or end is off the path, need to find the polygon        float extents[3] = {2.f, 4.f, 2.f};      // bounds of poly search area        dtQueryFilter filter = dtQueryFilter();     // filter for poly search        if(!startPoly)        {            getStartPosition(x, y, z);            float startPos[3] = {y, z, x};            startOffPath = true;            startPoly = m_navMesh->findNearestPoly(startPos, extents, &filter, 0);        }        if(!endPoly)        {            getEndPosition(x, y, z);            float endPos[3] = {y, z, x};            endOffPath = true;            endPoly = m_navMesh->findNearestPoly(endPos, extents, &filter, 0);        }        if(startPoly == 0 || endPoly == 0)        {            // source or dest not near navmesh polygons:            // flying, falling, swimming, or navmesh has a hole            // ignore obstacles/terrain is better than giving up            // PATHFIND TODO: prevent walking/swimming mobs from flying into the air            shortcut();            return;        }    }    if(startPoly == endPoly)    {        // start and end are on same polygon        // just need to move in straight line        // PATHFIND TODO: prevent walking/swimming mobs from flying into the air        clear();        m_pathPolyRefs = new dtPolyRef[1];        m_pathPolyRefs[0] = startPoly;        m_length = 1;        getEndPosition(x, y, z);        setNextPosition(x, y, z);        m_type = PathType(m_type | PATHFIND_NORMAL);        return;    }    if(startOffPath)    {        bool adjacent = false;        int i;//.........这里部分代码省略.........
开发者ID:klaas-netherstorm,项目名称:Mangos,代码行数:101,


示例10: main

int main(int argc, char* argv[], char *envp[]) {       // If you use execvp() without a fork, it'll take over the main system.    // This is why you need to fork a process, then call execvp()    list<char**> arguments;    list<char*> connectors;    // Grabs host name    char* login;    char host[127];    login = getlogin();    if (gethostname(host, 127) != 0) {        perror("failed to gethostname");        exit(EXIT_FAILURE);    }       string command = "";    printInfo(login, host);    cout << "$ ";    while (getline(cin, command)) {        while (command.length() == 0) {            printInfo(login, host);            cout << "$ ";            getline(cin,command);        }        char* cstrcmd = '/0';        list<char*> tokens;        list<char*> data;        cstrcmd = new char[command.size() + 1];         // This data is universal. It will be used until deallocated.        strcpy(cstrcmd, command.c_str());        data.push_back(cstrcmd);        // This is to hold locations of the data to deallocate later                tokens = parse(cstrcmd);        /*if (isDblConnector(tokens.back())) {            tokens.pop_back();            cout << "Terminated without command -- ignoring leading connector."                 << endl;        }*/        while (isDblConnector(tokens.back())) {             // If the stupid user ended with a connector            list<char*> tmpCmds;            cout << "> ";            getline(cin, command);            cstrcmd = new char[command.size() + 1];            strcpy(cstrcmd, command.c_str());            data.push_back(cstrcmd);            tmpCmds = parse(cstrcmd);            while (!tmpCmds.empty()) {                tokens.push_back(tmpCmds.front());                tmpCmds.pop_front();            }        }        // Creating the two argument and connector lists        int last; // There definitely has to be a better way to do this.        char* cmd[128][256];         // cmd is a list of pointers to the beginning of each token of the         // universal data        int n = 0;        for (int i = 0; !tokens.empty(); ++i) {            cutEndSpaces(tokens.front());            if (isQuoteBegin(tokens.front())) { // Quote parsing                trim(tokens.front());                while (!isQuoteEnd(tokens.front())) {                 // Input clause should prevent infinite loop                    cmd[n][i] = tokens.front();                    tokens.pop_front();                    ++i;                }                truncate(tokens.front()); // Cuts off the quotation mark                if (isAttached(tokens.front())) { // Same clause as below                     truncate(tokens.front());                     // This one should cut off the semicolon                     cmd[n][i] = tokens.front();                     tokens.front() = new char[1];                     data.push_back(tokens.front());                    strcpy(tokens.front(), ";/0");                     tokens.push_front(NULL); // Phony Value                }                else {                    cmd[n][i] = tokens.front(); // Throws it into the list                }                ++i;            }            else if (isComment(tokens.front())) break;            else if (isConnector(tokens.front())) {//.........这里部分代码省略.........
开发者ID:makloooo,项目名称:rshell,代码行数:101,


示例11: skinRead

int skinRead( char * dname ){ unsigned char   tmp[255]; unsigned char * ptmp; unsigned char   command[32]; unsigned char   param[256]; int             c,i; setname( skinDirInHome,dname ); if ( ( skinFile = fopen( fn,"rt" ) ) == NULL )  {   setname( skinMPlayerDir,dname );   if ( ( skinFile = fopen( fn,"rt" ) ) == NULL )    {     setname( skinDirInHome_obsolete,dname );     if ( ( skinFile = fopen( fn,"rt" ) ) == NULL )      {       setname( skinMPlayerDir_obsolete,dname );       if ( ( skinFile = fopen( fn,"rt" ) ) == NULL )        {         setname( skinMPlayerDir,dname );         mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_SkinFileNotFound,fn );         return -1;        }      }    }  } mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] file: %s/n",fn ); appInitStruct( skinAppMPlayer ); linenumber=0; while (fgets(tmp, 255, skinFile))  {   linenumber++;   c=tmp[ strlen( tmp ) - 1 ]; if ( c == '/n' || c == '/r' ) tmp[ strlen( tmp ) - 1 ]=0;   c=tmp[ strlen( tmp ) - 1 ]; if ( c == '/n' || c == '/r' ) tmp[ strlen( tmp ) - 1 ]=0;   for ( c=0;c<(int)strlen( tmp );c++ )    if ( tmp[c] == ';' )     {      tmp[c]=0;      break;     }   if ( strlen( tmp ) == 0 ) continue;   ptmp=trimleft( tmp );   if ( strlen( ptmp ) == 0 ) continue;   ptmp=strswap( ptmp,'/t',' ' );   ptmp=trim( ptmp );   cutItem( ptmp,command,'=',0 ); cutItem( ptmp,param,'=',1 );   strlower( command );   for( i=0;i<ITEMS;i++ )    if ( !strcmp( command,skinItem[i].name ) )     if ( skinItem[i].func( param ) ) return -2;  } if (linenumber == 0) {   mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_SKIN_SkinFileNotReadable, fn);   return -1; } return 0;}
开发者ID:OpenSageTV,项目名称:mplayer-sage9orig,代码行数:63,


示例12: dlg_bridge_tm_callback

void dlg_bridge_tm_callback(struct cell *t, int type, struct tmcb_params *ps){	struct sip_msg *msg = NULL;	dlg_transfer_ctx_t *dtc = NULL;	struct dlg_cell *dlg = NULL;	str s;	str cseq;	str empty = {"", 0};	if(ps->param==NULL || *ps->param==0)	{		LM_DBG("message id not received/n");		return;	}	dtc = *((dlg_transfer_ctx_t**)ps->param);	if(dtc==NULL)		return;	LM_DBG("completed with status %d/n", ps->code);	if(ps->code>=300)		goto error;	/* 2xx - build dialog/send refer */	msg = ps->rpl;	if(parse_headers(msg, HDR_EOH_F, 0) < 0) {		LM_ERR("failed to parse the reply headers/n");		goto error;	}	if((msg->cseq==NULL || parse_headers(msg,HDR_CSEQ_F,0)<0)			|| msg->cseq==NULL || msg->cseq->parsed==NULL)	{			LM_ERR("bad sip message or missing CSeq hdr :-//n");			goto error;	}	cseq = (get_cseq(msg))->number;	if((msg->to==NULL && parse_headers(msg, HDR_TO_F,0)<0) || msg->to==NULL)	{		LM_ERR("bad request or missing TO hdr/n");		goto error;	}	if(parse_from_header(msg))	{		LM_ERR("bad request or missing FROM hdr/n");		goto error;	}	if((msg->callid==NULL && parse_headers(msg,HDR_CALLID_F,0)<0)			|| msg->callid==NULL){		LM_ERR("bad request or missing CALLID hdr/n");		goto error;	}	s = msg->callid->body;	trim(&s);	/* some sanity checks */	if (s.len==0 || get_from(msg)->tag_value.len==0) {		LM_ERR("invalid request -> callid (%d) or from TAG (%d) empty/n",			s.len, get_from(msg)->tag_value.len);		goto error;	}	dlg = build_new_dlg(&s /*callid*/, &(get_from(msg)->uri) /*from uri*/,		&(get_to(msg)->uri) /*to uri*/,		&(get_from(msg)->tag_value)/*from_tag*/,		&(get_to(msg)->uri) /*use to as r-uri*/ );	if (dlg==0) {		LM_ERR("failed to create new dialog/n");		goto error;	}	dtc->dlg = dlg;	if (dlg_set_leg_info(dlg, &(get_from(msg)->tag_value),				&empty, &dlg_bridge_controller, &cseq, DLG_CALLER_LEG)!=0) {		LM_ERR("dlg_set_leg_info failed/n");		goto error;	}	if (populate_leg_info(dlg, msg, t, DLG_CALLEE_LEG,			&(get_to(msg)->tag_value)) !=0)	{		LM_ERR("could not add further info to the dialog/n");		shm_free(dlg);		goto error;	}	if(dlg_refer_callee(dtc)!=0)		goto error;	return;error:	dlg_transfer_ctx_free(dtc);	return;}
开发者ID:adubovikov,项目名称:kamailio,代码行数:91,


示例13: pv_parse_mongodb_name

static int pv_parse_mongodb_name(pv_spec_p sp, str *in){	mongodbc_pv_t *rpv=NULL;	str pvs;	int i;	if(in->s==NULL || in->len<=0)		return -1;	rpv = (mongodbc_pv_t*)pkg_malloc(sizeof(mongodbc_pv_t));	if(rpv==NULL)		return -1;	memset(rpv, 0, sizeof(mongodbc_pv_t));	pvs = *in;	trim(&pvs);	rpv->rname.s = pvs.s;	for(i=0; i<pvs.len-2; i++)	{		if(isspace(pvs.s[i]) || pvs.s[i]=='=') {			rpv->rname.len = i;			break;		}	}	rpv->rname.len = i;	if(rpv->rname.len==0)		goto error_var;	while(i<pvs.len-2 && isspace(pvs.s[i]))		i++;	if(pvs.s[i]!='=')		goto error_var;	if(pvs.s[i+1]!='>')		goto error_var;	i += 2;	while(i<pvs.len && isspace(pvs.s[i]))		i++;	if(i>=pvs.len)		goto error_key;	rpv->rkey.s   = pvs.s + i;	rpv->rkey.len = pvs.len - i;	if(rpv->rkey.len>=5 && strncmp(rpv->rkey.s, "value", 5)==0) {		rpv->rkeyid = 1;	} else if(rpv->rkey.len>=4 && strncmp(rpv->rkey.s, "type", 4)==0) {		rpv->rkeyid = 0;	} else if(rpv->rkey.len==4 && strncmp(rpv->rkey.s, "info", 4)==0) {		rpv->rkeyid = 2;	} else if(rpv->rkey.len==4 && strncmp(rpv->rkey.s, "size", 4)==0) {		rpv->rkeyid = 3;	} else {		goto error_key;	}	sp->pvp.pvn.u.dname = (void*)rpv;	sp->pvp.pvn.type = PV_NAME_OTHER;	return 0;error_var:	LM_ERR("invalid var spec [%.*s]/n", in->len, in->s);	pkg_free(rpv);	return -1;error_key:	LM_ERR("invalid key spec in [%.*s]/n", in->len, in->s);	pkg_free(rpv);	return -1;}
开发者ID:4N7HR4X,项目名称:kamailio,代码行数:76,


示例14: init_sidtab

int32_t init_sidtab(void){	FILE *fp = open_config_file(cs_sidt);	if(!fp)		{ return 1; }	int32_t nr, nro, nrr;	char *value, *token;	if(!cs_malloc(&token, MAXLINESIZE))		{ return 1; }	struct s_sidtab *ptr;	struct s_sidtab *sidtab = (struct s_sidtab *)0;	for(nro = 0, ptr = cfg.sidtab; ptr; nro++)	{		struct s_sidtab *ptr_next;		ptr_next = ptr->next;		free_sidtab(ptr);		ptr = ptr_next;	}	nr = 0;	nrr = 0;	while(fgets(token, MAXLINESIZE, fp))	{		int32_t l;		if((l = strlen(trim(token))) < 3) { continue; }		if((token[0] == '[') && (token[l - 1] == ']'))		{			token[l - 1] = 0;			if(nr > MAX_SIDBITS)			{				fprintf(stderr, "Warning: Service No.%d - '%s' ignored. Max allowed Services %d/n", nr, strtolower(token + 1), MAX_SIDBITS);				nr++;				nrr++;			}			else			{				if(!cs_malloc(&ptr, sizeof(struct s_sidtab)))				{					NULLFREE(token);					return (1);				}				if(sidtab)					{ sidtab->next = ptr; }				else					{ cfg.sidtab = ptr; }				sidtab = ptr;				nr++;				cs_strncpy(sidtab->label, strtolower(token + 1), sizeof(sidtab->label));				continue;			}		}		if(!sidtab) { continue; }		if(!(value = strchr(token, '='))) { continue; }		*value++ = '/0';		chk_sidtab(trim(strtolower(token)), trim(strtolower(value)), sidtab);	}	NULLFREE(token);	fclose(fp);	show_sidtab(cfg.sidtab);	++cfg_sidtab_generation;	cs_log("services reloaded: %d services freed, %d services loaded, rejected %d", nro, nr, nrr);	return (0);}
开发者ID:FFTEAM,项目名称:oscam,代码行数:65,


示例15: init_provid

int32_t init_provid(void){	FILE *fp = open_config_file(cs_provid);	if(!fp)		{ return 0; }	int32_t nr;	char *payload, *saveptr1 = NULL, *token;	if(!cs_malloc(&token, MAXLINESIZE))		{ return 0; }	struct s_provid *provid_ptr = NULL;	struct s_provid *new_cfg_provid = NULL, *last_provid;	nr = 0;	while(fgets(token, MAXLINESIZE, fp))	{		int32_t i, l;		struct s_provid *new_provid = NULL;		char *tmp, *ptr1;				tmp = trim(token);		if(tmp[0] == '#') { continue; }		if((l = strlen(tmp)) < 11) { continue; }		if(!(payload = strchr(token, '|'))) { continue; }		*payload++ = '/0';				if(!cs_malloc(&new_provid, sizeof(struct s_provid)))		{			NULLFREE(token);			fclose(fp);			return (1);		}						new_provid->nprovid = 0;		for(i = 0, ptr1 = strtok_r(token, ":@", &saveptr1); ptr1; ptr1 = strtok_r(NULL, ":@", &saveptr1), i++)		{			if(i==0)			{				new_provid->caid = a2i(ptr1, 3);				continue;				}						new_provid->nprovid++;		}		if(!cs_malloc(&new_provid->provid, sizeof(uint32_t) * new_provid->nprovid))		{			NULLFREE(new_provid);			NULLFREE(token);			fclose(fp);			return (1);		}		ptr1 = token + strlen(token) + 1;		for(i = 0; i < new_provid->nprovid ; i++)		{			new_provid->provid[i] = a2i(ptr1, 3);						ptr1 = ptr1 + strlen(ptr1) + 1;		}				for(i = 0, ptr1 = strtok_r(payload, "|", &saveptr1); ptr1; ptr1 = strtok_r(NULL, "|", &saveptr1), i++)		{			switch(i)			{			case 0:				cs_strncpy(new_provid->prov, trim(ptr1), sizeof(new_provid->prov));				break;			case 1:				cs_strncpy(new_provid->sat, trim(ptr1), sizeof(new_provid->sat));				break;			case 2:				cs_strncpy(new_provid->lang, trim(ptr1), sizeof(new_provid->lang));				break;			}		}				if(strlen(new_provid->prov) == 0)		{			NULLFREE(new_provid->provid);			NULLFREE(new_provid);			continue;		}				nr++;						if(provid_ptr)		{			provid_ptr->next = new_provid;		}		else		{ 			new_cfg_provid = new_provid;		}			provid_ptr = new_provid;	}		NULLFREE(token);//.........这里部分代码省略.........
开发者ID:FFTEAM,项目名称:oscam,代码行数:101,


示例16: trim

void CApplication::PrintError(const tstring& sText){	tstring sTrimmedText = trim(sText);	GetConsole()->PrintConsole(tstring("[color=FF0000]ERROR: ") + sTrimmedText + "[/color]" + (sText.endswith("/n")?"/n":""));}
开发者ID:BSVino,项目名称:LunarWorkshop,代码行数:6,


示例17: init_srvid

int32_t init_srvid(void){	int8_t new_syntax = 1;	FILE *fp = open_config_file("oscam.srvid2");	if(!fp)	{ 		fp = open_config_file(cs_srid);		if(fp)		{			new_syntax = 0;		}	}	if(!fp)	{ 		fp = create_config_file("oscam.srvid2");		if(fp)		{			flush_config_file(fp, "oscam.srvid2");		}				return 0;	}	int32_t nr = 0, i, j;	char *payload, *saveptr1 = NULL, *saveptr2 = NULL, *token;	const char *tmp;	if(!cs_malloc(&token, MAXLINESIZE))		{ return 0; }	struct s_srvid *srvid = NULL, *new_cfg_srvid[16], *last_srvid[16];	// A cache for strings within srvids. A checksum is calculated which is the start point in the array (some kind of primitive hash algo).	// From this point, a sequential search is done. This greatly reduces the amount of string comparisons.	const char **stringcache[1024];	int32_t allocated[1024] = { 0 };	int32_t used[1024] = { 0 };	struct timeb ts, te;	cs_ftime(&ts);	memset(last_srvid, 0, sizeof(last_srvid));	memset(new_cfg_srvid, 0, sizeof(new_cfg_srvid));	while(fgets(token, MAXLINESIZE, fp))	{		int32_t l, len = 0, len2, srvidtmp;		uint32_t k;		uint32_t pos;		char *srvidasc, *prov;		tmp = trim(token);		if(tmp[0] == '#') { continue; }		if((l = strlen(tmp)) < 6) { continue; }		if(!(srvidasc = strchr(token, ':'))) { continue; }		if(!(payload = strchr(token, '|'))) { continue; }		*payload++ = '/0';				if(!cs_malloc(&srvid, sizeof(struct s_srvid)))		{			NULLFREE(token);			fclose(fp);			return (1);		}		char tmptxt[128];		int32_t offset[4] = { -1, -1, -1, -1 };		char *ptr1 = NULL, *ptr2 = NULL;		const char *searchptr[4] = { NULL, NULL, NULL, NULL };		const char **ptrs[4] = { &srvid->prov, &srvid->name, &srvid->type, &srvid->desc };		uint32_t max_payload_length = MAXLINESIZE - (payload - token);				if(new_syntax)		{			ptrs[0] = &srvid->name;			ptrs[1] = &srvid->type;			ptrs[2] = &srvid->desc;			ptrs[3] = &srvid->prov;		}				// allow empty strings as "||"		if(payload[0] == '|' && (strlen(payload)+2 < max_payload_length))		{			memmove(payload+1, payload, strlen(payload)+1);			payload[0] = ' ';		}				for(k=1; ((k < max_payload_length) && (payload[k] != '/0')); k++)		{			if(payload[k-1] == '|' && payload[k] == '|')			{				if(strlen(payload+k)+2 < max_payload_length-k)				{					memmove(payload+k+1, payload+k, strlen(payload+k)+1);					payload[k] = ' ';				}				else				{					break;				}				}		}//.........这里部分代码省略.........
开发者ID:FFTEAM,项目名称:oscam,代码行数:101,


示例18: GetMcdBlockInfo

void GetMcdBlockInfo(int mcd, int block, McdBlock *Info) {	unsigned char *data = NULL, *ptr, *str, *sstr;	unsigned short clut[16];	unsigned short c;	int i, x;	memset(Info, 0, sizeof(McdBlock));	if (mcd == 1) data = Mcd1Data;	if (mcd == 2) data = Mcd2Data;	ptr = data + block * 8192 + 2;	Info->IconCount = *ptr & 0x3;	ptr += 2;	x = 0;	str = Info->Title;	sstr = Info->sTitle;	for (i = 0; i < 48; i++) {		c = *(ptr) << 8;		c |= *(ptr + 1);		if (!c) break;		// Convert ASCII characters to half-width		if (c >= 0x8281 && c <= 0x829A)			c = (c - 0x8281) + 'a';		else if (c >= 0x824F && c <= 0x827A)			c = (c - 0x824F) + '0';		else if (c == 0x8140) c = ' ';		else if (c == 0x8143) c = ',';		else if (c == 0x8144) c = '.';		else if (c == 0x8146) c = ':';		else if (c == 0x8147) c = ';';		else if (c == 0x8148) c = '?';		else if (c == 0x8149) c = '!';		else if (c == 0x815E) c = '/';		else if (c == 0x8168) c = '"';		else if (c == 0x8169) c = '(';		else if (c == 0x816A) c = ')';		else if (c == 0x816D) c = '[';		else if (c == 0x816E) c = ']';		else if (c == 0x817C) c = '-';		else {			str[i] = ' ';			sstr[x++] = *ptr++; sstr[x++] = *ptr++;			continue;		}		str[i] = sstr[x++] = c;		ptr += 2;	}	trim(str);	trim(sstr);	ptr = data + block * 8192 + 0x60; // icon palette data	for (i = 0; i < 16; i++) {		clut[i] = *((unsigned short *)ptr);		ptr += 2;	}	for (i = 0; i < Info->IconCount; i++) {		short *icon = &Info->Icon[i * 16 * 16];		ptr = data + block * 8192 + 128 + 128 * i; // icon data		for (x = 0; x < 16 * 16; x++) {			icon[x++] = clut[*ptr & 0xf];			icon[x] = clut[*ptr >> 4];			ptr++;		}	}	ptr = data + block * 128;	Info->Flags = *ptr;	ptr += 0xa;	strncpy(Info->ID, ptr, 12);	ptr += 12;	strncpy(Info->Name, ptr, 16);}
开发者ID:Asmodean-,项目名称:PCSXR,代码行数:87,


示例19: ReadClient

/** Read data from clients @param data data to be read */void* ReadClient(void *data) {	TuxLogger_Debug("Start ReadClient()",NULL);		if (data == NULL)		return NULL;	tux_client client = (tux_client) data;	if (client == NULL) {		return NULL;	}	char *buff = (char *) malloc(sizeof(char) * 2048);	int iResult;	int isAlive = 0;	TuxLogger_Debug("ReadClient() varible are initialized",NULL);	TuxLogger_Debug("Start reading data from the client %d",		client->id);	do {		TuxLogger_Debug("Reading looping for client %d",			client->id);				iResult = recv(client->sock, buff, 2048, 0);		if (iResult > 0) {			TuxLogger_Debug("Receiving data !",NULL);			isAlive = 1;			TuxLogger_Debug(					"Allocating memory for the command",NULL);			char *cmd = (char *) malloc(sizeof(char) * (iResult + 1));			TuxLogger_Debug( "Allocation OK",NULL);			TuxLogger_Debug( "Copy data in cmd",NULL);			snprintf(cmd, iResult + 1, "%s", buff);			TuxLogger_Debug( "Raw data received: %s", cmd);			if (buff != NULL) {				/*free(buff);				 buff=NULL;*/			}			ParseCommand(client, trim(cmd));			if (cmd != NULL) {				/*free(cmd);				 cmd=NULL;*/			}		} else			isAlive = 0;		break;	} while (iResult > 0);	if (isAlive == 1) {		TuxLogger_Debug(				"Client is still alive. Keep watching data coming from him",NULL);						ReadClient(data);	} else {		TuxLogger_Debug(				"Connection with the client %d has been closed by him. Closing the socket..",				client->id);				removeUniqueID(client->pID);				close(client->sock);		TuxLogger_Debug( "Socket closed", client->id);			int i;		for(i = 0; i < plugins->count; i++)		{			if(plugins->plugins[i]->delClient != NULL)				plugins->plugins[i]->delClient(client);		}	}	if (client->uKey != NULL) {		/*free(client->uKey);		 client->uKey = NULL;*/	}	if (client->username != NULL) {		/*free(client->username);		 client->username=NULL;*/	}	if (client != NULL) {		/*free(client);		 client=NULL;*///.........这里部分代码省略.........
开发者ID:joelmatteotti,项目名称:tuxdroidserver_experimental,代码行数:101,


示例20: F847124

int F847124(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg){	int	hi_custid = 0;											//客户ID	int	hi_custtype = 0;										//客户类型	int i=0;	int ret = 0;	int len = 0;	char h_showcardid[11] = "";						//显示卡号	char h_password[7] = "";							//卡密码	double h_temp_Card_id = 0;						//卡号	char seed_key[17] = "";							//种子密钥	char card_endtime[8 + 1] = "";						//卡的有效截至日期	char logicdate[11]="";								//业务日期	char sysdate[11]="";	char systime[9]="";	char sMsg[256]="";	char sMaxCardBalance[20]="";	double dMaxCardBalance=0;	int 	type=0;										//充值类型	T_t_card tCard;	T_t_customer tCustomer;	T_t_aif_account  tAccount;	T_t_tif_tradeserial  tradeserial;	T_t_tif_savdtl		tSavdtl;	T_t_spefee 	tSpeFee;	double h_temp_Serial_no = 0;	InAcc	IA;	ST_CPACK aPack;	ST_PACK *out_pack = &(aPack.pack);	memset(&IA,0,sizeof(IA));	memset(&tCard, 0, sizeof(tCard));	memset(&tAccount,0,sizeof(tAccount));	memset(&tradeserial,0,sizeof(tradeserial));	memset(&tSpeFee,0,sizeof(tSpeFee));	memset(&tCustomer,0,sizeof(tCustomer));	memset(&tSavdtl,0,sizeof(tSavdtl));#ifdef DEBUG	writelog(LOG_DEBUG,"rPack->scust_auth2[%s]",rPack->scust_auth2);#endif	ResetNormalCPack(&aPack,0,1);	SetCol(handle,F_LVOL0,F_LVOL1,F_LVOL5,				F_SCUST_NO,	F_SCUST_NO2,F_SCUST_AUTH,F_SCUST_AUTH2,				F_SDATE0,F_SNAME,F_SNAME2,				F_SOPEN_EMP,F_SSTATUS0,				F_DAMT2,F_LSERIAL1,F_VSMESS,0);	hi_custid = rPack->lvol0;									//客户ID	hi_custtype = rPack->lvol3;									//客户类别	des2src(h_showcardid,rPack->scust_no);					//显示卡号	getsysdate(sysdate);	getsystime(systime);	ret=GetLogicDate(logicdate);								//业务日期	if(ret)	{		*pRetCode=ret;		goto L_RETU;	}	//检查客户信息,判断是否可以发行卡	des2src(tCard.cardphyid, rPack->sbank_acc);				//物理卡号	trim(h_showcardid);	if(strlen(h_showcardid))	{		ret=IsExistShowCardNo(h_showcardid);		if(ret)		{			*pRetCode = ret;			goto L_RETU;		}	}	ret=IsExistCardByPhyCardNo(tCard.cardphyid);	if(ret)	{		*pRetCode = ret;		goto L_RETU;	}	ret=IsExistCardByCustomId(hi_custid);	if (ret)	{		*pRetCode = ret;		goto L_RETU;	}	ret=DB_t_customer_read_lock_by_cur_and_custid(hi_custid, &tCustomer);	if(ret)	{		writelog(LOG_ERR,"custid[%d]",hi_custid);		if(DB_NOTFOUND==ret)			*pRetCode= E_CUSTOMER_NOT_EXIST;		else			*pRetCode= E_DB_CUSTOMER_R;		goto L_RETU;	}	//得到收费类别	if(tCustomer.feetype<1)	{		ret=DB_t_spefee_read_by_deptcode_and_custtype(tCustomer.deptcode, tCustomer.custtype,&tSpeFee);		if(ret)		{			if(DB_NOTFOUND==ret)//.........这里部分代码省略.........
开发者ID:Codiscope-Research,项目名称:ykt4sungard,代码行数:101,


示例21: itemdb_read_itemgroup_sub

/** Read item group data* Structure: GroupID,ItemID,Rate{,Amount,isMust,isAnnounced,Duration,GUID,isBound,isNamed}*/static void itemdb_read_itemgroup_sub(const char* filename, bool silent){	FILE *fp;	int ln = 0, entries = 0;	char line[1024];	if ((fp=fopen(filename,"r")) == NULL) {		if(silent == 0) ShowError("Can't read %s/n", filename);		return;	}		while (fgets(line,sizeof(line),fp)) {		DBData data;		int group_id = -1;		unsigned int j, prob = 1;		uint8 rand_group = 1;		char *str[10], *p;		struct s_item_group_random *random = NULL;		struct s_item_group_db *group = NULL;		struct s_item_group_entry entry;		bool found = false;		ln++;		if (line[0] == '/' && line[1] == '/')			continue;		if (strstr(line,"import")) {			char w1[16], w2[64];			if (sscanf(line,"%15[^:]: %63[^/r/n]",w1,w2) == 2 &&				strcmpi(w1,"import") == 0)			{				itemdb_read_itemgroup_sub(w2, 0);				continue;			}		}		memset(str,0,sizeof(str));		for (j = 0, p = line; j < 9 && p;j++) {			str[j] = p;			p = strchr(p,',');			if (p) *p++=0;		}		if (str[0] == NULL) //Empty Group ID			continue;		if (j < 3) {			if (j > 1) // Or else it barks on blank lines...				ShowWarning("itemdb_read_itemgroup: Insufficient fields for entry at %s:%d/n", filename, ln);			continue;		}		memset(&entry, 0, sizeof(entry));		entry.amount = 1;		entry.bound = BOUND_NONE;		// Checking group_id		trim(str[0]);		if (ISDIGIT(str[0][0]))			group_id = atoi(str[0]);		else // Try reads group id by const			script_get_constant(trim(str[0]), &group_id);		if (group_id < 0) {			ShowWarning("itemdb_read_itemgroup: Invalid Group ID '%s' (%s:%d)/n", str[0], filename, ln);			continue;		}		// Remove from DB		if (strcmpi(str[1], "clear") == 0 && itemdb_group->remove(itemdb_group, db_ui2key(group_id), &data)) {			itemdb_group_free(db_ui2key(group_id), &data, 0);			ShowNotice("Item Group '%s' has been cleared./n", str[0]);			continue;		}		// Checking sub group		prob = atoi(str[2]);		if (str[4] != NULL)			rand_group = atoi(str[4]);		if (rand_group < 0 || rand_group > MAX_ITEMGROUP_RANDGROUP) {			ShowWarning("itemdb_read_itemgroup: Invalid sub group '%d' for group '%s' in %s:%d/n", rand_group, str[0], filename, ln);			continue;		}		if (rand_group != 0 && prob < 1) {			ShowWarning("itemdb_read_itemgroup: Random item must has probability. Group '%s' in %s:%d/n", str[0], filename, ln);			continue;		}		// Checking item		trim(str[1]);		if (ISDIGIT(str[1][0]) && ISDIGIT(str[1][1]) && itemdb_exists((entry.nameid = atoi(str[1]))))			found = true;		else {			struct item_data *id = itemdb_searchname(str[1]);			if (id) {				entry.nameid = id->nameid;				found = true;			}		}//.........这里部分代码省略.........
开发者ID:nirumasa,项目名称:rathena,代码行数:101,


示例22: dlg_new_dialog

/*! * /brief Create a new dialog from a sip message * * Create a new dialog from a SIP message, register a callback * to keep track of the dialog with help of the tm module. * This function is either called from the request callback, or * from the dlg_manage function in the configuration script. * /see dlg_onreq * /see w_dlg_manage * /param msg SIP message * /param t transaction * /return 0 on success, -1 on failure */int dlg_new_dialog(struct sip_msg *req, struct cell *t, const int run_initial_cbs) {    struct dlg_cell *dlg;    str s;    str callid;    str ftag;    str ttag;    str req_uri;    unsigned int dir;    LM_DBG("starting dlg_new_dialog and method is [%.*s]/n", req->first_line.u.request.method.len, req->first_line.u.request.method.s);    if (current_dlg_pointer != NULL)        return -1;    if (req->first_line.u.request.method_value == METHOD_CANCEL)        return -1;    if (pre_match_parse(req, &callid, &ftag, &ttag, 0) < 0) {        LM_WARN("pre-matching failed/n");        return -1;    }    if (ttag.s != 0 && ttag.len != 0)        return -1;    if (pv_printf_s(req, ruri_param_model, &req_uri) < 0) {        LM_ERR("error - cannot print the r-uri format/n");        return -1;    }    trim(&req_uri);    if (detect_spirals) {        if (spiral_detected == 1)            return 0;        dir = DLG_DIR_NONE;        dlg = get_dlg(&callid, &ftag, &ttag, &dir);        if (dlg) {            LM_DBG("Callid '%.*s' found, must be a spiraled request/n",                    callid.len, callid.s);            spiral_detected = 1;            if (run_initial_cbs)                run_dlg_callbacks(DLGCB_SPIRALED, dlg, req, NULL, DLG_DIR_DOWNSTREAM, 0);            //Add did to rr header for all spiralled requested INVITEs            if (req->first_line.u.request.method_value == METHOD_INVITE) {                if (add_dlg_rr_param(dlg, req, dlg->h_entry, dlg->h_id) < 0) {                    LM_ERR("failed to add RR param/n");                }            }            // get_dlg has incremented the ref count by 1            unref_dlg(dlg, 1);            goto finish;        }    }    spiral_detected = 0;    LM_DBG("Building new Dialog for call-id %.*s/n", callid.len, callid.s);    LM_DBG("SIP Method: %.*s  /n", req->first_line.u.request.method.len, req->first_line.u.request.method.s);    dlg = build_new_dlg(&callid /*callid*/,            &(get_from(req)->uri) /*from uri*/,            &ftag/*from_tag*/,            &req_uri /*r-uri*/);    if (dlg == 0) {        LM_ERR("failed to create new dialog/n");        return -1;    }    /* save caller's tag, cseq, contact and record route*/    if (populate_leg_info(dlg, req, t, DLG_CALLER_LEG,            &(get_from(req)->tag_value)) != 0) {        LM_ERR("could not add further info to the dialog/n");        shm_free(dlg);        lock_destroy(dlg->dlg_out_entries_lock);        lock_dealloc(dlg->dlg_out_entries_lock);        return -1;    }    dlg->transaction = t;    /* Populate initial varlist: *///.........这里部分代码省略.........
开发者ID:tsudot,项目名称:kamailio,代码行数:101,


示例23: while

void InteractiveSMTPServerWindow::slotReadyRead(){  while ( mSocket->canReadLine() )    slotDisplayClient( trim( mSocket->readLine() ) );}
开发者ID:pvuorela,项目名称:kcalcore,代码行数:5,


示例24: b_not

static int b_not (lua_State *L) {  lua_Unsigned r = ~checkunsigned(L, 1);  pushunsigned(L, trim(r));  return 1;}
开发者ID:1dao,项目名称:puss,代码行数:5,



注:本文中的trim函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ trimSpaces函数代码示例
C++ trill函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。