[BACK]Return to gnupmdrv.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gnuplot / os2

Annotation of OpenXM_contrib/gnuplot/os2/gnupmdrv.c, Revision 1.1.1.2

1.1       maekawa     1: #ifdef INCRCSDATA
1.1.1.2 ! maekawa     2: static char RCSid[]="$Id: gnupmdrv.c,v 1.2 1998/10/03 20:14:29 lhecking Exp $" ;
1.1       maekawa     3: #endif
                      4:
                      5: /****************************************************************************
                      6:
                      7:     PROGRAM: gnupmdrv
                      8:
                      9:     Outboard PM driver for GNUPLOT 3.3
                     10:
                     11:     MODULE:  gnupmdrv.c
                     12:
                     13:     This file contains the startup procedures for gnupmdrv
                     14:
                     15: ****************************************************************************/
                     16:
                     17: /* PM driver for GNUPLOT */
                     18:
                     19: /*[
                     20:  * Copyright 1992, 1993, 1998   Roger Fearick
                     21:  *
                     22:  * Permission to use, copy, and distribute this software and its
                     23:  * documentation for any purpose with or without fee is hereby granted,
                     24:  * provided that the above copyright notice appear in all copies and
                     25:  * that both that copyright notice and this permission notice appear
                     26:  * in supporting documentation.
                     27:  *
                     28:  * Permission to modify the software is granted, but not the right to
                     29:  * distribute the complete modified source code.  Modifications are to
                     30:  * be distributed as patches to the released version.  Permission to
                     31:  * distribute binaries produced by compiling modified sources is granted,
                     32:  * provided you
                     33:  *   1. distribute the corresponding source modifications from the
                     34:  *    released version in the form of a patch file along with the binaries,
                     35:  *   2. add special version identification to distinguish your version
                     36:  *    in addition to the base release version number,
                     37:  *   3. provide your name and address as the primary contact for the
                     38:  *    support of your modified version, and
                     39:  *   4. retain our contact information in regard to use of the base
                     40:  *    software.
                     41:  * Permission to distribute the released version of the source code along
                     42:  * with corresponding source modifications in the form of a patch file is
                     43:  * granted with same provisions 2 through 4 for binary distributions.
                     44:  *
                     45:  * This software is provided "as is" without express or implied warranty
                     46:  * to the extent permitted by applicable law.
                     47: ]*/
                     48:
                     49:
                     50: /*
                     51:  * AUTHOR
                     52:  *
                     53:  *   Gnuplot driver for OS/2:  Roger Fearick
                     54:  *
                     55:  * Send your comments or suggestions to
                     56:  *  info-gnuplot@dartmouth.edu.
                     57:  * This is a mailing list; to join it send a note to
                     58:  *  majordomo@dartmouth.edu.
                     59:  * Send bug reports to
                     60:  *  bug-gnuplot@dartmouth.edu.
                     61: **/
                     62:
                     63: #define INCL_PM
                     64: #define INCL_WIN
                     65: #define INCL_SPL
                     66: #define INCL_SPLDOSPRINT
                     67: #define INCL_DOSMEMMGR
                     68: #define INCL_DOSPROCESS
                     69: #define INCL_DOSFILEMGR
                     70: #include <os2.h>
                     71: #include <string.h>
                     72: #include <stdio.h>
                     73: #include <stdlib.h>
                     74: #include "gnupmdrv.h"
                     75:
                     76: /*==== g l o b a l    d a t a ================================================*/
                     77:
                     78: char szIPCName[256] ;
                     79: char szIniFile[256] ;
                     80: #define IPCDEFAULT "gnuplot"
                     81: int  bServer=0 ;
                     82: int  bPersist=0 ;
                     83: int  bWideLines=0 ;
                     84: int  bEnhanced=0 ;
                     85:
                     86: /*==== l o c a l    d a t a ==================================================*/
                     87:
                     88:             /* class names for window registration */
                     89:
                     90: static char szChildName []     = "Gnuchild" ;
                     91:
                     92: static char szTitle[256] = "Gnuplot" ;
                     93:
                     94: /*==== f u n c t i o n s =====================================================*/
                     95:
                     96: BOOL             QueryIni( HAB ) ;
                     97: int              main( int, char** ) ;
                     98: static HWND      InitHelp( HAB, HWND ) ;
                     99:
                    100: /*==== c o d e ===============================================================*/
                    101:
                    102: int main ( int argc, char **argv )
                    103: /*
                    104: ** args:  argv[1] : name to be used for IPC (pipes/semaphores) with gnuplot
                    105: **
                    106: ** Standard PM initialisation:
                    107: ** -- set up message processing loop
                    108: ** -- register all window classes
                    109: ** -- start up main window
                    110: ** -- subclass main window for help and dde message trapping to frame window
                    111: ** -- init help system
                    112: ** -- check command line and open any filename found there
                    113: **
                    114: */
                    115:     {
                    116:     static ULONG flFrameFlags = (FCF_ACCELTABLE|FCF_STANDARD);//&(~FCF_TASKLIST) ;
                    117:     static ULONG flClientFlags = WS_VISIBLE ;
                    118:     HMQ          hmq ;
                    119:     QMSG         qmsg ;
                    120:     PFNWP        pfnOldFrameWndProc ;
                    121:     HWND         hwndHelp ;
                    122:     BOOL         bPos ;
                    123:
                    124:     /* (am, 19981001)
                    125:      * A subtile problem is fixed here:
                    126:      * upon the first initialization of this driver (i.e. we're here in main())
                    127:      * it may inherit handles of files opened (temporarily) by gnuplot itself!
                    128:      * We close them here.
                    129:      */
                    130:     fcloseall();
                    131:
                    132:     if( argc <= 1 ) strcpy( szIPCName, IPCDEFAULT ) ;
                    133:     else {
                    134:         int i ;
                    135:         strcpy( szIPCName, argv[1] ) ;
                    136:         for ( i=2; i<argc; i++ ) {
                    137:                     while( *argv[i] != '\0' ) {
                    138:                 if( *argv[i] == '-' ) {
                    139:                     ++argv[i] ;
                    140:                     switch( *argv[i] ) {
                    141:                         case 's' :
                    142:                             bServer = 1 ;
                    143:                             break ;
                    144:                         case 'e' :
                    145:                             bEnhanced = 1 ;
                    146:                             break ;
                    147:                         case 'p' :
                    148:                             bPersist = 1 ;
                    149:                             break ;
                    150:                         case 'w' :
                    151:                             bWideLines = 1 ;
                    152:                             break ;
                    153:                         }
                    154:                     }
                    155:                 else if ( *argv[i] == '"' ) {
                    156:                     char *p = szTitle ;
                    157:                     argv[i]++ ;
                    158:                     while( *argv[i] != '"' ) {
                    159:                         *p++ = *argv[i]++ ;
                    160:                         }
                    161:                     *p = '\0' ;
                    162:                     }
                    163:                 argv[i]++ ;
                    164:                 }
                    165:             }
                    166:         }
                    167:     {
                    168:     char *p ;
                    169:         /* get path from argv[0] to track down program files */
                    170:     strcpy( szIniFile, argv[0] ) ;
                    171:     while( (p=strchr(szIniFile,'/'))!=NULL ) *p = '\\' ;
                    172:     p = strrchr(szIniFile,'\\') ;
                    173:     if(p==NULL) p = strrchr(szIniFile,':') ;
                    174:     if(p==NULL) p = szIniFile ;
                    175:     else ++p ;
                    176:     strcpy(p,GNUINI);
                    177:     }
                    178:
                    179:     hab = WinInitialize( 0 ) ;
                    180:     hmq = WinCreateMsgQueue( hab, 50 ) ;
                    181:
                    182:                 // get defaults from gnupmdrv.ini
                    183:
                    184:     bPos = QueryIni( hab ) ;
                    185:
                    186:                 // register window and child window classes
                    187:
                    188:     if( ! WinRegisterClass( hab,        /* Exit if can't register */
                    189:                             APP_NAME,
                    190:                             (PFNWP)DisplayClientWndProc,
                    191:                             CS_SIZEREDRAW,
                    192:                             0 )
                    193:                             ) return 0L ;
                    194:
                    195:                 // create main window
                    196:
                    197:     hwndFrame = WinCreateStdWindow (
                    198:                     HWND_DESKTOP,
                    199:                     0,//WS_VISIBLE,
                    200:                     &flFrameFlags,
                    201:                     APP_NAME,
                    202:                     NULL,
                    203:                     flClientFlags,
                    204:                     0L,
                    205:                     1,
                    206:                     &hApp) ;
                    207:
                    208:     if ( ! hwndFrame ) return 0 ;
                    209:
                    210:                 // subclass window for help & DDE trapping
                    211:
                    212:     pfnOldFrameWndProc = WinSubclassWindow( hwndFrame, (PFNWP)NewFrameWndProc ) ;
                    213:     WinSetWindowULong( hwndFrame, QWL_USER, (ULONG) pfnOldFrameWndProc ) ;
                    214:
                    215:                 // init the help manager
                    216:
                    217:     hwndHelp = InitHelp( hab, hwndFrame ) ;
                    218:
                    219:                 // set window title and make it active
                    220:
                    221:     {
                    222:     char text[256] = APP_NAME;
                    223:     strcat( text, " [" ) ;
                    224:     strcat( text, szTitle ) ;
                    225:     strcat( text, "]" ) ;
                    226:     WinSetWindowText( hwndFrame, text ) ;
                    227:     }
                    228:                 // process window messages
                    229:
                    230:     while (WinGetMsg (hab, &qmsg, NULLHANDLE, 0, 0))
                    231:          WinDispatchMsg (hab, &qmsg) ;
                    232:
                    233:                 // shut down
                    234:
                    235:     WinDestroyHelpInstance( hwndHelp ) ;
                    236:     WinDestroyWindow (hwndFrame) ;
                    237:     WinDestroyMsgQueue (hmq) ;
                    238:     WinTerminate (hab) ;
                    239:
                    240:     return 0 ;
                    241:     }
                    242:
                    243: static HWND InitHelp( HAB hab, HWND hwnd )
                    244: /*
                    245: **  initialise the help system
                    246: */
                    247:     {
                    248:     static HELPINIT helpinit = { sizeof(HELPINIT),
                    249:                                  0L,
                    250:                                  NULL,
                    251:                                  (PHELPTABLE)MAKELONG(1, 0xFFFF),
                    252:                                  0L,
                    253:                                  0L,
                    254:                                  0,
                    255:                                  0,
                    256:                                  "GnuplotPM Help",
                    257:                                  CMIC_HIDE_PANEL_ID,
                    258:                                  "gnupmdrv.hlp" } ;
                    259:     HWND hwndHelp ;
                    260:     static char helppath[256] ;
                    261:     char *p ;
                    262:     if( (p=getenv("GNUPLOT")) != NULL ) {
                    263:         strcpy( helppath, p ) ;
                    264:         strcat( helppath, "/" ) ;
                    265:         strcat( helppath, helpinit.pszHelpLibraryName ) ;
                    266:         helpinit.pszHelpLibraryName = helppath ;
                    267:         }
                    268:     hwndHelp = WinCreateHelpInstance( hab, &helpinit ) ;
                    269:     WinAssociateHelpInstance( hwndHelp, hwnd ) ;
                    270:     return hwndHelp ;
                    271:     }
                    272:
                    273: MRESULT EXPENTRY NewFrameWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
                    274: /*
                    275: **  Subclasses top-level frame window to trap help & dde messages
                    276: */
                    277:     {
                    278:     PFNWP       pfnOldFrameWndProc ;
                    279:
                    280:     pfnOldFrameWndProc = (PFNWP) WinQueryWindowULong( hwnd, QWL_USER ) ;
                    281:     switch( msg ) {
                    282:         default:
                    283:             break ;
                    284:
                    285:         case HM_QUERY_KEYS_HELP:
                    286:             return (MRESULT) IDH_KEYS ;
                    287:         }
                    288:     return (*pfnOldFrameWndProc)(hwnd, msg, mp1, mp2) ;
                    289:     }
                    290:
                    291:
                    292: MRESULT EXPENTRY About( HWND hDlg, ULONG message, MPARAM mp1, MPARAM mp2)
                    293: /*
                    294: ** 'About' box dialog function
                    295: */
                    296:     {
                    297:     return WinDefDlgProc( hDlg, message, mp1, mp2 ) ;
                    298:     }
                    299:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>