PLplot  5.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pdf.h
Go to the documentation of this file.
1 // Copyright (C) 1992 by Maurice J. LeBrun
2 //
3 // Macros and prototypes for the PDF package.
4 //
5 // This software may be freely copied, modified and redistributed without
6 // fee provided that this copyright notice is preserved intact on all
7 // copies and modified copies.
8 //
9 // There is no warranty or other guarantee of fitness of this software.
10 // It is provided solely "as is". The author(s) disclaim(s) all
11 // responsibility and liability with respect to this software's usage or
12 // its effect upon hardware or computer systems.
13 //
14 
15 #ifndef __PDF_H__
16 #define __PDF_H__
17 
18 //--------------------------------------------------------------------------
19 // dll functions
20 //--------------------------------------------------------------------------
21 #include "pldll.h"
22 
23 // Some unsigned types
24 
25 #ifndef U_CHAR
26 #define U_CHAR unsigned char
27 #endif
28 
29 #ifndef U_SHORT
30 #define U_SHORT unsigned short
31 #endif
32 
33 #ifndef U_INT
34 #define U_INT unsigned int
35 #endif
36 
37 #ifndef U_LONG
38 #define U_LONG unsigned long
39 #endif
40 
41 #ifdef PLPLOT_USE_TCL_CHANNELS
42 #include <tcl.h>
43 #endif
44 
45 // PDFstrm definition
46 // The low level PDF i/o routines use the transfer method appropriate for
47 // the first non-null type below
48 
49 typedef struct
50 {
51  FILE *file; // Filesystem
52  unsigned char *buffer; // Memory buffer
53 #ifdef PLPLOT_USE_TCL_CHANNELS
54  Tcl_Channel tclChan; // Tcl channel
55 #endif
56  size_t bp, bufmax; // Buffer pointer and max size
57 } PDFstrm;
58 
59 // Info for the i/o device. Only used by Tcl/TK/dp drivers for now
60 
61 typedef struct
62 {
63  int fd; // I/O device file descriptor
64  FILE *file; // File handle
65  const char *fileName; // Fifo or socket name (if needed)
66  const char *fileHandle; // Handle for use from interpreter
67  int type; // Communication channel type
68  const char *typeName; // As above, but in string form
69 } PLiodev;
70 
71 // Error numbers
72 
73 #define PDF_ERROR 1 // Unknown error
74 #define PDF_FNOPEN 2 // File not open
75 #define PDF_FAOPEN 3 // File already open
76 #define PDF_BADUN 4 // Bad unit number
77 #define PDF_BADNBITS 5 // Invalid # of bits
78 #define PDF_RDERR 6 // Read error
79 #define PDF_WRERR 7 // Write error
80 #define PDF_NOTPDF 8 // Not a valid PDF file
81 
82 // Prototypes
83 // Use a wrapper for the prototypes for use from K&R C
84 
85 void pdf_set( char *option, int value );
86 PLDLLIMPEXP PDFstrm *pdf_fopen( const char *fileName, const char *mode );
87 PLDLLIMPEXP PDFstrm *pdf_bopen( U_CHAR * buffer, size_t bufmax );
88 PLDLLIMPEXP PDFstrm *pdf_finit( FILE * file );
89 PDFstrm *plLibOpenPdfstrm( const char * fn );
90 PLDLLIMPEXP int pdf_close( PDFstrm * pdfs );
91 
92 int pdf_putc( int c, PDFstrm * pdfs );
93 PLDLLIMPEXP int pdf_getc( PDFstrm * pdfs );
94 PLDLLIMPEXP int pdf_ungetc( int c, PDFstrm * pdfs );
95 int pdf_rdx( U_CHAR * x, long nitems, PDFstrm * pdfs );
96 
97 PLDLLIMPEXP int pdf_rd_header( PDFstrm * pdfs, char *header );
98 PLDLLIMPEXP int pdf_wr_header( PDFstrm * pdfs, const char *header );
99 int pdf_wr_string( PDFstrm * pdfs, const char *string );
100 int pdf_rd_string( PDFstrm * pdfs, char *string, int nmax );
101 PLDLLIMPEXP int pdf_wr_1byte( PDFstrm * pdfs, U_CHAR s );
102 PLDLLIMPEXP int pdf_rd_1byte( PDFstrm * pdfs, U_CHAR * ps );
103 PLDLLIMPEXP int pdf_wr_2bytes( PDFstrm * pdfs, U_SHORT s );
104 PLDLLIMPEXP int pdf_rd_2bytes( PDFstrm * pdfs, U_SHORT * ps );
105 PLDLLIMPEXP int pdf_wr_2nbytes( PDFstrm * pdfs, U_SHORT * s, PLINT n );
106 PLDLLIMPEXP int pdf_rd_2nbytes( PDFstrm * pdfs, U_SHORT * s, PLINT n );
107 PLDLLIMPEXP int pdf_wr_4bytes( PDFstrm * pdfs, U_LONG s );
108 PLDLLIMPEXP int pdf_rd_4bytes( PDFstrm * pdfs, U_LONG * ps );
109 PLDLLIMPEXP int pdf_wr_ieeef( PDFstrm * pdfs, float f );
110 PLDLLIMPEXP int pdf_rd_ieeef( PDFstrm * pdfs, float *pf );
111 
112 #endif // __PDF_H__