Tizen 2.1 base
[platform/upstream/hplip.git] / prnt / hpijs / versioncode.cpp
1 /*****************************************************************************\
2   versioncode.cpp : version information routines
3
4   Copyright (c) 1996 - 2002, 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 #include "header.h"
32 #include "printerfactory.h"
33
34 APDK_BEGIN_NAMESPACE
35 extern BOOL ProprietaryImaging();
36 extern BOOL ProprietaryScaling();
37 APDK_END_NAMESPACE
38
39 APDK_BEGIN_NAMESPACE
40
41 extern char DeveloperString[32];
42
43 /*! \addtogroup globals
44 @{
45 */
46
47 const char VersionStringID[21] = "04.09.00A_11-06-2009";   //!< Version information
48
49 char result[500];
50
51 void HP_strcat(char* str1, const char* str2)
52 {
53     while(*str1)
54     {
55         str1++;
56     }
57     while( (*str1++ = *str2++) )
58     {
59         // nothing.  Just copying str2 to str1
60         ;
61     }
62 }
63
64
65 /*!
66 Returns a string identifying components and features of the driver build.
67 If bCompressed is TRUE then the string returned is a bit representation string
68 of the build options (ie. speed, scaling, capture, etc...).  If bCompressed is
69 FALSE then the string is a textual concatenation of the developer build string,
70 the APDK version string, and string representation of the build options.
71
72 This function returns a string identifying components and features of the driver
73 build, such as which printer-models are supported, whether font and scaling
74 support is included, and other information intended to help solve customer problems.
75
76 \param int bCompressed If true, the information is packed into a decimal number
77 that may be decoded by Hewlett-Packard. Otherwise, the string consists of
78 human-readable indicators.
79 \return char* string representing version information.
80 \note If bCompressed is TRUE then the return string has only build options and
81 no version information.
82 */
83 char* Version(BOOL bCompressed)
84 {
85     if (bCompressed)
86     {
87         unsigned int bits=0;
88
89         if (ProprietaryScaling())
90             bits = bits | 0x80000000;
91
92 #ifdef APDK_CAPTURE
93         bits = bits | 0x40000000;
94 #endif
95
96 #ifdef APDK_LITTLE_ENDIAN
97         bits = bits | 0x20000000;
98 #endif
99
100         if (ProprietaryImaging())
101             bits = bits | 0x10000000;
102
103 #ifdef APDK_COURIER
104         bits = bits | 0x08000000;
105 #endif
106 #ifdef APDK_CGTIMES
107         bits = bits | 0x04000000;
108 #endif
109 #ifdef APDK_LTRGOTHIC
110         bits = bits | 0x02000000;
111 #endif
112 #ifdef APDK_UNIVERS
113         bits = bits | 0x01000000;
114 #endif
115
116 #ifdef APDK_OPTIMIZE_FOR_SPEED
117         bits = bits | 0x00800000;
118 #endif
119
120     bits = bits | pPFI->GetModelBits();
121
122   // room left for 23 more here
123         sprintf(result,"%0x", bits);
124     }
125     else
126     {
127         strcpy(result,DeveloperString);
128         HP_strcat(result,"!!");
129         HP_strcat(result,VersionStringID);
130         HP_strcat(result," ");
131
132         if (ProprietaryScaling())
133             HP_strcat(result,"propscale ");
134         else 
135                         HP_strcat(result,"openscale ");
136
137         if (ProprietaryImaging())
138             HP_strcat(result,"propimg ");
139         else 
140                         HP_strcat(result,"openimg ");
141
142 #ifdef APDK_CAPTURE
143         HP_strcat(result,"debug ");
144 #else
145         HP_strcat(result,"normal ");
146 #endif
147
148 #ifdef APDK_LITTLE_ENDIAN
149         HP_strcat(result,"little_endian ");
150 #else
151         HP_strcat(result,"big_endian ");
152 #endif
153
154 #if defined(APDK_FONTS_NEEDED)
155         HP_strcat(result,"fonts:");
156 #else
157         HP_strcat(result,"no_fonts");
158 #endif
159 #ifdef APDK_COURIER
160         HP_strcat(result,"C");
161 #endif
162 #ifdef APDK_CGTIMES
163         HP_strcat(result,"T");
164 #endif
165 #ifdef APDK_LTRGOTHIC
166         HP_strcat(result,"L");
167 #endif
168 #ifdef APDK_UNIVERS
169         HP_strcat(result,"U");
170 #endif
171         HP_strcat(result," ");
172
173 #ifdef APDK_OPTIMIZE_FOR_SPEED
174         HP_strcat(result,"speed ");
175 #else
176         HP_strcat(result,"memory ");
177 #endif
178
179                 char modelstring[300];
180                 pPFI->GetModelString(modelstring, sizeof(modelstring));
181         HP_strcat(result, modelstring);
182
183     }
184
185     return result;
186 } //Version
187
188 /*! @} */
189
190 APDK_END_NAMESPACE