- Timestamp:
- Oct 8, 1999, 2:28:51 AM (26 years ago)
- Location:
- trunk/src/win32k
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k
-
Property svn:ignore
set to
makefile.inc
.depend
-
Property svn:ignore
set to
-
trunk/src/win32k/Makefile
r1120 r1178 1 1 ################################################################################ 2 # $Id: Makefile,v 1. 4 1999-10-04 10:39:42bird Exp $2 # $Id: Makefile,v 1.5 1999-10-08 00:28:51 bird Exp $ 3 3 # 4 4 # Copyright 1998-1999 knut st. osmundsen … … 282 282 ################################################################################ 283 283 depend: fastdep.exe 284 @fastdep -oObject $(CINCLUDES) misc\*.c* ldr\*.c* dev32\*.c* dev16\*.c* pe2lx\*.c* -oinclude\*.h pe2lx\*.h*284 @fastdep -oObject $(CINCLUDES) misc\*.c* ldr\*.c* dev32\*.c* dev16\*.c* pe2lx\*.c* include\*.h pe2lx\*.h* 285 285 286 286 fastdep.exe: fastdep.c -
trunk/src/win32k/fastdep.c
r909 r1178 1 1 /* 2 * Fast dependan ds. (Fase= Quick and Dirty!)2 * Fast dependants. (Fast = Quick and Dirty!) 3 3 * 4 4 * Copyright (c) 1999 knut st. osmundsen … … 6 6 */ 7 7 8 /******************************************************************************* 9 * Defined Constants And Macros * 10 *******************************************************************************/ 8 11 #define INCL_DOSERRORS 9 12 #define INCL_FILEMGR 13 14 /******************************************************************************* 15 * Header Files * 16 *******************************************************************************/ 10 17 #include <os2.h> 11 18 #include <stdio.h> … … 13 20 #include <string.h> 14 21 15 /*@Global*********************************************************************** 22 23 /******************************************************************************* 24 * Structures and Typedefs * 25 *******************************************************************************/ 26 typedef struct _Options 27 { 28 const char * pszInclude; 29 const char * pszExclude; 30 BOOL fExcludeAll; 31 const char * pszObjectDir; 32 BOOL fObjRule; 33 BOOL fNoObjectPath; 34 } OPTIONS, *POPTIONS; 35 36 37 /******************************************************************************* 16 38 * Global Variables * 17 39 *******************************************************************************/ 18 40 static const char pszDefaultDepFile[] = ".depend"; 19 41 20 21 /*@IntFunc********************************************************************** 42 /******************************************************************************* 22 43 * Internal Functions * 23 44 *******************************************************************************/ 24 static int makeDependent(FILE *phDep, const char *pszSource, const char *pszInclude, const char *pszObjectDir); 45 static void syntax(void); 46 static int makeDependent(FILE *phDep, const char *pszFilename, POPTIONS pOptions); 25 47 static int getFullIncludename(char *pszFilename, const char *pszInclude); 48 49 /* file operations */ 50 char *filePath(const char *pszFilename, char *pszBuffer); 51 char *filePathSlash(const char *pszFilename, char *pszBuffer); 52 char *fileName(const char *pszFilename, char *pszBuffer); 53 char *fileNameNoExt(const char *pszFilename, char *pszBuffer); 54 char *fileExt(const char *pszFilename, char *pszBuffer); 55 56 char *pathlistFindFile(const char *pszPathList, const char *pszFilename, char *pszBuffer); 26 57 27 58 … … 47 78 int argi = 1; 48 79 const char *pszDepFile = pszDefaultDepFile; 49 char szObjectDir[CCHMAXPATH] = {0}; 80 81 static char szObjectDir[CCHMAXPATH] = {0}; 50 82 static char szInclude[32768] = ";"; 83 static char szExclude[32768] = ";"; 84 85 OPTIONS options = 86 { 87 szInclude, /* pszInclude */ 88 szExclude, /* pszExclude */ 89 FALSE, /* fExcludeAll */ 90 szObjectDir, /* pszObjectDir */ 91 TRUE, /* fObjRule */ 92 FALSE /* fNoObjectPath */ 93 }; 51 94 52 95 /* look for depend filename option "-d <filename>" */ … … 62 105 while (argi < argc) 63 106 { 64 ULONG ulRc;65 FILEFINDBUF3 filebuf;66 HDIR hDir = HDIR_CREATE;67 ULONG ulFound = 1;68 69 107 if (argv[argi][0] == '-' || argv[argi][0] == '/') 70 108 { … … 72 110 switch (argv[argi][1]) 73 111 { 112 case 'E': /* list of paths. If a file is found in one of these directories the */ 113 case 'e': /* filename will be used without the directory path. */ 114 /* Eall<[+]|-> ? */ 115 if (strlen(&argv[argi][1]) <= 5 && strnicmp(&argv[argi][1], "Eall", 4) == 0) 116 { 117 options.fExcludeAll = argv[argi][5] != '-'; 118 break; 119 } 120 /* path or path list */ 121 if (strlen(argv[argi]) > 2) 122 strcat(szExclude, &argv[argi][2]); 123 else 124 { 125 strcat(szExclude, argv[argi+1]); 126 argi++; 127 } 128 if (szExclude[strlen(szExclude)-1] != ';') 129 strcat(szExclude, ";"); 130 break; 131 74 132 case 'I': /* optional include path. This has precedence over the INCLUDE environment variable. */ 75 133 case 'i': … … 85 143 break; 86 144 87 case 'o': /* object base directory */ 145 case 'n': /* no object path , -N<[+]|-> */ 146 case 'N': 147 if (strlen(argv[argi]) <= 1+1+1) 148 options.fNoObjectPath = argv[argi][2] != '-'; 149 else 150 { 151 fprintf(stderr, "error: invalid parameter!, '%s'\n", argv[argi]); 152 return -1; 153 } 154 break; 155 156 case 'o': /* object base directory or Obr<[+]|-> */ 88 157 case 'O': 89 strcpy(szObjectDir, argv[argi]+2); 158 if (strlen(&argv[argi][1]) <= 4 && strnicmp(&argv[argi][1], "Obr", 3) == 0) 159 { 160 options.fObjRule = argv[argi][4] != '-'; 161 break; 162 } 163 164 /* path */ 165 if (strlen(argv[argi]) > 2) 166 strcpy(szObjectDir, argv[argi]+2); 167 else 168 { 169 strcpy(szObjectDir, argv[argi+1]); 170 argi++; 171 } 172 if (szObjectDir[strlen(szObjectDir)-1] != '\\' 173 && szObjectDir[strlen(szObjectDir)-1] != '/' 174 ) 175 strcat(szObjectDir, "\\"); 90 176 break; 177 178 case 'h': 179 case 'H': 180 case '?': 181 syntax(); 182 return 1; 91 183 92 184 default: … … 97 189 } 98 190 else 99 { 100 /* not a parameter! */ 191 { /* not a parameter! */ 192 ULONG ulRc; 193 FILEFINDBUF3 filebuf; 194 HDIR hDir = HDIR_CREATE; 195 ULONG ulFound = 1; 196 101 197 ulRc = DosFindFirst(argv[argi], &hDir, 102 198 FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_ARCHIVED, … … 130 226 131 227 strcat(szSource, filebuf.achName); 132 rc -= makeDependent(phDep, &szSource[0], & szInclude[0], &szObjectDirTmp[0]);228 rc -= makeDependent(phDep, &szSource[0], &options); 133 229 ulRc = DosFindNext(hDir, &filebuf, sizeof(filebuf), &ulFound); 134 135 230 } 136 231 DosFindClose(hDir); … … 149 244 150 245 246 /** 247 * Displays the syntax description for this util. 248 * @status completely implemented. 249 * @author knut st. osmundsen 250 */ 251 static void syntax(void) 252 { 253 printf( 254 "FastDep v0.1\n" 255 "Quick and dirty dependant scanner. Creates a makefile readable depend file.\n" 256 "\n" 257 "Syntax: FastDep [-d <outputfn>] [-e <excludepath>] [-eall<[+]|->]\n" 258 " [-i <include>] [-n<[+]|->] [-o <objdir>] [-obr<[+]|->]\n" 259 "\n" 260 " -d <outputfn> Output filename. Default: %s\n" 261 " -e excludepath Exclude paths. If a filename is found in any\n" 262 " of these paths only the filename is used, not\n" 263 " the path+filename (which is default).\n" 264 " -eall<[+]|-> -eall+: No path are added to the filename.\n" 265 " -eall-: The filename is appended the include path\n" 266 " was found in.\n" 267 " Default: eall-\n" 268 " -i <include> Additional include paths. INCLUDE is searched after this.\n" 269 " -n<[+]|-> No path for object files in the rules.\n" 270 " -o <objdir> Path were object files are placed. This path replaces the\n" 271 " entire filename path\n" 272 " -obr<[+]|-> -obr+: Object rule.\n" 273 " -obr-: No object rule, rule for source filename is generated.\n" 274 "\n", 275 pszDefaultDepFile 276 ); 277 } 278 151 279 152 280 /** 153 281 * Generates depend info on this file, and fwrites it to phDep. 154 282 * @returns 155 * @param phDep Pointer to file struct for outfile. 156 * @param pszSource Name of source file. 157 * @param pszIncldue Pointer to additional include path. 158 * @param pszObjectDir Pointer to object directory. 159 */ 160 static int makeDependent(FILE *phDep, const char *pszSource, const char *pszInclude, const char *pszObjectDir) 283 * @param phDep Pointer to file struct for outfile. 284 * @param pszFilename Pointer to source filename. 285 * @param pOptions Pointer to options struct. 286 * @status completely implemented. 287 * @author knut st. osmundsen 288 */ 289 static int makeDependent(FILE *phDep, const char *pszFilename, POPTIONS pOptions) 161 290 { 162 291 FILE *phFile; 163 292 164 phFile = fopen(psz Source, "r");293 phFile = fopen(pszFilename, "r"); 165 294 if (phFile != NULL) 166 295 { 167 296 char szBuffer[4096]; /* max line lenght */ 168 int k = strlen(psz Source) - 1;297 int k = strlen(pszFilename) - 1; 169 298 int l; 299 int iLine; 300 170 301 /**********************************/ 171 302 /* print file name to depend file */ 172 303 /**********************************/ 173 while (pszSource[k] != '.' && k >= 0) k--; 174 l = k; 175 while (pszSource[l] != '\\' && pszSource[l] != '/' && l >= 0) 176 l--; 177 if (stricmp(&pszSource[k], ".c") == 0 178 || stricmp(&pszSource[k], ".cpp") == 0 179 || stricmp(&pszSource[k], ".asm") == 0 180 ) 181 fprintf(phDep, "%s%.*s.obj:%*s %s", 182 pszObjectDir, 183 k - l, &pszSource[l], 184 (k - l + strlen(pszObjectDir)) + 4 > 20 ? 0 : 20 - (k - l + strlen(pszObjectDir)) - 4, "", 185 pszSource); 186 else if (stricmp(&pszSource[k], ".rc") == 0) 187 fprintf(phDep, "%s%.*s.res:%*s %s", 188 pszObjectDir, 189 k - l, &pszSource[l], 190 (k - l + strlen(pszObjectDir)) + 4 > 20 ? 0 : 20 - (k - l + strlen(pszObjectDir)) - 4, "", 191 pszSource); 304 if (pOptions->fObjRule) 305 { 306 char szExt[CCHMAXPATH]; 307 char szObj[CCHMAXPATH]; 308 309 if (pOptions->fNoObjectPath) 310 fileNameNoExt(pszFilename, szObj); 311 else if (*pOptions->pszObjectDir != '\0') 312 { 313 fileNameNoExt(pszFilename, szExt); 314 strcpy(szObj, pOptions->pszObjectDir); 315 strcat(szObj, szExt); 316 } 317 else 318 { 319 filePathSlash(pszFilename, szObj); 320 fileNameNoExt(pszFilename, szObj + strlen(szObj)); 321 } 322 323 fileExt(pszFilename, szExt); 324 if (!stricmp(szExt, "c") || !stricmp(szExt, "sqc") 325 || !stricmp(szExt, "cpp") || !stricmp(szExt, "asm") 326 || !stricmp(szExt, "rc")) 327 { 328 if (!stricmp(szExt, "rc")) 329 strcat(szObj, ".res"); 330 else 331 strcat(szObj, ".obj"); 332 fprintf(phDep, "%s:%-*s", szObj, 333 strlen(szObj) > 19 ? 0 : 19 - strlen(szObj), ""); 334 } 335 else 336 fprintf(phDep, "%s:%-*s", pszFilename, 337 strlen(pszFilename) > 19 ? 0 : 19 - strlen(pszFilename), ""); 338 } 192 339 else 193 fprintf(phDep, "%s:%-*s", psz Source, strlen(pszSource) > 20 ? 0 : 20 - strlen(pszSource), "");194 340 fprintf(phDep, "%s:%-*s", pszFilename, 341 strlen(pszFilename) > 19 ? 0 : 19 - strlen(pszFilename), ""); 195 342 196 343 /*******************/ 197 344 /* find dependants */ 198 345 /*******************/ 199 while (!feof(phFile)) 346 iLine = 0; 347 while (!feof(phFile)) /* line loop */ 200 348 { 201 349 if (fgets(szBuffer, sizeof(szBuffer), phFile) != NULL) 202 350 { 203 /* search for #include */351 /* search for #include or RCINCLUDE */ 204 352 int cbLen; 205 353 int i = 0; 206 354 int f = 0; 355 iLine++; 207 356 208 357 cbLen = strlen(szBuffer); … … 210 359 && !(f = (strncmp(&szBuffer[i], "#include", 8) == 0 211 360 || strncmp(&szBuffer[i], "RCINCLUDE", 9) == 0) 212 ) 213 /*&& (szBuffer[i] == ' ' || szBuffer[i] == '\t') */ 361 ) 214 362 ) 215 363 i++; 216 364 217 /* found*/365 /* Found include! */ 218 366 if (f) 219 367 { … … 222 370 while (i < cbLen && !(f = (szBuffer[i] == '"' || szBuffer[i] == '<'))) 223 371 i++; 224 i++; /* skip p'"' or '<' */372 i++; /* skip '"' or '<' */ 225 373 if (f) 226 374 { … … 228 376 /* find end */ 229 377 j = f = 0; 230 while (i + j < cbLen && j < 260 && !(f = (szBuffer[i+j] == '"' || szBuffer[i+j] == '>'))) 378 while (i + j < cbLen && j < CCHMAXPATH && 379 !(f = (szBuffer[i+j] == '"' || szBuffer[i+j] == '>'))) 231 380 j++; 232 381 233 382 if (f) 234 383 { 235 char szFullname[261]; 236 237 /* find include file path */ 238 strncpy(&szFullname[1], &szBuffer[i], j); 239 szFullname[j+1] = '\0'; /* ensure terminatition. */ 240 if (getFullIncludename(&szFullname[1], pszInclude) == 0) 384 char szFullname[CCHMAXPATH]; 385 char *psz; 386 387 /* copy filename */ 388 strncpy(szFullname, &szBuffer[i], j); 389 szFullname[j] = '\0'; /* ensure terminatition. */ 390 391 /* find include file! */ 392 psz = pathlistFindFile(pOptions->pszInclude, szFullname, szBuffer); 393 if (psz == NULL) 394 psz = pathlistFindFile(getenv("INCLUDE"), szFullname, szBuffer); 395 396 if (psz != NULL) 241 397 { 242 szFullname[0] = ' '; /* blank char at begining */ 243 if (fwrite(&szFullname[0], strlen(szFullname), 1, phDep) != 1) 244 fprintf(stderr, "fwrite failed - loc 2\n"); 398 char szBuffer2[CCHMAXPATH]; 399 if (pOptions->fExcludeAll || 400 pathlistFindFile(pOptions->pszExclude, szFullname, szBuffer2) != NULL 401 ) 402 strcpy(szBuffer, szFullname); 403 if (fwrite(" ", 1, 1, phDep) != 1) /* blank */ 404 fprintf(stderr, "fwrite failed 1!\n"); 405 if (fwrite(szBuffer, strlen(szBuffer), 1, phDep) != 1) 406 fprintf(stderr, "fwrite failed 2!\n"); 245 407 } 408 else 409 fprintf(stderr, "%s(%d): warning include file '%s' not found!\n", 410 pszFilename, iLine, szFullname+1); 246 411 } 247 412 } 248 249 413 } 250 414 } … … 256 420 fputs("\n", phDep); 257 421 fclose(phFile); 258 } else 422 } 423 else 259 424 return -1; 260 425 … … 339 504 return -1; 340 505 } 506 507 508 509 /** 510 * Copies the path part (excluding the slash) into pszBuffer and returns 511 * a pointer to the buffer. 512 * If no path is found "" is returned. 513 * @returns Pointer to pszBuffer with path. 514 * @param pszFilename Pointer to readonly filename. 515 * @param pszBuffer Pointer to output Buffer. 516 * @status completely implemented. 517 * @author knut st. osmundsen 518 */ 519 char *filePath(const char *pszFilename, char *pszBuffer) 520 { 521 char *psz = strrchr(pszFilename, '\\'); 522 if (psz == NULL) 523 psz = strrchr(pszFilename, '/'); 524 525 if (psz == NULL) 526 *pszBuffer = '\0'; 527 else 528 { 529 strncpy(pszBuffer, pszFilename, psz - pszFilename - 1); 530 pszBuffer[psz - pszFilename - 1] = '\0'; 531 } 532 533 return pszBuffer; 534 } 535 536 537 /** 538 * Copies the path part including the slash into pszBuffer and returns 539 * a pointer to the buffer. 540 * If no path is found "" is returned. 541 * @returns Pointer to pszBuffer with path. 542 * @param pszFilename Pointer to readonly filename. 543 * @param pszBuffer Pointer to output Buffer. 544 * @status completely implemented. 545 * @author knut st. osmundsen 546 */ 547 char *filePathSlash(const char *pszFilename, char *pszBuffer) 548 { 549 char *psz = strrchr(pszFilename, '\\'); 550 if (psz == NULL) 551 psz = strrchr(pszFilename, '/'); 552 553 if (psz == NULL) 554 *pszBuffer = '\0'; 555 else 556 { 557 strncpy(pszBuffer, pszFilename, psz - pszFilename + 1); 558 pszBuffer[psz - pszFilename + 1] = '\0'; 559 } 560 561 return pszBuffer; 562 } 563 564 565 /** 566 * Copies the path name (with extention) into pszBuffer and returns 567 * a pointer to the buffer. 568 * If no path is found "" is returned. 569 * @returns Pointer to pszBuffer with path. 570 * @param pszFilename Pointer to readonly filename. 571 * @param pszBuffer Pointer to output Buffer. 572 * @status completely implemented. 573 * @author knut st. osmundsen 574 */ 575 char *fileName(const char *pszFilename, char *pszBuffer) 576 { 577 char *psz = strrchr(pszFilename, '\\'); 578 if (psz == NULL) 579 psz = strrchr(pszFilename, '/'); 580 581 strcpy(pszBuffer, psz == NULL ? pszFilename : psz + 1); 582 583 return pszBuffer; 584 } 585 586 587 /** 588 * Copies the name part with out extention into pszBuffer and returns 589 * a pointer to the buffer. 590 * If no name is found "" is returned. 591 * @returns Pointer to pszBuffer with path. 592 * @param pszFilename Pointer to readonly filename. 593 * @param pszBuffer Pointer to output Buffer. 594 * @status completely implemented. 595 * @author knut st. osmundsen 596 */ 597 char *fileNameNoExt(const char *pszFilename, char *pszBuffer) 598 { 599 char *psz = strrchr(pszFilename, '\\'); 600 if (psz == NULL) 601 psz = strrchr(pszFilename, '/'); 602 603 strcpy(pszBuffer, psz == NULL ? pszFilename : psz + 1); 604 605 psz = strrchr(pszBuffer, '.'); 606 if (psz > pszBuffer) /* an extetion on it's own (.depend) is a filename not an extetion! */ 607 *psz = '\0'; 608 609 return pszBuffer; 610 } 611 612 613 /** 614 * Copies the extention part into pszBuffer and returns 615 * a pointer to the buffer. 616 * If no extention is found "" is returned. 617 * The dot ('.') is not included! 618 * @returns Pointer to pszBuffer with path. 619 * @param pszFilename Pointer to readonly filename. 620 * @param pszBuffer Pointer to output Buffer. 621 * @status completely implemented. 622 * @author knut st. osmundsen 623 */ 624 char *fileExt(const char *pszFilename, char *pszBuffer) 625 { 626 char *psz = strrchr(pszFilename, '.'); 627 if (psz != NULL) 628 { 629 if (strchr(psz, '\\') != NULL || strchr(psz, '/') != NULL) 630 *pszBuffer = '\0'; 631 else 632 strcpy(pszBuffer, psz + 1); 633 } 634 else 635 *pszBuffer = '\0'; 636 637 return pszBuffer; 638 } 639 640 641 642 643 /** 644 * Finds a filename in a specified pathlist. 645 * @returns Pointer to a filename consiting of the path part + the given filename. 646 * (pointer into pszBuffer) 647 * NULL if file is not found. ("" in buffer) 648 * @param pszPathList Path list to search for filename. 649 * @parma pszFilename Filename to find. 650 * @parma pszBuffer Ouput Buffer. 651 * @status completely implemented. 652 * @author knut st. osmundsen 653 */ 654 char *pathlistFindFile(const char *pszPathList, const char *pszFilename, char *pszBuffer) 655 { 656 const char *psz = pszPathList; 657 const char *pszNext = NULL; 658 659 *pszBuffer = '\0'; 660 661 if (pszPathList == NULL) 662 return NULL; 663 664 while (*psz != '\0') 665 { 666 /* find end of this path */ 667 pszNext = strchr(psz, ';'); 668 if (pszNext == NULL) 669 pszNext = psz + strlen(psz); 670 671 if (pszNext - psz > 0) 672 { 673 HDIR hDir = HDIR_CREATE; 674 ULONG cFiles = 1UL; 675 FILEFINDBUF3 FileFindBuf; 676 APIRET rc; 677 char szFile[CCHMAXPATH]; 678 679 /* make search statment */ 680 strncpy(szFile, psz, pszNext - psz); 681 szFile[pszNext - psz] = '\0'; 682 if (szFile[pszNext - psz - 1] != '\\' && szFile[pszNext - psz - 1] != '/') 683 strcpy(&szFile[pszNext - psz], "\\"); 684 strcat(szFile, pszFilename); 685 686 /* search for file */ 687 rc = DosFindFirst(szFile, &hDir, FILE_NORMAL, &FileFindBuf, sizeof(FileFindBuf), 688 &cFiles, FIL_STANDARD); 689 DosFindClose(hDir); 690 if (rc == NO_ERROR && cFiles == 1UL) 691 { 692 strncpy(pszBuffer, psz, pszNext - psz); 693 pszBuffer[pszNext - psz] = '\0'; 694 if (pszBuffer[pszNext - psz - 1] != '\\' && pszBuffer[pszNext - psz - 1] != '/') 695 strcpy(&pszBuffer[pszNext - psz], "\\"); 696 strcat(pszBuffer, pszFilename); 697 break; 698 } 699 } 700 701 /* next */ 702 if (*pszNext != ';') 703 break; 704 psz = pszNext + 1; 705 } 706 707 return *pszBuffer == '\0' ? NULL : pszBuffer; 708 } 709
Note:
See TracChangeset
for help on using the changeset viewer.