home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / MAWK113.ZIP / mawk_os2.zip / mawk113 / main.c < prev    next >
C/C++ Source or Header  |  1993-04-24  |  1KB  |  71 lines

  1.  
  2. /********************************************
  3. main.c
  4. copyright 1991, Michael D. Brennan
  5.  
  6. This is a source file for mawk, an implementation of
  7. the AWK programming language.
  8.  
  9. Mawk is distributed without warranty under the terms of
  10. the GNU General Public License, version 2, 1991.
  11. ********************************************/
  12.  
  13. /* $Log: main.c,v $
  14.  * Revision 5.2.1.1  1993/01/15  03:33:44  mike
  15.  * patch3: safer double to int conversion
  16.  *
  17.  * Revision 5.2  1992/12/17  02:48:01  mike
  18.  * 1.1.2d changes for DOS
  19.  *
  20.  * Revision 5.1  1991/12/05  07:56:14  brennan
  21.  * 1.1 pre-release
  22.  *
  23. */
  24.  
  25.  
  26.  
  27. /*  main.c  */
  28.  
  29. #include "mawk.h"
  30. #include "code.h"
  31. #include "init.h"
  32. #include "fin.h"
  33. #include "bi_vars.h"
  34. #include "field.h"
  35. #include "files.h"
  36. #include <stdio.h>
  37.  
  38.  
  39. short mawk_state ; /* 0 is compiling */
  40. int  exit_code ;
  41.  
  42. int
  43. main(argc , argv )
  44.   int argc ; char **argv ;
  45.   _wildcard( &argc, &argv );  /* shell does no wildcard expansion */
  46.   initialize(argc, argv) ;
  47.  
  48.   if ( parse() || compile_error_count )  mawk_exit(1) ;
  49.  
  50.   compile_cleanup() ;
  51.   mawk_state = EXECUTION ;
  52.   execute(code_ptr, eval_stack-1, 0) ;
  53.   /* never returns */
  54.   return 0 ;
  55. }
  56.  
  57. void  mawk_exit(x)
  58.   int x ;
  59. {
  60. #if  HAVE_REAL_PIPES
  61.   close_out_pipes() ;  /* no effect, if no out pipes */
  62. #else
  63. #if  HAVE_FAKE_PIPES
  64.   close_fake_pipes() ;
  65. #endif
  66. #endif
  67.  
  68.   exit(x) ;
  69. }
  70.