blob: 989436c2d9a3907d4983e2b6c18fd038aa324836 (
plain) (
tree)
|
|
#ifndef _GNU_SOURCE /* glibc already provides asprintf, but some cucks tend not to use glibc */
int asprintf (char ** str, const char * format, ...) { /* allocates automaticalls (: */
va_list ap, aq; /* */
va_start(ap, format);
va_copy(aq, ap);
int len = vsnprintf(NULL, 0, format, ap);
if (!(*str = realloc(*str, len+1)))
fprintf(stderr, "[BUG] !!! realloc failed\n");
if (len != vsprintf(*str, format, aq /* we need to use a different va handler, because */))
fprintf(stderr, "[BUG] !!! len1 != len2\n"); /* you can't rewind an existing one you can't rewind an existing one.. */
va_end(ap);
va_end(aq);
return len;
}
#endif
char * startswith (char * testiranec, char * začetek) {
if (!strncmp(testiranec, začetek, strlen(začetek)))
return testiranec+strlen(začetek);
return NULL;
}
|