Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 76 lines (63 sloc) 2.038 kb
176e6d0 Add install of examples for Windows.
steve authored
1 /*
2 * Copyright (c) 2001 Stephen Williams (steve@icarus.com)
3 *
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18 *
19 * $Id: dosify.c,v 1.1 2001/08/03 17:06:47 steve Exp $
20 */
21
22 /*
23 * This is a simple program to make a dosified copy of the
24 * original. That is, it converts unix style line ends to DOS
25 * style. This is useful for installing text files.
26 *
27 * The exact substitution is to replace \n with \r\n. If the line
28 * already ends with \r\n then it is not changed to \r\r\n.
29 */
30
31 # include <stdio.h>
32
33 int main(int argc, char*argv[])
34 {
35 FILE*ifile;
36 FILE*ofile;
37 int ch, pr;
38
39 if (argc != 3) {
40 fprintf(stderr, "Usage: %s <input> <output>\n", argv[0]);
41 return 1;
42 }
43
44 ifile = fopen(argv[1], "rb");
45 if (ifile == 0) {
46 fprintf(stderr, "Unable to open %s for input.\n", argv[1]);
47 return 2;
48 }
49
50 ofile = fopen(argv[2], "wb");
51 if (ofile == 0) {
52 fprintf(stderr, "Unable to open %s for output.\n", argv[2]);
53 return 2;
54 }
55
56 pr = 0;
57 while ((ch = fgetc(ifile)) != EOF) {
58
59 if ((ch == '\n') && (pr != '\r'))
60 fputc('\r', ofile);
61
62 fputc(ch, ofile);
63 pr = ch;
64 }
65
66 return 0;
67 }
68
69 /*
70 * $Log: dosify.c,v $
71 * Revision 1.1 2001/08/03 17:06:47 steve
72 * Add install of examples for Windows.
73 *
74 */
75
Something went wrong with that request. Please try again.