-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of libpnd 0.0.5 so we cna restart with GIT
- Loading branch information
skeezix
committed
Feb 18, 2009
0 parents
commit e652306
Showing
35 changed files
with
8,010 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
0.0.3 REM: Slight fixup (if you can call it that) to replace copy/paste code with SEARCHPATH_PRE/POST pathiter.h | ||
REM: Added .so to Makefile | ||
REM: Added extern "C" wrappers for headers; just maybe this will help someone :P | ||
REM: Added 'locatetest' shitty test tool to verify pnd_locate code pretends to work; needs the | ||
shared lib version so you need to set your LD_LIBRARY_PATH, for what its worth | ||
|
||
0.0.2 REM: Working on INOTIFY in what little time I have before Christmas :) | ||
REM: I'm sick as hell. | ||
NEW: Added notifytest, pnd_notify.[ch] | ||
Seems to work 'okay' in a brute force fashion; only watching a couple events right now and | ||
didn't test yet against mount/unmount and such, but a start. | ||
|
||
0.0.1 Initial version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
# | ||
# libpnd Makefile | ||
# | ||
|
||
# tools | ||
CC = gcc | ||
AR = ar | ||
RANLIB = ranlib | ||
RM = rm | ||
|
||
# environment | ||
VPATH = lib test | ||
CFLAG_SO = -fPIC #-fPIC not always needed, but good to have | ||
CFLAGS = -Wall -I./include -g ${CFLAG_SO} | ||
|
||
# code | ||
LIB = libpnd.a | ||
SOLIB = libpnd.so.1 # canonicle name | ||
SOLIB1 = libpnd.so.1.0.1 # versioned name | ||
XMLOBJ = lib/tinyxml/tinystr.o lib/tinyxml/tinyxml.o lib/tinyxml/tinyxmlerror.o lib/tinyxml/tinyxmlparser.o | ||
ALLOBJ = pnd_conf.o pnd_container.o pnd_discovery.o pnd_pxml.o pnd_notify.o pnd_locate.o pnd_tinyxml.o | ||
|
||
all: ${SOLIB} ${LIB} conftest discotest notifytest locatetest | ||
|
||
clean: | ||
${RM} -f ${ALLOBJ} ${XMLOBJ} ${LIB} ${SOLIB1} locatetest.o bin/locatetest conftest.o bin/conftest discotest.o bin/discotest bin/notifytest notifytest.o | ||
|
||
libpnd.a: ${ALLOBJ} ${XMLOBJ} | ||
${AR} r ${LIB} ${ALLOBJ} ${XMLOBJ} | ||
${RANLIB} ${LIB} | ||
|
||
libpnd.so.1: ${ALLOBJ} ${XMLOBJ} | ||
${CC} -shared -Wl,-soname,${SOLIB} -o ${SOLIB1} ${ALLOBJ} ${XMLOBJ} | ||
|
||
conftest: conftest.o ${LIB} | ||
${CC} -lstdc++ -o bin/conftest conftest.o libpnd.a | ||
|
||
discotest: discotest.o ${LIB} | ||
${CC} -lstdc++ -o bin/discotest discotest.o libpnd.a | ||
|
||
notifytest: notifytest.o ${LIB} | ||
${CC} -lstdc++ -o bin/notifytest notifytest.o libpnd.a | ||
|
||
locatetest: locatetest.o ${SOLIB1} | ||
${CC} -lstdc++ -o bin/locatetest locatetest.o ${SOLIB1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
#ifndef h_pnd_apps_h | ||
#define h_pnd_apps_h | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#define PND_APPS_SEARCHPATH "/mnt/sd1/pandora/apps:/mnt/sd2/pandora/apps:./testdata/apps" | ||
#define PND_APPS_KEY "autodiscovery.searchpath" | ||
|
||
#define PND_PNDRUN_SEARCHPATH "pnd.searchpath" | ||
#define PND_PNDRUN_KEY "pnd.default" | ||
#define PND_PNDRUN_FILENAME "pnd_run.sh" | ||
#define PND_PNDRUN_DEFAULT "./testdata/scripts/pnd_run.sh" | ||
|
||
#define PND_PXML_OVERRIDE_SEARCHPATH "~/pxml-overrides" | ||
#define PND_PXML_OVERRIDE_KEY "overrides.searchpath" | ||
|
||
#define PND_MOUNT_PATH "/mnt/apps/" /* all mounted PND images should be here.. /mnt/apps/myapp/... */ | ||
|
||
/* pnd_apps_exec() is used to blindly launch an app, be it a .pnd file bundle or a plain executable | ||
* (shell, bin, whatever.) pndrun specifies the full path to the pnd_run sh script, which should be | ||
* found using searchpaths and locates.. see locatetest.c for a sample | ||
* if fullpath ends in PXML_FILENAME (PXML.xml) then pnd_run will be invoked (after extracting goodies | ||
* from PXML file as appropriate) | ||
* if fullpath ends in .pnd then pnd_run will be invoked (after inspecting embedded PXML or best-guess) | ||
* otherwise the fullpath will be executed as-is | ||
*/ | ||
signed char pnd_apps_exec ( char *fullpath, char *pndrun ); | ||
|
||
#ifdef __cplusplus | ||
} /* "C" */ | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
|
||
/* | ||
* libpnd - tools for the Open Pandora device | ||
* This code to be released under the terms of the GPLv2 | ||
*/ | ||
|
||
#ifndef h_pnd_conf_h | ||
#define h_pnd_conf_h | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/* Config file format | ||
* Since we're sticking configs in homedirs and /etc, it seems inappropriate to use XML; further | ||
* of course, XML means a heavy duty parser (expat or something at least) when people really just | ||
* use grep on these guys. Still, XML would afford us unicode which would be nice.. | ||
* Anyway, the very basic format of the config file supported herein is derived from .ini really | ||
* (sorry!) | ||
* | ||
* [section] | ||
* key value #comment | ||
* | ||
* Comments and leading/trailing space is removed; embedded space is left. | ||
* | ||
* Thats it; internally, 'section' is prepended to all keys, so it looks something like this. | ||
* Section can be [] to mean 'back to the top level.' I had | ||
* considered having no decorations around [section] (which is to say, a key with no value) but | ||
* I could see cases where folks want to have a valueless key, without something goofy like value | ||
* 'present' 'on' '0', when they just want a key 'use-foo' and don't want 'use foo' value 'no' | ||
* that feals yes/no-ey. | ||
* | ||
* NOTE: If a key is present in a config twice.. well, too bad. No warning is made. | ||
* | ||
* autodiscovery: | ||
* path /mnt/sd1/my/path | ||
* | ||
* Internally becomes: | ||
* | ||
* autodiscovery.path -> /mnt/sd1/my/path | ||
* | ||
*/ | ||
|
||
/* certain paths must be 'givens'; ideally as few assumptions as possible, but to | ||
* find further config files we need to look _somewhere_; note that searchpaths | ||
* are searched in order, so the most-canonicle should be listed last. | ||
* | ||
* NOTE: This search path is used to find the basic config files, which in turn | ||
* can specify a replacement config path .. it may be required to first locate the | ||
* 'conf' config, and then use its suggested searchpath! | ||
* | ||
*/ | ||
#define PND_CONF_SEARCHPATH "/mnt/sd1/pandora/conf:/mnt/sd2/pandora/conf:/etc/pandora:./testdata/conf" | ||
|
||
/* within the base conf file 'conf', the key for the searchpath is 'conf.searchpath' */ | ||
#define PND_CONF_FILE "conf" /* a config file for config settings! */ | ||
#define PND_CONF_KEY "conf.searchpath" /* if not found, use PND_CONF_SEARCHPATH */ | ||
|
||
/* we would like to open config files based on enums, so as to minimize specifying | ||
* filenames; ie: It makes it easier to rename them later or display them in a native | ||
* language, etc. It is optional as our API will allow direct open by filename as | ||
* well. | ||
*/ | ||
typedef enum { | ||
pnd_conf_nil = 0, | ||
pnd_conf_conf, // provides settings for the config system | ||
pnd_conf_apps, // provides application search-path, pxml override location, etc. | ||
pnd_conf_startup, // provides list of startup applications, basic shell application, etc. | ||
} pnd_conf_filename_e; | ||
|
||
typedef struct { | ||
pnd_conf_filename_e id; | ||
char *filename; | ||
} pnd_conf_filename_t; | ||
|
||
extern pnd_conf_filename_t pnd_conf_filenames[]; | ||
|
||
/* config file blackbox type | ||
*/ | ||
typedef void* pnd_conf_handle; | ||
|
||
/* | ||
* config FILE reading public API | ||
*/ | ||
|
||
/* fetch_searchpath() - since near every app may wish to use this piece of code, | ||
* it is encapsulated here. | ||
* Returns a search-path to be used hereafter; free it when done with it! | ||
*/ | ||
char *pnd_conf_query_searchpath ( void ); | ||
|
||
/* fetch_by_id() will try to locate the config file as referred to by the enum'd 'id'. If it | ||
* can be found and parsed a handle will be returned, otherwise a handle of 0 (NULL). | ||
* Returns a 0 handle on fail, otherwise a useful handle. | ||
*/ | ||
pnd_conf_handle pnd_conf_fetch_by_id ( pnd_conf_filename_e id, char *searchpath ); | ||
|
||
/* if you don't wish to use an 'id', you can fetch by filename. Essentially the fetch_by_id() | ||
* function simply uses this to do the work, but you could use it to load up alternate config-format | ||
* files. | ||
* Returns a 0 handle on fail, otherwise a useful handle. | ||
*/ | ||
pnd_conf_handle pnd_conf_fetch_by_name ( char *filename, char *searchpath ); | ||
|
||
/* fetch_by_path() will operate on a specific full filename; this essentially does the | ||
* dirty work for the above functions, but can be used to pull in a specific path for | ||
* whatever purpose. | ||
* Returns a 0 handle on fail, otherwise a useful handle. | ||
*/ | ||
pnd_conf_handle pnd_conf_fetch_by_path ( char *fullpath ); | ||
|
||
/* | ||
* config file accessor functions public API | ||
*/ | ||
|
||
/* get_as_char() will attempt to locate the specified key string (of format section,key) in the | ||
* provided config handle. Do not free up this value, it is considered read only. | ||
* Returns NULL on error, otherwise a READ ONLY char* reference to the value. | ||
*/ | ||
char *pnd_conf_get_as_char ( pnd_conf_handle c, char *key ); | ||
|
||
#ifdef __cplusplus | ||
} /* "C" */ | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
#ifndef h_pnd_container_h | ||
#define h_pnd_container_h | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
// this interface defines a simple container for storing unsorted data; it is likely to just be | ||
// the worst linked list you've ever seen, but could be changed later and applications should only | ||
// need a recompile | ||
|
||
// this simple 'Box' (shorter to type) container is not intended to be super efficient or highly usable | ||
// and as such does not include delete-node functionality or othe useful APIs, nor internal data to | ||
// support such operatins yet. Should performance become important, a hash or somesuch might be | ||
// needing implementing. | ||
|
||
// The user may have a payload of a simple char*string, or a struct, or whatever they choose to stuff | ||
// in there. | ||
|
||
typedef void* pnd_box_handle; | ||
|
||
/* return a new container with no contained nodes. | ||
* Returns NULL on failure. | ||
*/ | ||
pnd_box_handle pnd_box_new ( char *name ); | ||
|
||
/* delete the container and all of its contents. Note that of course you have to free up any memory | ||
* referred to in advance of this operation, lest there be leaks! | ||
* Assume success always (ie: the container is either destroyed or indeterminate after.) | ||
*/ | ||
void pnd_box_delete ( pnd_box_handle box ); | ||
|
||
/* allocinsert() is used to allocate a new entry in the container of the specified size; ie: | ||
* the 'key' is a regular char* string; the 'size' refers to the requested size of the payload | ||
* you need, not the size of the key. | ||
* Returns a new payload pointer of the requested size, or NULL. Do not free this payload pointer | ||
* ever by hand. | ||
*/ | ||
void *pnd_box_allocinsert ( pnd_box_handle box, char *key, unsigned int size ); | ||
|
||
/* find_by_key() will attempt to locate a payload based on the specified key. | ||
* Returns the payload pointer or NULL if not found. | ||
*/ | ||
void *pnd_box_find_by_key ( pnd_box_handle box, char *key ); | ||
|
||
/* should the user want to walk around the container, a couple basic functions are | ||
* provided. | ||
*/ | ||
char *pnd_box_get_name ( pnd_box_handle box ); | ||
void *pnd_box_get_head ( pnd_box_handle box ); | ||
char *pnd_box_get_key ( void *node ); | ||
void *pnd_box_get_next ( void *node ); | ||
|
||
#ifdef __cplusplus | ||
} /* "C" */ | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
#ifndef h_pnd_device_h | ||
#define h_pnd_device_h | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
// do we have a 'minimal' lib yet anywhere formalized? if not, we could | ||
// attempt to include it here. | ||
|
||
// set clock speed | ||
|
||
// set LED on | ||
|
||
// suspend/hibernate/etc | ||
|
||
#ifdef __cplusplus | ||
} /* "C" */ | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
|
||
#ifndef h_pnd_discovery_h | ||
#define h_pnd_discovery_h | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
// this code is for doing the application discovery against a given directory and its children (ie: this | ||
// code could be called on appliction startup, or as a result of media eject/insert, and so forth.) | ||
|
||
/* disco_search() will walk the given search path (one or more paths, colon separated) in order left to | ||
* right; as PXML's are found, basic analysis is performed to verfy validity. A list of valid applications | ||
* is returned, the union of all matches in the search path | ||
* If no matches are found, NULL is returned (to save you deleting the container) | ||
* overridespath may be NULL if you do not wish to search for pxml overrides | ||
*/ | ||
pnd_box_handle pnd_disco_search ( char *searchpath, char *overridespath ); | ||
|
||
/* pnd_disco_t describes a given entry found by the discovery code; ie: the containers key is the path to | ||
* the PXML file (since this is relatively unique), with the fields below detailing the executable path, | ||
* application name, unique-id and so on | ||
* | ||
* NOTE: this struct is dynamicly populated; you are responsible for invoking the destroy() function to | ||
* kill its contents, and the pnt_box_destroy() to kill the container at the end | ||
* | ||
* NOTE: The PXML path (or .pnd file path in bundle files) is used as a key since it is unique. The | ||
* application 'unique id' will be unique for a given app, but that app could be in multiple directories | ||
* or on multiple SD cards or wifi or whatever, so only the mounted path is truly unique. The key | ||
* is only used internally so the consumer can refer to multiple versions of the same app without | ||
* confusion.. it is not displayed. So no big deal. | ||
*/ | ||
|
||
typedef struct | ||
{ | ||
char *title_en; | ||
char *title_de; | ||
char *title_it; | ||
char *title_fr; | ||
char *unique_id; | ||
char *standalone; | ||
char *icon; | ||
char *description_en; | ||
char *description_de; | ||
char *description_it; | ||
char *description_fr; | ||
char *previewpic1; | ||
char *previewpic2; | ||
char *author_name; | ||
char *author_website; | ||
char *version_major; | ||
char *version_minor; | ||
char *version_release; | ||
char *version_build; | ||
char *exec; | ||
char *main_category; | ||
char *subcategory1; | ||
char *subcategory2; | ||
char *altcategory; | ||
char *altsubcategory1; | ||
char *altsubcategory2; | ||
char *osversion_major; | ||
char *osversion_minor; | ||
char *osversion_release; | ||
char *osversion_build; | ||
char *associationitem1_name; | ||
char *associationitem1_filetype; | ||
char *associationitem1_parameter; | ||
char *associationitem2_name; | ||
char *associationitem2_filetype; | ||
char *associationitem2_parameter; | ||
char *associationitem3_name; | ||
char *associationitem3_filetype; | ||
char *associationitem3_parameter; | ||
char *clockspeed; | ||
char *background; | ||
char *startdir; | ||
|
||
} pnd_disco_t; | ||
|
||
void pnd_disco_destroy ( pnd_disco_t *p ); // a function name that simply could not be avoided | ||
|
||
#ifdef __cplusplus | ||
} /* "C" */ | ||
#endif | ||
|
||
#endif |
Oops, something went wrong.