www.pudn.com > map_editor.rar > asc.c
#include#include #include "global.h" void my_strncp(Uint8 *dest,const Uint8 * source, Sint32 len) { while(*source && --len > 0) { *dest++=*source++; } *dest='\0'; } //find the first string occurance, and return the distance to that string //if beggining is 1, it returns the offset to the beginning of the string //otherwise it returns the offset to the end of the string int get_string_occurance(char * source_pointer, char * dest_pointer, int max_len,char beginning) { int i; int j; int k; char cur_src_char; char cur_dest_char; int source_lenght; source_lenght=strlen(source_pointer); i=j=0; for(i=0;i =65 && cur_src_char<=90)cur_src_char+=32; if(cur_dest_char>=65 && cur_dest_char<=90)cur_dest_char+=32; if(cur_src_char!=cur_dest_char)break;//not found, sorry i++; j++; k++; } if(k==source_lenght)//we found the string { if(!beginning)return i; else return i-k; } }//end of the for return -1;//if we are here, it means we didn't find the string... } //this function returns an integer, after the source string in the destination string //if the string is not found, after max_len, the function returns null. //the function is NOT case sensitive int get_integer_after_string(char * source_pointer, char * dest_pointer, int max_len) { int i; int j; int k; char cur_src_char; char cur_dest_char; int source_lenght; source_lenght=strlen(source_pointer); i=j=0; for(i=0;i =65 && cur_src_char<=90)cur_src_char+=32; if(cur_dest_char>=65 && cur_dest_char<=90)cur_dest_char+=32; if(cur_src_char!=cur_dest_char)break;//not found, sorry i++; j++; k++; } if(k==source_lenght)//we found the string { //we have to find the first number now (there might be spaces, or other chars first while(1) { cur_dest_char=*(dest_pointer+i); if((cur_dest_char>=48 && cur_dest_char<=57) || cur_dest_char=='-' || cur_dest_char=='+')break;//we found a number if(cur_dest_char==0x0a) return -1;//we didn't find any number on this line i++; } return atoi(dest_pointer+i); } }//end of the for return -1;//if we are here, it means we didn't find the string... } //this function returns an integer, after the source string in the destination string //if the string is not found, after max_len, the function returns null. //the function is NOT case sensitive float get_float_after_string(char * source_pointer, char * dest_pointer, int max_len) { int i; int j; int k; char cur_src_char; char cur_dest_char; int source_lenght; source_lenght=strlen(source_pointer); i=j=0; for(i=0;i =65 && cur_src_char<=90)cur_src_char+=32; if(cur_dest_char>=65 && cur_dest_char<=90)cur_dest_char+=32; if(cur_src_char!=cur_dest_char)break;//not found, sorry i++; j++; k++; } if(k==source_lenght)//we found the string { //we have to find the first number now (there might be spaces, or other chars first while(1) { cur_dest_char=*(dest_pointer+i); if((cur_dest_char>=48 && cur_dest_char<=57) || cur_dest_char=='-' || cur_dest_char=='+')break;//we found a number if(cur_dest_char==0x0a) return -1;//we didn't find any number on this line i++; } return atof(dest_pointer+i); } }//end of the for return -1;//if we are here, it means we didn't find the string... } int my_xmlStrncopy(char ** out, const char * in, int len) { if(in) { size_t lin=0; size_t lout=0; int l1=0; int l2=0; int retval=1; char *inbuf; char *inbuf2; char *outbuf; char *outbuf2; lin=strlen(in); l2=xmlUTF8Strlen(in); if(l2<0) lout=l1; else if (len>0 && len = size) { str[size-1] = '\0'; return size; } return ret; } #endif