Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

helper.h

00001 /* @(#)25       1.3  src/include/pos/helper.h, apicode, ptux1.2.0, 20 8/24/01 13:43:38 */
00002 
00003 /********************************************************************/
00004 /*  <helper.h> header file                                         */
00005 /*                                                                  */
00006 /*  Licensed Materials - Property of IBM                            */
00007 /*                                                                  */
00008 /*  IBM Point of Sale Subsystem                                     */
00009 /*  73G0950 (C) Copyright IBM Corporation 1995, 2001                */
00010 /*  All rights reserved                                             */
00011 /*                                                                  */
00012 /*  US Government Users Restricted Rights -                         */
00013 /*  Use, duplication, or disclosure restricted                      */
00014 /*  by GSA ADP Schedule Contract with IBM Corp.                     */
00015 /*                                                                  */
00016 /********************************************************************/
00017 
00018 #ifndef _H_POS_HELPER
00019 #define _H_POS_HELPER  1
00020 
00021 /********************************************************************/
00022 /* :H1 Message Crackers                                             */
00023 /*                                                                  */
00024 /* Due to architectural differences, the organization of data       */
00025 /* within mp1 and mp2 is not identical across all platforms.        */
00026 /* These message cracker macros provide a portable way to extract   */
00027 /* the individual fields from a POS message.                        */
00028 /*                                                                  */
00029 /* The message cracker macro names are built from a prefix,         */
00030 /* the message name, and the field name. The macro names            */
00031 /* are mixed case, and the 'POSM' prefix is discarded from          */
00032 /* the message name. Only the first letter of the field name        */
00033 /* part is capitalized, even if the name is a concatenation of      */
00034 /* multiple words ('charcode' becomes 'Charcode', not 'CharCode).   */
00035 /*                                                                  */
00036 /* For example, to get the 'cause' field from the                   */
00037 /* POSM_PRN_PRINTER_ERROR message you could issue                   */
00038 /*                                                                  */
00039 /*   unsigned short cause = PosGetPrnPrinterErrorCause(mp1,mp2);    */
00040 /*                                                                  */
00041 /* "PosGet" is the standard prefix,                                 */
00042 /* "PrnPrinterError" is derived from POSM_PRN_PRINTER_ERROR, and    */
00043 /* "Cause" is the field name as documented in the Programming       */
00044 /* Reference.                                                       */
00045 /*                                                                  */
00046 /* The advantages of this approach are that macro names are         */
00047 /* unambiguous and you don't have to remember their names           */
00048 /* (just the formula).                                              */
00049 /*                                                                  */
00050 /* The disadvantage is that the macro names can be looooooooong!    */
00051 /*                                                                  */
00052 /********************************************************************/
00053 
00054   /******************************************************************/
00055   /* POSM_KBD_STATUS_CHANGE message crackers                        */
00056   /******************************************************************/
00057 
00058   /* This macro actually extracts the field that the Programming  */
00059   /* Guide calls 'status'. The field will be renamed 'change' in  */
00060   /* a future release of the Programming Reference.               */
00061   /* 'status' will generally refer to device status.              */
00062 
00063   #define PosGetKbdStatusChangeChange(mp1,mp2) \
00064     ((unsigned short)(    ((mp1 >> 16) & 0x0FFFF) | (mp2 ^ mp2)))
00065 
00066   /* This macro extracts the unnamed field containing additional  */
00067   /* information about the status change.                         */
00068 
00069   #define PosGetKbdStatusChangeInfo(mp1,mp2) \
00070     ((unsigned long)(     (mp2)                   | (mp1 ^ mp1)))
00071 
00072   #define PosGetKbdStatusChangeDevdes(mp1,mp2) \
00073     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00074 
00075   
00076   /******************************************************************/
00077   /* POSM_KBD_WM_CHAR message crackers                              */
00078   /******************************************************************/
00079 
00080   #define PosGetKbdWmCharCharcode(mp1,mp2) \
00081     ((unsigned short)(    ((mp1 >> 16) & 0x0FFFF) | (mp2 ^ mp2)))
00082 
00083   #define PosGetKbdWmCharDevdes(mp1,mp2) \
00084     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00085 
00086   #define PosGetKbdWmCharFlags(mp1,mp2) \
00087     ((unsigned short)(    ((mp2 >> 16) & 0x0FFFF) | (mp1 ^ mp1)))
00088 
00089   #define PosGetKbdWmCharScancode(mp1,mp2) \
00090     ((unsigned char)(     (mp2 & 0x0FF)           | (mp1 ^ mp1)))
00091 
00092 
00093   /******************************************************************/
00094   /* POSM_MSR_DATA_AVAIL message crackers                           */
00095   /******************************************************************/
00096 
00097   #define PosGetMsrDataAvailDevdes(mp1,mp2) \
00098     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00099 
00100   #define PosGetMsrDataAvailLength(mp1,mp2) \
00101     ((unsigned short)(    (mp2 & 0x0FFFF)         | (mp1 ^ mp1)))
00102 
00103 
00104   /******************************************************************/
00105   /* POSM_PRN_CHASE_COMPLETE message crackers                       */
00106   /******************************************************************/
00107 
00108   #define PosGetPrnChaseCompleteDevdes(mp1,mp2) \
00109     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00110 
00111   #define PosGetPrnChaseCompleteStation(mp1,mp2) \
00112     ((unsigned short)(    ((mp1 >> 16) & 0x0FFFF) | (mp2 ^ mp2)))
00113 
00114   #define PosGetPrnChaseCompleteStatus(mp1,mp2) \
00115     ((unsigned long)(     (mp2)                   | (mp1 ^ mp1)))
00116 
00117 
00118   /******************************************************************/
00119   /* POSM_PRN_DATA_AVAIL message crackers                           */
00120   /******************************************************************/
00121 
00122   #define PosGetPrnDataAvailFrom(mp1,mp2) \
00123     ((unsigned short)(    ((mp1 >> 16) & 0x0FFFF) | (mp2 ^ mp2)))
00124 
00125   #define PosGetPrnDataAvailDevdes(mp1,mp2) \
00126     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00127 
00128   #define PosGetPrnDataAvailLength(mp1,mp2) \
00129     ((unsigned short)(    (mp2 & 0x0FFFF)         | (mp1 ^ mp1)))
00130 
00131   /******************************************************************/
00132   /* POSM_PRN_FISCAL_ERROR message crackers                         */
00133   /******************************************************************/
00134 
00135   #define PosGetPrnFiscalErrorDevdes(mp1,mp2) \
00136     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00137 
00138   #define PosGetPrnFiscalErrorCause(mp1,mp2) \
00139     ((unsigned short)(    ((mp1 >> 16) & 0x0FFFF) | (mp2 ^ mp2)))
00140 
00141   #define PosGetPrnFiscalErrorStatus(mp1,mp2) \
00142     ((unsigned long)(     (mp2)                   | (mp1 ^ mp1)))
00143 
00144 
00145   /******************************************************************/
00146   /* POSM_PRN_FISCAL_STATUS message crackers                        */
00147   /******************************************************************/
00148 
00149   #define PosGetPrnFiscalStatusDevdes(mp1,mp2) \
00150     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00151 
00152   #define PosGetPrnFiscalStatusCommand(mp1,mp2) \
00153     ((unsigned long)(     (mp2)                   | (mp1 ^ mp1)))
00154 
00155 
00156   /******************************************************************/
00157   /* POSM_PRN_PRINTER_ERROR message crackers                        */
00158   /******************************************************************/
00159 
00160   #define PosGetPrnPrinterErrorCause(mp1,mp2) \
00161     ((unsigned short)(    ((mp1 >> 16) & 0x0FFFF) | (mp2 ^ mp2)))
00162 
00163   #define PosGetPrnPrinterErrorDevdes(mp1,mp2) \
00164     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00165 
00166   #define PosGetPrnPrinterErrorStatus(mp1,mp2) \
00167     ((unsigned long)(     (mp2)                   | (mp1 ^ mp1)))
00168 
00169 
00170   /******************************************************************/
00171   /* POSM_PRN_STATUS_CHANGE message crackers                        */
00172   /******************************************************************/
00173 
00174   /* This macro extracts the field that the Programming Guide     */
00175   /* calls 'status1'.                                             */
00176 
00177   #define PosGetPrnStatusChangeChange(mp1,mp2) \
00178     ((unsigned short)(    ((mp1 >> 16) & 0x0FFFF) | (mp2 ^ mp2)))
00179 
00180   #define PosGetPrnStatusChangeDevdes(mp1,mp2) \
00181     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00182 
00183   /* This macro extracts the field that the Programming Guide     */
00184   /* calls 'status2'.                                             */
00185 
00186   #define PosGetPrnStatusChangeStatus(mp1,mp2) \
00187     ((unsigned long)(     (mp2)                   | (mp1 ^ mp1)))
00188 
00189 
00190   /******************************************************************/
00191   /* POSM_RS232_BREAK_DETECTED message crackers                     */
00192   /******************************************************************/
00193 
00194   #define PosGetRs232BreakDetectedDevdes(mp1,mp2) \
00195     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00196 
00197 
00198   /******************************************************************/
00199   /* POSM_RS232_DATA_AVAIL message crackers                         */
00200   /******************************************************************/
00201 
00202   #define PosGetRs232DataAvailDevdes(mp1,mp2) \
00203     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00204 
00205   #define PosGetRs232DataAvailLength(mp1,mp2) \
00206     ((unsigned short)(    (mp2 & 0x0FFFF)         | (mp1 ^ mp1)))
00207 
00208 
00209   /******************************************************************/
00210   /* POSM_RS232_XMIT_ABORT message crackers                         */
00211   /******************************************************************/
00212 
00213   #define PosGetRs232XmitAbortDevdes(mp1,mp2) \
00214     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00215 
00216 
00217   /******************************************************************/
00218   /* POSM_RS232_XMIT_COMPLETE message crackers                      */
00219   /******************************************************************/
00220 
00221   #define PosGetRs232XmitCompleteDevdes(mp1,mp2) \
00222     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00223 
00224 
00225   /******************************************************************/
00226   /* POSM_SCAN_DATA_AVAIL message crackers                          */
00227   /******************************************************************/
00228 
00229   #define PosGetScanDataAvailDevdes(mp1,mp2) \
00230     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00231 
00232   #define PosGetScanDataAvailLength(mp1,mp2) \
00233     ((unsigned short)(    (mp2 & 0x0FFFF)         | (mp1 ^ mp1)))
00234 
00235 
00236   /******************************************************************/
00237   /* POSM_SYS_DEVICE_OFFLINE message crackers                       */
00238   /******************************************************************/
00239 
00240   #define PosGetSysDeviceOfflineSlot(mp1,mp2) \
00241     ((unsigned char)(     ((mp1 >> 24) & 0x0FF)   | (mp2 ^ mp2)))
00242 
00243   #define PosGetSysDeviceOfflinePort(mp1,mp2) \
00244     ((unsigned char)(     ((mp1 >> 16) & 0x0FF)   | (mp2 ^ mp2)))
00245 
00246   #define PosGetSysDeviceOfflineDevice(mp1,mp2) \
00247     ((unsigned char)(     ((mp1 >> 8) & 0x0FF)    | (mp2 ^ mp2)))
00248 
00249   #define PosGetSysDeviceOfflineType(mp1,mp2) \
00250     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00251 
00252   #define PosGetSysDeviceOfflineSubType(mp1,mp2) \
00253     ((unsigned char)(     (mp2 & 0x0FF)           | (mp1 ^ mp1)))
00254 
00255   #define PosGetSysDeviceOfflineServdes(mp1,mp2) \
00256     ((unsigned char)(     ((mp2 >> 8) & 0x0FF)    | (mp1 ^ mp1)))
00257 
00258 
00259   /******************************************************************/
00260   /* POSM_SYS_DEVICE_ONLINE message crackers                        */
00261   /******************************************************************/
00262 
00263   #define PosGetSysDeviceOnlineSlot(mp1,mp2) \
00264     ((unsigned char)(     ((mp1 >> 24) & 0x0FF)   | (mp2 ^ mp2)))
00265 
00266   #define PosGetSysDeviceOnlinePort(mp1,mp2) \
00267     ((unsigned char)(     ((mp1 >> 16) & 0x0FF)   | (mp2 ^ mp2)))
00268 
00269   #define PosGetSysDeviceOnlineDevice(mp1,mp2) \
00270     ((unsigned char)(     ((mp1 >> 8) & 0x0FF)    | (mp2 ^ mp2)))
00271 
00272   #define PosGetSysDeviceOnlineType(mp1,mp2) \
00273     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00274 
00275   #define PosGetSysDeviceOnlineSubType(mp1,mp2) \
00276     ((unsigned char)(     (mp2 & 0x0FF)           | (mp1 ^ mp1)))
00277 
00278   #define PosGetSysDeviceOnlineServdes(mp1,mp2) \
00279     ((unsigned char)(     ((mp2 >> 8) & 0x0FF)    | (mp1 ^ mp1)))
00280 
00281 
00282   /******************************************************************/
00283   /* POSM_SYS_DEVICE_RELEASED message crackers                      */
00284   /******************************************************************/
00285 
00286   #define PosGetSysDeviceReleasedDevdes(mp1,mp2) \
00287     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00288 
00289 
00290   /******************************************************************/
00291   /* POSM_TILL_CLOSED message crackers                              */
00292   /******************************************************************/
00293 
00294   #define PosGetTillClosedDevdes(mp1,mp2) \
00295     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00296 
00297 
00298   /******************************************************************/
00299   /* POSM_TILL_OPENED message crackers                              */
00300   /******************************************************************/
00301 
00302   #define PosGetTillOpenedDevdes(mp1,mp2) \
00303     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00304 
00305 
00306   /******************************************************************/
00307   /* POSM_TOUCH_DATA message crackers                               */
00308   /******************************************************************/
00309 
00310   #define PosGetTouchDataStatus(mp1,mp2) \
00311     ((unsigned short)(    ((mp1 >> 16) & 0x0FFFF) | (mp2 ^ mp2)))
00312 
00313   #define PosGetTouchDataDevdes(mp1,mp2) \
00314     ((unsigned char)(     (mp1 & 0x0FF)           | (mp2 ^ mp2)))
00315 
00316   #define PosGetTouchDataX(mp1,mp2) \
00317     ((unsigned short)(    ((mp2 >> 16) & 0x0FFFF) | (mp1 ^ mp1)))
00318 
00319   #define PosGetTouchDataY(mp1,mp2) \
00320     ((unsigned short)(    (mp2 & 0x0FFFF)         | (mp1 ^ mp1)))
00321 
00322 
00323 #endif   /* _H_POS_HELPER */
00324 

 

L.A.B. Project © 2001-2004 LAB Project & DJ Anubis