]> www.wagner.pp.ru Git - oss/fgis.git/blob - lib/lookup.c
Removed erroneously checked in binaries
[oss/fgis.git] / lib / lookup.c
1 #include <stdio.h>
2 #include <sys/stat.h>
3 #include <unistd.h>
4 #include <string.h>
5 #include "eppl_ut.h"
6 FILE *lookup_file(const char *name,const char *suffix,const char *dir)
7 /* éÝÅÔ ÆÁÊÌ ÓÎÁÞÁÌÁ × ÔÅËÕÝÅÊ ÄÉÒÅËÔÏÒÉÉ, ÐÏÔÏÍ × ÄÉÒÅËÔÏÒÉÉ
8    dir × ÔÅËÕÝÅÊ ÄÉÒÅËÔÏÒÉÉ, ÐÏÔÏÍ × /usr/local/lib/fgis/$dir */
9 { char namebuf[1024],pathbuf[1024];
10   
11   struct stat buf;
12   strcpy(namebuf,name);
13   if (strlen(name)<strlen(suffix)||
14       strcmp(name+strlen(name)-strlen(suffix),suffix)) 
15         strcat(namebuf,suffix); 
16   if (!stat(namebuf,&buf)) return fopen(namebuf,"r");
17
18   if (dir)
19     {strcpy(pathbuf,dir);
20      if (pathbuf[strlen(dir)-1]!='/'){ pathbuf[strlen(dir)]='/';
21                                       pathbuf[strlen(dir)+1]=0;
22                                      }
23      strcat(pathbuf,namebuf);
24      strcpy(namebuf,pathbuf);
25      if (!stat(namebuf,&buf)) return fopen(namebuf,"r");
26     }
27   strcat(strcpy(pathbuf,LIBDIR),namebuf);
28   if (!stat(pathbuf,&buf)) return fopen(pathbuf,"r");
29     return NULL;
30 }