| 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 = PINMAIN.C
|
|---|
| 15 | *
|
|---|
| 16 | * DESCRIPTIVE NAME = main() function of PIN program
|
|---|
| 17 | *
|
|---|
| 18 | *
|
|---|
| 19 | * VERSION = V1.0
|
|---|
| 20 | *
|
|---|
| 21 | * DATE
|
|---|
| 22 | *
|
|---|
| 23 | * DESCRIPTION
|
|---|
| 24 | *
|
|---|
| 25 | *
|
|---|
| 26 | * FUNCTIONS
|
|---|
| 27 | *
|
|---|
| 28 | *
|
|---|
| 29 | *
|
|---|
| 30 | * NOTES
|
|---|
| 31 | *
|
|---|
| 32 | *
|
|---|
| 33 | * STRUCTURES
|
|---|
| 34 | *
|
|---|
| 35 | * EXTERNAL REFERENCES
|
|---|
| 36 | *
|
|---|
| 37 | * EXTERNAL FUNCTIONS
|
|---|
| 38 | *
|
|---|
| 39 | */
|
|---|
| 40 |
|
|---|
| 41 | // main
|
|---|
| 42 |
|
|---|
| 43 | #undef INTERNAL_BUILD
|
|---|
| 44 |
|
|---|
| 45 | #include <os2.h>
|
|---|
| 46 | #include <stdio.h>
|
|---|
| 47 | #include <string.h>
|
|---|
| 48 |
|
|---|
| 49 | #include "config.h"
|
|---|
| 50 | #include "ppd2pak.h"
|
|---|
| 51 | #include "afm2pak.h"
|
|---|
| 52 | #include "ppd2ppb.h"
|
|---|
| 53 |
|
|---|
| 54 | #ifdef __KLIBC__
|
|---|
| 55 | #define strcmpi strcmp
|
|---|
| 56 | #endif
|
|---|
| 57 | //
|
|---|
| 58 | //
|
|---|
| 59 | //
|
|---|
| 60 | static
|
|---|
| 61 | int ProducePAK(void)
|
|---|
| 62 | {
|
|---|
| 63 | if(!PPD2PAK_Init())
|
|---|
| 64 | goto EXIT_FAIL_INIT;
|
|---|
| 65 | printf("READY, STARTING TO CONVERT\n");
|
|---|
| 66 | if(!PPD2PAK_Work())
|
|---|
| 67 | goto EXIT_FAIL_WORK;
|
|---|
| 68 | printf("FINISHED, SHUTTING DOWN\n");
|
|---|
| 69 |
|
|---|
| 70 | PPD2PAK_Done(); // _Done() functions never fail
|
|---|
| 71 | // (actually they do, if _Init() function has not been called yet)
|
|---|
| 72 |
|
|---|
| 73 | printf("done\n");
|
|---|
| 74 | return TRUE;
|
|---|
| 75 |
|
|---|
| 76 | EXIT_FAIL_WORK:
|
|---|
| 77 | EXIT_FAIL_INIT:
|
|---|
| 78 | printf("fail\n");
|
|---|
| 79 | PPD2PAK_Done();
|
|---|
| 80 | return FALSE;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | //
|
|---|
| 84 | //
|
|---|
| 85 | //
|
|---|
| 86 | static
|
|---|
| 87 | int ProduceAFM(void)
|
|---|
| 88 | {
|
|---|
| 89 | if(!AFM2PAK_Init())
|
|---|
| 90 | goto EXIT_FAIL_INIT;
|
|---|
| 91 | printf("init ok\n");
|
|---|
| 92 | if(!AFM2PAK_Work())
|
|---|
| 93 | goto EXIT_FAIL_WORK;
|
|---|
| 94 | printf("work ok\n");
|
|---|
| 95 |
|
|---|
| 96 | AFM2PAK_Done(); // _Done() functions never fail
|
|---|
| 97 | // (actually they do, if _Init() function has not been called yet)
|
|---|
| 98 |
|
|---|
| 99 | printf("done ok\n");
|
|---|
| 100 | return TRUE;
|
|---|
| 101 |
|
|---|
| 102 | EXIT_FAIL_WORK:
|
|---|
| 103 | EXIT_FAIL_INIT:
|
|---|
| 104 | printf("fail\n");
|
|---|
| 105 | AFM2PAK_Done();
|
|---|
| 106 | return FALSE;
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 | #ifdef INTERNAL_BUILD
|
|---|
| 111 | static
|
|---|
| 112 | int ProducePPB(void)
|
|---|
| 113 | {
|
|---|
| 114 | if(!PPD2PPB_Init())
|
|---|
| 115 | goto EXIT_FAIL_INIT;
|
|---|
| 116 | printf("init ok\n");
|
|---|
| 117 | if(!PPD2PPB_Work())
|
|---|
| 118 | goto EXIT_FAIL_WORK;
|
|---|
| 119 | printf("work ok\n");
|
|---|
| 120 |
|
|---|
| 121 | PPD2PPB_Done(); // _Done() functions never fail
|
|---|
| 122 | // (actually they do, if _Init() function has not been called yet)
|
|---|
| 123 |
|
|---|
| 124 | printf("done ok\n");
|
|---|
| 125 | return TRUE;
|
|---|
| 126 |
|
|---|
| 127 | EXIT_FAIL_WORK:
|
|---|
| 128 | EXIT_FAIL_INIT:
|
|---|
| 129 | printf("fail\n");
|
|---|
| 130 | PPD2PPB_Done();
|
|---|
| 131 | return FALSE;
|
|---|
| 132 | }
|
|---|
| 133 | #endif
|
|---|
| 134 |
|
|---|
| 135 | int ParseConfig(int argc, char *argv[])
|
|---|
| 136 | {
|
|---|
| 137 | if(argc<2) return FALSE;
|
|---|
| 138 |
|
|---|
| 139 | if(!strcmpi(argv[1],"ppd"))
|
|---|
| 140 | {
|
|---|
| 141 | return PakConfig(argc,argv);
|
|---|
| 142 | }
|
|---|
| 143 | #ifdef INTERNAL_BUILD
|
|---|
| 144 | else if(!strcmpi(argv[1],"ppb"))
|
|---|
| 145 | {
|
|---|
| 146 | return PpbConfig(argc,argv);
|
|---|
| 147 | }
|
|---|
| 148 | #endif
|
|---|
| 149 | else if(!strcmpi(argv[1],"afm"))
|
|---|
| 150 | {
|
|---|
| 151 | return AfmConfig(argc,argv);
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | return FALSE;
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 | int main(int argc, char *argv[])
|
|---|
| 160 | {
|
|---|
| 161 | int rc = 1; // NMAKE takes nonzero return value for error
|
|---|
| 162 |
|
|---|
| 163 | // disable output buffering
|
|---|
| 164 | setvbuf( stdout, NULL, _IONBF, 0 );
|
|---|
| 165 |
|
|---|
| 166 | printf("PostScript resource packaging utility version 1.01\n");
|
|---|
| 167 | printf("Copyright (c) IBM Corp. 2000,2001. All rights reserved.\n");
|
|---|
| 168 | printf("Modification made by Bart van Leeuwen, netlabs.org 2007.\n\n");
|
|---|
| 169 |
|
|---|
| 170 | // parse the command line
|
|---|
| 171 |
|
|---|
| 172 | if(ParseConfig(argc,argv))
|
|---|
| 173 | {
|
|---|
| 174 | // ok, do what we're asked to do...
|
|---|
| 175 |
|
|---|
| 176 | switch(iAction)
|
|---|
| 177 | {
|
|---|
| 178 | #ifdef INTERNAL_BUILD
|
|---|
| 179 | case ACTION_PRODUCE_PPB:
|
|---|
| 180 | printf("Producing PPB\n");
|
|---|
| 181 | if( ProducePPB() ) rc = 0; // success
|
|---|
| 182 | break;
|
|---|
| 183 | #endif
|
|---|
| 184 | case ACTION_PRODUCE_PAK:
|
|---|
| 185 | printf("Producing Printer Device PAK\n");
|
|---|
| 186 | if( ProducePAK() ) rc = 0; // success
|
|---|
| 187 | break;
|
|---|
| 188 | //@AFM unsupported
|
|---|
| 189 | // case ACTION_PRODUCE_AFM:
|
|---|
| 190 | // printf("Producing Device Font PAK\n");
|
|---|
| 191 | // if( ProduceAFM() ) rc = 0; // success
|
|---|
| 192 | // break;
|
|---|
| 193 |
|
|---|
| 194 | default:
|
|---|
| 195 | rc = 1; // error
|
|---|
| 196 | }
|
|---|
| 197 | }
|
|---|
| 198 | else
|
|---|
| 199 | {
|
|---|
| 200 | // some problem with command line...
|
|---|
| 201 |
|
|---|
| 202 | printf(
|
|---|
| 203 | "Usage: PIN.EXE <command> <arguments>\n"
|
|---|
| 204 | " Commands:\n"
|
|---|
| 205 | " * 'PPD' to import devices (from PPD files)\n"
|
|---|
| 206 | " pin.exe ppd <path_to_directory_with_ppd_files> <path_to_driver>\n"
|
|---|
| 207 | " Example:\n"
|
|---|
| 208 | " * to import all devices from d:\\pvt_ppd to driver located in d:\\drv:\n"
|
|---|
| 209 | " pin.exe ppd d:\\pvt_ppd d:\\drv\\pscript.drv\n"
|
|---|
| 210 | //@AFM unsupported
|
|---|
| 211 | //" 'AFM' to import device font metrics (from AFM files)\n"
|
|---|
| 212 | //" pin.exe afm <path_to_directory_with_afm_files> <path_to_driver>\n"
|
|---|
| 213 | );
|
|---|
| 214 | rc = 1;
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | return rc; // nmake is picky picky picky
|
|---|
| 218 | }
|
|---|
| 219 |
|
|---|