source: trunk/tools/common/kDef2Wat.cpp@ 8003

Last change on this file since 8003 was 8003, checked in by bird, 24 years ago

New kFile* classes; now in sync with os2tools.

File size: 3.2 KB
Line 
1/* $Id: kDef2Wat.cpp,v 1.3 2002-02-24 02:47:23 bird Exp $
2 *
3 * Converter for IBM/MS linker definition files (.DEF) to Watcom linker directives and options.
4 *
5 * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
6 *
7 * Project Odin Software License can be found in LICENSE.TXT
8 *
9 */
10
11
12
13/*******************************************************************************
14* Header Files *
15*******************************************************************************/
16#include "kTypes.h"
17#include "kError.h"
18#include "kFile.h"
19#include "kFileInterfaces.h"
20#include "kFileFormatBase.h"
21#include "kFileDef.h"
22
23/*******************************************************************************
24* Internal Functions *
25*******************************************************************************/
26static void syntax(void);
27
28
29
30/**
31 * Main function.
32 * Parses arguments and tries to convert files.
33 * @returns 0 on success.
34 * -1 Bad syntax.
35 * -2 Failed to read .DEF file.
36 * -3 Failed to generate output file.
37 * @param See syntax().
38 */
39int main(int argc, char **argv)
40{
41 const char *pszInput;
42 const char *pszOutput;
43 const char *pszAppend;
44
45 /* check arguments */
46 if (argc != 3 && argc != 4)
47 {
48 syntax();
49 return -1;
50 }
51 pszInput = argv[1];
52 pszOutput = argv[2];
53 pszAppend = (argc == 4) ? argv[3] : NULL;
54
55 /*
56 *
57 */
58 try
59 {
60 kFileDef def(new kFile(pszInput));
61 try
62 {
63 kFile OutFile(pszOutput, FALSE);
64 OutFile.end();
65
66 def.makeWatcomLinkFileAddtion(&OutFile);
67 if (pszAppend)
68 {
69 try
70 {
71 kFile AppendFile(pszAppend);
72
73 OutFile += AppendFile;
74 kFile::StdOut.printf("Successfully converted %s to %s\n", pszInput, pszOutput);
75 }
76 catch (kError err)
77 {
78 kFile::StdErr.printf("Append file %s to %s, errorcode=%d\n", pszAppend, pszInput, err.getErrno());
79 return -3;
80 }
81 }
82 }
83 catch (kError err)
84 {
85 kFile::StdErr.printf("Failed to read .DEF file (%s), errorcode=%d\n", pszInput, err.getErrno());
86 return -3;
87 }
88 }
89 catch (kError err)
90 {
91 kFile::StdErr.printf("Failed to read .DEF file (%s), errorcode=%d\n", pszInput, err.getErrno());
92 return -2;
93 }
94
95 return 0;
96}
97
98
99/**
100 * Writes syntax to stdout.
101 */
102static void syntax(void)
103{
104 kFile::StdOut.printf(
105 "kDef2Wat v0.0.0 (untested)\n"
106 "\n"
107 "syntax: kDef2Wat.exe <def-file> <wlink-file> [extra-file]\n"
108 "\n"
109 "Where:\n"
110 " <def-file> The .DEF file to convert.\n"
111 " <wlink-file> The WLINK directive and option file.\n"
112 " [extra-file] Extra file with directives which should be appended to\n"
113 " the wlink-file\n"
114 "\n"
115 "Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)\n"
116 );
117}
Note: See TracBrowser for help on using the repository browser.