ftp.nice.ch/pub/next/developer/languages/eiffel/SmallEiffel.0.91.N.bs.tar.gz#/SmallEiffel/bin_c/finder2.c

This is finder2.c in view mode; [Download] [Up]

/* ANSI C code generated by SmallEiffel. */
/*
-- SmallEiffel  -- Release (- 0.91)    --      FRANCE
-- Copyright (C), 1994 - Dominique COLNET and Suzanne COLLIN 
-- University Henri Poincare' - Nancy 1 - email colnet@loria.fr 
-- CRIN (Centre de Recherche en Informatique de Nancy)
-- FRANCE 
*/
#include "finder.h"
/*STD_FILE_READ*/int rT43feof(T43 *C,void * a1){
int R=0;
R=feof((FILE*)C->_input_stream);
return R;
}
/*STD_FILE_READ*/int rT43end_of_input(T43 *C){
int R=0;
R=rT43feof(C,(C)->_input_stream);
return R;
}
/*STD_FILE_READ*/int rT43is_connected(T43 *C){
int R=0;
R=((int)(C)->_path);
return R;
}
/*STD_FILE_READ*/void rT43disconnect(T43 *C){
int _err=0;
_err=fclose((C)->_input_stream);
C->_path=NULL;
}T0*oRBC43last_string;
/*STD_FILE_READ*/char rT43last_character(T43 *C){
char R=0;
R=(C)->_last_character_memory;
return R;
}
/*STD_FILE_READ*/void rT43connect_to(T43 *C,T0* a1){
/*[IRF3:make*//*AW*/(C)->_mode=((T0 *)ms1_43);/*]*/
C->_input_stream=rT43fopen(a1,(C)->_mode);
/*IF*/{/*AT*/C->_path=a1;
}
/*FI*/}/*STD_FILE_READ*/void rT43skip_separators(T43 *C){
while (!((rT43end_of_input(C))||(!(rT3is_separator(rT43last_character(C)))))) {
rT43read_character(C);
}
}/*STD_FILE_READ*/void * rT43fopen(/*C*/T0* a1,T0* a2){
void * R=0;
void * _pm=0;
void * _pf=0;
_pf=rT7to_external((T7*)a1);
_pm=rT7to_external((T7*)a2);
R=(void*)fopen(((char*)_pf),((char*)_pm));
return R;
}
/*STD_FILE_READ*/void rT43read_word(T43 *C){
rT43skip_separators(C);
/*[IRF3:clear*//*AW*/((T7*)oRBC43last_string)->_count=(0);/*]*/
while (!((rT43end_of_input(C))||(rT3is_separator(rT43last_character(C))))) {
rT7extend((T7*)oRBC43last_string,rT43last_character(C));
rT43read_character(C);
}
}/*STD_FILE_READ*/void rT43read_line_in(T43 *C,T0* a1){
/*[IRF3:clear*//*AW*/((T7*)a1)->_count=(0);/*]*/
rT43read_character(C);
while (!((rT43end_of_input(C))||((rT43last_character(C))==('\12')))) {
rT7extend((T7*)a1,rT43last_character(C));
rT43read_character(C);
}
}/*STD_FILE_READ*/void rT43read_line(T43 *C){
rT43read_line_in(C,oRBC43last_string);
}/*STD_FILE_READ*/void rT43read_character(T43 *C){
C->_last_character_memory=fgetc((C)->_input_stream);
}/*FIXED_ARRAY[STRING]*/void rT34clear_all(T34 *C){
T0* _value=NULL;
rT34set_all_with(C,_value);
}/*FIXED_ARRAY[STRING]*/void rT34set_all_with(T34 *C,T0* a1){
int _i=0;
_i=(C)->_upper;
while (!((_i)<(0))) {
rT34put(C,a1,_i);
_i=(_i)-(1);
}
}/*FIXED_ARRAY[STRING]*/T0* rT34item(T34 *C,int a1){
T0* R=NULL;
R=(((T0**)(C->_storage))[a1]);
return R;
}
/*FIXED_ARRAY[STRING]*/T0** rT34realloc(/*C*/T0** a1,int a2){
T0** R=0;
T37 _mem={0/*dummy*/};
T0* _x=NULL;
/*IF*//*AF*//*AE*/
R=realloc(a1,(a2)*(sizeof(char *)));
/*FI*/return R;
}
/*FIXED_ARRAY[STRING]*/T0** rT34malloc(/*C*/int a1){
T0** R=0;
T37 _mem={0/*dummy*/};
T0* _x=NULL;
/*IF*//*AF*//*AE*/
R=malloc((a1)*(sizeof(char *)));
/*FI*/return R;
}
/*FIXED_ARRAY[STRING]*/void rT34put(T34 *C,T0* a1,int a2){
((T0**)(C->_storage))[a2]=a1;
}
/*FIXED_ARRAY[STRING]*/void rT34make(T34 *C,int a1){
/*IF*/if (((int)(C)->_storage)) {
C->_storage=rT34realloc((C)->_storage,a1);
}
else {
C->_storage=rT34malloc(a1);
}
/*FI*/C->_upper=(a1)-(1);
rT34clear_all(C);
}/*STRING*/T0* rT7twin(T7 *C){
T0* R=NULL;
/*IF*//*AF*//*AE*/
R=(T0 *)se_new(C->id);AF_1
rT7copy((T7*)R,(T0 *)C);
AF_0
/*FI*/return R;
}
/*STRING*/int rT7hash_code(T7 *C){
int R=0;
int _i=0;
_i=(C)->_count;
/*IF*/if ((_i)>(5)) {
_i=5;
}
/*FI*/while (!((_i)==(0))) {
R=(R)+(((unsigned char)rT7item(C,_i)));
_i=(_i)-(1);
}
return R;
}
/*STRING*/void rT7extend(T7 *C,char a1){
T37 _mem={0/*dummy*/};
/*IF*/if (((C)->_capacity)>((C)->_count)) {
}
 else if (((C)->_capacity)==(0)) {
C->_capacity=32;
C->_storage=malloc((C)->_capacity);
}
else {
C->_capacity=((C)->_capacity)+(32);
C->_storage=realloc((C)->_storage,(C)->_capacity);
}
/*FI*/C->_count=((C)->_count)+(1);
rT7put(C,a1,(C)->_count);
}/*STRING*/void rT7to_upper(T7 *C){
int _i=0;
_i=(C)->_count;
while (!((_i)==(0))) {
rT7put(C,rT3to_upper(rT7item(C,_i)),_i);
_i=(_i)-(1);
}
}/*STRING*/int rT7has_suffix(T7 *C,T0* a1){
int R=0;
int _i2=0;
int _i1=0;
/*IF*/if ((((T7*)a1)->_count)<=((C)->_count)) {
_i1=(((C)->_count)-(((T7*)a1)->_count))+(1);
_i2=1;
while (!((((_i1)>((C)->_count))||((_i2)>(((T7*)a1)->_count)))||((rT7item(C,_i1))!=(rT7item((T7*)a1,_i2))))) {
_i1=(_i1)+(1);
_i2=(_i2)+(1);
}
R=(_i1)>((C)->_count);
}
/*FI*/return R;
}
/*STRING*/int rT7empty(T7 *C){
int R=0;
R=((C)->_count)==(0);
return R;
}
/*STRING*/char rT7item(T7 *C,int a1){
char R=0;
R=(C->_storage)[a1-1];
return R;
}
/*STRING*/int rT7is_equal(T7 *C,T0* a1){
int R=0;
int _i=0;
/*IF*/if (((T0 *)C)==((T0 *)a1)) {
R=1;
}
else {
_i=(C)->_count;
R=(_i)==(((T7*)a1)->_count);
while (!(((!(R))||((_i)==(0))))) {
R=(rT7item(C,_i))==(rT7item((T7*)a1,_i));
_i=(_i)-(1);
}
}
/*FI*/return R;
}
/*STRING*/void rT7append(T7 *C,T0* a1){
int _i=0;
_i=1;
while (!((_i)>(((T7*)a1)->_count))) {
rT7extend(C,rT7item((T7*)a1,_i));
_i=(_i)+(1);
}
}/*STRING*/char rT7last(T7 *C){
char R=0;
R=rT7item(C,(C)->_count);
return R;
}
/*STRING*/void rT7put(T7 *C,char a1,int a2){
(C->_storage)[a2-1]=a1;
}/*STRING*/void rT7copy(T7 *C,T0* a1){
int _i=0;
/*IF*/if (((C)->_capacity)<(((T7*)a1)->_count)) {
rT7make(C,((T7*)a1)->_count);
}
/*FI*/_i=((T7*)a1)->_count;
C->_count=_i;
while (!((_i)==(0))) {
rT7put(C,rT7item((T7*)a1,_i),_i);
_i=(_i)-(1);
}
}/*STRING*/void rT7prepend(T7 *C,T0* a1){
int _old_count=0;
int _i=0;
_old_count=(C)->_count;
_i=((T7*)a1)->_count;
while (!((_i)==(0))) {
rT7extend(C,'\40');
_i=(_i)-(1);
}
_i=(C)->_count;
while (!((_old_count)==(0))) {
rT7put(C,rT7item(C,_old_count),_i);
_i=(_i)-(1);
_old_count=(_old_count)-(1);
}
_i=((T7*)a1)->_count;
while (!((_i)==(0))) {
rT7put(C,rT7item((T7*)a1,_i),_i);
_i=(_i)-(1);
}
}/*STRING*/void rT7to_lower(T7 *C){
int _i=0;
_i=(C)->_count;
while (!((_i)==(0))) {
rT7put(C,rT3to_lower(rT7item(C,_i)),_i);
_i=(_i)-(1);
}
}/*STRING*/void rT7make(T7 *C,int a1){
T37 _mem={0/*dummy*/};
/*IF*/if ((a1)>(0)) {
/*IF*/if (((C)->_capacity)<(a1)) {
/*IF*/if (((C)->_capacity)==(0)) {
C->_storage=malloc(a1);
}
else {
C->_storage=realloc((C)->_storage,a1);
}
/*FI*/C->_capacity=a1;
}
/*FI*/}
/*FI*/C->_count=0;
}/*STRING*/char * rT7to_external(T7 *C){
char * R=0;
rT7extend(C,'\0');
C->_count=((C)->_count)-(1);
R=(C)->_storage;
return R;
}
/*BOOLEAN*/int rT6_ix111114(T6 C,int a1){
int R=0;
R=(C)||(a1);
return R;
}
/*BOOLEAN*/int rT6_px110111116(T6 C){
int R=0;
/*IF*/if (C) {
}
else {
R=1;
}
/*FI*/return R;
}
/*INTEGER*/int rT2min(T2 C,int a1){
int R=0;
/*IF*/if ((C)<(a1)) {
R=C;
}
else {
R=a1;
}
/*FI*/return R;
}
/*INTEGER*/int rT2max(T2 C,int a1){
int R=0;
/*IF*/if ((a1)<(C)) {
R=C;
}
else {
R=a1;
}
/*FI*/return R;
}
/*SMALL_EIFFEL*/T0* rT44find_path_for(/*C*/T0* a1){
T0* R=NULL;
int _i=0;
rT7copy((T7*)(T0 *)ms21_44,a1);
rT7to_lower((T7*)(T0 *)ms21_44);
/*IF*/if (!(rT7has_suffix((T7*)(T0 *)ms21_44,(T0 *)ms24_27))) {
rT7append((T7*)(T0 *)ms21_44,(T0 *)ms24_27);
}
/*FI*//*IF*/if (rT44file_exists((T0 *)ms21_44)) {
R=rT7twin((T7*)(T0 *)ms21_44);
}
else {
_i=((T46*)rT44loading_path())->_lower;
while (!((((_i)>(((T46*)rT44loading_path())->_upper))||(((int)R))))) {
rT7copy((T7*)(T0 *)ms20_44,rT46item((T46*)rT44loading_path(),_i));
rT7append((T7*)(T0 *)ms20_44,(T0 *)ms21_44);
/*IF*/if (rT44file_exists((T0 *)ms20_44)) {
R=rT7twin((T7*)(T0 *)ms20_44);
}
/*FI*/_i=(_i)+(1);
}
}
/*FI*//*IF*/if ((!(R))&&(rT48has((T48*)rT44rename_dictionary(),(T0 *)ms21_44))) {
rT7copy((T7*)(T0 *)ms20_44,rT48at((T48*)rT44rename_dictionary(),(T0 *)ms21_44));
/*IF*/if (rT44file_exists((T0 *)ms20_44)) {
R=(T0 *)ms20_44;
}
else {
rT38put_string((T38*)oRBC1std_error,(T0 *)ms22_44);
rT38put_string((T38*)oRBC1std_error,(T0 *)ms20_44);
rT38put_string((T38*)oRBC1std_error,(T0 *)ms23_44);
rT44die_with_code(1);
}
/*FI*/}
/*FI*//*IF*/if (!(R)) {
rT38put_string((T38*)oRBC1std_error,(T0 *)ms24_44);
rT38put_string((T38*)oRBC1std_error,a1);
rT38put_string((T38*)oRBC1std_error,(T0 *)ms25_44);
/*[IRF3:clear*//*AW*/((T7*)(T0 *)ms20_44)->_count=(0);/*]*/
rT44append_loading_path_in((T0 *)ms20_44);
rT38put_string((T38*)oRBC1std_error,(T0 *)ms20_44);
}
/*FI*/return R;
}
/*SMALL_EIFFEL*/T0* rT44get_environment_variable(/*C*/T0* a1){
T0* R=NULL;
void * _p=0;
_p=rT7to_external((T7*)a1);
_p=((void*)getenv((char*)_p));
/*IF*/if (((int)_p)) {
R=(T0*)e2s((char*)_p);
}
/*FI*/return R;
}
/*SMALL_EIFFEL*/char rT44directory_separator(/*C*/void){
if (ofBC27directory_separator==0){
char R=0;
ofBC27directory_separator=1;
R=rT7last((T7*)rT44small_eiffel_directory());
oRBC27directory_separator=R;}
return oRBC27directory_separator;}
/*SMALL_EIFFEL*/void rT44die_with_code(/*C*/int a1){
exit(a1);
}int ofBC44loading_path=0;
T0*oRBC44loading_path;
/*SMALL_EIFFEL*/T0* rT44loading_path(/*C*/void){
if (ofBC44loading_path==0){
T0* R=NULL;
T0* _file=NULL;
T0* _defaults=NULL;
char _slash=0;
int _i=0;
T0* _path=NULL;
ofBC44loading_path=1;
_path=(T0 *)ms2_44;
{T46 *n=((T46*)se_new(46));
rT46make(n,1,10);
R=(T0 *)n;}
rT46clear((T46*)R);
_slash=rT44directory_separator();
/*IF*/if (rT44file_exists(_path)) {
{T43 *n=((T43*)se_new(43));
/*[IRF3:make*//*AW*/(n)->_mode=((T0 *)ms1_43);/*]*/
_file=(T0 *)n;}
rT44open_read(_file,_path);
while (!(rT43end_of_input((T43*)_file))) {
rT43read_line((T43*)_file);
_path=rT7twin((T7*)oRBC43last_string);
/*IF*/if (!(rT7empty((T7*)_path))) {
/*IF*/if ((rT7last((T7*)_path))!=(_slash)) {
rT7extend((T7*)_path,_slash);
}
/*FI*/rT46add_last((T46*)R,_path);
}
/*FI*/}
rT43disconnect((T43*)_file);
}
/*FI*/_defaults=ma(46,0,3,ms3_44,ms4_44,ms5_44);
_i=1;
while (!((_i)>(((T46*)_defaults)->_upper))) {
_path=rT46item((T46*)_defaults,_i);
rT7prepend((T7*)_path,rT44small_eiffel_directory());
rT7extend((T7*)_path,_slash);
rT46add_last((T46*)R,_path);
_i=(_i)+(1);
}
oRBC44loading_path=R;}
return oRBC44loading_path;}
/*SMALL_EIFFEL*/void rT44open_read(/*C*/T0* a1,T0* a2){
rT43connect_to((T43*)a1,a2);
/*IF*/if (!(rT43is_connected((T43*)a1))) {
rT38put_string((T38*)oRBC1std_error,(T0 *)ms7_27);
rT38put_string((T38*)oRBC1std_error,a2);
rT38put_string((T38*)oRBC1std_error,(T0 *)ms8_27);
rT44die_with_code(1);
}
/*FI*/}int ofBC44rename_dictionary=0;
T0*oRBC44rename_dictionary;
/*SMALL_EIFFEL*/T0* rT44rename_dictionary(/*C*/void){
if (ofBC44rename_dictionary==0){
T0* R=NULL;
T0* _short_name=NULL;
T0* _full_name=NULL;
int _i=0;
ofBC44rename_dictionary=1;
{T48 *n=((T48*)se_new(48));
rT48make(n);
R=(T0 *)n;}
_i=1;
while (!((_i)>(((T46*)rT44loading_path())->_upper))) {
rT7copy((T7*)(T0 *)ms20_44,rT46item((T46*)rT44loading_path(),_i));
rT7append((T7*)(T0 *)ms20_44,(T0 *)ms26_44);
/*IF*/if (rT44file_exists((T0 *)ms20_44)) {
rT44open_read(oRBC27tmp_file_read,(T0 *)ms20_44);
while (!(rT43end_of_input((T43*)oRBC27tmp_file_read))) {
rT43read_word((T43*)oRBC27tmp_file_read);
_full_name=rT7twin((T7*)oRBC43last_string);
rT43read_word((T43*)oRBC27tmp_file_read);
_short_name=rT7twin((T7*)oRBC43last_string);
rT7prepend((T7*)_short_name,rT46item((T46*)rT44loading_path(),_i));
/*IF*/if (rT48has((T48*)R,_full_name)) {
rT38put_string((T38*)oRBC1std_error,(T0 *)ms27_44);
rT38put_string((T38*)oRBC1std_error,_full_name);
rT38put_string((T38*)oRBC1std_error,(T0 *)ms28_44);
rT38put_string((T38*)oRBC1std_error,_short_name);
rT38put_string((T38*)oRBC1std_error,(T0 *)ms29_44);
rT38put_string((T38*)oRBC1std_error,rT48at((T48*)R,_full_name));
rT38put_string((T38*)oRBC1std_error,(T0 *)ms30_44);
rT44die_with_code(1);
}
/*FI*/rT48put((T48*)R,_short_name,_full_name);
rT43skip_separators((T43*)oRBC27tmp_file_read);
}
rT43disconnect((T43*)oRBC27tmp_file_read);
}
/*FI*/_i=(_i)+(1);
}
oRBC44rename_dictionary=R;}
return oRBC44rename_dictionary;}
/*SMALL_EIFFEL*/void rT44append_loading_path_in(/*C*/T0* a1){
T0* _sed=NULL;
int _i=0;
rT7append((T7*)a1,(T0 *)ms7_44);
_i=((T46*)rT44loading_path())->_lower;
while (!((_i)>(((T46*)rT44loading_path())->_upper))) {
rT7extend((T7*)a1,'\42');
rT7append((T7*)a1,rT46item((T46*)rT44loading_path(),_i));
rT7extend((T7*)a1,'\42');
rT7extend((T7*)a1,'\12');
_i=(_i)+(1);
}
rT7append((T7*)a1,(T0 *)ms8_44);
rT7append((T7*)a1,(T0 *)ms124_27);
_sed=rT44get_environment_variable((T0 *)ms124_27);
rT7append((T7*)a1,(T0 *)ms9_44);
/*IF*/if (!(_sed)) {
rT7append((T7*)a1,(T0 *)ms10_44);
}
else {
rT7append((T7*)a1,(T0 *)ms11_44);
rT7append((T7*)a1,_sed);
rT7append((T7*)a1,(T0 *)ms12_44);
}
/*FI*/rT7extend((T7*)a1,'\12');
}T0*oRBC27tmp_file_read;
/*SMALL_EIFFEL*/T0* rT44small_eiffel_directory(/*C*/void){
if (ofBC27small_eiffel_directory==0){
T0* R=NULL;
char _slash=0;
int _i=0;
ofBC27small_eiffel_directory=1;
R=rT44get_environment_variable((T0 *)ms124_27);
/*IF*/if (!(R)) {
R=rT7twin((T7*)(T0 *)ms124_27);
rT7to_upper((T7*)R);
R=rT44get_environment_variable(R);
/*IF*/if (((int)R)) {
rT7to_upper((T7*)(T0 *)ms124_27);
}
/*FI*/}
/*FI*//*IF*/if (!(R)) {
R=(T0 *)ms1_27;
}
/*FI*/_i=((T7*)R)->_count;
while (!((_i)<(0))) {
_slash=rT7item((T7*)R,_i);
/*IF*/if ((rT3is_letter(_slash))||(rT3is_digit(_slash))) {
_i=(_i)-(1);
}
else {
_i=-(1);
}
/*FI*/}
/*IF*/if ((_i)==(0)) {
rT7extend((T7*)R,'\57');
}
 else if (!((rT7last((T7*)R))==(_slash))) {
rT7extend((T7*)R,_slash);
}
/*FI*/oRBC27small_eiffel_directory=R;}
return oRBC27small_eiffel_directory;}
/*SMALL_EIFFEL*/int rT44file_exists(/*C*/T0* a1){
int R=0;
void * _p=0;
_p=rT7to_external((T7*)a1);
{FILE *f=fopen(((char*)_p),"r");
R=(f != NULL);
if (R) fclose(f);}
return R;
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.