home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fonts 1 / freshfonts1.bin / bbs / programs / amiga / pastex13.lha / DVIPS / dvips5519.lha / dvips / pc / winmain.c < prev   
C/C++ Source or Header  |  1992-11-15  |  2KB  |  90 lines

  1. /*
  2.  * dvips - winmain.c
  3.  *   This module is Copyright 1992 by Russell Lang and Maurice Castro.
  4.  *   This file may be freely copied and modified.
  5.  */
  6.  
  7. #include <windows.h>
  8. #include <dos.h>
  9. #include <stdio.h>
  10. #include <string.h>
  11.  
  12. /* local */
  13. #define MAXSTR 255
  14. HWND FAR hwndeasy;
  15. static char FAR szAppName[] = "dvips";
  16. char winline[MAXSTR];    /* command line for MS-Windows */
  17. int wargc;        /* argc for windows */
  18. char *wargv[32];    /* argv for windows */
  19.  
  20. /* external */
  21. extern void help();     /* in dvips.c */
  22. extern void error();    /* in dvips.c */
  23.  
  24. /* EasyWin */
  25. extern POINT _ScreenSize;
  26.  
  27. int main(int argc, char *argv[], char *env[]);
  28.  
  29. /* A fake system() for Microsoft Windows */
  30. int
  31. system(command)
  32. char *command;
  33. {
  34. char str[MAXSTR];
  35.    strcpy(str,"Windows can't do system(\042");
  36.    if (command) {
  37.      strncat(str,command,MAXSTR-strlen(str));
  38.    }
  39.    strncat(str,"\042);",MAXSTR-strlen(str));
  40.    error(str);
  41.    return(1);  /* error */
  42. }
  43.  
  44. /* Get a new command line */
  45. void
  46. winargs()
  47. {
  48.    fputs("Options: ",stdout);
  49.    fgets(winline,MAXSTR,stdin);
  50.    wargc=1;
  51.    if ( (wargv[1] = strtok(winline," \n")) != (char *)NULL ) {
  52.       wargc=2;
  53.       while ( ((wargv[wargc] = strtok((char *)NULL," \n")) != (char *)NULL)
  54.             && (wargc < 31) )
  55.          wargc++;
  56.    }
  57.    wargv[wargc] = (char *)NULL;
  58. }
  59.  
  60. int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance,
  61.         LPSTR lpszCmdLine, int cmdShow)
  62. {
  63.     char modulename[MAXSTR];
  64.  
  65.         /* start up the text window */
  66.     _ScreenSize.y = 50;
  67.     _InitEasyWin();
  68.  
  69.     /* fix up the EasyWindows window provided by Borland */
  70.     GetModuleFileName(hInstance, (LPSTR) modulename, MAXSTR);
  71.     hwndeasy = FindWindow("BCEasyWin", modulename);
  72.     SetWindowText(hwndeasy, szAppName);            /* change title */
  73.     SetClassWord(hwndeasy, GCW_HICON, LoadIcon(hInstance, "RadicalEye")); /* change icon */
  74.  
  75.     if (_argc==1) {
  76.         /* get new command line if no options or filenames */
  77.         help();
  78.         winargs();
  79.         wargv[0] = _argv[0];
  80.         _argc=wargc;
  81.         _argv=wargv;
  82.     }
  83.  
  84.     main(_argc, _argv, environ);
  85.     /* unfortunately dvips doesn't return from main(), it exits */
  86.     /* so the following code is never executed */
  87.     DestroyWindow(hwndeasy);
  88.     return 0;
  89. }
  90.