                                Source Listing                  24-APR-1996 13:22:53    DEC C T4.1-FT2                      Page   1
                                                                 6-DEC-1995 09:57:26    WORK$:[DAVENPORT.RTL]UTIL.C;4

	      1 
	      2 /******************************************************************************
	      3  *
	      4  * Util.C
	      5  *
	      6  ******************************************************************************/
	      7 
	      8 /******************************************************************************
	      9  *
	     10  * Headers
	     11  *
	     12  ******************************************************************************/
	     13 
	     14 #include <stdio.h>
	    396 #include <ctype.h>
	    627 
	    628 #include "intrinsic.h"
	    659 #include "util.h"
	    673 
	    674 /******************************************************************************
	    675  *
	    676  * Local Constants and Macros
	    677  *
	    678  ******************************************************************************/
	    679 
	    680 /******************************************************************************
	    681  *
	    682  * Local Declarations
	    683  *
	    684  ******************************************************************************/
	    685 
	    686 /******************************************************************************
	    687  *
	    688  * Local Prototypes
	    689  *
	    690  ******************************************************************************/
	    691 
	    692 /******************************************************************************
	    693  *
	    694  * ParseFilename
	    695  *
	    696  ******************************************************************************/
	    697 
	    698 #ifdef VMS
	    699 extern Status ParseFilename (String source, String path, String file,
	    700                              String type)
	    701 #else
       X    702 extern Status ParseFilename (source, path, file, type)
       X    703 
       X    704   String source;
       X    705   String path;
       X    706   String file;
       X    707   String type;
       X    708 #endif
	    709 
	    710 {
	    711   Buffer buff;

                                Source Listing                  24-APR-1996 13:22:53    DEC C T4.1-FT2                      Page   2
                                                                 6-DEC-1995 09:57:26    WORK$:[DAVENPORT.RTL]UTIL.C;4

	    712   String c1;
	    713   String c2;
	    714   String c3;
	    715 
	    716   /* initialize */
	    717   if (path) strcpy (path, "");
	    718   if (file) strcpy (file, "");
	    719   if (type) strcpy (type, "");
	    720 
	    721   strcpy (buff, source);
	    722   c1 = (String) strrchr (buff, '.');
	    723   if (c1) {
	    724     if (type) strcpy (type, c1 + 1);
	    725     *c1 = '\0';
	    726   }
	    727 
	    728   c2 = (String) strrchr (buff, ']');
	    729   if (!c2) c2 = (String) strrchr (buff,':');
	    730   if (c2) {
	    731     if (file) strcpy (file, c2 + 1);
	    732     *(c2 + 1) = '\0';
	    733     if (path) strcpy (path, buff);
	    734   }
	    735   else {
	    736     if ((c1) && (c1 != &buff[0])) {
	    737       if (file) strcpy (file, buff);
	    738     }
	    739     else if (strlen(buff)) {
	    740       if (file) strcpy (file, buff);
	    741     }
	    742   }
	    743 
	    744   /* done */
	    745   return (Success);
	    746 }
	    747 
	    748 /******************************************************************************
	    749  *
	    750  * BuildReplaceFilename
	    751  *
	    752  ******************************************************************************/
	    753 
	    754 #ifdef VMS
	    755 extern Status BuildReplaceFilename (String source, String path, String file, 
	    756                                     String type, String output)
	    757 #else
       X    758 extern Status BuildReplaceFilename (source, path, file, type, output)
       X    759 
       X    760   String source;
       X    761   String path;
       X    762   String file;
       X    763   String type;
       X    764   String output;
       X    765 #endif
	    766 
	    767 {
	    768   Buffer oldPath, oldFile, oldType;

                                Source Listing                  24-APR-1996 13:22:53    DEC C T4.1-FT2                      Page   3
                                                                 6-DEC-1995 09:57:26    WORK$:[DAVENPORT.RTL]UTIL.C;4

	    769 
	    770   ParseFilename (source, oldPath, oldFile, oldType);
	    771 
	    772   if (path) strcpy (oldPath, path);
	    773   if (file) strcpy (oldFile, file);
	    774   if (type) strcpy (oldType, type);
	    775 
	    776   if (strlen(oldType) != 0)
	    777     sprintf (output, "%s%s.%s", oldPath, oldFile, oldType);
	    778   else
	    779     sprintf (output, "%s%s", oldPath, oldFile);
	    780 
	    781   /* done */
	    782   return (Success);
	    783 }
	    784 
	    785 /******************************************************************************
	    786  *
	    787  * BuildDefaultFilename
	    788  *
	    789  ******************************************************************************/
	    790 
	    791 #ifdef VMS
	    792 extern Status BuildDefaultFilename (String source, String path, String file, 
	    793                                     String type, String output)
	    794 #else
       X    795 extern Status BuildDefaultFilename (source, path, file, type, output)
       X    796 
       X    797   String source;
       X    798   String path;
       X    799   String file;
       X    800   String type;
       X    801   String output;
       X    802 #endif
	    803 
	    804 {
	    805   Buffer oldPath, oldFile, oldType;
	    806 
	    807   ParseFilename (source, oldPath, oldFile, oldType);
	    808 
	    809   if (!strlen(oldPath)) strcpy (oldPath, path);
	    810   if (!strlen(oldFile)) strcpy (oldFile, file);
	    811   if (!strlen(oldType)) strcpy (oldType, type);
	    812 
	    813   if (strlen(oldType) != 0)
	    814     sprintf (output, "%s%s.%s", oldPath, oldFile, oldType);
	    815   else
	    816     sprintf (output, "%s%s", oldPath, oldFile);
	    817 
	    818   /* done */
	    819   return (Success);
	    820 }


Command Line
------- ----


                                Source Listing                  24-APR-1996 13:22:53    DEC C T4.1-FT2                      Page   4
                                                                 6-DEC-1995 09:57:26    WORK$:[DAVENPORT.RTL]UTIL.C;4

CC /NOANSI_ALIAS/ASSUME=(ACCURACY_SENSITIVE,ALIGNED_OBJECTS,WRITABLE_STRING_LITERALS)
/DEBUG=(SYMBOLS,TRACEBACK)/ENDIAN=LITTLE/EXTERN_MODEL=RELAXED_REFDEF/FLOAT=(
G_FLOAT)/GRANULARITY=QUADWORD/INSTRUCTION_SET=FLOATING_POINT/L_DOUBLE_SIZE=128
/LIST/NOMACHINE_CODE/MEMBER_ALIGNMENT/NAMES=UPPERCASE/NESTED_INCLUDE_DIRECTORY=INCLUDE_FILE
/OBJECT/NOOPTIMIZE/PREFIX=(ALL_ENTRIES)/PSECT_MODEL=NOMULTILANGUAGE/ROUNDING_MODE=NEAREST
/SHOW=(HEADER,SOURCE)/SIGNED_CHAR/STANDARD=VAXC/REENTRANCY=TOLERANT/WARNINGS
