home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / palmos / pippy-0.6beta-src.tar.gz / pippy-0.6beta-src.tar / pippy-0.6beta-src / src / Modules / _palmutils.c < prev    next >
C/C++ Source or Header  |  2000-12-21  |  1KB  |  50 lines

  1.  
  2. #include "Python.h"
  3. #include <PalmOS.h>
  4. #include "_palmutils.h"
  5.  
  6. /* must fix the following include - put somewhere else */
  7. #include "commonRsc.h"
  8.  
  9.  
  10. /* palmutil_buildErrObject:
  11.    
  12.    Build a Python string object containing the palmnet error and 
  13.    return the result.  Callers are handed ownership of the resulting
  14.    object and should decrement the reference when finished with it.
  15.  
  16. */
  17.  
  18. PyObject *
  19. palmutil_buildErrObject(UInt16 ifErrs) 
  20. {
  21.     UInt16 maxLen=30;
  22.     char netErrString[maxLen];
  23.     char errnoString[maxLen];
  24.     /* Grab the error id from the errno.  Extract last byte of 0x1200
  25.        error offset. */
  26.     Err i = ifErrs & 0x00FF;
  27.  
  28. /*     SysStringByIndex (netErrStringCodes_tSTL, i, netErrString, maxLen); */
  29.     SysErrString(ifErrs, netErrString, maxLen);
  30.     SysStringByIndex (errnoStringCodes_tSTL, i, errnoString, maxLen);
  31.     return Py_BuildValue("(iss)", (int)ifErrs, errnoString, netErrString);
  32.     
  33. }
  34.  
  35.  
  36. PyObject *
  37. palmutil_setErr(PyObject *exc, Err err)
  38. {
  39.     char msg[80];
  40.     SysErrString(err, msg, 80);
  41.     PyErr_SetString(exc, msg);
  42.     return NULL;
  43. }
  44.  
  45. PyObject *
  46. palmutil_setErr_FromDMError(PyObject *exc)
  47. {
  48.     return palmutil_setErr(exc, DmGetLastErr());
  49. }
  50.