source: abuse/tags/pd/macabuse/imlib/convert.c @ 49

Last change on this file since 49 was 49, checked in by Sam Hocevar, 11 years ago
  • Imported original public domain release, for future reference.
  • Property svn:keywords set to Id
File size: 894 bytes
Line 
1/* Jonathan Clark April 5, 93   Converts Unix file for to DOS & vice versa. */
2#include <stdio.h>
3
4#define STReq(x,y) (!strcmp(x,y))
5main(int argc, char **argv)
6{
7  FILE *fp,*o;
8  int i,strip,add,c;
9  char st[100];
10  if (argc<3 || !(STReq(argv[1],"2unix") || STReq(argv[1],"2dos")))
11  { printf("Usage : convert [2unix]|[2dos] files\n");
12    exit(0);
13  }
14  if (STReq(argv[1],"2unix"))
15  { strip=1; add=0; }
16  else {strip=0; add=1; }
17  printf("Converting...\n");
18  for (i=2;i<argc;i++)
19  {
20    printf("  %s\n",argv[i]);
21    fp=fopen(argv[i],"r");
22    o=fopen("testXDF.out","w");
23    while (!feof(fp))
24    {
25      c=fgetc(fp);
26      if (c>=0)
27      {
28        if (c=='\n' && add) { fputc('\r',o); }
29        if (!(c=='\r') || !strip)
30          fputc(c,o);
31      }
32    }
33    fclose(o);
34    fclose(fp);
35    sprintf(st,"cp testXDF.out %s",argv[i]);
36    system(st);
37    unlink("testXDF.out");
38  }
39}
Note: See TracBrowser for help on using the repository browser.