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

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

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

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

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

示例1: str_words_in_rev

void str_words_in_rev(char *input, int len){	int i = 0, j = 0, count = 0, k = 0;	strreverse(input, 0, len - 1);	while (input[k] != '/0'){		if (input[k] == ' '){			count++;		}		k++;	}	if (count == 0){		strreverse(input, 0, len - 1);	}	else{		while (input[j] != '/0'){			if (input[j] == ' ' && input[j + 1] != ' '){				i = j + 1;			}			else if (input[j + 1] == ' '){				strreverse(input, i, j);				i = j + 1;			}			else if (input[j + 1] == '/0'){				strreverse(input, i, j);			}			j++;		}	}}
开发者ID:harishmadamanchi,项目名称:MissionRnD-C-Strings-Worksheet,代码行数:28,


示例2: itoa

/** * Converts an integer into a string using an arbitrary base. Make sure the buffer for * the converted string is large enough. The smaller the base the more space is required, eg * for converting a 32 bit integer you can expect 35 bytes to be sufficient * (base 2: 32 bytes for digits + 1 byte for the terminator + some space just to feel safe * and take into account future format changes). * In other, GAD inspired words: * bufsize >= ceil(log2(MAX_INT)) which is equal to: bufsize >= sizeof(int) * 8 * * This is not a part of the C standard library. * * @param n the number to convert * @param str the target string buffer * @param base the base to use for the conversion * @return The original value of str */char* itoa(int n, char *str, unsigned int base){        char *ret = str;        bool neg = FALSE;        /* Treat negative base 10 integers specially. */        if (base == 10 && n < 0) {                *str++ = '-';                n = -n;                neg = TRUE;        }        /* Convert to unsigned to get proper two's complement hex strings. */        unsigned int num = n;        do {                int rem = num % base;                *str++ = rem < 10 ? '0' + rem : 55 + rem;        } while (num /= base);        *str = '/0';        /* Do not change the position of the minus sign. */        if (neg) {                strreverse(++ret);                return --ret;        } else                return strreverse(ret);}
开发者ID:MatiasNAmendola,项目名称:potatoes,代码行数:45,


示例3: ltoa

