summaryrefslogtreecommitdiffstats
path: root/src/lib.c
blob: 48f185c432705893d433b7345d85984b28192d90 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int dc_interrupted = 0;
#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;
}