/************************************************************************ バックスラッシュ処理プログラム copyright 2004, TKEN *************************************************************************/ #include int main( int argc, char **argv ) { int i; int j; FILE *fp; static unsigned char tmpbuf[4096]; static unsigned char tmpbuf2[4096*2]; if ( argc != 2 ) { fprintf( stderr, "Usage:%s filename\n", argv[0] ); exit(1); } fp = fopen( argv[1], "r" ); if ( !fp ) { fprintf( stderr, "Cannot open %s\n", argv[1] ); exit(1); } while( fgets( tmpbuf, 4096, fp ) != NULL ) { i = 0; j = 0; while( tmpbuf[i] != '\0' ) { if ( ( i > 0 ) && ( tmpbuf[i-1] > 127 ) && ( tmpbuf[i] == '\\' ) ) { tmpbuf2[j] = '\\'; j++; tmpbuf2[j] = '\\'; j++; i++; } else { tmpbuf2[j] = tmpbuf[i]; j++; i++; } } tmpbuf2[j] = '\0'; printf( "%s", tmpbuf2 ); } fclose( fp ); return 0; }