home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / program / a / backthrow / !backthrow_c_throwback < prev    next >
Encoding:
Text File  |  1993-02-07  |  2.1 KB  |  90 lines

  1. /* throwback.c - throwback client library */
  2. /* GTK 09.09.1992 */
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <kernel.h>
  8.  
  9. #define THROWBACK_START 0x42587
  10. #define THROWBACK_SEND  0x42588
  11. #define THROWBACK_END   0x42589
  12.  
  13. /* holds filename of file currently being processed */
  14. static char* current_pathname = NULL;
  15.  
  16. /* duplicate a string */
  17. char *strdup(char *from)
  18. {
  19.         char *to;
  20.  
  21.         to = malloc(strlen(from) + 1);
  22.         return(strcpy(to, from));
  23. }
  24.  
  25. /* start throwback session */
  26. void throwback_start(void)
  27. {
  28.         /* just dummies */
  29.         _kernel_swi_regs regs;
  30.  
  31.         /* just call the swi */
  32.         _kernel_swi(THROWBACK_START, ®s, ®s);
  33. }
  34.  
  35. /* send something to the throwback-handling task */
  36. static void throwback_send(_kernel_swi_regs regs)
  37. {
  38.         /* call swi passing on received register settings */
  39.         _kernel_swi(THROWBACK_SEND, ®s, ®s);
  40. }
  41.  
  42. /* end throwback session */
  43. void throwback_end(void)
  44. {
  45.         /* just dummies */
  46.         _kernel_swi_regs regs;
  47.  
  48.         /* just call the swi */
  49.         _kernel_swi(THROWBACK_END, ®s, ®s);
  50. }
  51.  
  52. /* tell throwback module (and this library) which file we're
  53.  * currently processing */
  54. void throwback_processing(char *pathname)
  55. {
  56.         _kernel_swi_regs r;
  57.  
  58.         r.r[0] = 0;               /* reason code */
  59.         current_pathname = strdup(pathname);
  60.         /* pathname of file being processed */
  61.         r.r[2] = (int) current_pathname;
  62.         throwback_send(r);      /* tell dde module about it */
  63. }
  64.  
  65. /* signal an error to the throwback-handling task */
  66. void throwback_error(int lineno, int severity, char *description)
  67. {
  68.         _kernel_swi_regs r;
  69.  
  70.         r.r[0] = 1;
  71.         r.r[2] = (int) current_pathname;
  72.         r.r[3] = lineno;
  73.         r.r[4] = severity;
  74.         r.r[5] = (int) description;
  75.         throwback_send(r);
  76. }
  77.  
  78. /* just issue a plain info message */
  79. void throwback_info(int lineno, char *description)
  80. {
  81.         _kernel_swi_regs r;
  82.  
  83.         r.r[0] = 2;
  84.         r.r[2] = (int) current_pathname;
  85.         r.r[3] = lineno;
  86.         r.r[4] = 0;
  87.         r.r[5] = (int) description;
  88.         throwback_send(r);
  89. }
  90.