samba36: reorganize patches, fix windows 7 compatibility
[openwrt/svn-archive/archive.git] / net / samba36 / patches / 110-multicall.patch
1 --- a/source3/Makefile.in
2 +++ b/source3/Makefile.in
3 @@ -214,7 +214,7 @@ PATH_FLAGS = -DSMB_PASSWD_FILE=\"$(SMB_P
4
5 # Note that all executable programs now provide for an optional executable suffix.
6
7 -SBIN_PROGS = bin/smbd@EXEEXT@ bin/nmbd@EXEEXT@ @SWAT_SBIN_TARGETS@ @EXTRA_SBIN_PROGS@
8 +SBIN_PROGS = bin/samba_multicall@EXEEXT@ bin/smbd@EXEEXT@ bin/nmbd@EXEEXT@ @SWAT_SBIN_TARGETS@ @EXTRA_SBIN_PROGS@
9
10 BIN_PROGS1 = bin/smbclient@EXEEXT@ bin/net@EXEEXT@ bin/smbspool@EXEEXT@ \
11 bin/testparm@EXEEXT@ bin/smbstatus@EXEEXT@ bin/smbget@EXEEXT@ \
12 @@ -1774,6 +1774,42 @@ bin/.dummy:
13 dir=bin $(MAKEDIR); fi
14 @: >> $@ || : > $@ # what a fancy emoticon!
15
16 +smbd/server_multicall.o: smbd/server.c smbd/server.o
17 + @echo Compiling $<.c
18 + @$(COMPILE_CC_PATH) -Dmain=smbd_main && exit 0;\
19 + echo "The following command failed:" 1>&2;\
20 + echo "$(COMPILE_CC_PATH)" 1>&2;\
21 + $(COMPILE_CC_PATH) >/dev/null 2>&1
22 +
23 +nmbd/nmbd_multicall.o: nmbd/nmbd.c nmbd/nmbd.o
24 + @echo Compiling $<.c
25 + @$(COMPILE_CC_PATH) -Dmain=nmbd_main && exit 0;\
26 + echo "The following command failed:" 1>&2;\
27 + echo "$(COMPILE_CC_PATH)" 1>&2;\
28 + $(COMPILE_CC_PATH) >/dev/null 2>&1
29 +
30 +utils/smbpasswd_multicall.o: utils/smbpasswd.c utils/smbpasswd.o
31 + @echo Compiling $<.c
32 + @$(COMPILE_CC_PATH) -Dmain=smbpasswd_main && exit 0;\
33 + echo "The following command failed:" 1>&2;\
34 + echo "$(COMPILE_CC_PATH)" 1>&2;\
35 + $(COMPILE_CC_PATH) >/dev/null 2>&1
36 +
37 +SMBD_MULTI_O = $(patsubst smbd/server.o,smbd/server_multicall.o,$(SMBD_OBJ))
38 +NMBD_MULTI_O = $(patsubst nmbd/nmbd.o,nmbd/nmbd_multicall.o,$(filter-out $(LIB_DUMMY_OBJ),$(NMBD_OBJ)))
39 +SMBPASSWD_MULTI_O = $(patsubst utils/smbpasswd.o,utils/smbpasswd_multicall.o,$(filter-out $(LIB_DUMMY_OBJ),$(SMBPASSWD_OBJ)))
40 +MULTI_O = multi.o
41 +
42 +MULTICALL_O = $(sort $(SMBD_MULTI_O) $(NMBD_MULTI_O) $(SMBPASSWD_MULTI_O) $(MULTI_O))
43 +
44 +bin/samba_multicall@EXEEXT@: $(BINARY_PREREQS) $(MULTICALL_O) $(LIBTALLOC) $(LIBTDB) $(LIBWBCLIENT) @BUILD_POPT@
45 + @echo Linking $@
46 + @$(CC) -o $@ $(MULTICALL_O) $(LDFLAGS) $(LDAP_LIBS) @SMBD_FAM_LIBS@ \
47 + $(KRB5LIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) \
48 + $(ACL_LIBS) $(PASSDB_LIBS) $(LIBS) $(DNSSD_LIBS) $(AVAHI_LIBS) \
49 + $(POPT_LIBS) @SMBD_LIBS@ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) \
50 + $(LIBWBCLIENT_LIBS) $(ZLIB_LIBS)
51 +
52 bin/smbd@EXEEXT@: $(BINARY_PREREQS) $(SMBD_OBJ) $(LIBTALLOC) $(LIBTDB) $(LIBWBCLIENT) @BUILD_POPT@
53 @echo Linking $@
54 @$(CC) -o $@ $(SMBD_OBJ) $(LDFLAGS) $(LDAP_LIBS) @SMBD_FAM_LIBS@ \
55 --- /dev/null
56 +++ b/source3/multi.c
57 @@ -0,0 +1,35 @@
58 +#include <stdio.h>
59 +#include <string.h>
60 +
61 +extern int smbd_main(int argc, char **argv);
62 +extern int nmbd_main(int argc, char **argv);
63 +extern int smbpasswd_main(int argc, char **argv);
64 +
65 +static struct {
66 + const char *name;
67 + int (*func)(int argc, char **argv);
68 +} multicall[] = {
69 + { "smbd", smbd_main },
70 + { "nmbd", nmbd_main },
71 + { "smbpasswd", smbpasswd_main },
72 +};
73 +
74 +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
75 +
76 +int main(int argc, char **argv)
77 +{
78 + int i;
79 +
80 + for (i = 0; i < ARRAY_SIZE(multicall); i++) {
81 + if (strstr(argv[0], multicall[i].name))
82 + return multicall[i].func(argc, argv);
83 + }
84 +
85 + fprintf(stderr, "Invalid multicall command, available commands:");
86 + for (i = 0; i < ARRAY_SIZE(multicall); i++)
87 + fprintf(stderr, " %s", multicall[i].name);
88 +
89 + fprintf(stderr, "\n");
90 +
91 + return 1;
92 +}