version 1.1, 1999/12/08 05:47:43 |
version 1.4, 2006/02/12 08:55:26 |
|
|
/* $OpenXM: OpenXM/src/asir99/doc/extract_func.c,v 1.1 1999/11/12 09:21:36 noro Exp $ */ |
/* $OpenXM: OpenXM/src/asir-doc/extract_func.c,v 1.3 2005/02/09 03:25:50 noro Exp $ */ |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <string.h> |
#include <string.h> |
|
|
char *name[BUFSIZ]; |
char *name[BUFSIZ]; |
char cmd[BUFSIZ]; |
char cmd[BUFSIZ]; |
char fn[BUFSIZ]; |
char fn[BUFSIZ]; |
|
char *file; |
|
int jis; |
int i,j; |
int i,j; |
|
|
if ( argc != 2 ) { |
if ( (argc != 2) && (argc != 3) ) { |
fprintf(stderr,"usage : extract_func infofile\n"); |
fprintf(stderr,"usage : extract_func [-j] infofile\n"); |
exit(0); |
exit(0); |
} |
} |
in = fopen(argv[1],"rb"); |
if ( argc == 3 ) { |
|
jis = 1; |
|
file = argv[2]; |
|
} else { |
|
jis = 0; |
|
file = argv[1]; |
|
} |
|
in = fopen(file,"rb"); |
if ( !in ) { |
if ( !in ) { |
fprintf(stderr,"%s : not found",argv[1]); |
fprintf(stderr,"%s : not found",file); |
exit(0); |
exit(0); |
} |
} |
fp = 0; |
fp = 0; |
|
|
if ( i >= 3 && buf1[i] == '\n' ) { |
if ( i >= 3 && buf1[i] == '\n' ) { |
fputs(buf,stderr); |
fputs(buf,stderr); |
strcpy(fn,name[0]); |
strcpy(fn,name[0]); |
|
create_dir(fn); |
fp = fopen(fn,"w"); |
fp = fopen(fn,"w"); |
for ( j = 1; name[j]; j++ ) |
for ( j = 1; name[j]; j++ ) |
symlink(fn,name[j]); |
symlink(fn,name[j]); |
|
|
fputs(buf,fp); |
fputs(buf,fp); |
if ( buf1[0] == 0x1f ) { |
if ( buf1[0] == 0x1f ) { |
fclose(fp); fp = 0; |
fclose(fp); fp = 0; |
sprintf(cmd,"nkf %s > %s.tmp; rm -f %s; mv %s.tmp %s", |
if ( jis ) { |
name[0],name[0],name[0]); |
sprintf(cmd,"nkf %s > %s.tmp; rm -f %s; mv %s.tmp %s", |
system(cmd); |
name[0],name[0],name[0]); |
|
system(cmd); |
|
} |
} else |
} else |
fputs(buf1,fp); |
fputs(buf1,fp); |
} |
} |
} else if ( fp ) |
} else if ( fp ) |
if ( buf[0] == 0x1f ) { |
if ( buf[0] == 0x1f ) { |
fclose(fp); fp = 0; |
fclose(fp); fp = 0; |
sprintf(cmd,"nkf %s > %s.tmp; rm -f %s; mv %s.tmp %s", |
if ( jis ) { |
fn,fn,fn,fn,fn); |
sprintf(cmd,"nkf %s > %s.tmp; rm -f %s; mv %s.tmp %s", |
system(cmd); |
fn,fn,fn,fn,fn); |
|
system(cmd); |
|
} |
} else |
} else |
fputs(buf,fp); |
fputs(buf,fp); |
} |
} |
} |
} |
|
|
|
int create_dir(char *fname) |
|
{ |
|
char *p; |
|
|
|
p = fname; |
|
while ( *p && (p = strchr(p,'/')) ) { |
|
*p = 0; |
|
mkdir(fname,0755); |
|
*p = '/'; |
|
p++; |
|
} |
|
|
|
} |
|
|
int fname(buf,name) |
int fname(buf,name) |
char *buf; |
char *buf; |
char **name; |
char **name; |
{ |
{ |
int i,len; |
int i,len; |
char *quote,*bquote,*comma; |
char *quote,*bquote,*comma,*space,*p; |
|
|
/* XXX */ |
if ( *buf != '`' ) { |
if ( *buf != '`' ) |
/* skip X.X.X if exists */ |
return 0; |
space = index(buf,' '); |
|
if ( !space ) return 0; |
|
for ( p = buf; p < space; p++ ) |
|
if ( !isdigit(*p) && *p != '.' ) return 0; |
|
buf = space+1; |
|
} |
i = 0; |
i = 0; |
while ( 1 ) { |
while ( 1 ) { |
/* search a back quote */ |
/* search a back quote */ |