home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / GRAPHICS / rayshade.lzh / input.c < prev    next >
Text File  |  1990-05-08  |  2KB  |  97 lines

  1. /*
  2.  * input.c
  3.  *
  4.  * Copyright (C) 1989, Craig E. Kolb
  5.  *
  6.  * This software may be freely copied, modified, and redistributed,
  7.  * provided that this copyright notice is preserved on all copies.
  8.  *
  9.  * There is no warranty or other guarantee of fitness for this software,
  10.  * it is provided solely .  Bug reports or fixes may be sent
  11.  * to the author, who may or may not act on them as he desires.
  12.  *
  13.  * You may not include this software in a program or other software product
  14.  * without supplying the source, or without informing the end-user that the
  15.  * source is available for no extra charge.
  16.  *
  17.  * If you modify this software, you should include a notice giving the
  18.  * name of the person performing the modification, the date of modification,
  19.  * and the reason for such modification.
  20.  *
  21.  * $Id: input.c,v 3.0.1.2 89/12/07 22:53:32 craig Exp $
  22.  *
  23.  * $Log:    input.c,v $
  24.  * Revision 3.0.1.2  89/12/07  22:53:32  craig
  25.  * patch2: Added comments, lint-related goofiness.
  26.  * 
  27.  * Revision 3.0.1.1  89/12/06  16:08:43  craig
  28.  * patch2: Removed #include handling.  Added RSmessage(), RSwarning(),
  29.  * patch2: and RSerror().
  30.  * 
  31.  * Revision 3.0  89/10/27  02:05:51  craig
  32.  * Baseline for first official release.
  33.  * 
  34.  */
  35. #include <stdio.h>
  36.  
  37. char *infilename;    /* Name of input file.  NULL signifies stdin. */
  38.  
  39. /*
  40.  * Open input file and call yyparse().
  41.  */
  42. read_input_file()
  43. {
  44.     extern FILE *yyin;    /* lex/yacc file pointer */
  45.     extern char yyfilename[];
  46.  
  47.     if (infilename == (char *)NULL) {
  48.         yyin = stdin;
  49.         strcpy(yyfilename, "stdin");
  50.     } else {
  51.         yyin = fopen(infilename, "r");
  52.         if (yyin == (FILE *)NULL)
  53.             RSerror("Cannot open %s.\n",infilename);
  54.         strcpy(yyfilename, infilename);
  55.     }
  56.     yyparse();
  57. }
  58.  
  59. /*
  60.  * Print message to standard output with format:
  61.  * program_name: message_type: message
  62.  */
  63. /*VARARGS2*/
  64. RSmessage(type, str, pat1, pat2, pat3)
  65. char *type, *str, *pat1, *pat2, *pat3;
  66. {
  67.     extern char *progname;
  68.  
  69.     fprintf(stderr,"%s: %s: ",progname, type);
  70.     fprintf(stderr, str, pat1, pat2, pat3);
  71.     fflush(stderr);
  72. }
  73.  
  74. /*
  75.  * Issue warning message if not in Quiet mode.
  76.  */
  77. /*VARARGS1*/
  78. RSwarning(str, pat1, pat2, pat3)
  79. char *str, *pat1, *pat2, *pat3;
  80. {
  81.     extern int Quiet;
  82.  
  83.     if (!Quiet)
  84.         RSmessage("Warning", str, pat1, pat2, pat3);
  85. }
  86.  
  87. /*
  88.  * Issue error message and exit.
  89.  */
  90. /*VARARGS1*/
  91. RSerror(str, pat1, pat2, pat3)
  92. char *str, *pat1, *pat2, *pat3;
  93. {
  94.     RSmessage("Error", str, pat1, pat2, pat3);
  95.     exit(1);
  96. }
  97.