home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / drdobbs / 1987 / 12 / naro / printloc.c < prev    next >
Text File  |  1987-12-21  |  7KB  |  74 lines

  1. #include <stdio.h>                                                                           
  2. #include <stdlib.h>                                                                          
  3. #include <string.h>                                                                          
  4. #include <time.h>                                                                            
  5.                                                                                              
  6. #include "loc.h"                                                                             
  7. #include "externs.h"                                                                         
  8.                                                                                              
  9.                                                                                              
  10. int   print_statistics(map_filename, stat_filename, command_line, \                          
  11.       exename, output_file, configname, entry_point)                                         
  12. char  *map_filename ;                                                                        
  13. char  *stat_filename ;                                                                       
  14. char  *command_line ;                                                                        
  15. char  *exename ;                                                                             
  16. char  *output_file ;                                                                         
  17. char  *configname ;                                                                          
  18. unsigned char  *entry_point ;                                                                
  19. {                                                                                            
  20.    unsigned long  temp ;                                                                     
  21.    long  ltime ;                                                                             
  22.    int   i ;                                                                                 
  23.    SEG_DESCRIPTOR *p ;                                                                       
  24.    SYMBOL_LIST *q ;                                                                          
  25.                                                                                              
  26.    /*                                                                                        
  27.       This function generates the locate map file.  The locate map                           
  28.       file contains the segment information with the physical                                
  29.       segment addresses.                                                                     
  30.    */                                                                                        
  31.                                                                                              
  32.    fprintf(print_file, "MS-DOS Locate Utility Version 1.0\n\n") ;                            
  33.    fprintf(print_file, "Input File: %s\n", exename) ;                                        
  34.    fprintf(print_file, "Output File: %s\n", output_file) ;                                   
  35.    fprintf(print_file, "Configuration File: %s\n", configname) ;                             
  36.    fprintf(print_file, "Invoked by: %s\n", command_line) ;                                   
  37.                                                                                              
  38.    time(<ime) ;                                                                            
  39.    fprintf(print_file, "Date/Time: %s\n", ctime(<ime)) ;                                   
  40.                                                                                              
  41.    /* Display the located segment information */                                             
  42.    fprintf(print_file, "Segment Information\n");                                             
  43.    fprintf(print_file, "%-16s%-16s%-12s%-12s\n", "Name", "Class",                            
  44.                "Address", "Length");                                                         
  45.                                                                                              
  46.    p = seg_list ;                                                                            
  47.    while (p != NULL)   {                                                                     
  48.       temp = (unsigned long) p->pseg ;                                                       
  49.       temp = temp * 16 + p->offset ;                                                         
  50.       fprintf(print_file, "%-16s%-16s%05lXH%10.04XH\n", p->name,                             
  51.                   p->class, temp, p->len) ;                                                  
  52.       p = p->next ;                                                                          
  53.    }                                                                                         
  54.                                                                                              
  55.    /* Display the symbol information */                                                      
  56.    fprintf(print_file, "\n\nPublic Symbols\n");                                              
  57.    i = 0 ;                                                                                   
  58.    p = seg_list ;                                                                            
  59.    while (p != NULL)   {                                                                     
  60.       q = p->symbol_list ;                                                                   
  61.       while (q != NULL)   {                                                                  
  62.          fprintf(print_file, "%04X:%04X  %-16s%s", p->pseg,                                  
  63.                      q->value, q->name, i++ ? "\n" : "\t\t") ;                               
  64.          i %= 2 ;                                                                            
  65.          q = q->next ;                                                                       
  66.       }                                                                                      
  67.       p = p->next ;                                                                          
  68.    }                                                                                         
  69.                                                                                              
  70.    fprintf(print_file, "%sEntry Point - %p\n", (i == 1) ? "\n\n" : "\n",                     
  71.                entry_point) ;                                                                
  72.                                                                                              
  73.    return ;                                                                                  
  74. }