1 /****************************************************************************** 2 File: $Id: pclscan.h,v 1.6 2000-10-22 11:05:34+02 Martin Rel $ 3 Contents: Header for PCL scanner 4 Author: Martin Lottermoser, Greifswaldstrasse 28, 38124 Braunschweig, 5 Germany, e-mail: Martin.Lottermoser@t-online.de 6 7 ******************************************************************************* 8 * * 9 * Copyright (C) 1999, 2000 by Martin Lottermoser * 10 * All rights reserved * 11 * * 12 ******************************************************************************/ 13 14 #ifndef _pclscan_h /* Inclusion protection */ 15 #define _pclscan_h 16 17 /* Configuration management identification */ 18 #ifdef __GNUC__ 19 #ident "@(#)$Id: pclscan.h,v 1.6 2000-10-22 11:05:34+02 Martin Rel $" 20 #else 21 #pragma ident "@(#)$Id: pclscan.h,v 1.6 2000-10-22 11:05:34+02 Martin Rel $" 22 #endif 23 24 /*****************************************************************************/ 25 26 /* Standard headers */ 27 #include <stdio.h> 28 29 /*****************************************************************************/ 30 31 /* Macro to convert a termination character into a parameter character. 32 It should only be applied to arguments in the range 64-94. 33 */ 34 #define pcl_to_parameter_character(c) ((c) + ('a' - 'A')) 35 36 /*****************************************************************************/ 37 38 #ifndef _pcl_Octet_defined 39 #define _pcl_Octet_defined 40 typedef unsigned char pcl_Octet; 41 #endif 42 43 typedef struct { 44 unsigned short kind; 45 /* The value can be in the range 1-6: 46 1: control code. chars[0] is this code and 'i' gives the number of its 47 occurrences (positive). 48 2: two-character escape sequence. chars[0] is the second character, the 49 first was ESC. 50 3: parameterized escape sequence. chars[0] is the parameterized 51 character, chars[1] is the group character, and chars[2] is the 52 termination character. 53 4: same as 3, except that the sequence is not terminated. In this case 54 chars[2] is the octet which would be used as the termination 55 character, not the octet actually read from the input stream 56 (parameter character). pcl_to_parameter_character() can be used to 57 obtain the latter. 58 5: same as 3, except that this is a part of a combined escape sequence 59 started earlier. 60 6: same as 4, except that this is a part of a combined escape sequence 61 started earlier. 62 */ 63 pcl_Octet chars[3]; 64 pcl_Octet prefix; 65 /* This can be one of: 66 '\0': no value given 67 ' ': value given without a sign 68 '+': value given with prefix "+" 69 '-': value given with prefix "-" 70 */ 71 int i; /* integer part of the value (including the sign) */ 72 unsigned int scale; 73 /* This can be zero or any power of ten. A value of zero means that the 74 value was given without a decimal point, a value of one that there were 75 no digits after the point. */ 76 int fraction; 77 /* fractional part of the value (including the sign). The entire value is 78 i + ((float)fraction)/scale, provided 'scale' is non-zero. */ 79 } pcl_Command; 80 81 /* 82 A negative return code indicates an error which will terminate scanning. 83 A return code of zero indicates success. 84 A positive return code indicates that the interpreter or handler does not know 85 the command or the data and that the scanner should handle the case. */ 86 typedef int (*pcl_CommandInterpreter)(FILE *in, const pcl_Command *cmd, 87 void *idata); 88 typedef int (*pcl_UnknownDataHandler)(FILE *in, void *hdata); 89 /* A handler for unknown data should never read over an ESC character which 90 might start a printer command. */ 91 92 extern int pcl_is_control_code(int c); 93 extern int pcl_scan(FILE *in, pcl_CommandInterpreter interpreter, void *idata, 94 pcl_UnknownDataHandler handler, void *hdata); 95 96 /*****************************************************************************/ 97 98 #endif /* Inclusion protection */ 99