home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Multimed / Multimed.zip / chord3_6.zip / chord / common.c < prev    next >
C/C++ Source or Header  |  1995-04-25  |  3KB  |  106 lines

  1. static char SccsId[] = "@(#)common.c    3.6\t Mar. 1995";
  2. static char copyright[] = "Copyright 1991-1995 by Martin Leclerc & Mario Dorion";
  3.  
  4. #include <stdio.h>
  5. #include "chord.h"
  6.  
  7. extern char *current_file;
  8. extern char *command_name;
  9. extern char *mesg;
  10. extern int  in_chordrc;
  11. extern int  first_time_in_chordrc;
  12.  
  13. /* --------------------------------------------------------------------------------*/
  14. char *tolower_str(str)
  15. char *str;
  16. {
  17.     static char    temp_str[MAXLINE];
  18.     char    *ptr;
  19.  
  20.     strcpy(temp_str, str);
  21.     ptr=temp_str;
  22.  
  23.     while (*ptr=(char) tolower((int) *ptr)) 
  24.         ptr++;
  25.  
  26.     return(temp_str);
  27. }
  28.  
  29. /* --------------------------------------------------------------------------------*/
  30. char *toupper_str(str)
  31. char *str;
  32. {
  33.     static char    temp_str[MAXLINE];
  34.     char    *ptr;
  35.  
  36.     strcpy(temp_str, str);
  37.     ptr=temp_str;
  38.  
  39.     while (*ptr=(char) toupper((int) *ptr)) 
  40.         ptr++;
  41.  
  42.     return(temp_str);
  43. }
  44.  
  45.  
  46. /* --------------------------------------------------------------------------------*/
  47. void error(err_str)
  48. char *err_str;
  49. {
  50.     extern int n_lines;
  51.  
  52.                 fprintf(stderr, "WARNING: %s\n",err_str);
  53.                fprintf(stderr, "         in file \"%s\", line %d\n\n", current_file,n_lines+1);
  54. }
  55.  
  56. /* --------------------------------------------------------------------------------*/
  57. void error_rt(err_str)
  58. char *err_str;
  59. {
  60.     extern int n_lines;
  61.                 fprintf(stderr, "WARNING: %s defined as a run-time option\n\n",err_str);
  62. }
  63.  
  64. /* --------------------------------------------------------------------------------*/
  65. void debug(dbg_str)
  66. char *dbg_str;
  67. {
  68.     extern int debug_mode;
  69.  
  70.         if ( debug_mode )
  71.                 fprintf (stderr, "Debug: %s\n", dbg_str);
  72. }
  73.  
  74. /* --------------------------------------------------------------------------------*/
  75. void print_version()
  76. {
  77.  
  78.         char *version = VERSION;
  79.         char *patch_level = PATCH_LEVEL;
  80.         
  81.         printf ("%s version %s, patchlevel %s\n", command_name, version, patch_level);
  82. }
  83.  
  84. /* --------------------------------------------------------------------------------*/
  85. /* read the file passed as argument */
  86. void read_input_file(source, source_fd)
  87. char source[];
  88. FILE *source_fd;
  89.         {
  90.     sprintf (mesg , "start of read_input_file on [%s]", source);
  91.     debug (mesg);
  92.         current_file = source; 
  93.  
  94.         source_fd = fopen (source, "r");
  95.  
  96.         if (source_fd == NULL)
  97.                 {
  98.                 fprintf(stderr, "Unable to open \"%s\"\n", source);
  99.                 exit (1);
  100.                 }
  101.  
  102.         process_file(source_fd);
  103.         fclose(source_fd);
  104.         }
  105.  
  106.