pndevmapperd: don't do charge control too often
[pandora-libraries.git] / test / locatetest.c
1
2 #include <stdio.h> // for stdio
3 #include <unistd.h> // for exit()
4 #include <stdlib.h> // for exit()
5
6 #include "pnd_conf.h"
7 #include "pnd_container.h"
8 #include "pnd_apps.h"
9 #include "pnd_locate.h"
10
11 int main ( int argc, char *argv[] ) {
12   char *configpath;
13   char *pndpath;
14
15   /* attempt to sort out the config file madness
16    */
17
18   // attempt to fetch a sensible default searchpath for configs
19   configpath = pnd_conf_query_searchpath();
20
21   // attempt to fetch app config, or default the pnd_run.sh location
22   pnd_conf_handle apph;
23
24   apph = pnd_conf_fetch_by_id ( pnd_conf_apps, configpath );
25
26   if ( apph ) {
27     pndpath = pnd_conf_get_as_char ( apph, PND_PNDRUN_SEARCHPATH_KEY );
28
29     printf ( "Found a path in apps config: '%s'\n", pndpath );
30
31     if ( ! pndpath ) {
32       pndpath = PND_PNDRUN_SEARCHPATH_KEY;
33     }
34
35   } else {
36     // couldn't find a useful app search path so use the default
37     pndpath = PND_PNDRUN_SEARCHPATH_KEY;
38   }
39
40   // given a searchpath (Default or configured), try to find pnd_run.sh; if not
41   // found, then just use the default
42   char *pndrun;
43
44   printf ( "Searching in path '%s'\n", pndpath );
45
46   pndrun = pnd_locate_filename ( pndpath, PND_PNDRUN_FILENAME );
47
48   if ( ! pndrun ) {
49     printf ( "Result is default, not a locate-find\n" );
50     pndrun = PND_PNDRUN_DEFAULT;
51   }
52
53   printf ( "Locate found pnd_run.sh in '%s'\n", pndrun );
54
55   return ( 0 );
56 }