blob: bf132a54a87907ae99519c580ea82123d3946b3e [file] [log] [blame]
Guido van Rossumce9739b1994-01-05 16:17:15 +00001/***********************************************************
Guido van Rossum99546991995-01-08 14:33:34 +00002Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
3The Netherlands.
Guido van Rossumce9739b1994-01-05 16:17:15 +00004
5 All Rights Reserved
6
7Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
9provided that the above copyright notice appear in all copies and that
10both that copyright notice and this permission notice appear in
11supporting documentation, and that the names of Stichting Mathematisch
12Centrum or CWI not be used in advertising or publicity pertaining to
13distribution of the software without specific, written prior permission.
14
15STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
16THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
18FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
23******************************************************************/
24
Guido van Rossum87f223c1994-05-06 15:54:15 +000025/* Mac module implementation */
Guido van Rossumce9739b1994-01-05 16:17:15 +000026
27#include "allobjects.h"
Guido van Rossumce9739b1994-01-05 16:17:15 +000028#include "modsupport.h"
Guido van Rossum87f223c1994-05-06 15:54:15 +000029#include "ceval.h"
Guido van Rossumce9739b1994-01-05 16:17:15 +000030
Guido van Rossum87f223c1994-05-06 15:54:15 +000031#include <stdio.h>
32#include <string.h>
33#include <errno.h>
Guido van Rossum739267b1994-08-29 08:42:37 +000034
35#ifdef THINK_C
36#include "unix.h"
37#undef S_IFMT
38#undef S_IFDIR
39#undef S_IFCHR
40#undef S_IFBLK
41#undef S_IFREG
42#undef S_ISDIR
43#undef S_ISREG
44#endif
45
Jack Jansenc743c8d1996-02-14 16:02:30 +000046#ifdef USE_GUSI
47#include <sys/types.h>
48#include <stat.h>
49#define macstat stat
50#else
Guido van Rossum739267b1994-08-29 08:42:37 +000051#include "macstat.h"
Jack Jansenc743c8d1996-02-14 16:02:30 +000052#endif
Guido van Rossumce9739b1994-01-05 16:17:15 +000053
Jack Jansen9eeb82d1995-01-26 16:34:53 +000054#ifdef __MWERKS__
55/* For CodeWarrior 4 also define CW4 */
56#include <unix.h>
57#else
Guido van Rossum87f223c1994-05-06 15:54:15 +000058#include <fcntl.h>
Jack Jansen0c097ea1994-12-14 13:48:38 +000059#endif
Guido van Rossumce9739b1994-01-05 16:17:15 +000060
Guido van Rossum56934121995-02-13 16:19:04 +000061#if defined(__MWERKS__) && defined(__powerc)
Jack Jansen7cbf4801995-01-22 16:52:38 +000062#define MALLOC_DEBUG
63#endif
64
Guido van Rossumd4d77281994-08-19 10:51:31 +000065#include "macdefs.h"
Jack Jansenc743c8d1996-02-14 16:02:30 +000066#ifdef USE_GUSI
67#include <dirent.h>
68#else
Guido van Rossumd4d77281994-08-19 10:51:31 +000069#include "dirent.h"
Jack Jansenc743c8d1996-02-14 16:02:30 +000070#endif
Guido van Rossum87f223c1994-05-06 15:54:15 +000071
72#ifndef MAXPATHLEN
73#define MAXPATHLEN 1024
74#endif
75
76/* Prototypes for Unix simulation on Mac */
77
Guido van Rossum921a08f1994-05-06 15:56:22 +000078int chdir PROTO((const char *path));
Guido van Rossum87f223c1994-05-06 15:54:15 +000079char *getbootvol PROTO((void));
80char *getwd PROTO((char *));
Jack Jansenc743c8d1996-02-14 16:02:30 +000081#ifdef USE_GUSI
82int mkdir PROTO((const char *path));
83DIR * opendir PROTO((const char *));
84int closedir PROTO((DIR *));
85#else
Guido van Rossum921a08f1994-05-06 15:56:22 +000086int mkdir PROTO((const char *path, int mode));
87DIR * opendir PROTO((char *));
Guido van Rossum87f223c1994-05-06 15:54:15 +000088void closedir PROTO((DIR *));
Jack Jansenc743c8d1996-02-14 16:02:30 +000089#endif
Guido van Rossumd4d77281994-08-19 10:51:31 +000090struct dirent * readdir PROTO((DIR *));
Guido van Rossum921a08f1994-05-06 15:56:22 +000091int rmdir PROTO((const char *path));
Guido van Rossum87f223c1994-05-06 15:54:15 +000092int sync PROTO((void));
Jack Jansenc743c8d1996-02-14 16:02:30 +000093#if defined(THINK_C) || defined(__SC__) || defined(USE_GUSI)
Guido van Rossum739267b1994-08-29 08:42:37 +000094int unlink PROTO((char *));
95#else
Guido van Rossum921a08f1994-05-06 15:56:22 +000096int unlink PROTO((const char *));
Guido van Rossum739267b1994-08-29 08:42:37 +000097#endif
Guido van Rossum87f223c1994-05-06 15:54:15 +000098
99
100
101static object *MacError; /* Exception mac.error */
102
103/* Set a MAC-specific error from errno, and return NULL */
104
105static object *
106mac_error()
107{
Guido van Rossum921a08f1994-05-06 15:56:22 +0000108 return err_errno(MacError);
Guido van Rossum87f223c1994-05-06 15:54:15 +0000109}
110
111/* MAC generic methods */
112
113static object *
114mac_1str(args, func)
115 object *args;
116 int (*func) FPROTO((const char *));
117{
118 char *path1;
119 int res;
120 if (!getargs(args, "s", &path1))
121 return NULL;
122 BGN_SAVE
123 res = (*func)(path1);
124 END_SAVE
125 if (res < 0)
126 return mac_error();
127 INCREF(None);
128 return None;
129}
130
131static object *
132mac_2str(args, func)
133 object *args;
134 int (*func) FPROTO((const char *, const char *));
135{
136 char *path1, *path2;
137 int res;
138 if (!getargs(args, "(ss)", &path1, &path2))
139 return NULL;
140 BGN_SAVE
141 res = (*func)(path1, path2);
142 END_SAVE
143 if (res < 0)
144 return mac_error();
145 INCREF(None);
146 return None;
147}
148
149static object *
150mac_strint(args, func)
151 object *args;
152 int (*func) FPROTO((const char *, int));
153{
154 char *path;
155 int i;
156 int res;
157 if (!getargs(args, "(si)", &path, &i))
158 return NULL;
159 BGN_SAVE
160 res = (*func)(path, i);
161 END_SAVE
162 if (res < 0)
163 return mac_error();
164 INCREF(None);
165 return None;
166}
167
168static object *
Guido van Rossumce9739b1994-01-05 16:17:15 +0000169mac_chdir(self, args)
170 object *self;
171 object *args;
172{
Guido van Rossum87f223c1994-05-06 15:54:15 +0000173 return mac_1str(args, chdir);
174}
175
Jack Jansen9eeb82d1995-01-26 16:34:53 +0000176#ifndef CW4
Guido van Rossum87f223c1994-05-06 15:54:15 +0000177static object *
178mac_close(self, args)
179 object *self;
180 object *args;
181{
182 int fd, res;
183 if (!getargs(args, "i", &fd))
Guido van Rossumce9739b1994-01-05 16:17:15 +0000184 return NULL;
Guido van Rossum87f223c1994-05-06 15:54:15 +0000185 BGN_SAVE
186 res = close(fd);
187 END_SAVE
188 if (res < 0)
189 return mac_error();
Guido van Rossumce9739b1994-01-05 16:17:15 +0000190 INCREF(None);
191 return None;
192}
Jack Jansen0c097ea1994-12-14 13:48:38 +0000193#endif /* !__MWERKS__ */
Guido van Rossumce9739b1994-01-05 16:17:15 +0000194
Guido van Rossum921a08f1994-05-06 15:56:22 +0000195#ifdef MPW
196
Guido van Rossum87f223c1994-05-06 15:54:15 +0000197static object *
198mac_dup(self, args)
199 object *self;
200 object *args;
201{
202 int fd;
203 if (!getargs(args, "i", &fd))
204 return NULL;
205 BGN_SAVE
206 fd = dup(fd);
207 END_SAVE
208 if (fd < 0)
209 return mac_error();
210 return newintobject((long)fd);
211}
212
Guido van Rossume7834441994-08-26 09:09:48 +0000213#endif /* MPW */
214
Jack Jansen0c097ea1994-12-14 13:48:38 +0000215#ifndef __MWERKS__
Guido van Rossum87f223c1994-05-06 15:54:15 +0000216static object *
217mac_fdopen(self, args)
218 object *self;
219 object *args;
220{
221 extern int fclose PROTO((FILE *));
222 int fd;
223 char *mode;
224 FILE *fp;
225 if (!getargs(args, "(is)", &fd, &mode))
226 return NULL;
227 BGN_SAVE
228 fp = fdopen(fd, mode);
229 END_SAVE
230 if (fp == NULL)
231 return mac_error();
232 return newopenfileobject(fp, "(fdopen)", mode, fclose);
233}
Jack Jansen0c097ea1994-12-14 13:48:38 +0000234#endif
Guido van Rossum87f223c1994-05-06 15:54:15 +0000235
236static object *
237mac_getbootvol(self, args)
238 object *self;
239 object *args;
240{
241 char *res;
242 if (!getnoarg(args))
243 return NULL;
244 BGN_SAVE
245 res = getbootvol();
246 END_SAVE
247 if (res == NULL)
248 return mac_error();
249 return newstringobject(res);
250}
Guido van Rossumce9739b1994-01-05 16:17:15 +0000251
252static object *
253mac_getcwd(self, args)
254 object *self;
255 object *args;
256{
Guido van Rossum87f223c1994-05-06 15:54:15 +0000257 char path[MAXPATHLEN];
258 char *res;
Guido van Rossumce9739b1994-01-05 16:17:15 +0000259 if (!getnoarg(args))
260 return NULL;
Guido van Rossum87f223c1994-05-06 15:54:15 +0000261 BGN_SAVE
262 res = getwd(path);
263 END_SAVE
264 if (res == NULL) {
265 err_setstr(MacError, path);
Guido van Rossumce9739b1994-01-05 16:17:15 +0000266 return NULL;
267 }
Guido van Rossum87f223c1994-05-06 15:54:15 +0000268 return newstringobject(res);
Guido van Rossumce9739b1994-01-05 16:17:15 +0000269}
270
Guido van Rossumce9739b1994-01-05 16:17:15 +0000271static object *
272mac_listdir(self, args)
273 object *self;
274 object *args;
275{
Guido van Rossumce9739b1994-01-05 16:17:15 +0000276 char *name;
Guido van Rossum87f223c1994-05-06 15:54:15 +0000277 object *d, *v;
Guido van Rossumce9739b1994-01-05 16:17:15 +0000278 DIR *dirp;
Guido van Rossumd4d77281994-08-19 10:51:31 +0000279 struct dirent *ep;
Guido van Rossum87f223c1994-05-06 15:54:15 +0000280 if (!getargs(args, "s", &name))
Guido van Rossumce9739b1994-01-05 16:17:15 +0000281 return NULL;
Guido van Rossum87f223c1994-05-06 15:54:15 +0000282 BGN_SAVE
283 if ((dirp = opendir(name)) == NULL) {
284 RET_SAVE
285 return mac_error();
286 }
Guido van Rossumce9739b1994-01-05 16:17:15 +0000287 if ((d = newlistobject(0)) == NULL) {
288 closedir(dirp);
Guido van Rossum87f223c1994-05-06 15:54:15 +0000289 RET_SAVE
Guido van Rossumce9739b1994-01-05 16:17:15 +0000290 return NULL;
291 }
292 while ((ep = readdir(dirp)) != NULL) {
293 v = newstringobject(ep->d_name);
294 if (v == NULL) {
295 DECREF(d);
296 d = NULL;
297 break;
298 }
299 if (addlistitem(d, v) != 0) {
300 DECREF(v);
301 DECREF(d);
302 d = NULL;
303 break;
304 }
305 DECREF(v);
306 }
307 closedir(dirp);
Guido van Rossum87f223c1994-05-06 15:54:15 +0000308 END_SAVE
309
Guido van Rossumce9739b1994-01-05 16:17:15 +0000310 return d;
311}
312
Jack Jansen9eeb82d1995-01-26 16:34:53 +0000313#ifndef CW4
Guido van Rossum87f223c1994-05-06 15:54:15 +0000314static object *
315mac_lseek(self, args)
316 object *self;
317 object *args;
318{
319 int fd;
320 int where;
321 int how;
322 long res;
323 if (!getargs(args, "(iii)", &fd, &where, &how))
324 return NULL;
325 BGN_SAVE
326 res = lseek(fd, (long)where, how);
327 END_SAVE
328 if (res < 0)
329 return mac_error();
330 return newintobject(res);
331}
Jack Jansen9eeb82d1995-01-26 16:34:53 +0000332#endif /* !CW4 */
Guido van Rossumce9739b1994-01-05 16:17:15 +0000333
Jack Jansenc743c8d1996-02-14 16:02:30 +0000334#ifdef USE_GUSI
335/* GUSI mkdir doesn't accept the (dummy) mode. Grrr. */
336int _gusi_mkdir(name, mode)
337 char *name;
338 int mode;
339{
340 return mkdir(name);
341}
342#endif /* USE_GUSI */
343
Guido van Rossumce9739b1994-01-05 16:17:15 +0000344static object *
345mac_mkdir(self, args)
346 object *self;
347 object *args;
348{
Jack Jansenc743c8d1996-02-14 16:02:30 +0000349#ifdef USE_GUSI
350 return mac_strint(args, _gusi_mkdir);
351#else
Guido van Rossum87f223c1994-05-06 15:54:15 +0000352 return mac_strint(args, mkdir);
Jack Jansenc743c8d1996-02-14 16:02:30 +0000353#endif
Guido van Rossumce9739b1994-01-05 16:17:15 +0000354}
355
Jack Jansen9eeb82d1995-01-26 16:34:53 +0000356#ifndef CW4
Guido van Rossum87f223c1994-05-06 15:54:15 +0000357static object *
358mac_open(self, args)
359 object *self;
360 object *args;
361{
362 char *path;
363 int mode;
364 int fd;
365 if (!getargs(args, "(si)", &path, &mode))
366 return NULL;
367 BGN_SAVE
368 fd = open(path, mode);
369 END_SAVE
370 if (fd < 0)
371 return mac_error();
372 return newintobject((long)fd);
373}
374
375static object *
376mac_read(self, args)
377 object *self;
378 object *args;
379{
380 int fd, size;
381 object *buffer;
382 if (!getargs(args, "(ii)", &fd, &size))
383 return NULL;
384 buffer = newsizedstringobject((char *)NULL, size);
385 if (buffer == NULL)
386 return NULL;
387 BGN_SAVE
388 size = read(fd, getstringvalue(buffer), size);
389 END_SAVE
390 if (size < 0) {
391 DECREF(buffer);
392 return mac_error();
393 }
394 resizestring(&buffer, size);
395 return buffer;
396}
Jack Jansen0c097ea1994-12-14 13:48:38 +0000397#endif /* !__MWERKS */
Guido van Rossumce9739b1994-01-05 16:17:15 +0000398
399static object *
400mac_rename(self, args)
401 object *self;
402 object *args;
403{
Guido van Rossum87f223c1994-05-06 15:54:15 +0000404 return mac_2str(args, rename);
Guido van Rossumce9739b1994-01-05 16:17:15 +0000405}
406
Guido van Rossumce9739b1994-01-05 16:17:15 +0000407static object *
408mac_rmdir(self, args)
409 object *self;
410 object *args;
411{
Guido van Rossum87f223c1994-05-06 15:54:15 +0000412 return mac_1str(args, rmdir);
Guido van Rossumce9739b1994-01-05 16:17:15 +0000413}
414
Guido van Rossumce9739b1994-01-05 16:17:15 +0000415static object *
416mac_stat(self, args)
417 object *self;
418 object *args;
419{
Guido van Rossum739267b1994-08-29 08:42:37 +0000420 struct macstat st;
Guido van Rossumce9739b1994-01-05 16:17:15 +0000421 char *path;
Guido van Rossum87f223c1994-05-06 15:54:15 +0000422 int res;
423 if (!getargs(args, "s", &path))
Guido van Rossumce9739b1994-01-05 16:17:15 +0000424 return NULL;
Guido van Rossum87f223c1994-05-06 15:54:15 +0000425 BGN_SAVE
Guido van Rossum739267b1994-08-29 08:42:37 +0000426 res = macstat(path, &st);
Guido van Rossum87f223c1994-05-06 15:54:15 +0000427 END_SAVE
428 if (res != 0)
429 return mac_error();
Guido van Rossumd4d77281994-08-19 10:51:31 +0000430 return mkvalue("(llllllllll)",
Guido van Rossum87f223c1994-05-06 15:54:15 +0000431 (long)st.st_mode,
Guido van Rossume7834441994-08-26 09:09:48 +0000432 (long)st.st_ino,
Guido van Rossumd4d77281994-08-19 10:51:31 +0000433 (long)st.st_dev,
434 (long)st.st_nlink,
435 (long)st.st_uid,
436 (long)st.st_gid,
Guido van Rossum87f223c1994-05-06 15:54:15 +0000437 (long)st.st_size,
Guido van Rossumd4d77281994-08-19 10:51:31 +0000438 (long)st.st_atime,
439 (long)st.st_mtime,
440 (long)st.st_ctime);
Guido van Rossumce9739b1994-01-05 16:17:15 +0000441}
442
Guido van Rossumce9739b1994-01-05 16:17:15 +0000443static object *
Guido van Rossum222c8921995-08-08 14:10:22 +0000444mac_xstat(self, args)
445 object *self;
446 object *args;
447{
448 struct macstat st;
449 char *path;
450 int res;
451 if (!getargs(args, "s", &path))
452 return NULL;
453 BGN_SAVE
454 res = macstat(path, &st);
455 END_SAVE
456 if (res != 0)
457 return mac_error();
Jack Jansenc743c8d1996-02-14 16:02:30 +0000458#ifdef USE_GUSI
459 return mkvalue("(llllllllll)",
460 (long)st.st_mode,
461 (long)st.st_ino,
462 (long)st.st_dev,
463 (long)st.st_nlink,
464 (long)st.st_uid,
465 (long)st.st_gid,
466 (long)st.st_size,
467 (long)st.st_atime,
468 (long)st.st_mtime,
469 (long)st.st_ctime);
470#else
Guido van Rossum222c8921995-08-08 14:10:22 +0000471 return mkvalue("(llllllllllls#s#)",
472 (long)st.st_mode,
473 (long)st.st_ino,
474 (long)st.st_dev,
475 (long)st.st_nlink,
476 (long)st.st_uid,
477 (long)st.st_gid,
478 (long)st.st_size,
479 (long)st.st_atime,
480 (long)st.st_mtime,
481 (long)st.st_ctime,
482 (long)st.st_rsize,
483 st.st_creator, 4,
484 st.st_type, 4);
Jack Jansenc743c8d1996-02-14 16:02:30 +0000485#endif
Guido van Rossum222c8921995-08-08 14:10:22 +0000486}
487
488static object *
Guido van Rossumce9739b1994-01-05 16:17:15 +0000489mac_sync(self, args)
490 object *self;
491 object *args;
492{
Guido van Rossum87f223c1994-05-06 15:54:15 +0000493 int res;
Guido van Rossumce9739b1994-01-05 16:17:15 +0000494 if (!getnoarg(args))
495 return NULL;
Guido van Rossum87f223c1994-05-06 15:54:15 +0000496 BGN_SAVE
497 res = sync();
498 END_SAVE
499 if (res != 0)
500 return mac_error();
Guido van Rossumce9739b1994-01-05 16:17:15 +0000501 INCREF(None);
502 return None;
503}
504
Guido van Rossumce9739b1994-01-05 16:17:15 +0000505static object *
506mac_unlink(self, args)
507 object *self;
508 object *args;
509{
Guido van Rossum739267b1994-08-29 08:42:37 +0000510 return mac_1str(args, (int (*)(const char *))unlink);
Guido van Rossumce9739b1994-01-05 16:17:15 +0000511}
512
Jack Jansen9eeb82d1995-01-26 16:34:53 +0000513#ifndef CW4
Guido van Rossum87f223c1994-05-06 15:54:15 +0000514static object *
515mac_write(self, args)
516 object *self;
517 object *args;
518{
519 int fd, size;
520 char *buffer;
521 if (!getargs(args, "(is#)", &fd, &buffer, &size))
522 return NULL;
523 BGN_SAVE
524 size = write(fd, buffer, size);
525 END_SAVE
526 if (size < 0)
527 return mac_error();
528 return newintobject((long)size);
529}
Jack Jansen0c097ea1994-12-14 13:48:38 +0000530#endif /* !__MWERKS__ */
Guido van Rossumce9739b1994-01-05 16:17:15 +0000531
Jack Jansend50e4e11995-01-18 13:58:04 +0000532#ifdef MALLOC_DEBUG
533static object *
534mac_mstats(self, args)
535 object*self;
536 object *args;
537{
538 mstats("python");
539 INCREF(None);
540 return None;
541}
542#endif MALLOC_DEBUG
543
Guido van Rossumce9739b1994-01-05 16:17:15 +0000544static struct methodlist mac_methods[] = {
545 {"chdir", mac_chdir},
Jack Jansen9eeb82d1995-01-26 16:34:53 +0000546#ifndef CW4
Guido van Rossum87f223c1994-05-06 15:54:15 +0000547 {"close", mac_close},
Jack Jansen0c097ea1994-12-14 13:48:38 +0000548#endif
Guido van Rossum921a08f1994-05-06 15:56:22 +0000549#ifdef MPW
Guido van Rossum87f223c1994-05-06 15:54:15 +0000550 {"dup", mac_dup},
Guido van Rossum921a08f1994-05-06 15:56:22 +0000551#endif
Jack Jansen0c097ea1994-12-14 13:48:38 +0000552#ifndef __MWERKS__
Guido van Rossume7834441994-08-26 09:09:48 +0000553 {"fdopen", mac_fdopen},
Jack Jansen0c097ea1994-12-14 13:48:38 +0000554#endif
Guido van Rossum87f223c1994-05-06 15:54:15 +0000555 {"getbootvol", mac_getbootvol}, /* non-standard */
Guido van Rossumce9739b1994-01-05 16:17:15 +0000556 {"getcwd", mac_getcwd},
Guido van Rossumd1ef5961995-02-19 15:50:35 +0000557 {"listdir", mac_listdir, 0},
Jack Jansen9eeb82d1995-01-26 16:34:53 +0000558#ifndef CW4
Guido van Rossum87f223c1994-05-06 15:54:15 +0000559 {"lseek", mac_lseek},
Jack Jansen0c097ea1994-12-14 13:48:38 +0000560#endif
Guido van Rossumce9739b1994-01-05 16:17:15 +0000561 {"mkdir", mac_mkdir},
Jack Jansen9eeb82d1995-01-26 16:34:53 +0000562#ifndef CW4
Guido van Rossum87f223c1994-05-06 15:54:15 +0000563 {"open", mac_open},
564 {"read", mac_read},
Jack Jansen0c097ea1994-12-14 13:48:38 +0000565#endif
Guido van Rossumce9739b1994-01-05 16:17:15 +0000566 {"rename", mac_rename},
567 {"rmdir", mac_rmdir},
568 {"stat", mac_stat},
Guido van Rossum222c8921995-08-08 14:10:22 +0000569 {"xstat", mac_xstat},
Guido van Rossumce9739b1994-01-05 16:17:15 +0000570 {"sync", mac_sync},
571 {"unlink", mac_unlink},
Jack Jansen9eeb82d1995-01-26 16:34:53 +0000572#ifndef CW4
Guido van Rossum87f223c1994-05-06 15:54:15 +0000573 {"write", mac_write},
Jack Jansen0c097ea1994-12-14 13:48:38 +0000574#endif
Jack Jansend50e4e11995-01-18 13:58:04 +0000575#ifdef MALLOC_DEBUG
576 {"mstats", mac_mstats},
577#endif
Guido van Rossum87f223c1994-05-06 15:54:15 +0000578
Guido van Rossumce9739b1994-01-05 16:17:15 +0000579 {NULL, NULL} /* Sentinel */
580};
581
582
583void
584initmac()
585{
Jack Jansend50e4e11995-01-18 13:58:04 +0000586 object *m, *d;
Guido van Rossumce9739b1994-01-05 16:17:15 +0000587
588 m = initmodule("mac", mac_methods);
589 d = getmoduledict(m);
590
591 /* Initialize mac.error exception */
592 MacError = newstringobject("mac.error");
593 if (MacError == NULL || dictinsert(d, "error", MacError) != 0)
594 fatal("can't define mac.error");
595}