PLplot  5.15.0
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__
Definition: pdf.h:61
PLDLLIMPEXP int pdf_wr_2bytes(PDFstrm *pdfs, U_SHORT s)
Definition: pdfutils.c:684
const char header[]
Definition: deltaT-gen.c:41
PLDLLIMPEXP int pdf_wr_4bytes(PDFstrm *pdfs, U_LONG s)
Definition: pdfutils.c:804
const char * typeName
Definition: pdf.h:68
const char * fileHandle
Definition: pdf.h:66
PLDLLIMPEXP int pdf_wr_header(PDFstrm *pdfs, const char *header)
Definition: pdfutils.c:509
Definition: pdf.h:49
PLDLLIMPEXP int pdf_wr_1byte(PDFstrm *pdfs, U_CHAR s)
Definition: pdfutils.c:636
PLDLLIMPEXP int pdf_rd_4bytes(PDFstrm *pdfs, U_LONG *ps)
Definition: pdfutils.c:832
int fd
Definition: pdf.h:63
PLDLLIMPEXP PDFstrm * pdf_fopen(const char *fileName, const char *mode)
Definition: pdfutils.c:74
const char * fileName
Definition: pdf.h:65
FILE * file
Definition: pdf.h:64
PLDLLIMPEXP int pdf_rd_ieeef(PDFstrm *pdfs, float *pf)
Definition: pdfutils.c:992
#define U_SHORT
Definition: pdf.h:30
int PLINT
Definition: plplot.h:181
PLDLLIMPEXP int pdf_close(PDFstrm *pdfs)
Definition: pdfutils.c:238
size_t bufmax
Definition: pdf.h:56
int pdf_rd_string(PDFstrm *pdfs, char *string, int nmax)
Definition: pdfutils.c:604
static const char * fileName
Definition: tkMain.c:134
PLDLLIMPEXP int pdf_ungetc(int c, PDFstrm *pdfs)
Definition: pdfutils.c:365
#define U_LONG
Definition: pdf.h:38
static PLINT * buffer
Definition: plfill.c:74
int pdf_wr_string(PDFstrm *pdfs, const char *string)
Definition: pdfutils.c:574
int pdf_rdx(U_CHAR *x, long nitems, PDFstrm *pdfs)
Definition: pdfutils.c:464
PDFstrm * plLibOpenPdfstrm(const char *fn)
Definition: plctrl.c:2263
static PLFLT value(double n1, double n2, double hue)
Definition: plctrl.c:1219
PLDLLIMPEXP int pdf_rd_1byte(PDFstrm *pdfs, U_CHAR *ps)
Definition: pdfutils.c:660
FILE * file
Definition: pdf.h:51
PLDLLIMPEXP int pdf_rd_header(PDFstrm *pdfs, char *header)
Definition: pdfutils.c:542
PLDLLIMPEXP int pdf_rd_2nbytes(PDFstrm *pdfs, U_SHORT *s, PLINT n)
Definition: pdfutils.c:771
PLDLLIMPEXP PDFstrm * pdf_finit(FILE *file)
Definition: pdfutils.c:204
PLDLLIMPEXP int pdf_wr_ieeef(PDFstrm *pdfs, float f)
Definition: pdfutils.c:916
PLDLLIMPEXP PDFstrm * pdf_bopen(U_CHAR *buffer, size_t bufmax)
Definition: pdfutils.c:152
int type
Definition: pdf.h:67
int pdf_putc(int c, PDFstrm *pdfs)
Definition: pdfutils.c:276
#define PLDLLIMPEXP
Definition: pldll.h:49
PLDLLIMPEXP int pdf_getc(PDFstrm *pdfs)
Definition: pdfutils.c:325
PLDLLIMPEXP int pdf_wr_2nbytes(PDFstrm *pdfs, U_SHORT *s, PLINT n)
Definition: pdfutils.c:741
PLDLLIMPEXP int pdf_rd_2bytes(PDFstrm *pdfs, U_SHORT *ps)
Definition: pdfutils.c:710
unsigned char * buffer
Definition: pdf.h:52
#define U_CHAR
Definition: pdf.h:26
void pdf_set(char *option, int value)
Definition: pdfutils.c:56