7 char* default_ext(const char *name,const char *ext)
8 {static char buf [1024];
10 if (strcmp(buf+strlen(buf)-strlen(ext),ext)) {
13 if (stat(buf,&statbuf)&&!stat(name,&statbuf)) {
20 char *force_ext(const char *name,const char *ext)
21 {static char buf [1024];
24 if ((last_ext=strrchr(buf,'.'))&&last_ext>strrchr(buf,'/')) *last_ext='\0';
25 return strcat(buf,ext);
27 char *last_ext(const char *name)
28 {static char buf[128];
30 extptr=strrchr(name,'.');
31 if(!extptr) return NULL;
32 if (strchr(extptr,'/')) return NULL;
33 return strcpy(buf,extptr);
37 int show_progress(int row,int seqno,int total)
38 { fprintf(stderr,"\rProcessing row %d of %d",seqno,total);
40 return (signal_recieved);
42 int show_percent(int row,int seqno,int total)
43 { static int already_done;
44 int percent=seqno*1000/total;
45 if (percent!=already_done)
46 { fprintf(stderr,"\r%3d.%1d%% complete",percent/10,percent%10);
50 return signal_recieved;
54 int check_int(int row,int seqno,int total)
56 return (signal_recieved);
59 void int_handler(int sig_no)
60 { signal_recieved=sig_no;
61 signal(sig_no,int_handler);
64 void install_progress_indicator(int (*show_progress)(int,int,int))
66 signal(SIGINT,int_handler);
67 EndLineProc=show_progress;
70 int clear_progress(int success)
72 { fprintf(stderr,"\r%s \n",success?"Aborted":"Done");
73 signal(SIGINT,SIG_DFL);
77 void show_version(char *name,char *RCS_ID)
78 { char ver[25],*version=RCS_ID+1;
79 for(;*version!='$' && *version!=':';version++);
81 version=strrchr(ver,'$');
82 if (version) *version=0;
83 printf("SoftWeyr %c%s. Version %s\n",toupper(name[0]),name+1,ver);