1 /* 2 3 Machine-readable parser for libpics 4 5 6 7 8 9 10 !Machine-readable parser! 11 12 */ 13 14 /* 15 ** (c) COPYRIGHT MIT 1996. 16 ** Please first read the full copyright statement in the file COPYRIGH. 17 */ 18 19 /* 20 21 This module provides the interface to CSMacRed.c. 22 Labels are parsed from strings (see CSParse.html). 23 These labels may then be kept in a CSMachRead_t structure for inspection by the 24 application. 25 26 */ 27 28 #ifndef CSMR_H 29 #define CSMR_H 30 31 /* 32 33 (State Change Enumeration) 34 35 Call to the TargetChangeCallback 36 will have one of the following values. 37 38 */ 39 40 typedef enum { 41 CSMRTC_MACHREAD = 1, 42 CSMRTC_VERSION, 43 CSMRTC_SYSTEM, 44 CSMRTC_SERVICE, 45 CSMRTC_ICON, 46 CSMSRC_NAME, 47 CSMSRC_VALUE, 48 CSMSRC_DESC, 49 CSMRTC_DEF, 50 CSMRTC_MIN, 51 CSMRTC_MAX, 52 CSMRTC_MULTI, 53 CSMRTC_UNORD, 54 CSMRTC_INT, 55 CSMRTC_LABL, 56 CSMRTC_CAT, 57 CSMRTC_TRANS, 58 CSMRTC_ENUM, 59 CSMRTC_COUNT 60 } CSMRTC_t; 61 62 /* 63 64 (Data shell) 65 66 All PICS Machine-readable data is stored in a CSMRData_t 67 68 */ 69 70 typedef struct CSMachReadData_s CSMachReadData_t; 71 72 /* 73 74 (TargetChangeCallback) 75 76 As the label is parsed, it will call the assigned TargetChangeCallback as it 77 passes from state to state. 78 79 */ 80 81 typedef StateRet_t MachReadTargetCallback_t(CSMachRead_t * pCSMachRead, 82 CSParse_t * pCSParse, 83 CSMRTC_t target, BOOL closed, 84 void * pVoid); 85 86 /* 87 88 (ErrorHandler) 89 90 All parsing error will be passed to the Apps MRErrorHandler for user display 91 or automatic dismissal. 92 93 */ 94 95 typedef StateRet_t MRErrorHandler_t(CSMachRead_t * pCSMachRead, 96 CSParse_t * pCSParse, const char * token, 97 char demark, StateRet_t errorCode); 98 99 /* 100 101 (Construction/Destruction) 102 103 These methods allow the user to create and get access to both the description 104 and the state. CSMachReads may be cloned so that one saves state while another 105 continues to iterate or parse. The states must all be freed. description data 106 will only be freed after all the CSMachReads that refer to it are deleted. 107 108 */ 109 110 extern CSParse_t * CSParse_newMachRead( 111 MachReadTargetCallback_t * pMachReadTargetCallback, 112 MRErrorHandler_t * pMRErrorHandler); 113 extern BOOL CSParse_deleteMachRead(CSParse_t *); 114 extern CSMachRead_t * CSParse_getMachRead(CSParse_t * me); 115 extern char * CSMachRead_getSystem(CSMachRead_t * pCSMachRead); 116 extern char * CSMachRead_getService(CSMachRead_t * pCSMachRead); 117 118 119 120 /* 121 122 (Iterating methods) 123 124 (Callback function) 125 126 The Iterators are passed a callback function to be called for each matching 127 element. For instance, when iterating through ranges, the callback function is 128 called once for each range, or, if a match is requested, only for the matching 129 range. 130 131 */ 132 133 134 135 typedef CSError_t CSMachRead_callback_t(CSMachRead_t *, 136 State_Parms_t *, 137 const char *, void * pVoid); 138 typedef CSError_t CSMachRead_iterator_t(CSMachRead_t *, 139 CSMachRead_callback_t *, 140 State_Parms_t *, const char *, 141 void * pVoid); 142 143 extern CSMachRead_iterator_t CSMachRead_iterateCategories; 144 extern CSMachRead_iterator_t CSMachRead_iterateLabels; 145 146 /* 147 148 */ 149 150 #endif /* CSMR_H */ 151 152 /* 153 154 End of Declaration 155 156 */ 157