Mercurial > cpython-lru_cache-weakref
annotate Modules/nismodule.c @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | 4224ff77a1dd |
| children | de58f61386c3 |
| rev | line source |
|---|---|
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 /*********************************************************** |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 Written by: |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 Fred Gansevles <Fred.Gansevles@cs.utwente.nl> |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
4 B&O group, |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 Faculteit der Informatica, |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 Universiteit Twente, |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 Enschede, |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 the Netherlands. |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 ******************************************************************/ |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 /* NIS module implementation */ |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 |
| 4674 | 13 #include "Python.h" |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 #include <sys/time.h> |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 #include <sys/types.h> |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 #include <rpc/rpc.h> |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 #include <rpcsvc/yp_prot.h> |
|
3975
b76fe67eed44
Rearrange include headers (needed on some platforms).
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
19 #include <rpcsvc/ypclnt.h> |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 |
|
4619
c3ca006554d4
Added ``extern int get_default_domain();'' for SGI, to keep gcc -Wall happy.
Guido van Rossum <guido@python.org>
parents:
3975
diff
changeset
|
21 #ifdef __sgi |
|
c3ca006554d4
Added ``extern int get_default_domain();'' for SGI, to keep gcc -Wall happy.
Guido van Rossum <guido@python.org>
parents:
3975
diff
changeset
|
22 /* This is missing from rpcsvc/ypclnt.h */ |
|
13667
a6c7bfdd6777
Even more ANSIfication: fix as many function pointers and declarations as
Thomas Wouters <thomas@python.org>
parents:
13651
diff
changeset
|
23 extern int yp_get_default_domain(char **); |
|
4619
c3ca006554d4
Added ``extern int get_default_domain();'' for SGI, to keep gcc -Wall happy.
Guido van Rossum <guido@python.org>
parents:
3975
diff
changeset
|
24 #endif |
|
c3ca006554d4
Added ``extern int get_default_domain();'' for SGI, to keep gcc -Wall happy.
Guido van Rossum <guido@python.org>
parents:
3975
diff
changeset
|
25 |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
26 PyDoc_STRVAR(get_default_domain__doc__, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
27 "get_default_domain() -> str\n\ |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
28 Corresponds to the C library yp_get_default_domain() call, returning\n\ |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
29 the default NIS domain.\n"); |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
30 |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
31 PyDoc_STRVAR(match__doc__, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
32 "match(key, map, domain = defaultdomain)\n\ |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
33 Corresponds to the C library yp_match() call, returning the value of\n\ |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
34 key in the given map. Optionally domain can be specified but it\n\ |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
35 defaults to the system default domain.\n"); |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
36 |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
37 PyDoc_STRVAR(cat__doc__, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
38 "cat(map, domain = defaultdomain)\n\ |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
39 Returns the entire map as a dictionary. Optionally domain can be\n\ |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
40 specified but it defaults to the system default domain.\n"); |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
41 |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
42 PyDoc_STRVAR(maps__doc__, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
43 "maps(domain = defaultdomain)\n\ |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
44 Returns an array of all available NIS maps within a domain. If domain\n\ |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
45 is not specified it defaults to the system default domain.\n"); |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
46 |
| 4674 | 47 static PyObject *NisError; |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
48 |
| 4674 | 49 static PyObject * |
|
13505
0edeb4efe6db
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13447
diff
changeset
|
50 nis_error (int err) |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
51 { |
| 4674 | 52 PyErr_SetString(NisError, yperr_string(err)); |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
53 return NULL; |
|
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
54 } |
|
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
55 |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 static struct nis_map { |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 char *alias; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 char *map; |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
59 int fix; |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 } aliases [] = { |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
61 {"passwd", "passwd.byname", 0}, |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
62 {"group", "group.byname", 0}, |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
63 {"networks", "networks.byaddr", 0}, |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
64 {"hosts", "hosts.byname", 0}, |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
65 {"protocols", "protocols.bynumber", 0}, |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
66 {"services", "services.byname", 0}, |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
67 {"aliases", "mail.aliases", 1}, /* created with 'makedbm -a' */ |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
68 {"ethers", "ethers.byname", 0}, |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
69 {0L, 0L, 0} |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
70 }; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
71 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
72 static char * |
|
13505
0edeb4efe6db
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13447
diff
changeset
|
73 nis_mapname (char *map, int *pfix) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
74 { |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
75 int i; |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
76 |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
77 *pfix = 0; |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
78 for (i=0; aliases[i].alias != 0L; i++) { |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
79 if (!strcmp (aliases[i].alias, map)) { |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
80 *pfix = aliases[i].fix; |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
81 return aliases[i].map; |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
82 } |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
83 if (!strcmp (aliases[i].map, map)) { |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
84 *pfix = aliases[i].fix; |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
85 return aliases[i].map; |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
86 } |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
87 } |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
88 |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
89 return map; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
90 } |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
91 |
|
32567
0064f55bafa7
Add an #ifdef __APPLE__ around typedef of foreachfunc to match Apple's
Brett Cannon <bcannon@gmail.com>
parents:
26027
diff
changeset
|
92 #ifdef __APPLE__ |
|
0064f55bafa7
Add an #ifdef __APPLE__ around typedef of foreachfunc to match Apple's
Brett Cannon <bcannon@gmail.com>
parents:
26027
diff
changeset
|
93 typedef int (*foreachfunc)(unsigned long, char *, int, char *, int, void *); |
|
0064f55bafa7
Add an #ifdef __APPLE__ around typedef of foreachfunc to match Apple's
Brett Cannon <bcannon@gmail.com>
parents:
26027
diff
changeset
|
94 #else |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
12576
diff
changeset
|
95 typedef int (*foreachfunc)(int, char *, int, char *, int, char *); |
|
32567
0064f55bafa7
Add an #ifdef __APPLE__ around typedef of foreachfunc to match Apple's
Brett Cannon <bcannon@gmail.com>
parents:
26027
diff
changeset
|
96 #endif |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1393
diff
changeset
|
97 |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
98 struct ypcallback_data { |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
99 PyObject *dict; |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
100 int fix; |
|
47880
4224ff77a1dd
Try a blind fix to nismodule which fails on the solaris10 3.0 buildbot:
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47527
diff
changeset
|
101 PyThreadState *state; |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
102 }; |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
103 |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
104 static int |
|
13505
0edeb4efe6db
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13447
diff
changeset
|
105 nis_foreach (int instatus, char *inkey, int inkeylen, char *inval, |
|
0edeb4efe6db
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13447
diff
changeset
|
106 int invallen, struct ypcallback_data *indata) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
107 { |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
108 if (instatus == YP_TRUE) { |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
109 PyObject *key; |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
110 PyObject *val; |
|
1393
7d6a2d950f13
* nismodule.c: database keys and values can contain null bytes. be more
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
111 int err; |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
112 |
|
47880
4224ff77a1dd
Try a blind fix to nismodule which fails on the solaris10 3.0 buildbot:
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47527
diff
changeset
|
113 PyEval_RestoreThread(indata->state); |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
114 if (indata->fix) { |
|
26027
d68fc49a7096
SF #633013, Fix NIS causing interpreter core dump
Neal Norwitz <nnorwitz@gmail.com>
parents:
22709
diff
changeset
|
115 if (inkeylen > 0 && inkey[inkeylen-1] == '\0') |
|
d68fc49a7096
SF #633013, Fix NIS causing interpreter core dump
Neal Norwitz <nnorwitz@gmail.com>
parents:
22709
diff
changeset
|
116 inkeylen--; |
|
d68fc49a7096
SF #633013, Fix NIS causing interpreter core dump
Neal Norwitz <nnorwitz@gmail.com>
parents:
22709
diff
changeset
|
117 if (invallen > 0 && inval[invallen-1] == '\0') |
|
d68fc49a7096
SF #633013, Fix NIS causing interpreter core dump
Neal Norwitz <nnorwitz@gmail.com>
parents:
22709
diff
changeset
|
118 invallen--; |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
119 } |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
120 key = PyString_FromStringAndSize(inkey, inkeylen); |
|
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
121 val = PyString_FromStringAndSize(inval, invallen); |
|
1393
7d6a2d950f13
* nismodule.c: database keys and values can contain null bytes. be more
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
122 if (key == NULL || val == NULL) { |
|
7d6a2d950f13
* nismodule.c: database keys and values can contain null bytes. be more
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
123 /* XXX error -- don't know how to handle */ |
| 4674 | 124 PyErr_Clear(); |
| 125 Py_XDECREF(key); | |
| 126 Py_XDECREF(val); | |
|
1393
7d6a2d950f13
* nismodule.c: database keys and values can contain null bytes. be more
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
127 return 1; |
|
7d6a2d950f13
* nismodule.c: database keys and values can contain null bytes. be more
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
128 } |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
129 err = PyDict_SetItem(indata->dict, key, val); |
| 4674 | 130 Py_DECREF(key); |
| 131 Py_DECREF(val); | |
|
47880
4224ff77a1dd
Try a blind fix to nismodule which fails on the solaris10 3.0 buildbot:
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47527
diff
changeset
|
132 if (err != 0) |
| 4674 | 133 PyErr_Clear(); |
|
47880
4224ff77a1dd
Try a blind fix to nismodule which fails on the solaris10 3.0 buildbot:
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47527
diff
changeset
|
134 indata->state = PyEval_SaveThread(); |
|
4224ff77a1dd
Try a blind fix to nismodule which fails on the solaris10 3.0 buildbot:
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47527
diff
changeset
|
135 if (err != 0) |
|
4224ff77a1dd
Try a blind fix to nismodule which fails on the solaris10 3.0 buildbot:
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47527
diff
changeset
|
136 return 1; |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
137 return 0; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
138 } |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
139 return 1; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
140 } |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
141 |
| 4674 | 142 static PyObject * |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
143 nis_get_default_domain (PyObject *self) |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
144 { |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
145 char *domain; |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
146 int err; |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
147 PyObject *res; |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
148 |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
149 if ((err = yp_get_default_domain(&domain)) != 0) |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
150 return nis_error(err); |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
151 |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
152 res = PyString_FromStringAndSize (domain, strlen(domain)); |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
153 return res; |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
154 } |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
155 |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
156 static PyObject * |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
157 nis_match (PyObject *self, PyObject *args, PyObject *kwdict) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
158 { |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
159 char *match; |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
160 char *domain = NULL; |
|
1393
7d6a2d950f13
* nismodule.c: database keys and values can contain null bytes. be more
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
161 int keylen, len; |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
162 char *key, *map; |
|
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
163 int err; |
| 4674 | 164 PyObject *res; |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
165 int fix; |
|
36675
dba6494735d0
Revert backwards-incompatible const changes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36438
diff
changeset
|
166 static char *kwlist[] = {"key", "map", "domain", NULL}; |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
167 |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
168 if (!PyArg_ParseTupleAndKeywords(args, kwdict, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
169 "t#s|s:match", kwlist, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
170 &key, &keylen, &map, &domain)) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
171 return NULL; |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
172 if (!domain && ((err = yp_get_default_domain(&domain)) != 0)) |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
173 return nis_error(err); |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
174 map = nis_mapname (map, &fix); |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
175 if (fix) |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
176 keylen++; |
| 4674 | 177 Py_BEGIN_ALLOW_THREADS |
|
1393
7d6a2d950f13
* nismodule.c: database keys and values can contain null bytes. be more
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
178 err = yp_match (domain, map, key, keylen, &match, &len); |
| 4674 | 179 Py_END_ALLOW_THREADS |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
180 if (fix) |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
181 len--; |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
182 if (err != 0) |
|
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
183 return nis_error(err); |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
184 res = PyString_FromStringAndSize (match, len); |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
185 free (match); |
|
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
186 return res; |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
187 } |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
188 |
| 4674 | 189 static PyObject * |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
190 nis_cat (PyObject *self, PyObject *args, PyObject *kwdict) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
191 { |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
192 char *domain = NULL; |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
193 char *map; |
|
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
194 struct ypall_callback cb; |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
195 struct ypcallback_data data; |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
196 PyObject *dict; |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
197 int err; |
|
36675
dba6494735d0
Revert backwards-incompatible const changes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36438
diff
changeset
|
198 static char *kwlist[] = {"map", "domain", NULL}; |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
199 |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
200 if (!PyArg_ParseTupleAndKeywords(args, kwdict, "s|s:cat", |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
201 kwlist, &map, &domain)) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
202 return NULL; |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
203 if (!domain && ((err = yp_get_default_domain(&domain)) != 0)) |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
204 return nis_error(err); |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
205 dict = PyDict_New (); |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
206 if (dict == NULL) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
207 return NULL; |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1393
diff
changeset
|
208 cb.foreach = (foreachfunc)nis_foreach; |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
209 data.dict = dict; |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
210 map = nis_mapname (map, &data.fix); |
|
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
211 cb.data = (char *)&data; |
|
47880
4224ff77a1dd
Try a blind fix to nismodule which fails on the solaris10 3.0 buildbot:
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47527
diff
changeset
|
212 data.state = PyEval_SaveThread(); |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
213 err = yp_all (domain, map, &cb); |
|
47880
4224ff77a1dd
Try a blind fix to nismodule which fails on the solaris10 3.0 buildbot:
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47527
diff
changeset
|
214 PyEval_RestoreThread(data.state); |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
215 if (err != 0) { |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
216 Py_DECREF(dict); |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
217 return nis_error(err); |
|
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
218 } |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
219 return dict; |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
220 } |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
221 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1393
diff
changeset
|
222 /* These should be u_long on Sun h/w but not on 64-bit h/w. |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1393
diff
changeset
|
223 This is not portable to machines with 16-bit ints and no prototypes */ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1393
diff
changeset
|
224 #ifndef YPPROC_MAPLIST |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1393
diff
changeset
|
225 #define YPPROC_MAPLIST 11 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1393
diff
changeset
|
226 #endif |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1393
diff
changeset
|
227 #ifndef YPPROG |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1393
diff
changeset
|
228 #define YPPROG 100004 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1393
diff
changeset
|
229 #endif |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1393
diff
changeset
|
230 #ifndef YPVERS |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1393
diff
changeset
|
231 #define YPVERS 2 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1393
diff
changeset
|
232 #endif |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
233 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
234 typedef char *domainname; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
235 typedef char *mapname; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
236 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
237 enum nisstat { |
| 4674 | 238 NIS_TRUE = 1, |
| 239 NIS_NOMORE = 2, | |
| 240 NIS_FALSE = 0, | |
| 241 NIS_NOMAP = -1, | |
| 242 NIS_NODOM = -2, | |
| 243 NIS_NOKEY = -3, | |
| 244 NIS_BADOP = -4, | |
| 245 NIS_BADDB = -5, | |
| 246 NIS_YPERR = -6, | |
| 247 NIS_BADARGS = -7, | |
| 248 NIS_VERS = -8 | |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
249 }; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
250 typedef enum nisstat nisstat; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
251 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
252 struct nismaplist { |
| 4674 | 253 mapname map; |
| 254 struct nismaplist *next; | |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
255 }; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
256 typedef struct nismaplist nismaplist; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
257 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
258 struct nisresp_maplist { |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
259 nisstat stat; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
260 nismaplist *maps; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
261 }; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
262 typedef struct nisresp_maplist nisresp_maplist; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
263 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
264 static struct timeval TIMEOUT = { 25, 0 }; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
265 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
266 static |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
267 bool_t |
|
13505
0edeb4efe6db
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13447
diff
changeset
|
268 nis_xdr_domainname(XDR *xdrs, domainname *objp) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
269 { |
| 4674 | 270 if (!xdr_string(xdrs, objp, YPMAXDOMAIN)) { |
| 271 return (FALSE); | |
| 272 } | |
| 273 return (TRUE); | |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
274 } |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
275 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
276 static |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
277 bool_t |
|
13505
0edeb4efe6db
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13447
diff
changeset
|
278 nis_xdr_mapname(XDR *xdrs, mapname *objp) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
279 { |
| 4674 | 280 if (!xdr_string(xdrs, objp, YPMAXMAP)) { |
| 281 return (FALSE); | |
| 282 } | |
| 283 return (TRUE); | |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
284 } |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
285 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
286 static |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
287 bool_t |
|
13505
0edeb4efe6db
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13447
diff
changeset
|
288 nis_xdr_ypmaplist(XDR *xdrs, nismaplist *objp) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
289 { |
| 4674 | 290 if (!nis_xdr_mapname(xdrs, &objp->map)) { |
| 291 return (FALSE); | |
| 292 } | |
| 293 if (!xdr_pointer(xdrs, (char **)&objp->next, | |
| 9289 | 294 sizeof(nismaplist), (xdrproc_t)nis_xdr_ypmaplist)) |
| 4674 | 295 { |
| 296 return (FALSE); | |
| 297 } | |
| 298 return (TRUE); | |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
299 } |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
300 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
301 static |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
302 bool_t |
|
13505
0edeb4efe6db
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13447
diff
changeset
|
303 nis_xdr_ypstat(XDR *xdrs, nisstat *objp) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
304 { |
| 4674 | 305 if (!xdr_enum(xdrs, (enum_t *)objp)) { |
| 306 return (FALSE); | |
| 307 } | |
| 308 return (TRUE); | |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
309 } |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
310 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
311 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
312 static |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
313 bool_t |
|
13505
0edeb4efe6db
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13447
diff
changeset
|
314 nis_xdr_ypresp_maplist(XDR *xdrs, nisresp_maplist *objp) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
315 { |
| 4674 | 316 if (!nis_xdr_ypstat(xdrs, &objp->stat)) { |
| 317 return (FALSE); | |
| 318 } | |
| 319 if (!xdr_pointer(xdrs, (char **)&objp->maps, | |
| 9289 | 320 sizeof(nismaplist), (xdrproc_t)nis_xdr_ypmaplist)) |
| 4674 | 321 { |
| 322 return (FALSE); | |
| 323 } | |
| 324 return (TRUE); | |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
325 } |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
326 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
327 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
328 static |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
329 nisresp_maplist * |
|
13505
0edeb4efe6db
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13447
diff
changeset
|
330 nisproc_maplist_2(domainname *argp, CLIENT *clnt) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
331 { |
| 4674 | 332 static nisresp_maplist res; |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
333 |
| 4674 | 334 memset(&res, 0, sizeof(res)); |
| 9289 | 335 if (clnt_call(clnt, YPPROC_MAPLIST, |
| 336 (xdrproc_t)nis_xdr_domainname, (caddr_t)argp, | |
| 337 (xdrproc_t)nis_xdr_ypresp_maplist, (caddr_t)&res, | |
| 338 TIMEOUT) != RPC_SUCCESS) | |
| 339 { | |
| 4674 | 340 return (NULL); |
| 341 } | |
| 342 return (&res); | |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
343 } |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
344 |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
345 static |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
346 nismaplist * |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
347 nis_maplist (char *dom) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
348 { |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
349 nisresp_maplist *list; |
|
16092
f3f6b7598bc5
Move declaration of 'clnt_create()' NIS function to pyport.h, as it's
Thomas Wouters <thomas@python.org>
parents:
13667
diff
changeset
|
350 CLIENT *cl; |
|
4917
1bcd4972da7e
Nailed a couple of memory leaks, caught by Purify.
Barry Warsaw <barry@python.org>
parents:
4676
diff
changeset
|
351 char *server = NULL; |
| 4674 | 352 int mapi = 0; |
|
4675
0c01a23c7dcd
nis_maplist(): Use check of yp_get_default_domain() return value
Barry Warsaw <barry@python.org>
parents:
4674
diff
changeset
|
353 |
|
4917
1bcd4972da7e
Nailed a couple of memory leaks, caught by Purify.
Barry Warsaw <barry@python.org>
parents:
4676
diff
changeset
|
354 while (!server && aliases[mapi].map != 0L) { |
| 4674 | 355 yp_master (dom, aliases[mapi].map, &server); |
| 356 mapi++; | |
| 357 } | |
|
4917
1bcd4972da7e
Nailed a couple of memory leaks, caught by Purify.
Barry Warsaw <barry@python.org>
parents:
4676
diff
changeset
|
358 if (!server) { |
| 4674 | 359 PyErr_SetString(NisError, "No NIS master found for any map"); |
| 360 return NULL; | |
| 361 } | |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
362 cl = clnt_create(server, YPPROG, YPVERS, "tcp"); |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
363 if (cl == NULL) { |
| 4674 | 364 PyErr_SetString(NisError, clnt_spcreateerror(server)); |
|
4917
1bcd4972da7e
Nailed a couple of memory leaks, caught by Purify.
Barry Warsaw <barry@python.org>
parents:
4676
diff
changeset
|
365 goto finally; |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
366 } |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
367 list = nisproc_maplist_2 (&dom, cl); |
|
4917
1bcd4972da7e
Nailed a couple of memory leaks, caught by Purify.
Barry Warsaw <barry@python.org>
parents:
4676
diff
changeset
|
368 clnt_destroy(cl); |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
369 if (list == NULL) |
|
4917
1bcd4972da7e
Nailed a couple of memory leaks, caught by Purify.
Barry Warsaw <barry@python.org>
parents:
4676
diff
changeset
|
370 goto finally; |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
371 if (list->stat != NIS_TRUE) |
|
4917
1bcd4972da7e
Nailed a couple of memory leaks, caught by Purify.
Barry Warsaw <barry@python.org>
parents:
4676
diff
changeset
|
372 goto finally; |
|
1bcd4972da7e
Nailed a couple of memory leaks, caught by Purify.
Barry Warsaw <barry@python.org>
parents:
4676
diff
changeset
|
373 |
|
12576
1c7c2dd1beb1
Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents:
11883
diff
changeset
|
374 free(server); |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
375 return list->maps; |
|
4917
1bcd4972da7e
Nailed a couple of memory leaks, caught by Purify.
Barry Warsaw <barry@python.org>
parents:
4676
diff
changeset
|
376 |
|
1bcd4972da7e
Nailed a couple of memory leaks, caught by Purify.
Barry Warsaw <barry@python.org>
parents:
4676
diff
changeset
|
377 finally: |
|
12576
1c7c2dd1beb1
Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents:
11883
diff
changeset
|
378 free(server); |
|
4917
1bcd4972da7e
Nailed a couple of memory leaks, caught by Purify.
Barry Warsaw <barry@python.org>
parents:
4676
diff
changeset
|
379 return NULL; |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
380 } |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
381 |
| 4674 | 382 static PyObject * |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
383 nis_maps (PyObject *self, PyObject *args, PyObject *kwdict) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
384 { |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
385 char *domain = NULL; |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
386 nismaplist *maps; |
| 4674 | 387 PyObject *list; |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
388 int err; |
|
36675
dba6494735d0
Revert backwards-incompatible const changes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36438
diff
changeset
|
389 static char *kwlist[] = {"domain", NULL}; |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
390 |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
391 if (!PyArg_ParseTupleAndKeywords(args, kwdict, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
392 "|s:maps", kwlist, &domain)) |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
393 return NULL; |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
394 if (!domain && ((err = yp_get_default_domain (&domain)) != 0)) { |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
395 nis_error(err); |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
396 return NULL; |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
397 } |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
398 |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
399 if ((maps = nis_maplist (domain)) == NULL) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
400 return NULL; |
| 4674 | 401 if ((list = PyList_New(0)) == NULL) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
402 return NULL; |
|
11883
0c4729e38c3d
Patch by Fred Gansevles (the module's original author).
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
403 for (maps = maps; maps; maps = maps->next) { |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
404 PyObject *str = PyString_FromString(maps->map); |
|
4917
1bcd4972da7e
Nailed a couple of memory leaks, caught by Purify.
Barry Warsaw <barry@python.org>
parents:
4676
diff
changeset
|
405 if (!str || PyList_Append(list, str) < 0) |
| 4674 | 406 { |
| 407 Py_DECREF(list); | |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
408 list = NULL; |
|
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
409 break; |
|
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
410 } |
|
4917
1bcd4972da7e
Nailed a couple of memory leaks, caught by Purify.
Barry Warsaw <barry@python.org>
parents:
4676
diff
changeset
|
411 Py_DECREF(str); |
|
940
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
412 } |
|
844482b6467a
Added error handling and free resources.
Guido van Rossum <guido@python.org>
parents:
939
diff
changeset
|
413 /* XXX Shouldn't we free the list of maps now? */ |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
414 return list; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
415 } |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
416 |
| 4674 | 417 static PyMethodDef nis_methods[] = { |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
418 {"match", (PyCFunction)nis_match, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
419 METH_VARARGS | METH_KEYWORDS, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
420 match__doc__}, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
421 {"cat", (PyCFunction)nis_cat, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
422 METH_VARARGS | METH_KEYWORDS, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
423 cat__doc__}, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
424 {"maps", (PyCFunction)nis_maps, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
425 METH_VARARGS | METH_KEYWORDS, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
426 maps__doc__}, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
427 {"get_default_domain", (PyCFunction)nis_get_default_domain, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
428 METH_NOARGS, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
429 get_default_domain__doc__}, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
430 {NULL, NULL} /* Sentinel */ |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
431 }; |
|
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
432 |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
433 PyDoc_STRVAR(nis__doc__, |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
434 "This module contains functions for accessing NIS maps.\n"); |
|
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
435 |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
436 void |
|
13651
8a063423e0b7
Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents:
13505
diff
changeset
|
437 initnis (void) |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
438 { |
| 4674 | 439 PyObject *m, *d; |
|
36438
94d27e01833d
Patch #1422385: Changes to nis module to support multiple NIS domains
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
440 m = Py_InitModule3("nis", nis_methods, nis__doc__); |
|
36324
1af7f719ed28
Check return result from Py_InitModule*(). This API can fail.
Neal Norwitz <nnorwitz@gmail.com>
parents:
32567
diff
changeset
|
441 if (m == NULL) |
|
1af7f719ed28
Check return result from Py_InitModule*(). This API can fail.
Neal Norwitz <nnorwitz@gmail.com>
parents:
32567
diff
changeset
|
442 return; |
| 4674 | 443 d = PyModule_GetDict(m); |
|
6367
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
4917
diff
changeset
|
444 NisError = PyErr_NewException("nis.error", NULL, NULL); |
|
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
4917
diff
changeset
|
445 if (NisError != NULL) |
|
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
4917
diff
changeset
|
446 PyDict_SetItemString(d, "error", NisError); |
|
939
7243a906937c
NIS interface by Fred Gansevles <Fred.Gansevles@cs.utwente.nl>.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
447 } |
