Tizen 2.1 base
[platform/upstream/hplip.git] / prnt / hpijs / script.h
1 /*****************************************************************************\
2   script.h : Interface for Scripter classes
3
4   Copyright (c) 1996 - 2001, Hewlett-Packard Co.
5   All rights reserved.
6
7   Redistribution and use in source and binary forms, with or without
8   modification, are permitted provided that the following conditions
9   are met:
10   1. Redistributions of source code must retain the above copyright
11      notice, this list of conditions and the following disclaimer.
12   2. Redistributions in binary form must reproduce the above copyright
13      notice, this list of conditions and the following disclaimer in the
14      documentation and/or other materials provided with the distribution.
15   3. Neither the name of Hewlett-Packard nor the names of its
16      contributors may be used to endorse or promote products derived
17      from this software without specific prior written permission.
18
19   THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
20   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
22   NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24   TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
25   OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26   ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 \*****************************************************************************/
30
31
32 APDK_BEGIN_NAMESPACE
33
34 class Scripter
35 {
36 public:
37     Scripter(SystemServices* pSS);
38     virtual ~Scripter();
39
40     unsigned int TokenCount;
41     unsigned int ReplayTokenCount;
42
43     FILE* ScriptFile;
44     char ScriptFileName[200];
45     unsigned int fontcount;
46
47     SystemServices* pSys;
48     short* GlobalBuffer;
49     int buffsize;
50
51
52     virtual BOOL OpenDebugStreamR(const char* filename)=0;
53     virtual BOOL CloseDebugStreamR()=0;
54     virtual BOOL OpenDebugStreamW(const char* filename)=0;
55     virtual BOOL CloseDebugStreamW()=0;
56     virtual BOOL PutDebugToken(const int token)=0;
57     virtual BOOL PutDebugInt(const int data)=0;
58     virtual BOOL PutDebugByte(const BYTE data)=0;
59     virtual BOOL PutDebugStream(const BYTE* stream,const int len)=0;
60     virtual BOOL PutDebugString(const char* str,const int len)=0;
61     virtual BOOL GetDebugToken(int& token)=0;
62     virtual BOOL GetDebugInt(int& data)=0;
63     virtual BOOL GetDebugString(char*& str,int& len)=0;
64     virtual BOOL GetDebugStream(const unsigned int buffersize, BYTE*& buffer)=0;
65     virtual BOOL GetDebugByte(BYTE& data)=0;
66
67     BOOL ParseVer(char* str);
68 };
69
70 class AsciiScripter : public Scripter
71 {
72 public:
73     AsciiScripter(SystemServices* pSS);
74     ~AsciiScripter();
75
76     virtual BOOL OpenDebugStreamR(const char* filename);
77     virtual BOOL CloseDebugStreamR();
78     virtual BOOL OpenDebugStreamW(const char* filename);
79     virtual BOOL CloseDebugStreamW();
80     virtual BOOL PutDebugToken(const int token);
81     virtual BOOL PutDebugInt(const int data);
82     virtual BOOL PutDebugByte(const BYTE data);
83     virtual BOOL PutDebugString(const char* str,const int len);
84     virtual BOOL PutDebugStream(const BYTE* stream,const int len);
85     virtual BOOL GetDebugToken(int& token);
86     virtual BOOL GetDebugInt(int& data);
87     virtual BOOL GetDebugByte(BYTE& data);
88     virtual BOOL GetDebugString(char*& str,int& len);
89     virtual BOOL GetDebugStream(const unsigned int buffersize, BYTE*& buffer );
90
91     void ReadRLE(int instreamlen, BYTE* outstream);
92     void ReadRaw(int instreamlen, BYTE* outstream);
93
94     BOOL FindPercent();
95     char* digits();
96     char scanner[30];
97         #define TEMPLEN 600
98     char tempStr[TEMPLEN];
99
100     char TokString[25][40]; // 25=# of tokens in harness.h; table set in ProtoServices cons.
101     unsigned int TokCount[25];
102
103 };
104
105 class BinaryScripter : public AsciiScripter
106 {
107 public:
108     BinaryScripter(SystemServices* pSS);
109     ~BinaryScripter();
110
111     BOOL OpenDebugStreamR(const char* filename);
112     BOOL OpenDebugStreamW(const char* filename);
113     BOOL PutDebugToken(const int token);
114     BOOL PutDebugInt(const int data);
115     BOOL PutDebugByte(const BYTE data);
116     BOOL PutDebugString(const char* str,const int len);
117     BOOL PutDebugStream(const BYTE* stream,const int len);
118     BOOL GetDebugToken(int& token);
119     BOOL GetDebugInt(int& data);
120     BOOL GetDebugString(char*& str,int& len);
121     BOOL GetDebugStream(const unsigned int buffersize, BYTE*& buffer );
122     BOOL GetDebugByte(BYTE& data);
123
124 };
125
126 APDK_END_NAMESPACE
127