home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
bslash.zip
/
bslash.c
next >
Wrap
C/C++ Source or Header
|
2000-02-23
|
1KB
|
49 lines
#define VERSION "bslash 0.00\tCopyright (c) 2000, NBG01720@nifty.ne.jp"
/* To compile:
* gcc -Zomf -O2 -Wall bslash.c
*/
#include <sys/nls.h>
#include <getopt.h>
#include <stdio.h>
int main(int argc,char**argv){
int textmode=0,c;
FILE*in=stdin,*out=stdout;
char*name=NULL;
for(optind=0;(c=getopt(argc,argv,"to:V"))!=-1;)
switch(c){
case't': textmode=1; break;
case'o': name=optarg; break;
case'V': puts(VERSION); return 0;
default: puts(VERSION"\n\nUsage: bslash [-t] [-o outfile] [infile]");
return 0;
}
if(name){
if(!(out=fopen(name,textmode?"wt":"wb"))){
perror(name);
return 1;
}
}else
if(!textmode)
_fsetmode(stdout,"b");
if(argv[optind])
if(!(in=fopen(argv[optind],"rt"))){
perror(argv[optind]);
return 1;
}
while((c=getc(in))!=EOF){
putc(c,out);
if(_nls_is_dbcs_lead(c))
switch(c=getc(in)){
case'\\': fputs("\\\\",out); break;
case EOF: return 0;
default: putc(c,out);
}
}
return 0;
}