home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 February / PCWK0296.iso / sharewar / dos / program / gs300sr1 / gs300sr1.exe / GP_WIN32.C < prev    next >
C/C++ Source or Header  |  1994-07-31  |  3KB  |  106 lines

  1. /* Copyright (C) 1992, 1993, 1994 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gp_win32.c */
  20. /* Common platform-specific routines for MS-Windows WIN32 */
  21. /* hacked from gp_msdos.c by Russell Lang */
  22. #include "stdio_.h"
  23. #include "string_.h"        /* for strerror */
  24. #include "dos_.h"
  25. #include "gstypes.h"
  26. #include "gsmemory.h"        /* for gp.h */
  27. #include "gp.h"
  28. #include "windows_.h"
  29.  
  30. /* ------ Miscellaneous ------ */
  31.  
  32. /* Get the string corresponding to an OS error number. */
  33. /* This is compiler-, not OS-, specific, but it is ANSI-standard and */
  34. /* all MS-DOS and MS Windows compilers support it. */
  35. const char *
  36. gp_strerror(int errnum)
  37. {    return strerror(errnum);
  38. }
  39.  
  40. /* ------ Date and time ------ */
  41.  
  42. /* Read the current date (in days since Jan. 1, 1980) */
  43. /* and time (in milliseconds since midnight). */
  44. void
  45. gp_get_clock(long *pdt)
  46. {
  47. SYSTEMTIME st;
  48. long idate;
  49. static const int mstart[12] =
  50.    { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
  51.     /* This gets UTC, not local time */
  52.     /* We have no way of knowing the time zone correction */
  53.     GetSystemTime(&st);
  54.     /* following calculation is correct until 2100 */
  55.     idate = (st.wYear - 1980) * 365 +    /* days per year */
  56.         (st.wYear - 1980) / 4 + 1 +    /* account for leap years */
  57.         mstart[st.wMonth - 1] +        /* month is 1-origin */
  58.         st.wDay - 1;            /* day of month is 1-origin */
  59.     if ( st.wMonth <= 2 && st.wYear % 4 == 0 ) /* Jan. or Feb. of leap year */
  60.         idate--;
  61.     pdt[0] = idate;    /* # days */
  62.     pdt[1] =
  63.         (st.wHour * 60 + st.wMinute ) * 60000L +
  64.         st.wSecond * 1000 + st.wMilliseconds;
  65. }
  66.  
  67. /* ------ Console management ------ */
  68.  
  69. /* Answer whether a given file is the console (input or output). */
  70. /* This is not a standard gp procedure, */
  71. /* but the MS Windows configuration needs it, */
  72. /* and other MS-DOS configurations might need it someday. */
  73. int
  74. gp_file_is_console(FILE *f)
  75. {
  76. #ifdef __DLL__
  77.     if ( f == NULL )
  78.         return 1;
  79. #else
  80.     if ( f == NULL )
  81.         return 0;
  82. #endif
  83.     if (fileno(f) <= 2)
  84.         return 1;
  85.     return 0;
  86. }
  87.  
  88. /* ------ Screen management ------ */
  89.  
  90. /* Get the environment variable that specifies the display to use. */
  91. const char *
  92. gp_getenv_display(void)
  93. {    return NULL;
  94. }
  95.  
  96. /* ------ File names ------ */
  97.  
  98. /* Define the default scratch file name prefix. */
  99. const char gp_scratch_file_name_prefix[] = "_temp_";
  100.  
  101. /* Define the name of the null output file. */
  102. const char gp_null_file_name[] = "nul";
  103.  
  104. /* Define the name that designates the current directory. */
  105. const char gp_current_directory_name[] = ".";
  106.