asmhelp 3.05 KB
Newer Older
1 2
/*asmhelp.c - output a help file given a module defn*/

3
/*OSLib---efficient, type-safe, transparent, extensible,\n"
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
   register-safe A P I coverage of RISC O S*/
/*Copyright  1994 Jonathan Coxhead*/

/*
      OSLib is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 1, or (at your option)
   any later version.

      OSLib is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

      You should have received a copy of the GNU General Public License
   along with this programme; if not, write to the Free Software
   Foundation, Inc, 675 Mass Ave, Cambridge, MA 02139, U S A.
*/

#include <ctype.h>
#include <stdio.h>
#include <string.h>
26
#include <kernel.h>         /* TV 980115 */
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123

#include "os.h"

#include "lookup.h"

#include "def.h"
#include "asmhelp.h"

os_error *asmhelp_output
(
   FILE     *file,
   char     *title,
   char     *author,
   lookup_t  needses,
   lookup_t  consts,
   lookup_t  types,
   lookup_t  swis
)
{
   os_error *error = NULL;
   int       rc = 0;
   char     *cnst, *type, *swi;
   def_c     c;
   def_t     t;
   def_s     s;
   void     *context;

   NOT_USED (author)
   NOT_USED (needses)

   /*Emit the CONST declarations.*/
   context = 0;
   while (TRUE)
   {
      if ((error = lookup_enumerate (consts, &cnst, (void **) &c, &context))
            != NULL)
         goto finish;

      if (context == 0) break;

      if ((rc = fprintf
            (  file,
               "%%%s\n"
               "Defined in:   Hdr.%s\n"
               "Symbol for a constant value\n\n",
               cnst, title)) < 0)
         goto finish;
   }

   /*Emit the TYPE declarations.*/
   context = 0;
   while (TRUE)
   {
      if ((error = lookup_enumerate (types, &type, (void **) &t, &context))
            != NULL)
         goto finish;

      if (context == 0) break;

      if ((rc = fprintf (file,
            "%%%s\n"
            "Defined in:   Hdr.%s.h\n"
            "Symbol for the size of a data structure\n\n",
            type, title)) < 0)
         goto finish;
   }

   /*Emit the SWI declarations.*/
   context = 0;
   while (TRUE)
   {
      if ((error = lookup_enumerate (swis, &swi, (void **) &s, &context)) !=
            NULL)
         goto finish;

      if (context == 0) break;

      if (s->starred_swi)
      {
         if ((rc = fprintf (file,
               "%%%s\n"
               "Defined in:   Hdr.%s\n"
               "Symbol for a SWI number\n\n",
               swi, title)) < 0)
            goto finish;
      }
      else
      {
         if ((rc = fprintf (file,
               "%%%s\n"
               "Defined in:   Hdr.%s\n"
               "Symbol for a SWI reason code\n\n",
               swi, title)) < 0)
            goto finish;
   }  }

finish:
124
   if (rc < 0) error = (os_error*)_kernel_last_oserror ();              /* TV 980115 */
125 126
   return error;
}