Skip to content

Commit

Permalink
Implement nss-altfiles-config tool
Browse files Browse the repository at this point in the history
Closes issue #4
  • Loading branch information
aperezdc committed Dec 15, 2015
1 parent 88c3fa7 commit 4f96876
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
nss-altfiles-config
*.so*
*.o
.*.sw[op]
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,20 @@ ifneq ($(strip $(BUILDAPI_JOBS)),)
MAKEOPTS += -j$(BUILDAPI_JOBS)
endif

all: $T
all: $T nss-altfiles-config

$T: $O
$(CC) -shared -o $@ $^ $(LDFLAGS)

$O: src/nss_altfiles/files-XXX.c src/nss_altfiles/files-parse.c src/compat.h
src/nss_altfiles/files-hosts.o: src/resolv/mapv4v6addr.h src/resolv/res_hconf.h

nss-altfiles-config: src/main.o
$(CC) -o $@ $^

clean:
find src -name '*.o' -delete
$(RM) $T
$(RM) $T nss-altfiles-config

distclean: clean
$(RM) config.mk
Expand Down
36 changes: 36 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* main.c
* Copyright (C) 2015 Adrian Perez <aperez@igalia.com>
*
* Distributed under terms of the MIT license.
*/

#include "compat.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#define XSTRINGIZE(y) #y
#define STRINGIZE(x) XSTRINGIZE(x)

static int
usage (const char *prgname)
{
fprintf (stderr, "Usage: %s [datadir | modulename]\n", prgname);
return EXIT_FAILURE;
}

int
main (int argc, const char *argv[])
{
if (argc > 2) return usage (argv[0]);

if (argc == 1 || strcmp (argv[1], "datadir") == 0) {
printf ("%s\n", ALTFILES_DATADIR);
} else if (strcmp (argv[1], "modulename") == 0) {
printf ("%s\n", STRINGIZE (ALTFILES_MODULE_NAME));
} else {
return usage (argv[0]);
}
return EXIT_SUCCESS;
}

0 comments on commit 4f96876

Please sign in to comment.