Initial commit of libpnd 0.0.5 so we cna restart with GIT
[pandora-libraries.git] / lib / pnd_locate.c
1
2 #include <stdio.h> /* for FILE etc */
3 #include <stdlib.h> /* for malloc */
4 #include <string.h> /* for making ftw.h happy */
5
6 #include <sys/types.h> /* for stat(2) */
7 #include <sys/stat.h>
8 #include <unistd.h>
9
10 #include "pnd_pathiter.h"
11 #include "pnd_locate.h"
12
13 static char pnd_locate_buffer [ FILENAME_MAX ]; // exceedingly lame
14
15 char *pnd_locate_filename ( char *searchpath, char *filename ) {
16   struct stat foo;
17
18   SEARCHPATH_PRE
19   {
20
21     strncat ( buffer, "/", FILENAME_MAX );
22     strncat ( buffer, filename, FILENAME_MAX );
23
24     //printf ( "foo: %s\n", buffer );
25
26     if ( stat ( buffer, &foo ) == 0 ) {
27       strcpy ( pnd_locate_buffer, buffer );
28       return ( pnd_locate_buffer );
29     }
30
31   }
32   SEARCHPATH_POST
33
34   return ( NULL );
35 }