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

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "o.h"
  4.  
  5. int struc_compare( STRUC_T *, STRUC_T * );
  6.  
  7. int struc_compare( rec_1, rec_2 )
  8.     STRUC_T *rec_1;
  9.     STRUC_T *rec_2;
  10. {
  11.     int     result;
  12.  
  13.     result = strcmp(rec_1->form, rec_2->form);
  14.  
  15.     if ( result == 1 ) {
  16.         result = LEFT;
  17.     } else {
  18.         if ( result == 0 ) {
  19.             return( EQUAL );
  20.         } else {
  21.             return( RIGHT );
  22.         }
  23.     }
  24. }
  25.  
  26. STRUC_T *struc_insert( form )
  27.     char    *form;
  28. {
  29.     STRUC_T *struc_rec;
  30.     NODE_T  *struc_node;
  31.     char    *form_copy;
  32.     int     length;
  33.  
  34.     struc_rec = (STRUC_T *)o_malloc( sizeof(STRUC_T) );
  35.     length = strlen(form) + 1;
  36.     form_copy = (char *)o_malloc( length );
  37.     strcpy( form_copy, form );
  38.     struc_rec->form  = form_copy;
  39.     struc_rec->index = 0;               /* Not determined yet */
  40.  
  41.     struc_node = insert( (char *)struc_rec, struc_tree, struc_compare );
  42.     return( (STRUC_T *)struc_node->data );
  43. }
  44.