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

  1. /* Copyright (C) 1991, 1992, 1993 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.h */
  20. /* Interface to platform-specific routines */
  21. /* Requires gsmemory.h, gstypes.h */
  22.  
  23. /*
  24.  * This file defines the interface to ***ALL*** platform-specific routines.
  25.  * The routines are implemented in a gp_*.c file specific to each platform.
  26.  * We try very hard to keep this list short!
  27.  */
  28.  
  29. /* ------ Initialization/termination ------ */
  30.  
  31. /*
  32.  * This routine is called early in the initialization.
  33.  * It should do as little as possible.  In particular, it should not
  34.  * do things like open display connections: that is the responsibility
  35.  * of the display device driver.
  36.  */
  37. void    gp_init(P0());
  38.  
  39. /*
  40.  * This routine is called just before the program exits (normally or
  41.  * abnormally).  It too should do as little as possible.
  42.  */
  43. void    gp_exit(P2(int exit_status, int code));
  44.  
  45. /* ------ Miscellaneous ------ */
  46.  
  47. /*
  48.  * Get the string corresponding to an OS error number.
  49.  * If no string is available, return NULL.  The caller may assume
  50.  * the string is allocated statically and permanently.
  51.  */
  52. const char *    gp_strerror(P1(int));
  53.  
  54. /* ------ Date and time ------ */
  55.  
  56. /*
  57.  * Read the current date (in days since Jan. 1, 1980) into pdt[0],
  58.  * and time (in milliseconds since midnight) into pdt[1].
  59.  */
  60. void    gp_get_clock(P1(long *pdt));
  61.  
  62. /* ------ Screen management ------ */
  63.  
  64. /*
  65.  * The following routines are only relevant in a single-window environment
  66.  * such as a PC; on platforms with window systems, the 'make current'
  67.  * routines do nothing.
  68.  */
  69.  
  70. #ifndef gx_device_DEFINED
  71. #  define gx_device_DEFINED
  72. typedef struct gx_device_s gx_device;
  73. #endif
  74.  
  75. /* Initialize the console. */
  76. void    gp_init_console(P0());
  77.  
  78. /* Write a string to the console. */
  79. void    gp_console_puts(P2(const char *, uint));
  80.  
  81. /* Make the console current on the screen. */
  82. int    gp_make_console_current(P1(gx_device *));
  83.  
  84. /* Make the graphics current on the screen. */
  85. int    gp_make_graphics_current(P1(gx_device *));
  86.  
  87. /*
  88.  * The following are only relevant for X Windows.
  89.  */
  90.  
  91. /* Get the environment variable that specifies the display to use. */
  92. const char *    gp_getenv_display(P0());
  93.  
  94. /* ------ Printer accessing ------ */
  95.  
  96. /*
  97.  * Open a connection to a printer.  A null file name means use the
  98.  * standard printer connected to the machine, if any.
  99.  * If possible, support "|command" for opening an output pipe.
  100.  * Return NULL if the connection could not be opened.
  101.  */
  102. FILE *    gp_open_printer(P2(char *fname, int binary_mode));
  103.  
  104. /* Close the connection to the printer. */
  105. void    gp_close_printer(P2(FILE *pfile, const char *fname));
  106.  
  107. /* ------ File names ------ */
  108.  
  109. /* Define the character used for separating file names in a list. */
  110. extern const char gp_file_name_list_separator;
  111.  
  112. /* Define the default scratch file name prefix. */
  113. extern const char gp_scratch_file_name_prefix[];
  114.  
  115. /* Define the name of the null output file. */
  116. extern const char gp_null_file_name[];
  117.  
  118. /* Define the name that designates the current directory. */
  119. extern const char gp_current_directory_name[];
  120.  
  121. /* Define the string to be concatenated with the file mode */
  122. /* for opening files without end-of-line conversion. */
  123. /* This is always either "" or "b". */
  124. extern const char gp_fmode_binary_suffix[];
  125. /* Define the file modes for binary reading or writing. */
  126. /* (This is just a convenience: they are "r" or "w" + the suffix.) */
  127. extern const char gp_fmode_rb[];
  128. extern const char gp_fmode_wb[];
  129.  
  130. /* Create and open a scratch file with a given name prefix. */
  131. /* Write the actual file name at fname. */
  132. FILE *    gp_open_scratch_file(P3(const char *prefix, char *fname,
  133.                 const char *mode));
  134.  
  135. /* Answer whether a file name contains a directory/device specification, */
  136. /* i.e. is absolute (not directory- or device-relative). */
  137. bool    gp_file_name_is_absolute(P2(const char *fname, uint len));
  138.  
  139. /* Answer the string to be used for combining a directory/device prefix */
  140. /* with a base file name.  The file name is known to not be absolute. */
  141. const char *
  142.     gp_file_name_concat_string(P4(const char *prefix, uint plen,
  143.                       const char *fname, uint len));
  144.  
  145. /* ------ File enumeration ------ */
  146.  
  147. #ifndef file_enum_DEFINED        /* also defined in iodev.h */
  148. #  define file_enum_DEFINED
  149. struct file_enum_s;    /* opaque to client, defined by implementor */
  150. typedef struct file_enum_s file_enum;
  151. #endif
  152.  
  153. /*
  154.  * Begin an enumeration.  pat is a C string that may contain *s or ?s.
  155.  * The implementor should copy the string to a safe place.
  156.  * If the operating system doesn't support correct, arbitrarily placed
  157.  * *s and ?s, the implementation should modify the string so that it
  158.  * will return a conservative superset of the request, and then use
  159.  * the string_match procedure to select the desired subset.  E.g., if the
  160.  * OS doesn't implement ? (single-character wild card), any consecutive
  161.  * string of ?s should be interpreted as *.  Note that \ can appear in
  162.  * the pattern also, as a quoting character.
  163.  */
  164. file_enum *    gp_enumerate_files_init(P3(const char *pat, uint patlen,
  165.                        gs_memory_t *memory));
  166.  
  167. /*
  168.  * Return the next file name in the enumeration.  The client passes in
  169.  * a scratch string and a max length.  If the name of the next file fits,
  170.  * the procedure returns the length.  If it doesn't fit, the procedure
  171.  * returns max length +1.  If there are no more files, the procedure
  172.  * returns -1.
  173.  */
  174. uint    gp_enumerate_files_next(P3(file_enum *pfen, char *ptr, uint maxlen));
  175.  
  176. /*
  177.  * Clean up a file enumeration.  This is only called to abandon
  178.  * an enumeration partway through: ...next should do it if there are
  179.  * no more files to enumerate.  This should deallocate the file_enum
  180.  * structure and any subsidiary structures, strings, buffers, etc.
  181.  */
  182. void    gp_enumerate_files_close(P1(file_enum *pfen));
  183.