Changeset 4402 for trunk/tools
- Timestamp:
- Oct 3, 2000, 7:42:41 AM (25 years ago)
- Location:
- trunk/tools
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/common/kFile.cpp
r4358 r4402 1 /* $Id: kFile.cpp,v 1. 5 2000-10-02 04:01:39bird Exp $1 /* $Id: kFile.cpp,v 1.6 2000-10-03 05:42:38 bird Exp $ 2 2 * 3 3 * kFile - Simple (for the time being) file class. … … 25 25 #include <stdarg.h> 26 26 #include <stdio.h> 27 #include <stdlib.h> 27 28 28 29 #include "kFile.h" … … 245 246 246 247 /** 248 * Reads a single line from the file into the given buffer. 249 * Newline is stripped! 250 * @returns Success indicator. 251 * @param pszBuffer Pointer to string buffer. 252 * Will hold a zero-string upon successful return. 253 * @param cchBuffer Buffer size. 254 * @sketch 255 * @status partially implemented. 256 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 257 * @remark Should implemented buffered read ASAP! 258 */ 259 BOOL kFile::readln(char *pszBuffer, long cchBuffer) throw (int) 260 { 261 char *psz; 262 long cbRead = min(max((long)filestatus.cbFile - (long)offVirtual, 0), cchBuffer-1); 263 264 /* 265 * Read full buffer length or remining part of file into the buffer. 266 * Look for line end. 267 * Found lineend: cut buffer there and rewind file back to that point (but skipping the newline). 268 */ 269 if (cbRead == 0 || !read(pszBuffer, cbRead) ) 270 return FALSE; 271 272 pszBuffer[cbRead] = '\0'; 273 274 psz = strpbrk(pszBuffer, "\r\n"); 275 if (psz != NULL) 276 { 277 cbRead -= psz - pszBuffer; 278 if (*psz == '\r') 279 { 280 if (psz[1] == '\n') 281 cbRead -= 2; 282 else 283 cbRead--; 284 } 285 else if (*psz == '\n') 286 cbRead--; 287 288 *psz = '\0'; 289 290 return move(-cbRead); 291 } 292 293 return TRUE; 294 } 295 296 297 /** 247 298 * Writes <cbBuffer> bytes to the file at the current file position. 248 299 * @returns success indicator. (TRUE/FALSE) … … 352 403 353 404 /** 405 * Appends the AppendFile to this file. 406 * @returns Reference to this file. 407 * @param AppendFile Reference to the file we're to append. 408 */ 409 kFile & kFile::operator+=(kFile &AppendFile) 410 { 411 long cb; 412 char * pachBuffer = new char[1024*256]; 413 long pos = AppendFile.getPos(); 414 BOOL fAppend = AppendFile.fThrowErrors; 415 BOOL fThis = fThrowErrors; 416 417 setThrowOnErrors(); 418 AppendFile.setThrowOnErrors(); 419 420 end(); 421 AppendFile.start(); 422 AppendFile.refreshFileStatus(); 423 424 cb = min(1024*256, AppendFile.filestatus.cbFile); 425 while (cb > 0) 426 { 427 AppendFile.read(pachBuffer, cb); 428 write(pachBuffer, cb); 429 cb = min(1024*256, (long)AppendFile.filestatus.cbFile - (long)AppendFile.offVirtual); 430 } 431 432 delete pachBuffer; 433 AppendFile.set(pos); 434 AppendFile.fThrowErrors = fAppend; 435 fThrowErrors = fThis; 436 437 return *this; 438 } 439 440 441 442 /** 354 443 * Seek relative to the current position. 355 444 * @returns Success indicator. … … 468 557 throw(ERROR_NOT_SUPPORTED); //this method don't currently work! Need to use flag! 469 558 #else 470 if (! refreshFileStatus())559 if (!fReadOnly && !refreshFileStatus()) 471 560 return (BOOL)-1; 472 561 473 return filestatus.cbFile >= offReal; //???562 return filestatus.cbFile <= offVirtual; //??? - !!! 474 563 #endif 475 564 } -
trunk/tools/common/kFile.h
r4358 r4402 1 /* $Id: kFile.h,v 1. 5 2000-10-02 04:01:39bird Exp $1 /* $Id: kFile.h,v 1.6 2000-10-03 05:42:38 bird Exp $ 2 2 * 3 3 * kFile - Simple (for the time being) file class. … … 54 54 BOOL readAt(void *pvBuffer, long cbBuffer, long off) throw(int); 55 55 void * readFile() throw(int); 56 BOOL readln(char *pszBuffer, long cchBuffer); 56 57 57 58 BOOL write(void *pvBuffer, long cbBuffer) throw(int); … … 61 62 62 63 BOOL setSize(unsigned long cbFile = ~0UL); 64 65 kFile & operator+=(kFile &AppendFile); 63 66 64 67 /** @cat File seek methods */ -
trunk/tools/common/kFileDef.cpp
r2759 r4402 18 18 #include <string.h> 19 19 #include <stdlib.h> 20 20 #include <assert.h> 21 22 #include "kFile.h" 21 23 #include "kFileFormatBase.h" 22 24 #include "kFileDef.h" … … 26 28 * Internal Functions * 27 29 *******************************************************************************/ 28 static char *dupeString(const char *psz );30 static char *dupeString(const char *psz, BOOL fSkipFirstWord = FALSE); 29 31 static char *trim(char *psz); 32 static char *ltrim(const char *psz); 30 33 static char *removeFnutts(char *pszStr); 34 inline char upcase(char ch); 35 static char *stristr(const char *pszStr, const char *pszSubStr); 36 31 37 32 38 /** 33 39 * Duplicates a string. 34 * @returns Pointer to stringcopy. Remeber to delete this! 35 * @param psz Pointer to string to duplicate. 36 */ 37 static char *dupeString(const char *psz) 40 * @returns Pointer to stringcopy. Remeber to delete this! 41 * @param psz Pointer to string to duplicate. 42 * @param fSkipFirstWord Skips the first word before duplicating the string. 43 */ 44 static char *dupeString(const char *psz, BOOL fSkipFirstWord/* = FALSE*/) 38 45 { 39 46 char *pszDupe; 40 47 if (psz == NULL) 41 48 return NULL; 49 50 if (fSkipFirstWord) 51 { 52 while (*psz != ' ' && *psz != '\t' && *psz != '\n' && *psz != '\r' && *psz != '\0') 53 psz++; 54 psz = ltrim(psz); 55 } 56 42 57 pszDupe = new char[strlen(psz)+1]; 43 return strcpy(pszDupe, psz); 58 strcpy(pszDupe, psz); 59 if (fSkipFirstWord) 60 return removeFnutts(pszDupe); 61 return pszDupe; 44 62 } 45 63 … … 56 74 if (psz == NULL) 57 75 return NULL; 58 while (*psz == ' ' )76 while (*psz == ' ' || *psz == '\t') 59 77 psz++; 60 78 i = strlen(psz) - 1; 61 while (i >= 0 && psz[i] == ' ')79 while (i >= 0 && (psz[i] == ' ' || psz[i] == '\t')) 62 80 i--; 63 81 psz[i+1] = '\0'; … … 66 84 67 85 68 kFileDef::kFileDef(FILE *phFile) throw(int) 69 :pszType(NULL), pszBase(NULL), pszCode(NULL), pszData(NULL), pszDescription(NULL), 86 /** 87 * Trims a string, that is removing blank spaces at start and end. 88 * @returns Pointer to first non-blank char. 89 * @param psz Pointer to string. 90 * @result Blank at end of string is removed. ('\0' is moved to the left.) 91 */ 92 static char *ltrim(const char *psz) 93 { 94 if (psz == NULL) 95 return NULL; 96 97 while (*psz == ' ' || *psz == '\t') 98 psz++; 99 return (char *)psz; 100 } 101 102 103 104 kFileDef::kFileDef(kFile *pFile) throw(int) 105 :pszType(NULL), pszModName(NULL), pszBase(NULL), pszCode(NULL), pszData(NULL), pszDescription(NULL), 70 106 pszExeType(NULL), pszHeapSize(NULL), pszOld(NULL), pszProtmode(NULL), pszStackSize(NULL), 71 pszStub(NULL), pSegments(NULL), pImports(NULL), pExports(NULL) 107 pszStub(NULL), pSegments(NULL), pImports(NULL), pExports(NULL), 108 fProgram(FALSE), fLibrary(FALSE), fPhysicalDevice(FALSE), fVirtualDevice(FALSE), 109 fInitInstance(FALSE), fTermInstance(FALSE), fInitGlobal(FALSE), fTermGlobal(FALSE), 110 chAppType(kFileDef::unknown) 72 111 { 73 112 /* determin file size */ 74 if (!fseek(phFile, 0, SEEK_SET)) 75 { 76 this->read(phFile); 113 114 if (pFile->start()) 115 { 116 this->read(pFile); 77 117 } 78 118 else … … 126 166 /** 127 167 * Read/parse the Definition file. 128 * @param phFile Handle to file.129 * @remark 130 */ 131 void kFileDef::read( FILE *phFile) throw (int)168 * @param pFile Pointer to fileobject. 169 * @remark throws errorcode on error (TODO: errorhandling) 170 */ 171 void kFileDef::read(kFile *pFile) throw (int) 132 172 { 133 173 char *pszTmp; … … 136 176 137 177 /* readloop */ 138 psz = readln(p hFile, &szBuffer[0], sizeof(szBuffer));178 psz = readln(pFile, &szBuffer[0], sizeof(szBuffer)); 139 179 while (psz != NULL) 140 180 { … … 146 186 if (pszType != NULL) throw (0x101); 147 187 pszType = dupeString(psz); 188 fLibrary = TRUE; 189 if (!setModuleName()) 190 throw (0x107); 191 fInitInstance = stristr(pszType, "INITINSTANCE") != NULL; 192 fInitGlobal = stristr(pszType, "INITGLOBAL") != NULL || !fInitInstance; 193 fTermInstance = stristr(pszType, "TERMINSTANCE") != NULL; 194 fTermGlobal = stristr(pszType, "TERMGLOBAL") != NULL || !fTermInstance; 148 195 } 149 196 else if (StringCase(psz, "NAME")) … … 151 198 if (pszType != NULL) throw (0x101); 152 199 pszType = dupeString(psz); 200 fProgram = TRUE; 201 setModuleName(); 202 if (stristr(pszType, "WINDOWAPI")) 203 chAppType = kFileDef::pm; 204 else if (stristr(pszType, "NOTWINDOWCOMPAT")) 205 chAppType = kFileDef::fullscreen; 206 else if (stristr(pszType, "WINDOWCOMPAT")) 207 chAppType = kFileDef::pmvio; 208 else 209 chAppType = kFileDef::unknown; 153 210 } 154 211 else if (StringCase(psz, "PHYSICAL DEVICE")) //gap is fixed to one space, this may be fixed in readln. … … 156 213 if (pszType != NULL) throw (0x101); 157 214 pszType = dupeString(psz); 215 fPhysicalDevice = TRUE; 216 setModuleName(); 158 217 } 159 218 else if (StringCase(psz, "VIRTUAL DEVICE")) //gap is fixed to one space, this may be fixed in readln. … … 161 220 if (pszType != NULL) throw (0x101); 162 221 pszType = dupeString(psz); 222 fVirtualDevice = TRUE; 223 setModuleName(); 163 224 } 164 225 else if (StringCase(psz, "BASE")) 165 pszBase = dupeString(psz );226 pszBase = dupeString(psz, TRUE); 166 227 else if (StringCase(psz, "CODE")) 167 pszCode = dupeString(psz );228 pszCode = dupeString(psz, TRUE); 168 229 else if (StringCase(psz, "DATA")) 169 pszData = dupeString(psz );230 pszData = dupeString(psz, TRUE); 170 231 else if (StringCase(psz, "DESCRIPTION")) 171 pszDescription = dupeString(psz );232 pszDescription = dupeString(psz, TRUE); 172 233 else if (StringCase(psz, "EXETYPE")) 173 pszExeType = dupeString(psz );234 pszExeType = dupeString(psz, TRUE); 174 235 else if (StringCase(psz, "HEAPSIZE")) 175 pszHeapSize = dupeString(psz );236 pszHeapSize = dupeString(psz, TRUE); 176 237 else if (StringCase(psz, "OLD")) 177 pszOld = dupeString(psz );238 pszOld = dupeString(psz, TRUE); 178 239 else if (StringCase(psz, "PROTMODE")) 179 pszProtmode = dupeString(psz );240 pszProtmode = dupeString(psz, TRUE); 180 241 else if (StringCase(psz, "STACKSIZE")) 181 pszStackSize = dupeString(psz );242 pszStackSize = dupeString(psz, TRUE); 182 243 else if (StringCase(psz, "STUB")) 183 pszStub = dupeString(psz );244 pszStub = dupeString(psz, TRUE); 184 245 else if (StringCase(psz, "SEGMENTS")) 185 246 { 186 247 PDEFSEGMENT *pps = &pSegments; 187 while (!isKeyword(psz = readln(p hFile, &szBuffer[0], sizeof(szBuffer))) && psz != NULL)248 while (!isKeyword(psz = readln(pFile, &szBuffer[0], sizeof(szBuffer))) && psz != NULL) 188 249 { 189 250 *pps = new DEFSEGMENT; memset(*pps, 0, sizeof(**pps)); … … 196 257 { 197 258 PDEFIMPORT *ppi = &pImports; 198 while (!isKeyword(psz = readln(p hFile, &szBuffer[0], sizeof(szBuffer))) && psz != NULL)259 while (!isKeyword(psz = readln(pFile, &szBuffer[0], sizeof(szBuffer))) && psz != NULL) 199 260 { 200 261 //DOSCALL1.154 or DosQueryHeaderInfo = DOSCALL1.154 … … 229 290 { 230 291 PDEFEXPORT *ppe = &pExports; 231 while (!isKeyword(psz = readln(p hFile, &szBuffer[0], sizeof(szBuffer))) && psz != NULL)292 while (!isKeyword(psz = readln(pFile, &szBuffer[0], sizeof(szBuffer))) && psz != NULL) 232 293 { 233 294 /* CloseHandle = CloseHandle@4 @1234 RESIDENTNAME 2 */ … … 312 373 /* next ? */ 313 374 if (fNext) 314 psz = readln(p hFile, &szBuffer[0], sizeof(szBuffer));375 psz = readln(pFile, &szBuffer[0], sizeof(szBuffer)); 315 376 } 316 377 317 378 /* sanity check */ 318 379 if (pszType == NULL) 319 throw ( 0x106);380 throw ((int)0x106); 320 381 } 321 382 … … 324 385 * Reads first meaning full line from a file into a buffer. 325 386 * @returns Pointer to buffer on success; NULL on error. 326 * @param p hFile Filea handle.387 * @param pFile Pointer to fileobject to read line from. 327 388 * @param pszBuffer Pointer to buffer. 328 389 * @param cbBuffer Size of buffer. 329 390 * @remark tabs are expanded. string is trimmed. comments removed. 330 391 */ 331 char *kFileDef::readln( FILE *phFile, char *pszBuffer, int cbBuffer) throw (int)392 char *kFileDef::readln(kFile *pFile, char *pszBuffer, int cbBuffer) throw (int) 332 393 { 333 394 int i; … … 337 398 { 338 399 /* read line */ 339 if (!fgets(pszBuffer, cbBuffer, phFile)) 340 { 341 if (feof(phFile)) 342 return FALSE; 343 else 400 if (!pFile->readln(pszBuffer, cbBuffer)) 401 { 402 if (!pFile->isEOF()) 344 403 throw (0x201); 404 return FALSE; 345 405 } 346 406 … … 378 438 memmove(pszBuffer, &pszBuffer[i], cch + 1); 379 439 } 380 } while ((*pszBuffer == ';' || cch == 0) && ! feof(phFile));440 } while ((*pszBuffer == ';' || cch == 0) && !pFile->isEOF()); 381 441 382 442 return !(*pszBuffer == ';' || cch == 0) ? pszBuffer : NULL; … … 416 476 417 477 /** 418 * Queries the module name.478 * Extracts the module name from the pszType string. 419 479 * @returns Success indicator. 420 480 * @param pszBuffer Pointer to string buffer which is to hold the module name upon return. 421 481 * @remark Assumes that pszBuffer is large enough. 422 482 */ 483 BOOL kFileDef::setModuleName(void) 484 { 485 char *pszEnd; 486 char *pszStart; 487 488 assert(pszType); 489 490 /* skip the first word */ 491 pszStart = strpbrk(pszType, " \t"); 492 if (pszStart != NULL) 493 { 494 pszStart = ltrim(pszStart); 495 pszEnd = strpbrk(pszStart, " \t"); 496 if (pszEnd == NULL) 497 pszEnd = pszStart + strlen(pszEnd); 498 pszModName = new char[pszEnd - pszStart + 1]; 499 memcpy(pszModName, pszStart, pszEnd - pszStart); 500 pszModName[pszEnd - pszStart] = '\0'; 501 } 502 else 503 return !StringCase(pszType, "LIBRARY"); 504 return TRUE; 505 } 506 507 508 /** 509 * Query for the module name. 510 * @returns Success indicator. TRUE / FALSE. 511 * @param pszBuffer Pointer to buffer which to put the name into. 512 */ 423 513 BOOL kFileDef::queryModuleName(char *pszBuffer) 424 514 { 425 char *psz; 426 427 if (pszType != NULL && StringCase(pszType, "LIBRARY")) 428 { 429 psz = pszType + sizeof("LIBRARY") - 1; 430 while (*psz == ' ') 431 psz++; 432 while (*psz != '\0' && *psz != ' ') 433 *pszBuffer++ = *psz++; 434 *pszBuffer = '\0'; 435 } 436 else 515 if (pszModName == NULL) 437 516 return FALSE; 517 518 strcpy(pszBuffer, pszModName); 519 438 520 return TRUE; 439 521 } … … 497 579 498 580 /** 581 * Make a Watcom Linker parameter file addtition of this definition file. 582 * @returns Success indicator. 583 * @param pFile File which we're to write to (append). 584 * Appends at current posistion. 585 * @sketch 586 * @status 587 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 588 * @remark 589 */ 590 BOOL kFileDef::makeWatcomLinkFileAddtion(kFile *pFile) throw(int) 591 { 592 PDEFSEGMENT pSeg; 593 PDEFIMPORT pImp; 594 PDEFEXPORT pExp; 595 pFile->setThrowOnErrors(); 596 597 /* 598 * Write a little remark first to tell that converted stuff starts here. 599 */ 600 pFile->printf("#\n# Directives generated from .DEF-file.\n#\n"); 601 602 /* Format - Module type */ 603 pFile->printf("FORMAT OS2 LX %s %s %s\n", 604 fLibrary ? "DLL" : 605 (fProgram ? (chAppType == pm ? "PM" 606 : (chAppType == fullscreen ? "FULLSCREEN" 607 : "PMCOMPATIBLE")) 608 : (fVirtualDevice ? "VIRTDEVICE" 609 : "PHYSDEVICE" )), 610 fLibrary ? (fInitGlobal ? "INITGLOBAL" : "INITINSTANCE") : "", 611 fLibrary ? (fTermGlobal ? "TERMGLOBAL" : "TERMINSTANCE") : ""); 612 613 614 /* Module name */ 615 if (pszModName) 616 pFile->printf("OPTION MODNAME=%s\n", pszModName); 617 618 /* Description */ 619 if (pszDescription) 620 pFile->printf("OPTION DESCRIPTION '%s'\n", pszDescription); 621 622 /* Base */ 623 if (pszBase) 624 pFile->printf("OPTION OFFSET=%s\n", pszBase); 625 626 /* Stub */ 627 if (pszStub) 628 pFile->printf("OPTION STUB='%s'\n", pszStub); 629 630 /* Old */ 631 if (pszOld) 632 pFile->printf("OPTION OLDLIBRARY=%s\n", pszOld); 633 634 /* Protected mode */ 635 if (pszProtmode) 636 pFile->printf("OPTION PROTMODE\n", pszProtmode); 637 638 /* Stacksize */ 639 if (pszStackSize) 640 pFile->printf("OPTION STACK=%s\n", pszStackSize); 641 642 /* HeapSize */ 643 if (pszHeapSize) 644 pFile->printf("OPTION HEAPSIZE=%s\n", pszHeapSize); 645 646 /* Code - not supported */ 647 648 /* Data - not supported */ 649 650 /* 651 * Segments. 652 */ 653 pSeg = pSegments; 654 while (pSeg != NULL) 655 { 656 pFile->printf("SEGMENT %s\n", pSeg->psz); 657 pSeg = pSeg->pNext; 658 } 659 660 /* 661 * Imports. 662 */ 663 pImp = pImports; 664 while (pImp != NULL) 665 { 666 if (pImp->pszName == NULL) 667 pFile->printf("IMPORT '%s' '%s'.%d\n", pImp->pszIntName, pImp->pszDll, pImp->ulOrdinal); 668 else 669 pFile->printf("IMPORT '%s' '%s'.'%s'\n", pImp->pszIntName, pImp->pszDll, pImp->pszName); 670 pImp = pImp->pNext; 671 } 672 673 /* 674 * Exports. 675 */ 676 pExp = pExports; 677 while (pExp != NULL) 678 { 679 pFile->printf("EXPORT '%s'", pExp->pszName); 680 if (pExp->ulOrdinal != ~0UL) 681 pFile->printf(".%d", pExp->ulOrdinal); 682 if (pExp->pszIntName) 683 pFile->printf("='%s'", pExp->pszIntName); 684 if (pExp->fResident) 685 pFile->printf(" RESIDENT"); 686 if (pExp->cParam != ~0UL) 687 pFile->printf(" %d", pExp->cParam * 2); /* .DEFs this is number of words. Watcom should have bytes. */ 688 pFile->printf("\n"); 689 pExp = pExp->pNext; 690 } 691 692 return TRUE; 693 } 694 695 696 697 698 /** 499 699 * Removes '"' and ''' at start and end of the string. 500 700 * @returns pszStr! … … 514 714 return pszStr; 515 715 } 716 717 718 /** 719 * Upcases a char. 720 * @returns Upper case of the char given in ch. 721 * @param ch Char to capitalize. 722 */ 723 inline char upcase(char ch) 724 { 725 return ch >= 'a' && ch <= 'z' ? (char)(ch - ('a' - 'A')) : ch; 726 } 727 728 729 /** 730 * Searches for a substring in a string. 731 * @returns Pointer to start of substring when found, NULL when not found. 732 * @param pszStr String to be searched. 733 * @param pszSubStr String to be searched. 734 * @remark Depends on the upcase function. 735 */ 736 static char *stristr(const char *pszStr, const char *pszSubStr) 737 { 738 int cchSubStr = strlen(pszSubStr); 739 int i = 0; 740 741 while (*pszStr != '\0' && i < cchSubStr) 742 { 743 i = 0; 744 while (i < cchSubStr && pszStr[i] != '\0' && 745 (upcase(pszStr[i]) == upcase(pszSubStr[i]))) 746 i++; 747 pszStr++; 748 } 749 750 return (char*)(*pszStr != '\0' ? pszStr - 1 : NULL); 751 } 752 -
trunk/tools/common/kFileDef.h
r824 r4402 51 51 char *pszIntName; 52 52 BOOL fResident; 53 ULONGcParam;53 unsigned long cParam; 54 54 struct _DefExport *pNext; 55 55 } DEFEXPORT, *PDEFEXPORT; … … 66 66 /**@cat pointers to different sections */ 67 67 char *pszType; 68 BOOL fProgram; 69 BOOL fLibrary; 70 BOOL fPhysicalDevice; 71 BOOL fVirtualDevice; 72 BOOL fInitInstance; 73 BOOL fTermInstance; 74 BOOL fInitGlobal; 75 BOOL fTermGlobal; 76 char *pszModName; 77 char chAppType; 78 68 79 char *pszBase; 69 80 char *pszCode; … … 83 94 84 95 /**@cat internal functions */ 85 void read( FILE *phFile) throw (int);86 char *readln( FILE *phFile, char *pszBuffer, int cbBuffer) throw (int);96 void read(kFile *pFile) throw (int); 97 char *readln(kFile *pFile, char *pszBuffer, int cbBuffer) throw (int); 87 98 BOOL isKeyword(const char *psz); 99 BOOL setModuleName(void); 88 100 89 101 public: 90 102 /**@cat Constructor/Destructor */ 91 kFileDef( FILE *phFile) throw(int);103 kFileDef(kFile *pFile) throw(int); 92 104 virtual ~kFileDef(); 93 105 … … 97 109 BOOL findNextExport(PEXPORTENTRY pExport); 98 110 BOOL isDef() const { return TRUE;} 111 char const *queryModuleName(void) const { return pszModName; } 99 112 char const *queryType(void) const { return pszType; } 100 113 char const *queryBase(void) const { return pszBase; } … … 108 121 char const *queryStackSize(void) const { return pszStackSize; } 109 122 char const *queryStub(void) const { return pszStub; } 123 124 /**@cat Operations */ 125 BOOL makeWatcomLinkFileAddtion(kFile *pFile) throw(int); 126 127 enum {fullscreen = 0, pmvio = 2, pm = 3, unknown = 255}; 110 128 }; 111 129 -
trunk/tools/common/makefile
r4358 r4402 1 # $Id: makefile,v 1. 6 2000-10-02 04:01:40bird Exp $1 # $Id: makefile,v 1.7 2000-10-03 05:42:39 bird Exp $ 2 2 3 3 # … … 24 24 25 25 26 needed: commonicc.lib 26 needed: commonicc.lib $(PDWIN32_TOOLS)\kDef2Wat.exe 27 27 28 28 … … 39 39 @$(MAKE_CMD) OMF=1 -f makefile.gcc 40 40 41 kDump.exe: dummy 41 42 $(PDWIN32_TOOLS)\kDump.exe $(OBJDIR)\kDump.exe kDump.exe: dummy 42 43 -@echo $@ 43 @$(MAKE_CMD) -f makefile.icc kDump.exe 44 @$(MAKE_CMD) -f makefile.icc $@ 45 46 47 $(PDWIN32_TOOLS)\kDef2Wat.exe $(OBJDIR)\kDef2Wat.exe kDef2Wat.exe: dummy 48 -@echo $@ 49 @$(MAKE_CMD) -f makefile.icc $@ 44 50 45 51 -
trunk/tools/common/makefile.icc
r4358 r4402 1 # $Id: makefile.icc,v 1.1 1 2000-10-02 04:01:40 bird Exp $1 # $Id: makefile.icc,v 1.12 2000-10-03 05:42:40 bird Exp $ 2 2 3 3 # … … 10 10 11 11 # Directory macros. 12 PDWIN32_INCLUDE = ..\..\include13 PDWIN32_BIN = ..\..\bin\$(OBJDIR)14 PDWIN32_LIB = ..\..\lib15 PDWIN32_TOOLS = ..\bin16 12 PDWIN32_TCOMMON = ..\common 17 13 … … 24 20 25 21 # Compiler, tools, and interference rules. 26 !include $(PDWIN32_INCLUDE)\pdwin32.mk22 !include ..\..\include\pdwin32.mk 27 23 28 24 29 25 # Addjust common definitions... 30 26 CFLAGS = $(CFLAGS) -Wall+ppt-ppc-inl-cnv-gnr-vft- 31 CXXFLAGS = $(CXXFLAGS) -Wall+ppt-ppc-inl-cnv-gnr-vft- 27 CXXFLAGS = $(CXXFLAGS) -Wall+ppt-ppc-inl-cnv-gnr-vft- -Gx- 32 28 33 29 … … 61 57 62 58 # kDump 63 kDump.exe : $(OBJDIR)\kDump.exe59 kDump.exe $(PDWIN32_TOOLS)\kDump.exe: $(OBJDIR)\kDump.exe 64 60 $(CP) $** $@ 65 61 66 62 $(OBJDIR)\kDump.exe: commonicc.lib $(OBJDIR)\kDump.obj 67 63 $(LD) $(LDFLAGS) -Fe$@ $** $(RTLLIB) OS2386.LIB 64 65 # kDef2Wat.exe 66 kDef2Wat.exe $(PDWIN32_TOOLS)\kDef2Wat.exe: $(OBJDIR)\kDef2Wat.exe 67 $(CP) $** $@ 68 69 $(OBJDIR)\kDef2Wat.exe: commonicc.lib $(OBJDIR)\kDef2Wat.obj 70 $(LD) $(LDFLAGS) -Fe$@ $** $(RTLLIB) OS2386.LIB 71 68 72 69 73 -
trunk/tools/impdef/ImpDef.cpp
r867 r4402 1 /* $Id: ImpDef.cpp,v 1. 3 1999-09-08 07:30:09bird Exp $ */1 /* $Id: ImpDef.cpp,v 1.4 2000-10-03 05:42:41 bird Exp $ */ 2 2 /* 3 3 * ImpDef - Create export file which use internal names and ordinals. … … 15 15 #include <stdlib.h> 16 16 #include "ImpDef.h" 17 #include "kFile.h" 17 18 #include "kFileFormatBase.h" 18 19 #include "kFileDef.h" … … 75 76 options.ulOrdStartInternalFunctions = atol(&argv[argi][3]); 76 77 if (options.ulOrdStartInternalFunctions == 0) 77 fprintf(stderr,"warning: internal functions starts at ordinal 0!\n");78 kFile::StdErr.printf("warning: internal functions starts at ordinal 0!\n"); 78 79 } 79 80 else 80 81 { 81 fprintf(stderr,"incorrect parameter -I:<ord>. (argi=%d, argv[argi]=%s)\n", argi, argv[argi]);82 kFile::StdErr.printf("incorrect parameter -I:<ord>. (argi=%d, argv[argi]=%s)\n", argi, argv[argi]); 82 83 fFatal = TRUE; 83 84 } … … 96 97 97 98 default: 98 fprintf(stderr,"incorrect parameter. (argi=%d, argv[argi]=%s)\n", argi, argv[argi]);99 kFile::StdErr.printf("incorrect parameter. (argi=%d, argv[argi]=%s)\n", argi, argv[argi]); 99 100 fFatal = TRUE; 100 101 break; … … 109 110 else 110 111 { 111 fprintf(stderr,"To many files are specified!\n");112 kFile::StdErr.printf("To many files are specified!\n"); 112 113 fFatal = TRUE; 113 114 } … … 119 120 { 120 121 fFatal = TRUE; 121 fprintf(stderr,"Missing input file.\n");122 kFile::StdErr.printf("Missing input file.\n"); 122 123 } 123 124 else if (pszOutput == NULL) 124 125 { 125 126 fFatal = TRUE; 126 fprintf(stderr,"Missing output file.\n");127 kFile::StdErr.printf("Missing output file.\n"); 127 128 } 128 129 … … 141 142 static void syntax(void) 142 143 { 143 printf("\n" 144 "ImpDef - Creates internal import definition file\n" 145 "------------------------------------------------\n" 146 "syntax: ImpDef.exe [-h|-?] [-S] <infile> <outfile>\n" 147 " -h or -? Syntax help. (this)\n" 148 " -F<[+]|-> Fix! Export int.name for int.functions. default: F+\n" 149 " -I:<ord> Start of internal function. default: I:%d\n" 150 " -O<[+]|-> Remove OS2 prefix on APIs. default: O-\n" 151 " -S<[+]|-> Similar to exported name. default: S+\n" 152 " infile Name of input file\n" 153 " outfile Name of output file\n" 154 "\n" 155 "Notes:\n" 156 " -S+ only works on stdcall functions (having '@' in the internal name).\n" 157 " -S+ takes the '_' and the '@..' parts from the internal name and adds it\n" 158 " to the exported name. This way the OS2 prefix is removed.\n" 159 " -O+ has no effect on stdcall functions when -S+ is set. -S+ has higher\n" 160 " precedence than -O+.\n" 161 " -O+ only removes the OS2 prefix from internal names.\n", 162 ORD_START_INTERNAL_FUNCTIONS 163 ); 144 kFile::StdOut.printf( 145 "\n" 146 "ImpDef - Creates internal import definition file\n" 147 "------------------------------------------------\n" 148 "syntax: ImpDef.exe [-h|-?] [-S] <infile> <outfile>\n" 149 " -h or -? Syntax help. (this)\n" 150 " -F<[+]|-> Fix! Export int.name for int.functions. default: F+\n" 151 " -I:<ord> Start of internal function. default: I:%d\n" 152 " -O<[+]|-> Remove OS2 prefix on APIs. default: O-\n" 153 " -S<[+]|-> Similar to exported name. default: S+\n" 154 " infile Name of input file\n" 155 " outfile Name of output file\n" 156 "\n" 157 "Notes:\n" 158 " -S+ only works on stdcall functions (having '@' in the internal name).\n" 159 " -S+ takes the '_' and the '@..' parts from the internal name and adds it\n" 160 " to the exported name. This way the OS2 prefix is removed.\n" 161 " -O+ has no effect on stdcall functions when -S+ is set. -S+ has higher\n" 162 " precedence than -O+.\n" 163 " -O+ only removes the OS2 prefix from internal names.\n", 164 ORD_START_INTERNAL_FUNCTIONS 165 ); 164 166 } 165 167 … … 179 181 static long processFile(const char *pszInput, const char *pszOutput, const POPTIONS pOptions) 180 182 { 181 FILE *phInput;182 FILE *phOutput;183 183 long lRc = 0; 184 184 185 phInput = fopen(pszInput, "rb");186 if (phInput != NULL)187 {185 try 186 { 187 kFile Input(pszInput); 188 188 try 189 189 { 190 kFileDef DefFile(phInput); 191 phOutput = fopen(pszOutput, "w"); 192 if (phOutput != NULL) 190 kFileDef DefFile(&Input); 191 try 193 192 { 194 193 EXPORTENTRY export; 194 kFile Output(pszOutput, FALSE); 195 195 196 196 /* generate LIBRARY line */ 197 fputs(";Internal export definition file - autogenerated by ImpDef.", phOutput); 198 fputc('\n', phOutput); 199 fputs(DefFile.queryType(), phOutput); 200 fputc('\n', phOutput); 197 Output.printf( 198 ";Internal export definition file - autogenerated by ImpDef.\n" 199 "%s\n", 200 DefFile.queryType()); 201 202 /* Description line */ 201 203 if (DefFile.queryDescription()) 202 { 203 fputs(DefFile.queryDescription(), phOutput); 204 fputc('\n', phOutput); 205 } 204 Output.printf("DESCRIPTION %s\n", DefFile.queryDescription()); 205 206 /* Exports */ 206 207 if (DefFile.findFirstExport(&export)) 207 208 { 208 fputs("EXPORTS\n", phOutput);209 Output.printf("EXPORTS\n"); 209 210 do 210 211 { … … 215 216 if (export.achName[0] == '\0') 216 217 { 217 fprintf(stderr, "Warning export name is missing.\n"); 218 fprintf(stderr, "info:\texport.achIntName=%s\n\texport.achName=%s\n\texport.ulOrdinal=%ld\n", export.achIntName, export.achName, export.ulOrdinal); 218 kFile::StdErr.printf( 219 "Warning export name is missing.\n" 220 "info:\texport.achIntName=%s\n\texport.achName=%s\n\texport.ulOrdinal=%ld\n", 221 export.achIntName, export.achName, export.ulOrdinal); 219 222 continue; 220 223 } 221 224 if (export.ulOrdinal == ~0UL) 222 225 { 223 fprintf(stderr, "warning: export is missing ordinal value. Export is ignored\n"); 224 fprintf(stderr, "info:\texport.achIntName=%s\n\texport.achName=%s\n\texport.ulOrdinal=%ld\n", export.achIntName, export.achName, export.ulOrdinal); 226 kFile::StdErr.printf( 227 "warning: export is missing ordinal value. Export is ignored\n" 228 "info:\texport.achIntName=%s\n\texport.achName=%s\n\texport.ulOrdinal=%ld\n", 229 export.achIntName, export.achName, export.ulOrdinal); 225 230 continue; 226 231 } … … 229 234 pszName = generateExportName(&export, &szName[0], pOptions); 230 235 231 fprintf(phOutput," %-*s @%ld\n", 40, pszName, export.ulOrdinal);236 Output.printf(" %-*s @%ld\n", 40, pszName, export.ulOrdinal); 232 237 } while (DefFile.findNextExport(&export)); 233 238 } 234 fclose(phOutput); 235 } 236 else 237 { 238 fprintf(stderr, "error creating output file, '%s'\n", pszOutput); 239 } 240 catch (int errorcode) 241 { 242 kFile::StdErr.printf("error creating output file, '%s', errorcode 0x%x\n", pszOutput, errorcode); 239 243 lRc = -4; 240 244 } … … 242 246 catch (int errorcode) 243 247 { 244 fprintf(stderr,"%s is not a valid def file, errorcode 0x%x\n", pszInput, errorcode);248 kFile::StdErr.printf("%s is not a valid def file, errorcode 0x%x\n", pszInput, errorcode); 245 249 lRc = -3; 246 250 } 247 fclose(phInput); 248 } 249 else 250 { 251 fprintf(stderr, "error openining inputfile, '%s'\n", pszInput); 251 } 252 catch (int errorcode) 253 { 254 kFile::StdErr.printf( "error openining inputfile, '%s', errorcode 0x%x\n", pszInput, errorcode); 252 255 lRc = -2; 253 256 }
Note:
See TracChangeset
for help on using the changeset viewer.