home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OBJASM.ZIP / OREXTDEF.C < prev    next >
Text File  |  1990-09-28  |  2KB  |  70 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "o.h"
  4.  
  5. int ext_compare( EXT_T *, EXT_T * );
  6.  
  7. int ext_compare( rec_1, rec_2 )
  8.     EXT_T  *rec_1;
  9.     EXT_T  *rec_2;
  10. {
  11.     if ( rec_1->index > rec_2->index ) {
  12.         return( LEFT );
  13.     } else {
  14.         if ( rec_1->index < rec_2->index ) {
  15.             return( RIGHT );
  16.         } else {
  17.             return( EQUAL );
  18.         }
  19.     }
  20. }
  21.  
  22. void ext_insert( this_name, com_ext, var_type, count, size, scope )
  23.     char            *this_name;
  24.     int             com_ext;
  25.     int             var_type;
  26.     unsigned long   count;
  27.     unsigned int    size;
  28.     int             scope;
  29. {
  30.     static  extern_count = 0;
  31.     EXT_T   *extern_rec;
  32.  
  33.     extern_count++;
  34.     extern_rec = (EXT_T *)o_malloc( sizeof(EXT_T) );
  35.     extern_rec->index    = extern_count;
  36.     extern_rec->type     = size_to_type(size);
  37.     extern_rec->pos_abs  = TRUE;
  38.     extern_rec->size     = count;
  39.     extern_rec->com_ext  = com_ext;
  40.     extern_rec->var_type = var_type;
  41.     extern_rec->used     = 0;                   /* Default to never used */
  42.     extern_rec->scope    = scope;
  43.     strcpy( extern_rec->name, this_name );
  44.  
  45.     insert( (char *)extern_rec, extern_tree, ext_compare );
  46. }
  47.  
  48. void extdef( length, scope )
  49.     unsigned int length;
  50.     int          scope;
  51. {
  52.     char    name[41];
  53.     int     typ_idx;
  54.     char    cksum;
  55.  
  56.     --length;
  57.     while( length ) {
  58.         length -= get_name( name );
  59.         length -= get_index( &typ_idx );
  60.  
  61. #ifdef DEBUG
  62. printf("%s\n", name );
  63. #endif
  64.  
  65.         ext_insert( name, 0, 0, 0L, 0, scope );
  66.     }
  67.     cksum = get_byte();
  68. }
  69. 
  70.