#include "string.h" #include #include #include "stdlib.h" void* memcpy(void* dest_ptr,const void* source_ptr,size_t len) { char* source=(char*)source_ptr; char* dest=(char*)dest_ptr; for(size_t i=0;i 0); if (sign < 0) { str[i++] = '-'; } str[i]='\0'; strrev(str); } void hex_to_ascii(int n, char* str) { append(str, '0'); append(str, 'x'); char zeros = 0; unsigned int tmp; int i; for (i = 28; i > 0; i -= 4) { tmp = (n >> i) & 0xF; if (tmp == 0 && zeros == 0) continue; zeros = 1; if (tmp > 0xA) append(str, tmp - 0xA + 'a'); else append(str, tmp + '0'); } tmp = n & 0xF; if (tmp >= 0xA) append(str, tmp - 0xA + 'a'); else append(str, tmp + '0'); } void append(char* s, char n) { int len = strlen(s); s[len] = n; s[len+1] = '\0'; } void backspace(char* s) { int len = strlen(s); s[len-1] = '\0'; } char* strtok_str=NULL; size_t strtok_index; char strtok_delim_check(char* delim) { for (int i=0;istrlen(strtok_str)) { return NULL; } char* tok=malloc(sizeof(char)*32); tok[0]='\0'; size_t max_len=32; for (;strtok_delim_check(delim);strtok_index++) { if (strlen(tok)+1==max_len) { tok=realloc(tok,sizeof(char)*(max_len+32)); max_len+=32; } append(tok,strtok_str[strtok_index]); } strtok_index++; return tok; }