Esempio n. 1
0
void line2list(struct list_head *head, const char *file)
{
	FILE *fp;
	struct str_ent *p;
	char *line = NULL;
	size_t n;
	int nl = 0;

	fp = fopen(file, "r");
	if (fp == NULL) {
		ULIB_FATAL("cannot open %s", file);
		exit(EXIT_FAILURE);
	}
	while (getline(&line, &n, fp) > 0) {
		p = (struct str_ent *) malloc(sizeof(struct str_ent));
		if (p == NULL) {
			ULIB_FATAL("cannot new entry");
			exit(EXIT_FAILURE);
		}
		list_add_tail(&p->aaa, head);
		p->str = line;
		line = NULL;
		++nl;
	}
	free(line);
	fclose(fp);
	ULIB_NOTICE("%d line(s) has been loaded", nl);
}
Esempio n. 2
0
int main()
{
    ULIB_DEBUG("debug log");
    ULIB_WARNING("warning log");
    ULIB_NOTICE("notice log");
    ULIB_FATAL("fatal log");

    printf("passed\n");

    return 0;
}