]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/CodeTools/Source/SplitFile/SplitFile.c
More renames for Tool Packages
[mirror_edk2.git] / Tools / CodeTools / Source / SplitFile / SplitFile.c
CommitLineData
d25c4bf0 1/*\r
2\r
ad1f8df0 3Copyright (c) 1999-2006 Intel Corporation. All rights reserved\r
4This program and the accompanying materials are licensed and made available \r
5under the terms and conditions of the BSD License which accompanies this \r
6distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
d25c4bf0 11\r
12*/\r
13\r
14// GC_TODO: fix comment to start with /*++\r
15#include "stdio.h"\r
16#include "string.h"\r
17#include "stdlib.h"\r
18\r
19void\r
20helpmsg (\r
21 void\r
22 )\r
23/*++\r
24\r
25Routine Description:\r
26\r
27 GC_TODO: Add function description\r
28\r
29Arguments:\r
30\r
31\r
32Returns:\r
33\r
34 GC_TODO: add return values\r
35\r
36--*/\r
37{\r
38 printf (\r
39 "SplitFile Filename Offset\n"" Filename = Input file to split\n"" Offset = offset at which to split file\n"\r
40 "\n\n""SplitFile will break a file in two pieces at the requested offset\n"\r
41 " outputting Filename1 and Filename2\n"\r
42 );\r
43}\r
44\r
45int\r
46main (\r
47 int argc,\r
48 char*argv[]\r
49 )\r
50/*++\r
51\r
52Routine Description:\r
53\r
54 GC_TODO: Add function description\r
55\r
56Arguments:\r
57\r
58 argc - GC_TODO: add argument description\r
59 ] - GC_TODO: add argument description\r
60\r
61Returns:\r
62\r
63 GC_TODO: add return values\r
64\r
65--*/\r
66{\r
67 FILE *In;\r
68\r
69 FILE *Out1;\r
70\r
71 FILE *Out2;\r
72 char OutName1[512];\r
73 char OutName2[512];\r
74 unsigned long Index;\r
75 unsigned long splitpoint;\r
76 char CharC;\r
77\r
78 if (argc != 3) {\r
79 helpmsg ();\r
80 return -1;\r
81 }\r
82\r
83 In = fopen (argv[1], "rb");\r
84 if (In == NULL) {\r
85 printf ("Unable to open file \"%s\"\n", argv[1]);\r
86 return -1;\r
87 }\r
88\r
89 strncpy (OutName1, argv[1], 510);\r
90 strncpy (OutName2, argv[1], 510);\r
91 strcat (OutName1, "1");\r
92 strcat (OutName2, "2");\r
93\r
94 Out1 = fopen (OutName1, "wb");\r
95 if (Out1 == NULL) {\r
96 printf ("Unable to open file \"%s\"\n", OutName1);\r
97 return -1;\r
98 }\r
99\r
100 Out2 = fopen (OutName2, "wb");\r
101 if (Out2 == NULL) {\r
102 printf ("Unable to open file \"%s\"\n", OutName2);\r
103 return -1;\r
104 }\r
105\r
106 splitpoint = atoi (argv[2]);\r
107\r
108 for (Index = 0; Index < splitpoint; Index++) {\r
109 CharC = (char) fgetc (In);\r
110 if (feof (In)) {\r
111 break;\r
112 }\r
113\r
114 fputc (CharC, Out1);\r
115 }\r
116\r
117 for (;;) {\r
118 CharC = (char) fgetc (In);\r
119 if (feof (In)) {\r
120 break;\r
121 }\r
122\r
123 fputc (CharC, Out2);\r
124 }\r
125\r
126 fclose (In);\r
127 fclose (Out1);\r
128 fclose (Out2);\r
129\r
130 return 0;\r
131}\r