home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OBJASM.ZIP / ORPUBDEF.C < prev    next >
C/C++ Source or Header  |  1990-11-03  |  2KB  |  85 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "o.h"
  4.  
  5. int pub_compare( PUB_T *, PUB_T * );
  6.  
  7. int pub_compare( rec_1, rec_2 )
  8.     PUB_T  *rec_1;
  9.     PUB_T  *rec_2;
  10. {
  11.     if ( rec_1->seg_idx > rec_2->seg_idx ) {
  12.         return( LEFT );
  13.     } else {
  14.         if ( rec_1->seg_idx < rec_2->seg_idx ) {
  15.             return( RIGHT );
  16.         } else {
  17.             if ( rec_1->offset > rec_2->offset ) {
  18.                 return( LEFT );
  19.             } else {
  20.                 if ( rec_1->offset < rec_2->offset ) {
  21.                     return( RIGHT );
  22.                 } else {
  23.                     return( EQUAL );
  24.                 }
  25.             }
  26.         }
  27.     }
  28. }
  29.  
  30. NODE_T *pub_insert( seg_idx, offset, this_name, domain, scope )
  31.     int             seg_idx;
  32.     unsigned long   offset;
  33.     char            *this_name;
  34.     int             domain;
  35.     int             scope;
  36. {
  37.     PUB_T   *public_rec;
  38.  
  39.     public_rec = (PUB_T *)o_malloc( sizeof(PUB_T) );
  40.     public_rec->seg_idx   = seg_idx;
  41.     public_rec->offset    = offset;
  42.     public_rec->type      = UNKNOWN;                /* Default to UNKNOWN */
  43.     public_rec->domain    = domain;
  44.     public_rec->scope     = scope;
  45.     public_rec->structure = NULL;
  46.     strcpy( public_rec->name, this_name );
  47.  
  48.     return ( insert( (char *)public_rec, public_tree, pub_compare ) );
  49. }
  50.  
  51. void pubdef( length, scope )
  52.     unsigned int    length;
  53.     int             scope;
  54. {
  55.     int             grp_idx;
  56.     int             seg_idx;
  57.     int             frame;
  58.     int             typ_idx;
  59.     unsigned long   offset;
  60.     char            pub_name[41];
  61.  
  62.     length -= get_index( &grp_idx );
  63.     length -= get_index( &seg_idx );
  64.  
  65.     if ( seg_idx == 0 ) {
  66.         frame = get_word();
  67.         length -= 2;
  68.     }
  69.  
  70.     --length;
  71.     while ( length ) {
  72.         length -= get_name( pub_name );
  73.  
  74. #ifdef DEBUG
  75. printf("%s\n", pub_name );
  76. #endif
  77.  
  78.         offset = (unsigned long)get_word();
  79.  
  80.         pub_insert( seg_idx, offset, pub_name, PUBLIC, scope );
  81.         length -= 2;
  82.         length -= get_index( &typ_idx );
  83.     }
  84. }
  85.