home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 May / cica_0595_4.zip / cica_0595_4 / UTIL / GPT34SRC / WIN / WGNUPLIB.C < prev    next >
C/C++ Source or Header  |  1993-05-11  |  3KB  |  141 lines

  1. #ifndef lint
  2. static char *RCSid = "$Id: wgnuplib.c%v 3.38.2.74 1993/02/19 01:19:51 woo Exp woo $";
  3. #endif
  4.  
  5. /* GNUPLOT - win/wgnuplib.c */
  6. /*
  7.  * Copyright (C) 1992   Russell Lang
  8.  *
  9.  * Permission to use, copy, and distribute this software and its
  10.  * documentation for any purpose with or without fee is hereby granted, 
  11.  * provided that the above copyright notice appear in all copies and 
  12.  * that both that copyright notice and this permission notice appear 
  13.  * in supporting documentation.
  14.  *
  15.  * Permission to modify the software is granted, but not the right to
  16.  * distribute the modified code.  Modifications are to be distributed 
  17.  * as patches to released version.
  18.  *  
  19.  * This software is provided "as is" without express or implied warranty.
  20.  * 
  21.  *
  22.  * AUTHORS
  23.  * 
  24.  *   Russell Lang
  25.  * 
  26.  * Send your comments or suggestions to 
  27.  *  info-gnuplot@dartmouth.edu.
  28.  * This is a mailing list; to join it send a note to 
  29.  *  info-gnuplot-request@dartmouth.edu.  
  30.  * Send bug reports to
  31.  *  bug-gnuplot@dartmouth.edu.
  32.  */
  33.  
  34. #define STRICT
  35. #include <windows.h>
  36. #include <windowsx.h>
  37. #include <ctype.h>
  38. #include "wgnuplib.h"
  39. #include "wresourc.h"
  40. #include "wcommon.h"
  41.  
  42. HINSTANCE hdllInstance;
  43. LPSTR szParentClass = "wgnuplot_parent";
  44. LPSTR szTextClass = "wgnuplot_text";
  45. LPSTR szPauseClass = "wgnuplot_pause";
  46. LPSTR szGraphClass = "wgnuplot_graph";
  47.  
  48. /* Window ID */
  49. struct WID {
  50.     BOOL       used;
  51.     HWND       hwnd;
  52.     void FAR * ptr;
  53. };
  54. struct WID *widptr = NULL;
  55. unsigned int nwid = 0;
  56. HLOCAL hwid = 0;
  57.  
  58. #ifdef __DLL__
  59. int WDPROC
  60. LibMain(HINSTANCE hInstance, WORD wDataSeg, WORD wHeapSize, LPSTR lpszCmdLine)
  61. {
  62.     hdllInstance = hInstance;
  63.     return 1;
  64. }
  65.  
  66. int WDPROC
  67. WEP(int nParam)
  68. {
  69.     return 1;
  70. }
  71.  
  72. BOOL WDPROC
  73. CheckWGNUPLOTVersion(LPSTR str)
  74. {
  75. char mess[256];
  76. LPSTR version;
  77.     version = WGNUPLOTVERSION;
  78.     if (lstrcmp(str,version)) {
  79.         wsprintf(mess,"Incorrect DLL version\nExpected version   %s\nThis is version   %s",str,version);
  80.         MessageBox(NULL, mess , "WGNUPLOT.DLL", MB_OK | MB_ICONSTOP | MB_TASKMODAL);
  81.         return TRUE;
  82.     }
  83.     return FALSE;    /* Correct version */
  84. }
  85. #endif /* __DLL__ */
  86.  
  87. void NEAR *
  88. LocalAllocPtr(UINT flags, UINT size)
  89. {
  90. HLOCAL hlocal;
  91.     hlocal = LocalAlloc(flags, size+1);
  92.     return (char *)LocalLock(hlocal);
  93. }
  94.  
  95. void
  96. LocalFreePtr(void NEAR *ptr)
  97. {
  98. HLOCAL hlocal;
  99.     hlocal = LocalHandle(ptr);
  100.     LocalUnlock(hlocal);
  101.     LocalFree(hlocal);
  102.     return;
  103. }
  104.  
  105.  
  106. /* ascii to int */
  107. /* returns:
  108.  *  A pointer to character past int if successful,
  109.  *  otherwise NULL on failure.
  110.  *  convert int is stored at pval.
  111.  */
  112. LPSTR
  113. GetInt(LPSTR str, LPINT pval)
  114. {
  115. int val = 0;
  116. BOOL negative = FALSE;
  117. BOOL success = FALSE;
  118. int ch;
  119.     if (!str)
  120.         return NULL;
  121.     while ( (ch = *str)!=0 && isspace(ch) )
  122.         str++;
  123.     if (ch == '-') {
  124.         negative = TRUE;
  125.         str++;
  126.     }
  127.     while ( (ch = *str)!=0 && isdigit(ch) ) {
  128.         success = TRUE;
  129.         val = val * 10 + (ch - '0');
  130.         str++;
  131.     }
  132.     if (success) {
  133.         if (negative)
  134.             val = -val;
  135.         *pval = val;
  136.         return str;
  137.     }
  138.     return NULL;
  139. }
  140.  
  141.