home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Programming / Python2 / Python20_source / Amiga_Misc / experimental_modules / Execlibmodule.c next >
Encoding:
C/C++ Source or Header  |  2000-10-29  |  1.3 KB  |  66 lines

  1.  
  2. /********************************************************************
  3.  
  4.     Lowlevel Amiga exec.library module.
  5.  
  6.     Currently only for MsgPorts and Messages.
  7.  
  8. -----------------------------------------------
  9.     ©Irmen de Jong.
  10.  
  11.     History:
  12.  
  13.     14-apr-96   Created.
  14.     29-okt-00    Fixup for Python 2.0
  15.  
  16.  
  17. Module members:
  18.  
  19.     error       -- Exeption string object.  ('Execlib.error')
  20.  
  21.  
  22. **************************************************************************/
  23.  
  24. #include <exec/memory.h>
  25. #include <proto/exec.h>
  26. #include "Python.h"
  27. //#include "modsupport.h"
  28.  
  29.  
  30. static PyObject *error;    // Exception
  31.  
  32.  
  33.  
  34. /************** MODULE FUNCTIONS *******************/
  35.  
  36.  
  37. static PyObject *
  38. Execlib_Avail(PyObject *self, PyObject *arg)
  39. {
  40.     if(!PyArg_NoArgs(arg)) return NULL;
  41.     return PyInt_FromLong(AvailMem(MEMF_ANY|MEMF_TOTAL));
  42. }
  43.  
  44. /*** FUNCTIONS FROM THE MODULE ***/
  45.  
  46. static PyMethodDef Execlib_global_methods[] = {
  47.     {"Avail", Execlib_Avail,  METH_OLDARGS},
  48.     {NULL,      NULL}       /* sentinel */
  49. };
  50. ///
  51.  
  52. void
  53. initExeclib Py_PROTO((void))
  54. {
  55.     PyObject *m, *d;
  56.  
  57.     m = Py_InitModule("Execlib", Execlib_global_methods);
  58.     d = PyModule_GetDict(m);
  59.  
  60.     /* Initialize error exception */
  61.     error = PyString_FromString("Execlib.error");
  62.     if (error == NULL || PyDict_SetItemString(d, "error", error) != 0)
  63.         Py_FatalError("can't define Execlib.error");
  64. }
  65.  
  66.