home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pyth_os2.zip / python-1.0.2 / OS2 / Modules / config.c next >
C/C++ Source or Header  |  1994-06-02  |  5KB  |  205 lines

  1. /* Generated automatically from ./config.c.in by makesetup. */
  2. /* -*- C -*- ***********************************************
  3. Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
  4. Amsterdam, The Netherlands.
  5.  
  6.                         All Rights Reserved
  7.  
  8. Permission to use, copy, modify, and distribute this software and its 
  9. documentation for any purpose and without fee is hereby granted, 
  10. provided that the above copyright notice appear in all copies and that
  11. both that copyright notice and this permission notice appear in 
  12. supporting documentation, and that the names of Stichting Mathematisch
  13. Centrum or CWI not be used in advertising or publicity pertaining to
  14. distribution of the software without specific, written prior permission.
  15.  
  16. STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  17. THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  18. FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  19. FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  20. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  21. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  22. OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  23.  
  24. ******************************************************************/
  25.  
  26. /* Universal Python configuration file */
  27.  
  28. #ifdef HAVE_CONFIG_H
  29. #include "config.h"
  30. #endif
  31.  
  32. #include <stdio.h>
  33. #include <string.h>
  34.  
  35. #include "myproto.h"
  36. #include "mymalloc.h"
  37. #include "osdefs.h"
  38. #include "intrcheck.h"
  39.  
  40.  
  41. #ifndef NO_MAIN
  42.  
  43. /* Normally, the main program is called from here (so everything else
  44.    can be in libPython.a).  We save a pointer to argv[0] because it
  45.    may be needed for dynamic loading of modules in import.c.  If you
  46.    have your own main program and want to use non-SunOS dynamic
  47.    loading, you will have to provide your own version of
  48.    getprogramname(). */
  49.  
  50. static char *argv0;
  51.  
  52. main(argc, argv)
  53.     int argc;
  54.     char **argv;
  55. {
  56. #ifdef macintosh
  57.     wargs(&argc, &argv);
  58. #endif
  59.     argv0 = argv[0];
  60.     realmain(argc, argv);
  61. }
  62.  
  63. char *
  64. getprogramname()
  65. {
  66.     return argv0;
  67. }
  68.  
  69. #endif
  70.  
  71.  
  72. /* Return the initial python search path.  This is called once from
  73.    initsys() to initialize sys.path.
  74.    The environment variable PYTHONPATH is fetched and the default path
  75.    appended.  (The Mac has no environment variables, so there the
  76.    default path is always returned.)  The default path may be passed
  77.    to the preprocessor; if not, a system-dependent default is used. */
  78.  
  79. #ifndef PYTHONPATH
  80. #ifdef macintosh
  81. #define PYTHONPATH ": :Lib :Lib:stdwin :Demo"
  82. #endif /* macintosh */
  83. #endif /* !PYTHONPATH */
  84.  
  85. #ifndef PYTHONPATH
  86. #if defined(MSDOS) || defined(NT)
  87. #define PYTHONPATH ".;..\\lib;\\python\\lib"
  88. #endif /* MSDOS || NT */
  89. #endif /* !PYTHONPATH */
  90.  
  91. #ifndef PYTHONPATH
  92. #define PYTHONPATH ".:/usr/local/lib/python"
  93. #endif /* !PYTHONPATH */
  94.  
  95. extern char *getenv();
  96.  
  97. char *
  98. getpythonpath()
  99. {
  100. #ifdef macintosh
  101.     return PYTHONPATH;
  102. #else /* !macintosh */
  103.     char *path = getenv("PYTHONPATH");
  104.     char *defpath = PYTHONPATH;
  105.     char *buf;
  106.     char *p;
  107.     int n;
  108.  
  109.     if (path == 0 || *path == '\0')
  110.         return defpath;
  111.     n = strlen(path) + strlen(defpath) + 2;
  112.     buf = malloc(n);
  113.     if (buf == NULL)
  114.         return path; /* XXX too bad -- but not likely */
  115.     strcpy(buf, path);
  116.     p = buf + strlen(buf);
  117.     *p++ = DELIM;
  118.     strcpy(p, defpath);
  119.     return buf;
  120. #endif /* !macintosh */
  121. }
  122.  
  123.  
  124. /* Table of built-in modules.
  125.    These are initialized when first imported.
  126.    Note: selection of optional extensions is now generally done by the
  127.    makesetup script. */
  128.  
  129. extern void initarray();
  130. extern void initmath();
  131. extern void initparser();
  132. extern void initposix();
  133. extern void initregex();
  134. extern void initstrop();
  135. extern void initstruct();
  136. extern void inittime();
  137. extern void initfcntl();
  138. extern void initpwd();
  139. extern void initgrp();
  140. extern void initselect();
  141. extern void initsocket();
  142. extern void initaudioop();
  143. extern void initimageop();
  144. extern void initrgbimg();
  145. extern void initmd5();
  146. extern void initrotor();
  147.  
  148. /* -- ADDMODULE MARKER 1 -- */
  149.  
  150. extern void initmarshal();
  151.  
  152. struct {
  153.     char *name;
  154.     void (*initfunc)();
  155. } inittab[] = {
  156.  
  157.     {"array", initarray},
  158.     {"math", initmath},
  159.     {"parser", initparser},
  160.     {"posix", initposix},
  161.     {"regex", initregex},
  162.     {"strop", initstrop},
  163.     {"struct", initstruct},
  164.     {"time", inittime},
  165.     {"fcntl", initfcntl},
  166.     {"pwd", initpwd},
  167. #ifdef HAVE_GRP_H
  168.     {"grp", initgrp},
  169. #endif
  170.     {"select", initselect},
  171. #ifdef HAVE_SOCKETS
  172.     {"socket", initsocket},
  173. #endif
  174.     {"audioop", initaudioop},
  175.     {"imageop", initimageop},
  176.     {"rgbimg", initrgbimg},
  177.     {"md5", initmd5},
  178.     {"rotor", initrotor},
  179.  
  180. /* -- ADDMODULE MARKER 2 -- */
  181.  
  182.     /* This module "lives in" with marshal.c */
  183.     {"marshal", initmarshal},
  184.  
  185.     /* These entries are here for sys.builtin_module_names */
  186.     {"__main__", NULL},
  187.     {"__builtin__", NULL},
  188.     {"sys", NULL},
  189.  
  190.     /* Sentinel */
  191.     {0, 0}
  192. };
  193.  
  194. #ifdef USE_FROZEN
  195. #include "frozen.c"
  196. #else
  197. struct frozen {
  198.     char *name;
  199.     char *code;
  200.     int size;
  201. } frozen_modules[] = {
  202.     {0, 0, 0}
  203. };
  204. #endif
  205.