[1] | 1 | /*DDK*************************************************************************/
|
---|
| 2 | /* */
|
---|
| 3 | /* COPYRIGHT Copyright (C) 1991, 2003 IBM Corporation */
|
---|
| 4 | /* */
|
---|
| 5 | /* The following IBM OS/2 source code is provided to you solely for */
|
---|
| 6 | /* the purpose of assisting you in your development of OS/2 device */
|
---|
| 7 | /* drivers. You may use this code in accordance with the IBM License */
|
---|
| 8 | /* Agreement provided in the IBM Developer Connection Device Driver */
|
---|
| 9 | /* Source Kit for OS/2. This Copyright statement may not be removed. */
|
---|
| 10 | /* */
|
---|
| 11 | /*****************************************************************************/
|
---|
| 12 | /**************************************************************************
|
---|
| 13 | *
|
---|
| 14 | * SOURCE FILE NAME = CONFIG.C
|
---|
| 15 | *
|
---|
| 16 | * DESCRIPTIVE NAME = Program configuration global variables, config parsing
|
---|
| 17 | *
|
---|
| 18 | *
|
---|
| 19 | * VERSION = V1.0
|
---|
| 20 | *
|
---|
| 21 | * DATE
|
---|
| 22 | *
|
---|
| 23 | * DESCRIPTION Program configuration global variables.
|
---|
| 24 | * Also parses command line for configurations.
|
---|
| 25 | *
|
---|
| 26 | *
|
---|
| 27 | * FUNCTIONS
|
---|
| 28 | *
|
---|
| 29 | *
|
---|
| 30 | *
|
---|
| 31 | * NOTES
|
---|
| 32 | *
|
---|
| 33 | *
|
---|
| 34 | * STRUCTURES
|
---|
| 35 | *
|
---|
| 36 | * EXTERNAL REFERENCES
|
---|
| 37 | *
|
---|
| 38 | * EXTERNAL FUNCTIONS
|
---|
| 39 | *
|
---|
| 40 | */
|
---|
| 41 |
|
---|
| 42 | // configuration variables
|
---|
| 43 | #include <os2.h>
|
---|
| 44 | #include <stdio.h>
|
---|
| 45 | #include <string.h>
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 | #include "package.h"
|
---|
| 49 | #include "config.h"
|
---|
| 50 | #include "ppd2pak.h"
|
---|
| 51 | #include "ppd2ppb.h"
|
---|
| 52 |
|
---|
| 53 | CHAR PPD_SOURCE_PATH[CCHMAXPATH] = "";
|
---|
| 54 | CHAR AFM_SOURCE_PATH[CCHMAXPATH] = "";
|
---|
| 55 | PSZ OUTPUT_DRV = NULL;
|
---|
| 56 | CHAR OUTPUT_PAK[CCHMAXPATH] = "";
|
---|
| 57 | PSZ OUTPUT_PAK_FILENAME = NULL;
|
---|
| 58 | PSZ OUTPUT_PPB = NULL;
|
---|
| 59 | PSZ PPD_FILE_LIST = NULL;
|
---|
| 60 | PSZ AFM_FILE_LIST = NULL;
|
---|
| 61 | PSZ MRI_LANG = NULL;
|
---|
| 62 |
|
---|
| 63 | int iAction = 0;
|
---|
| 64 |
|
---|
| 65 | // copy pathname from source to dest, and add trailing slash, if missing
|
---|
| 66 | static
|
---|
| 67 | void copy_pathname( char *dest, char *src)
|
---|
| 68 | {
|
---|
| 69 | strcpy(dest,src);
|
---|
| 70 |
|
---|
| 71 | // add slash as last character, if it's not present
|
---|
| 72 | if(dest[strlen(dest)-1]!='\\')
|
---|
| 73 | strcat(dest,"\\");
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | static
|
---|
| 77 | void alter_destination( char *destpath, char *filename )
|
---|
| 78 | {
|
---|
| 79 | char *fp = strrchr(destpath,'\\'); // filename follows after last slash
|
---|
| 80 |
|
---|
| 81 | if( fp != NULL ) // slash was found in pathname
|
---|
| 82 | fp++; // jump over the last slash, make buffer point to filename
|
---|
| 83 | else
|
---|
| 84 | fp = destpath; // just overwrite the whole string (probably it's just filename with no path)
|
---|
| 85 |
|
---|
| 86 | // alter the destination file name
|
---|
| 87 | strcpy(fp,filename);
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | // parse command line for PAK create operation (IPIN version)
|
---|
| 91 | //
|
---|
| 92 | // parsed args:
|
---|
| 93 | // "pak <input_ppd_path> <path_to_driver> <pak_filename> [path_to_ppdfilelist [mri_lang_path]]"
|
---|
| 94 |
|
---|
| 95 | int InternalPakConfig(int argc,char *argv[])
|
---|
| 96 | {
|
---|
| 97 | if( argc < 5 || argc > 7 ) return FALSE; // 5,6 or 7 args
|
---|
| 98 |
|
---|
| 99 | iAction = ACTION_PRODUCE_PAK;
|
---|
| 100 |
|
---|
| 101 | copy_pathname( PPD_SOURCE_PATH, argv[2] );
|
---|
| 102 | OUTPUT_DRV = argv[3];
|
---|
| 103 |
|
---|
| 104 | strcpy(OUTPUT_PAK,argv[3]);
|
---|
| 105 | OUTPUT_PAK_FILENAME = argv[4];
|
---|
| 106 | alter_destination( OUTPUT_PAK, OUTPUT_PAK_FILENAME );
|
---|
| 107 |
|
---|
| 108 | // expected behaviour: if PPD_FILE_LIST not specified, add *.ppd files in PPD_SOURCE_PATH
|
---|
| 109 | // if MRI_LANG_PATH not specified, add only PPDs in list without LANGUAGE: tag
|
---|
| 110 |
|
---|
| 111 | if( argc > 5 )
|
---|
| 112 | PPD_FILE_LIST = argv[5];
|
---|
| 113 | if( argc > 6 )
|
---|
| 114 | MRI_LANG = argv[6];
|
---|
| 115 |
|
---|
| 116 | return TRUE;
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | // parse command line for PAK create operation (consumer version)
|
---|
| 120 | //
|
---|
| 121 | // parsed args:
|
---|
| 122 | // "pak <source path> <driver path>"
|
---|
| 123 | int PakConfig(int argc,char *argv[])
|
---|
| 124 | {
|
---|
| 125 | if( argc != 4 ) return FALSE; // strictly 3 command line args
|
---|
| 126 | //FILE_LIST support disabled
|
---|
| 127 | // if( argc < 4 || argc > 6 ) return FALSE; // 5,6 or 7 args
|
---|
| 128 |
|
---|
| 129 | iAction = ACTION_PRODUCE_PAK;
|
---|
| 130 |
|
---|
| 131 | copy_pathname( PPD_SOURCE_PATH, argv[2] );
|
---|
| 132 | OUTPUT_DRV = argv[3];
|
---|
| 133 |
|
---|
| 134 | strcpy(OUTPUT_PAK,argv[3]);
|
---|
| 135 | OUTPUT_PAK_FILENAME = PAKNAME_AUXDEV_PACK;
|
---|
| 136 | alter_destination( OUTPUT_PAK, OUTPUT_PAK_FILENAME );
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 | //FILE_LIST support disabled
|
---|
| 140 | // // expected behaviour: if PPD_FILE_LIST not specified, add *.ppd files in PPD_SOURCE_PATH
|
---|
| 141 | // // if MRI_LANG_PATH not specified, add only PPDs in list without LANGUAGE: tag
|
---|
| 142 | //
|
---|
| 143 | // if( argc > 4 )
|
---|
| 144 | // PPD_FILE_LIST = argv[4];
|
---|
| 145 | // if( argc > 5 )
|
---|
| 146 | // MRI_LANG = argv[5];
|
---|
| 147 |
|
---|
| 148 | return TRUE;
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 |
|
---|
| 152 | // parse command line for PPB create operation (IPIN version)
|
---|
| 153 | //
|
---|
| 154 | // parsed args:
|
---|
| 155 | // "ppb <path_to_ppdfilelist> <path_to_ppb_out> <input_ppd_path> <mri_lang_path>"
|
---|
| 156 | int InternalPpbConfig(int argc,char *argv[])
|
---|
| 157 | {
|
---|
| 158 | if(argc!=6) return FALSE; // must be exactly 6 args!
|
---|
| 159 |
|
---|
| 160 | iAction = ACTION_PRODUCE_PPB;
|
---|
| 161 |
|
---|
| 162 | PPD_FILE_LIST = argv[2];
|
---|
| 163 | OUTPUT_PPB = argv[3];
|
---|
| 164 | copy_pathname( PPD_SOURCE_PATH, argv[4] );
|
---|
| 165 | MRI_LANG = argv[5];
|
---|
| 166 |
|
---|
| 167 | return TRUE;
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 | // parse command line for AFM create operation (IPIN version)
|
---|
| 171 | //
|
---|
| 172 | // parsed args:
|
---|
| 173 | // "afm <path_to_afm_files> <path_to_driver> <pak_filename>"
|
---|
| 174 |
|
---|
| 175 | int InternalAfmConfig(int argc,char *argv[])
|
---|
| 176 | {
|
---|
| 177 | if( argc < 5 || argc > 7 ) return FALSE; // 5,6 or 7 args
|
---|
| 178 |
|
---|
| 179 | iAction = ACTION_PRODUCE_AFM;
|
---|
| 180 |
|
---|
| 181 | copy_pathname( AFM_SOURCE_PATH, argv[2] );
|
---|
| 182 | OUTPUT_DRV = argv[3];
|
---|
| 183 |
|
---|
| 184 | strcpy(OUTPUT_PAK, argv[3]);
|
---|
| 185 | OUTPUT_PAK_FILENAME = argv[4];
|
---|
| 186 | alter_destination( OUTPUT_PAK, OUTPUT_PAK_FILENAME );
|
---|
| 187 |
|
---|
| 188 | // expected behaviour: if AFM_FILE_LIST not specified, add *.afm files in AFM_SOURCE_PATH
|
---|
| 189 | // if MRI_LANG_PATH not specified, add only PPDs in list without LANGUAGE: tag
|
---|
| 190 |
|
---|
| 191 | if( argc > 5 )
|
---|
| 192 | AFM_FILE_LIST = argv[5];
|
---|
| 193 | if( argc > 6 )
|
---|
| 194 | MRI_LANG = argv[6];
|
---|
| 195 |
|
---|
| 196 | return TRUE;
|
---|
| 197 | }
|
---|
| 198 |
|
---|
| 199 | // parse command line for AFM create operation (consumer version)
|
---|
| 200 | //
|
---|
| 201 | // parsed args:
|
---|
| 202 | // "afm <source path> <driver path>"
|
---|
| 203 | int AfmConfig(int argc,char *argv[])
|
---|
| 204 | {
|
---|
| 205 | if( argc != 4 ) return FALSE; // 5,6 or 7 args
|
---|
| 206 | //FONT_LIST support disabled
|
---|
| 207 | // if( argc < 4 || argc > 6 ) return FALSE; // 5,6 or 7 args
|
---|
| 208 |
|
---|
| 209 | iAction = ACTION_PRODUCE_AFM;
|
---|
| 210 |
|
---|
| 211 | copy_pathname( AFM_SOURCE_PATH, argv[2] );
|
---|
| 212 | OUTPUT_DRV = argv[3];
|
---|
| 213 |
|
---|
| 214 | strcpy(OUTPUT_PAK, argv[3]);
|
---|
| 215 | OUTPUT_PAK_FILENAME = PAKNAME_AUXFONT_PACK;
|
---|
| 216 | alter_destination( OUTPUT_PAK, OUTPUT_PAK_FILENAME );
|
---|
| 217 |
|
---|
| 218 | //FONT_LIST support disabled
|
---|
| 219 | // // expected behaviour: if AFM_FILE_LIST not specified, add *.afm files in AFM_SOURCE_PATH
|
---|
| 220 | // // if MRI_LANG_PATH not specified, add only PPDs in list without LANGUAGE: tag
|
---|
| 221 | //
|
---|
| 222 | // if( argc > 4 )
|
---|
| 223 | // AFM_FILE_LIST = argv[4];
|
---|
| 224 | // if( argc > 5)
|
---|
| 225 | // MRI_LANG = argv[5];
|
---|
| 226 |
|
---|
| 227 | return TRUE;
|
---|
| 228 | }
|
---|