strcpy(buffer + buflen, otherbuf); buflen += strlen(buffer + buflen) + 1; } } while (ret); enum_settings_finish(handle);
} while (ret); enum_settings_finish(handle); }
void get_sesslist(int allocate){    static char otherbuf[2048];    static char *buffer;    int buflen, bufsize, i;    char *p, *ret;    void *handle;    if (allocate) {	if ((handle = enum_settings_start()) == NULL)	    return;	buflen = bufsize = 0;	buffer = NULL;	do {	    ret = enum_settings_next(handle, otherbuf, sizeof(otherbuf));	    if (ret) {		int len = strlen(otherbuf) + 1;		if (bufsize < buflen + len) {		    bufsize = buflen + len + 2048;		    buffer = srealloc(buffer, bufsize);		}		strcpy(buffer + buflen, otherbuf);		buflen += strlen(buffer + buflen) + 1;	    }	} while (ret);	enum_settings_finish(handle);	buffer = srealloc(buffer, buflen + 1);	buffer[buflen] = '\0';	/*	 * Now set up the list of sessions. Note that "Default	 * Settings" must always be claimed to exist, even if it	 * doesn't really.	 */	p = buffer;	nsessions = 1;		       /* "Default Settings" counts as one */	while (*p) {	    if (strcmp(p, "Default Settings"))		nsessions++;	    while (*p)		p++;	    p++;	}	sessions = smalloc((nsessions + 1) * sizeof(char *));	sessions[0] = "Default Settings";	p = buffer;	i = 1;	while (*p) {	    if (strcmp(p, "Default Settings"))		sessions[i++] = p;	    while (*p)		p++;	    p++;	}	qsort(sessions, i, sizeof(char *), sessioncmp);    } else {	sfree(buffer);	sfree(sessions);    }}