source: abuse/trunk/src/imlib/convert.cpp @ 56

Last change on this file since 56 was 56, checked in by Sam Hocevar, 15 years ago
  • Add licensing terms to most C / C++ files (Ref #5).
File size: 1.2 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *
5 *  This software was released into the Public Domain. As with most public
6 *  domain software, no warranty is made or implied by Crack dot Com or
7 *  Jonathan Clark.
8 */
9
10#include "config.h"
11
12#include <stdio.h>
13
14/* Jonathan Clark April 5, 93   Converts Unix file for to DOS & vice versa. */
15
16#define STReq(x,y) (!strcmp(x,y))
17main(int argc, char **argv)
18{
19  FILE *fp,*o;
20  int i,strip,add,c;
21  char st[100];
22  if (argc<3 || !(STReq(argv[1],"2unix") || STReq(argv[1],"2dos")))
23  { printf("Usage : convert [2unix]|[2dos] files\n");
24    exit(0);
25  }
26  if (STReq(argv[1],"2unix"))
27  { strip=1; add=0; }
28  else {strip=0; add=1; }
29  printf("Converting...\n");
30  for (i=2;i<argc;i++)
31  {
32    printf("  %s\n",argv[i]);
33    fp=fopen(argv[i],"r");
34    o=fopen("testXDF.out","w");
35    while (!feof(fp))
36    {
37      c=fgetc(fp);
38      if (c>=0)
39      {
40        if (c=='\n' && add) { fputc('\r',o); }
41        if (!(c=='\r') || !strip)
42          fputc(c,o);
43      }
44    }
45    fclose(o);
46    fclose(fp);
47    sprintf(st,"cp testXDF.out %s",argv[i]);
48    system(st);
49    unlink("testXDF.out");
50  }
51}
Note: See TracBrowser for help on using the repository browser.