summaryrefslogtreecommitdiff
path: root/test/tparse-dir.c
blob: e3d24dbba8c6c4e70d2f4238d7474b1494ad7b04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include "initd.h"

static void print_list(const initd_list_t *list);

int main(int argc, char *argv[])
{
	char *dir;
	initd_list_t *test;

	if (argc > 1)
		dir = argv[1];
	else
		dir = ".";

	test = initd_list_from_dir(dir);
	if (test)
		print_list(test);

	return 0;
}

static void print_list(const initd_list_t *list)
{
	initd_t *ip;
	int n;
	for (ip = list->first; ip; ip = ip->next) {
		printf("Service %s provides:", ip->name);
		for (n = 0; n < prov_get_num(ip->prov); n++)
			printf(" %s", prov_get_prov(ip->prov, n));
		printf("\n");
	}
}