#include "string.h" int dec_to_int(char *src, char **dst) { int ret; src = skip_non_numbers(src); ret = atoi(src); if (dst) { *dst = skip_numbers(src); } return ret; } long long dec_to_longlong(char *src, char **dst) { long long ret; src = skip_non_numbers(src); ret = atoll(src); if (dst) { *dst = skip_numbers(src); } return ret; } float dec_to_float(char *src, char **dst) { float ret; src = skip_non_numbers(src); ret = atof(src); if (dst) { *dst = skip_float_numbers(src); } return ret; } /* * Copy white space separated stirng from *src to *word * * src: source * dst: place where store the end of word pointer from source string * word: destination where to copy the string * size: maximum size of bytes to copy to the output buffer * * return the number of bytes copied */ int get_word(char *src, char **dst, char *word, int size) { int ret = 0; while(((*src == ' ') || (*src == '\t') || (*src == '\n')) && *src) src++; while(((*src != ' ') && (*src != '\t') && (*src != '\n')) && *src && (ret < (size - 1))) { *word = *src; word++; src++; ret++; } *word = 0; if (dst) *dst = src; return ret; }