summaryrefslogtreecommitdiffstats
path: root/src/lib.c
blob: 07d339d887066554f16e067956e4a6c9a0705a66 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int smprintf (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);
	*str = malloc(len+1);
	if (len != vsprintf(*str, format, ap))
		fprintf(stderr, "[BUG] !!! len1 != len2\n");
	va_end(ap);
	va_end(aq);
	return len;
}
char * startswith (char * testiranec, char * začetek) {
	if (!strncmp(testiranec, začetek, strlen(začetek)))
		return testiranec+strlen(začetek);
	return NULL;
}