BOOL _XTENSN_EXPORT PASCAL ExportMCodeEntryAsXml (long MCode, DWORD, void *pData) { PBDMERKMAL pbdData; char KText[34]; char pLText[1025]; INITSTRUCT(pbdData, PBDMERKMAL); pbdData.pbdTyp = 'm'; pbdData.pbdCode = MCode; pbdData.pbdKText = KText; pbdData.pbdLText = pLText; pbdData.pbdKTextLen = sizeof(KText) -1; pbdData.pbdLTextLen = 1024; ErrCode RC = DEX_GetPBDData (pbdData); KText[32] = '\0'; // Systemmerkmale nicht ausgeben if (pbdData.ipbdMTyp & MPSystemFeatures || !strncmp (KText, "__", 2)) return true; EXPORTDATA *pED = (EXPORTDATA *)pData; RemoveNewLines (pbdData.pbdLText); CXMLAttribute Attr (g_cbMCode, (10 == DEX_GetMkBase()) ? "%08ld" : "0x%08lx", DEX_MapHandleToMCode(MCode)); CXMLNode Node (pED -> fh, g_cbFeature, Attr); // nur OBJEKT-Eigenschaften ausgeben if (pbdData.ipbdMTyp & MPReadOnlyFeatures) { string strType = char (toupper(pbdData.ipbdMTyp & 0xff)); strType += 'R'; // readonly CXMLText (pED -> fh, g_cbType, strType.c_str()); } // KurzText, Langtext ausgeben { CXMLAttribute IsDefault (g_cbIsDefault, "%d", EC_OKAY == RC ? 0 : 1); CXMLText (pED -> fh, g_cbName, pbdData.pbdKText, IsDefault); } if (pbdData.pbdLTextLen > 0 && pbdData.pbdLText[0] != '\0') { CXMLText (pED -> fh, g_cbDescription, pbdData.pbdLText); } if (_MAX_PATH != pbdData.ipbdMLen && 256 != pbdData.ipbdMLen) { CXMLTextEx (pED -> fh, g_cbLength, "%d", pbdData.ipbdMLen); } // if (pED -> pIUnk) { // LPPROGRESSINDICATOR(pED -> pIUnk) -> SetPosition (++(pED -> ulCnt)); // if (LPPROGRESSINDICATOR(pED -> pIUnk) -> WasCanceled()) // return false; // abbrechen // } return true; // weitermachen }
int main(int argc, char *const argv[]) { puts(""); argF = 0; // -f argument: file - use file as a makefile argK = 0; // -k argument: keep going - Continue as much as possible after error argN = 0; // -n argument: Just print - print the commands that would be executed, don't execute argQ = 0; // -q argument: question - don't run commands hasChanged = 0; bool hasTarget = 0; // whether or not a target is specified from command line char *makeFile; // filename for the makefile being used. char *target; // target to be used FILE *myFile; // file to be used for reading int c; // used for getopt loop while((c = getopt(argc, argv, "f:knq")) != -1) // Collect command arguments { if(c == 'k') argK = 1; // set K if(c == 'f' && argF == 0) // set F (only if it has not been set before) { argF = 1; makeFile = (char*)calloc(1, strlen(optarg) + 1); // extract filename strcpy(makeFile, optarg); } if(c == 'n') argN = 1; // set N if(c == 'q') argQ = 1; // set Q } if(!argF) { struct stat fileBuf; if(stat("GNUmakefile", &fileBuf) == 0) makeFile = "GNUmakefile"; else if(stat("makefile", &fileBuf) == 0) makeFile = "makefile"; else if(stat("Makefile", &fileBuf) == 0) makeFile = "Makefile"; else { printf("Could not find a default makefile. Program terminating...\n"); exit(0); } } if(argc > optind) // if there are still arguments after the command options, { // extract the target command from the argument list hasTarget = 1; target = calloc(1, strlen(argv[optind]) + 1); strcpy(target, argv[optind]); originalTarget = target; } myFile = fopen(makeFile, "r"); char line[MACROSIZE]; char *makeString[MACROSIZE]; int counter = 0; if( myFile != NULL) { while(fgets (line, sizeof line, myFile) != NULL) { makeString[counter] = calloc(1, strlen(line) + 1); strcpy(makeString[counter], line); // puts(makeString[counter]); counter ++; } fclose(myFile); } macI *firstMacro = calloc(1, sizeof(macI)); firstMacro = createList(firstMacro, makeString, counter); for(int i = 0; i < counter; i++) { char *temp = subMacros(makeString[i], firstMacro); makeString[i] = realloc(makeString[i], strlen(temp) + 1); strcpy(makeString[i], temp); RemoveNewLines(makeString[i]); makeString[i] = RemoveStartSpaces(makeString[i]); } tItem *firstTarget = calloc(1, sizeof(tItem)); firstTarget = insertTarget(firstTarget, FIRSTTARGET); switch(evaluateTarget(makeString, target, counter, hasTarget, firstTarget)) { case 3: // puts("1"); return 1; break; case 4: // puts("0"); return 0; break; default: break; } // ****************************************** FREE MEMORY ************************************* // ****************************************** FREE MEMORY ************************************* // ****************************************** FREE MEMORY ************************************* if(hasChanged == 0) printf("mymake: `%s' is up to date.\n", originalTarget); if(argF) free(makeFile); if(hasTarget) free(target); for(int i = 0; i < counter; i ++) free(makeString[counter]); freeTargets(firstTarget); freeMacros(firstMacro); }
BOOL _XTENSN_EXPORT PASCAL ExportIdentEntryAsXml (long Ident, BOOL, void *pData) { PBDDATA pbdData; char KText[34]; char pLText[1025]; INITSTRUCT(pbdData, PBDDATA); pbdData.pbdTyp = 'i'; pbdData.pbdCode = Ident; pbdData.pbdKText = KText; pbdData.pbdLText = pLText; pbdData.pbdKTextLen = sizeof(KText) -1; pbdData.pbdLTextLen = 1024; ErrCode RC = DEX_GetPBDData (pbdData); KText[32] = '\0'; EXPORTDATA *pED = (EXPORTDATA *)pData; RemoveNewLines (pbdData.pbdLText); char cbBuffer[MAX_OKS_LENX]; HRESULT hr = ClassFromIdentX (Ident, cbBuffer); CXMLAttribute Attr (g_cbIdent, (10 == DEX_GetIdBase()) ? "%ld" : "0x%lx", Ident); CXMLNode Node (pED -> fh, g_cbObjectClass, Attr); if (EXPORTMODE_Normal == (s_rgExportMode & EXPORTMODE_TXI)) { if (S_OK == hr) { CXMLText (pED -> fh, g_cbOKS, cbBuffer); } } else { if (SUCCEEDED(hr) && s_rgExportMode & EXPORTMODE_OKSOnly) { // S_OK oder S_FALSE CXMLText (pED -> fh, g_cbOKS, cbBuffer); } } // evtl. Tabellennamen ausgeben TABLENAME TN; INITSTRUCT(TN, TABLENAME); TN.lIdent = Ident; TN.pBuffer = cbBuffer; TN.iLen = sizeof(cbBuffer); hr = DEX_GetTableName (TN); if (S_OK == hr) CXMLText (pED -> fh, g_cbTableName, cbBuffer); // KurzText, Langtext ausgeben { CXMLAttribute IsDefault (g_cbIsDefault, "%d", EC_OKAY == RC ? 0 : 1); CXMLText (pED -> fh, g_cbName, pbdData.pbdKText, IsDefault); } if (pbdData.pbdLTextLen > 0 && pbdData.pbdLText[0] != '\0') { // Langtext (Beschreibungstext ausgeben CXMLText (pED -> fh, g_cbDescription, pbdData.pbdLText); } // Objekteigenschaften ausgeben bool fRet = true; // Identifikator übergeben pED -> ulIdent = (ULONG)Ident; { CXMLNode Feats (pED -> fh, g_cbObjectFeatures); ENUMLONGKEYEX ELK; ELK.eKey = Ident; ELK.eFcn = (ENUMLONGKEYEXPROC)ExportMCodeEntryAsXml; ELK.ePtr = pED; ELK.eData = MPObjectFeature|MPReadOnlyFeatures|FEATURETYPE_DefinitionOnly /*|MPSystemFeatures*/; fRet = DEX_EnumObjektMerkmaleClassEx (ELK); } if (pED -> pIUnk) { LPPROGRESSINDICATOR(pED -> pIUnk) -> SetPosition (++(pED -> ulCnt)); if (LPPROGRESSINDICATOR(pED -> pIUnk) -> WasCanceled()) return false; // abbrechen } return fRet; // weitermachen }