void ltoa(long value, char* str, int base){	char* wstr = str;	long sign;	div_t res;		// Validate base	if (base<2 || base>35)  {    *wstr='/0';    return;  }			// Take care of sign		if ((sign=value) < 0)    value = -value;			// Conversion. Number is reversed.		do  {			res = div(value,base);			*wstr++ = num[res.rem];		} while (value=res.quot);	if (sign<0)    *wstr++='-';		*wstr='/0';		// Reverse string		strreverse(str, wstr-1);}
开发者ID:DavidZemon,项目名称:libArduino,代码行数:32,


示例4: lltoa

void lltoa( long long value, char* str, int base ) {    static char num[] = "0123456789abcdefghijklmnopqrstuvwxyz";    char* wstr = str;    int sign = 0;    // for all other bases we interpret value as unsigned!    if (base != 10) return (uitoa((unsigned int) value,str,base));    // Validate base    if ( base < 2 || base > 35 ) {        *wstr = '/0';        return;    }    if ( ( sign = value ) < 0 )        value = -value;    // Conversion. Number is reversed.    do        *wstr++ = num[ value % base ];    while ( value /= base );    if ( sign < 0 )        *wstr++ = '-';    *wstr = '/0';    // Reverse string    strreverse( str, wstr - 1 );}
开发者ID:ORCOS,项目名称:ORCOS,代码行数:30,


示例5: main

int main(void){	char s[] = "world";	strreverse(s);	printf("after reverse, s = %s/n", s);	return 0;}
开发者ID:sktwj,项目名称:var,代码行数:7,


示例6: itoa

void itoa(int value, char* str, int base) {  static char num[] = "0123456789abcdefghijklmnopqrstuvwxyz";  char* wstr=str;  int sign;  // Validate base  if (base<2 || base>35) {    *wstr='/0';    return;  }  // Take care of sign  if ((sign=value) < 0)    value = -value;  // Conversion. Number is reversed.  do    *wstr++ = num[value%base];  while(value/=base);  if(sign<0)    *wstr++='-';  *wstr='/0';  // Reverse string  strreverse(str,wstr-1);}
开发者ID:chcbaram,项目名称:OpenCM9.04,代码行数:28,


示例7: str_words_in_rev

void str_words_in_rev(char *input, int len){	int i, j;	for (i = 0, j = 0; i <= len; i++){		if (input[i] == ' '){			strreverse(input, j, i - 1);			while (input[i + 1] == ' '&&input[i + 1] != '/0'){				i = i + 1;			}			j = i + 1;		}		else if (input[i] == '/0'){			strreverse(input, j, i - 1);		}	}	strreverse(input, 0, len - 1);}
开发者ID:srujansmec,项目名称:MissionRnD-C-Strings-Worksheet,代码行数:16,


示例8: modp_ulitoa10

void modp_ulitoa10(uint64_t value, char* str){    char* wstr=str;    // Conversion. Number is reversed.    do *wstr++ = (char)(48 + (value % 10)); while (value /= 10);    *wstr='/0';    // Reverse string    strreverse(str, wstr-1);}
开发者ID:elrasguno,项目名称:libten,代码行数:9,


示例9: modp_uitoa10

size_t modp_uitoa10(uint32_t value, char* str){    char* wstr=str;    // Conversion. Number is reversed.    do *wstr++ = (char)(48 + (value % 10)); while (value /= 10);    *wstr='/0';    // Reverse string    strreverse(str, wstr-1);    return (size_t)(wstr - str);}
开发者ID:343829084,项目名称:thirdparty,代码行数:10,


示例10: reverse_onwrite

static void reverse_onwrite(sst_t* self, sst_chunk_t* chunk) {  char *s;  sst_chunk_t *chunk_out;  s = (char*)chunk->data;  chunk_out = sst_chunk_new(strreverse(s), free);  self->emit(self, chunk_out);  sst_chunk_free(chunk);}
开发者ID:thlorenz,项目名称:sync-stream.c,代码行数:10,


示例11: itoa

// int to strvoid itoa(int value, char* str, int base) {	static char num[] = "0123456789abcdefghijklmnopqrstuvwxyz";	char* wstr=str;	int sign;	if (base<2 || base>35){ *wstr='/0'; return; }	if ((sign=value) < 0) value = -value;	do *wstr++ = num[value%base]; while(value/=base);	if(sign<0) *wstr++='-';	*wstr='/0';	strreverse(str,wstr-1);}
开发者ID:rpeter90,项目名称:stm32f4-robodebugger,代码行数:12,


示例12: modp_litoa10

void modp_litoa10(int64_t value, char* str){    char* wstr=str;    unsigned long uvalue = (value < 0) ? -value : value;    // Conversion. Number is reversed.    do *wstr++ = (char)(48 + (uvalue % 10)); while(uvalue /= 10);    if (value < 0) *wstr++ = '-';    *wstr='/0';    // Reverse string    strreverse(str,wstr-1);}
开发者ID:elrasguno,项目名称:libten,代码行数:13,


示例13: modp_itoa10

size_t modp_itoa10(int32_t value, char* str){    char* wstr=str;    /* Take care of sign */    uint32_t uvalue = (value < 0) ? (uint32_t)(-value) : (uint32_t)(value);    /* Conversion. Number is reversed. */    do *wstr++ = (char)(48 + (uvalue % 10)); while(uvalue /= 10);    if (value < 0) *wstr++ = '-';    *wstr='/0';    /* Reverse string */    strreverse(str,wstr-1);    return (size_t)(wstr - str);}
开发者ID:ColinGilbert,项目名称:stringencoders,代码行数:14,


示例14: modp_itoa10

unsigned modp_itoa10(int32_t value, char* str){    char* wstr=str;    // Take care of sign    unsigned int uvalue = (value < 0) ? -value : value;    // Conversion. Number is reversed.    do *wstr++ = (char)(48 + (uvalue % 10)); while(uvalue /= 10);    if (value < 0) *wstr++ = '-';    *wstr='/0';    // Reverse string    strreverse(str,wstr-1);    return wstr-str;}
开发者ID:RedSunCMX,项目名称:izenelib,代码行数:14,


示例15: modp_litoa10

size_t modp_litoa10(int64_t value, char* str){    char* wstr=str;    uint64_t uvalue = (value < 0) ? (uint64_t)(-value) : (uint64_t)(value);    // Conversion. Number is reversed.    do *wstr++ = (char)(48 + (uvalue % 10)); while(uvalue /= 10);    if (value < 0) *wstr++ = '-';    *wstr='/0';    // Reverse string    strreverse(str,wstr-1);    return (size_t)(wstr - str);}
开发者ID:343829084,项目名称:thirdparty,代码行数:14,


示例16: long2str

static void long2str(long value, TCHAR *str){  int i = 0;  long sign = value;  int n;  /* generate digits in reverse order */  do {    n = (int)(value % 10);              /* get next lowest digit */    str[i++] = (TCHAR)(ABS(n) + '0');   /* handle case of negative digit */  } while (value /= 10);                /* delete the lowest digit */  if (sign < 0)    str[i++] = '-';  str[i] = '/0';  strreverse(str);}
开发者ID:Daniel-Eckert,项目名称:piksi_firmware,代码行数:17,


示例17: int_to_string

ALWAYS_INLINE int32_tint_to_string(int32_t value, char *str){    char *wstr = str;    // Take care of sign    unsigned int uvalue = (value < 0) ? -value : value;    // Conversion. Number is reversed.    do        *wstr++ = (char) decimal_digits[uvalue % 10];    while (uvalue /= 10);    if (value < 0)        *wstr++ = '-';    *wstr = '/0';    // Reverse string    strreverse(str, wstr - 1);    return wstr - str;}
开发者ID:rakuco,项目名称:lwan,代码行数:18,


示例18: ulltoa

void ulltoa( unsigned long long value, char* str, int base ) {    static char num[] = "0123456789abcdefghijklmnopqrstuvwxyz";    char* wstr = str;    // Validate base    if ( base < 2 || base > 35 ) {        *wstr = '/0';        return;    }    // Conversion. Number is reversed.    do        *wstr++ = num[ value % base ];    while ( value /= base );      *wstr = '/0';    // Reverse string    strreverse( str, wstr - 1 );}
开发者ID:ORCOS,项目名称:ORCOS,代码行数:20,


示例19: itoa

static void itoa(intptr_t value, char* str, int base) {	static char num[] = "0123456789abcdefghijklmnopqrstuvwxyz";	char* wstr=str;	intptr_t sign;	div_t res;	// Validate base	if (base<2 || base>35){ *wstr='/0'; return; }	// Take care of sign	if ((sign=value) < 0) value = -value;	// Conversion. Number is reversed.	do {		res = div(value, base);		*wstr++ = num[res.rem];	} while((value=res.quot));	if (sign < 0) *wstr++='-';	*wstr = '/0';	// Reverse string	strreverse(str, wstr - 1);}
开发者ID:kevinw,项目名称:kracket,代码行数:23,


示例20: utoa

void utoa(unsigned int value, char* str, int base){	char* wstr = str;	div_t res;		// Validate base	if (base<2 || base>35)  {    *wstr='/0';    return;  }			// Conversion. Number is reversed.		do  {			res = div(value,base);			*wstr++ = num[res.rem];		} while (value=res.quot);	*wstr='/0';		// Reverse string		strreverse(str, wstr-1);}
开发者ID:DavidZemon,项目名称:libArduino,代码行数:24,


示例21: modp_dtoa

void modp_dtoa(double value, char* str, int prec){    /* Hacky test for NaN     * under -fast-math this won't work, but then you also won't     * have correct nan values anyways.  The alternative is     * to link with libmath (bad) or hack IEEE double bits (bad)     */    if (! (value == value)) {        str[0] = 'n'; str[1] = 'a'; str[2] = 'n'; str[3] = '/0';        return;    }    /* if input is larger than thres_max, revert to exponential */    const double thres_max = (double)(0x7FFFFFFF);    double diff = 0.0;    char* wstr = str;    if (prec < 0) {        prec = 0;    } else if (prec > 9) {        /* precision of >= 10 can lead to overflow errors */        prec = 9;    }    /* we'll work in positive values and deal with the       negative sign issue later */    int neg = 0;    if (value < 0) {        neg = 1;        value = -value;    }    int whole = (int) value;    double tmp = (value - whole) * pow10a[prec];    uint32_t frac = (uint32_t)(tmp);    diff = tmp - frac;    if (diff > 0.5) {        ++frac;        /* handle rollover, e.g.  case 0.99 with prec 1 is 1.0  */        if (frac >= pow10a[prec]) {            frac = 0;            ++whole;        }    } else if (diff == 0.5 && ((frac == 0) || (frac & 1))) {        /* if halfway, round up if odd, OR           if last digit is 0.  That last part is strange */        ++frac;    }    /* for very large numbers switch back to native sprintf for exponentials.       anyone want to write code to replace this? */    /*      normal printf behavior is to print EVERY whole number digit      which can be 100s of characters overflowing your buffers == bad    */    if (value > thres_max) {        sprintf(str, "%e", neg ? -value : value);        return;    }    if (prec == 0) {        diff = value - whole;        if (diff > 0.5) {            /* greater than 0.5, round up, e.g. 1.6 -> 2 */            ++whole;        } else if (diff == 0.5 && (whole & 1)) {            /* exactly 0.5 and ODD, then round up */            /* 1.5 -> 2, but 2.5 -> 2 */            ++whole;        }    } else {        int count = prec;        // now do fractional part, as an unsigned number        do {            --count;            *wstr++ = (char)(48 + (frac % 10));        } while (frac /= 10);        // add extra 0s        while (count-- > 0) *wstr++ = '0';        // add decimal        *wstr++ = '.';    }    // do whole part    // Take care of sign    // Conversion. Number is reversed.    do *wstr++ = (char)(48 + (whole % 10)); while (whole /= 10);    if (neg) {        *wstr++ = '-';    }    *wstr='/0';    strreverse(str, wstr-1);}
开发者ID:elrasguno,项目名称:libten,代码行数:96,


示例22: itoa

void itoa(int pvalue, char* pstr, size_t *rlen) {	static char num[] = "0123456789";		int value = pvalue;	char *str = pstr; 	// take care of sign	if(pvalue<0) { *str++ = '-'; value = -value; }	/* -999 - +999 */	if (value<1000) {		// printf(" x %d", value);		// printf("Rest: %d $ ", value);		if(!mux) initmux();		char *q = mux + value*4;		char qq;		*str++=*q++; if((qq=*q++)) { *str++=qq; if((qq=*q++)) { *str++=qq; } }		#ifdef FLEECE_ALWAYS_DELIMIT		*str=0;		#endif		*rlen = str - pstr;		goto ret;	}	if (value<1000000) {		if(!mux) initmux();		char *q = mux + (value/1000*4);		char qq;		*(str++)=*q++; if((qq=*q++)) { *(str++)=qq; if((qq=*q++)) { *(str++)=qq; } }		// printf("Now: %s $ ", pstr);		value %= 1000;		q = mux0 + (4*value);		*str++=*q++;		*str++=*q++;		*str++=*q++;		#ifdef FLEECE_ALWAYS_DELIMIT		*str=0;		#endif		*rlen = str - pstr;		goto ret;	}	/* #4 any length	   Source: Stuart Lowe's optimization of the Kernighan & Ritchie sample       at http://www.strudel.org.uk/itoa/       DO NOT CHANGE ANYTHING IN THIS FUNCTION WITHOUT SYNCHING ilen() */		/* prototype TODO: move */	void strreverse(char* begin, char* end);	/* note: sign is taken care of above. if minus, *str IS alread '-' here. */		char* wstr=str;	div_t res;		// Conversion. Number is reversed in the end.		do {		res = div(value,10);		*wstr++ = num[res.rem];	} while((value=res.quot));	#ifdef FLEECE_ALWAYS_DELIMIT	*wstr='/0';	#endif	*rlen = wstr - pstr;		// Reverse string	strreverse(str,wstr-1);	#if SELFCHECK >=3	    *(pstr+*rlen) = 0;		char test[32];		sprintf(test, "%d", pvalue);		if(strcmp(test, pstr)) {			printf("fleece [3]: ** fast integer K&R conversion error: %d made to '%s', should be '%s'./n", pvalue, pstr,test);			exit(180);		}	#endif		ret:;	#if SELFCHECK >=3	    *(pstr+*rlen) = 0;		sprintf(test, "%d", pvalue);		if(strcmp(test, pstr)) {			printf("fleece [3]: ** fast integer look up conversion error: %d made to '%s', should be '%s'./n", pvalue, pstr,test);			exit(194);		}	#endif	return;}
开发者ID:Eonblast,项目名称:fleece-lite,代码行数:91,


示例23: float_to_string

//.........这里部分代码省略.........	if (prec < 0)	{		prec = 0;	}	else if (prec > 6)	{		/* precision of >= 7 for float can lead to overflow errors */		prec = 6;	}	/* we'll work in positive values and deal with the	   negative sign issue later */	int neg = 0;	if (value < 0)	{		neg = 1;		value = -value;	}	int whole = static_cast<int>(value);	double tmp = (value - whole) * pow_of_10[prec];	uint32_t frac = static_cast<uint32_t>(tmp);	diff = tmp - frac;	if(diff > 0.5)	{		++frac;		/* handle rollover, e.g.  case 0.99 with prec 1 is 1.0  */		if(frac >= pow_of_10[prec])		{			frac = 0;			++whole;		}	}	else if( diff == 0.5 && ((frac == 0) || (frac & 1)) )	{		/* if halfway, round up if odd, OR		   if last digit is 0.  That last part is strange */		++frac;	}	/* for very large numbers switch back to native */	/*		normal printf behavior is to print EVERY whole number digit		which can be 100s of characters overflowing your buffers == bad	*/	if( value > thres_max )	{		std::ostringstream temp;		temp.setf( std::ios_base::fixed );		temp << number;		return temp.str();	}	if( prec == 0 )	{		diff = value - whole;		if(diff > 0.5)		{			/* greater than 0.5, round up, e.g. 1.6 -> 2 */			++whole;		}		else if(diff == 0.5 && (whole & 1))		{			/* exactly 0.5 and ODD, then round up */			/* 1.5 -> 2, but 2.5 -> 2 */			++whole;		}	}	else	{		int count = prec;		// now do fractional part, as an unsigned number		do		{			--count;			*wstr++ = 48 + (frac % 10);		}		while(frac /= 10);		// add extra 0s		while(count-- > 0) *wstr++ = '0';		// add decimal		*wstr++ = '.';	}	// do whole part	// Take care of sign	// Conversion. Number is reversed.	do *wstr++ = 48 + (whole % 10); while (whole /= 10);	if(neg)	{		*wstr++ = '-';	}	*wstr='/0';	strreverse(str, wstr-1);	return str;}
开发者ID:sKabYY,项目名称:SMC,代码行数:101,


示例24: on_d2cs_charloginreq

static int on_d2cs_charloginreq(t_connection * c, t_packet const * packet){	t_connection *	client;	char const *	charname;	char const *	portrait;	char const *	clienttag;	char *	temp;	unsigned int	sessionnum;	t_realm * 	realm;	char const *	realmname;	unsigned int	pos, reply;	t_packet *	rpacket;		if (packet_get_size(packet)<sizeof(t_d2cs_bnetd_charloginreq)) {		eventlog(eventlog_level_error,__FUNCTION__,"got bad packet size");		return -1;	}	sessionnum=bn_int_get(packet->u.d2cs_bnetd_charloginreq.sessionnum);	pos=sizeof(t_d2cs_bnetd_charloginreq);	if (!(charname=packet_get_str_const(packet,pos,CHAR_NAME_LEN))) {		eventlog(eventlog_level_error,__FUNCTION__,"got bad character name");		return -1;	}	pos+=strlen(charname)+1;	if (!(portrait=packet_get_str_const(packet,pos,CHAR_PORTRAIT_LEN))) {		eventlog(eventlog_level_error,__FUNCTION__,"got bad character portrait");		return -1;	}	if (!(client=connlist_find_connection_by_sessionnum(sessionnum))) {		eventlog(eventlog_level_error,__FUNCTION__,"user %d not found",sessionnum);		reply = BNETD_D2CS_CHARLOGINREPLY_FAILED;	} else if (!(clienttag=clienttag_uint_to_str(conn_get_clienttag(client)))) {		eventlog(eventlog_level_error,__FUNCTION__,"got NULL clienttag");		reply = BNETD_D2CS_CHARLOGINREPLY_FAILED;	} else if (!(realm=conn_get_realm(client))) {		eventlog(eventlog_level_error,__FUNCTION__,"got NULL realm");		reply = BNETD_D2CS_CHARLOGINREPLY_FAILED;	} else {		char revtag[8];		realmname = realm_get_name(realm);		temp=xmalloc(strlen(clienttag)+strlen(realmname)+1+strlen(charname)+1+			strlen(portrait)+1);		reply = BNETD_D2CS_CHARLOGINREPLY_SUCCEED;		strcpy(revtag,clienttag);		strreverse(revtag);		sprintf(temp,"%4s%s,%s,%s",revtag,realmname,charname,portrait);		conn_set_charname(client,charname);		conn_set_realminfo(client,temp);		xfree(temp);		eventlog(eventlog_level_debug,__FUNCTION__,			"loaded portrait for character %s",charname);	}	if ((rpacket=packet_create(packet_class_d2cs_bnetd))) {		packet_set_size(rpacket,sizeof(t_bnetd_d2cs_charloginreply));		packet_set_type(rpacket,BNETD_D2CS_CHARLOGINREPLY);		bn_int_set(&rpacket->u.bnetd_d2cs_charloginreply.h.seqno,			bn_int_get(packet->u.d2cs_bnetd_charloginreq.h.seqno));		bn_int_set(&rpacket->u.bnetd_d2cs_charloginreply.reply,reply);		conn_push_outqueue(c,rpacket);		packet_del_ref(rpacket);	}	return 0;}
开发者ID:BackupTheBerlios,项目名称:pvpgn,代码行数:64,


示例25: userlog_read

		// read "count" lines from the end starting from "startline"		extern std::map<long, char*> userlog_read(const char * username, long startline, const char * search_substr)		{			std::map<long, char*> lines;			long linecount = 0;			char line[MAX_MESSAGE_LEN+1];			int linepos = 0;			char c, prev_c = 0;			long pos;			char * filename = userlog_filename(username);			if (FILE *fp = fopen(filename, "r"))			{				// set position to the end of file				fseek(fp, 0, SEEK_END);				pos = ftell(fp);				// read file reversely by byte				do {					pos--;					fseek(fp, pos, SEEK_SET);					c = fgetc(fp);					// add char into line array					if (c != '/n')						line[linepos] = c;					// end of line (or start of file)					if ((c == '/n' && c != prev_c) || pos == -1)					{						// hack for large lines (instead we will receive cut line without start symbols)						if (linepos == MAX_MESSAGE_LEN)						{							// return carriage to read whole line to(from) start							pos = pos + MAX_MESSAGE_LEN;							linepos = 0;						}						if (linepos > 0)						{							line[linepos] = '/0'; // set end of string							strreverse(line);							linepos = 0; // reset position inside line							linecount++;							if (linecount >= startline)							{								if (search_substr && strlen(search_substr) > 0)								{									if (find_substr(line, search_substr))										lines[linecount] = xstrdup(line);								}								else								{									lines[linecount] = xstrdup(line);								}							}							// limitation of results							if (lines.size() >= userlog_max_output_lines)								break;						}					}					prev_c = c;					if (c != '/n' && linepos < MAX_MESSAGE_LEN)						linepos++;				} while (c != EOF);				fclose(fp);			}			return lines;		}
开发者ID:sbg2005,项目名称:pvpgn-server,代码行数:75,


示例26: logg_internal

static int logg_internal(const enum loglevel level,                         const char *file,                         const char *func,                         const unsigned int line,                         int log_errno,                         const char *fmt,                         va_list args                        ){	struct big_buff *logg_buff;	int ret_val, old_errno, retry_cnt;	old_errno  = errno;	/* get our tls-print buf */	if(!(logg_buff = logg_get_buf()))	{		/*		 * hmmm, something went wrong, lets see, if we can get the message to		 * the user by other means		 */		return do_vlogging(level, fmt, args);	}	/* add time, if wanted, to buffer */	if(server.settings.logging.add_date_time)		logg_buff->pos += add_time_to_buffer(buffer_start(*logg_buff), buffer_remaining(*logg_buff));	/* put out the "extra" stuff, if there */	if(file)	{		retry_cnt = 0;		prefetch(strlpcpy);		prefetch(file);		prefetch(func);		/*		 * calling snprintf for 2 * strcpy + an itoa is "nice"		 * but goes round the full stdio bloat:		 * snprintf->vsnprintf->vfprintf-> myriads of funcs to print		 */		do		{			char *sptr, *stmp, *rstart;			size_t remaining;			stmp = sptr = buffer_start(*logg_buff);			remaining = buffer_remaining(*logg_buff);			rstart = strlpcpy(sptr, file, remaining);			remaining -= rstart - sptr;			if(unlikely(remaining < 7))				goto realloc;			sptr = rstart;			*sptr++ = ':';			remaining--;			rstart = strlpcpy(sptr, func, remaining);			remaining -= rstart - sptr;			if(unlikely(remaining < 18)) /* make sure we have enough space */				goto realloc;			sptr = rstart;			*sptr++ = '(';			*sptr++ = ')';			*sptr++ = '@';			remaining -= 3;			rstart = put_dec_trunc(sptr, line); /* 99,999 lines should be... */			strreverse(sptr, rstart - 1);			remaining -= rstart - sptr;			if(unlikely(remaining < 2))				goto realloc;			sptr = rstart;			*sptr++ = ':';			*sptr++ = ' ';			logg_buff->pos += sptr - stmp;			break;realloc:			/* now we are in a slow path, no need to hurry */			{				struct big_buff *tmp_buff;				size_t len = strlen(file) + strlen(func) + 6 + 30 + strlen(fmt) * 3;				len = ROUND_ALIGN(len * 2, 2048) + logg_buff->capacity;				tmp_buff = realloc(logg_buff, sizeof(*logg_buff) + len);				if(tmp_buff) {					logg_buff = tmp_buff;					logg_buff->limit = logg_buff->capacity = len;				} else					break;				retry_cnt++;			}		} while(retry_cnt < 4);	}	ret_val = 0; retry_cnt = 0;	/* format the message in tls */	do	{		size_t len = logg_buff->capacity;		va_list tmp_valist;		if(ret_val < 0)		{//.........这里部分代码省略.........
开发者ID:kaffeemonster,项目名称:g2cd,代码行数:101,


示例27: parse_exeinfo

t_parsed_exeinfo * parse_exeinfo(char const * _exeinfo){  t_parsed_exeinfo * parsed_exeinfo;    if (!_exeinfo) {	return NULL;    }    parsed_exeinfo = (t_parsed_exeinfo*)xmalloc(sizeof(t_parsed_exeinfo));    parsed_exeinfo->exe = xstrdup(_exeinfo);    parsed_exeinfo->time = 0;    parsed_exeinfo->size = 0;        if (strcmp(prefs_get_version_exeinfo_match(),"parse")==0)     {#ifdef HAVE_MKTIME	struct tm t1;	char *exe;	char mask[MAX_EXEINFO_STR+1];	char * marker;	int size;        char time_invalid = 0;	if ((parsed_exeinfo->exe[0]=='/0') ||	   //happens when using war3-noCD and having deleted war3.org	    (strcmp(parsed_exeinfo->exe,"badexe")==0)) //happens when AUTHREQ had no owner/exeinfo entry	{          xfree((void *)parsed_exeinfo->exe);          xfree((void *)parsed_exeinfo);          eventlog(eventlog_level_error,__FUNCTION__,"found empty exeinfo");          return NULL;	}        memset(&t1,0,sizeof(t1));        t1.tm_isdst = -1;		char *exeinfo = xstrdup(_exeinfo);        exeinfo    = strreverse((char *)exeinfo);        if (!(marker     = strchr(exeinfo,' ')))        {	  xfree((void *)parsed_exeinfo->exe);	  xfree((void *)parsed_exeinfo);	  xfree((void*)exeinfo);	  return NULL;        }	for (; marker[0]==' ';marker++);         if (!(marker     = strchr(marker,' ')))        {	  xfree((void *)parsed_exeinfo->exe);	  xfree((void *)parsed_exeinfo);	  xfree((void*)exeinfo);	  return NULL;	} 	for (; marker[0]==' ';marker++);        if (!(marker     = strchr(marker,' ')))        {	  xfree((void *)parsed_exeinfo->exe);	  xfree((void *)parsed_exeinfo);	  xfree((void*)exeinfo);	  return NULL;	}        for (; marker[0]==' ';marker++);        marker--;        marker[0]  = '/0';        marker++;                 exe = xstrdup(marker);		xfree((void*)exeinfo);        xfree((void *)parsed_exeinfo->exe);        parsed_exeinfo->exe = strreverse((char *)exe);        exeinfo    = strreverse((char *)exeinfo);	sprintf(mask,"%%02u/%%02u/%%u %%02u:%%02u:%%02u %%u");	if (sscanf(exeinfo,mask,&t1.tm_mon,&t1.tm_mday,&t1.tm_year,&t1.tm_hour,&t1.tm_min,&t1.tm_sec,&size)!=7) {            if (sscanf(exeinfo,"%*s %*s %u",&size) != 1)            {	      eventlog(eventlog_level_warn,__FUNCTION__,"parser error while parsing pattern /"%s/"",exeinfo);	      xfree((void *)parsed_exeinfo->exe);	      xfree((void *)parsed_exeinfo);	      return NULL; /* neq */            }            time_invalid=1;	}       /* Now we have a Y2K problem :)  Thanks for using a 2 digit decimal years, Blizzard. */        /* 00-79 -> 2000-2079 	*             * 80-99 -> 1980-1999 	*             * 100+ unchanged */        if (t1.tm_year<80) 	 t1.tm_year = t1.tm_year + 100;        if (time_invalid)         parsed_exeinfo->time = -1;       else          parsed_exeinfo->time = mktime(&t1);//.........这里部分代码省略.........
开发者ID:Danteoriginal,项目名称:PvPGN-2,代码行数:101,



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


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