Added basic pndvalidator app, though it doesn't actually validate anyone. <- fill...
authorskeezix <skeezix@flotsam-vm.(none)>
Wed, 10 Jun 2009 03:16:21 +0000 (23:16 -0400)
committerskeezix <skeezix@flotsam-vm.(none)>
Wed, 10 Jun 2009 03:16:21 +0000 (23:16 -0400)
Added <package name="foo" released="bar"/> to PXML parser

Makefile
apps/pndnotifyd.c
include/pnd_pxml.h
include/pnd_pxml_names.h
include/pnd_utility.h
lib/pnd_tinyxml.cpp
lib/pnd_utility.c

index d359b3e..b3c4bb7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -23,10 +23,10 @@ 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 pnd_pndfiles.o pnd_apps.o pnd_utility.o pnd_desktop.o
 
-all: ${SOLIB} ${LIB} conftest discotest notifytest pndnotifyd rawpxmltest
+all: ${SOLIB} ${LIB} conftest discotest notifytest pndnotifyd rawpxmltest pndvalidator
 
 clean:
-       ${RM} -f ${ALLOBJ} ${XMLOBJ} ${LIB} ${SOLIB1} locatetest.o bin/locatetest conftest.o bin/conftest discotest.o bin/discotest bin/notifytest notifytest.o bin/rawpxmltest rawpxmltest.o bin/pndnotifyd pndnotifyd.o ${SOLIB} testdata/dotdesktop/*.desktop testdata/apps/*.pnd testdata/dotdesktop/*.png deployment/usr/lib/libpnd* deployment/usr/bin/pndnotifyd deployment/usr/pandora/scripts/* deployment/etc/sudoers deployment/etc/init.d/pndnotifyd
+       ${RM} -f ${ALLOBJ} ${XMLOBJ} ${LIB} ${SOLIB1} locatetest.o bin/locatetest conftest.o bin/conftest discotest.o bin/discotest bin/notifytest notifytest.o bin/rawpxmltest rawpxmltest.o bin/pndnotifyd pndnotifyd.o ${SOLIB} testdata/dotdesktop/*.desktop testdata/apps/*.pnd testdata/dotdesktop/*.png deployment/usr/lib/libpnd* deployment/usr/bin/pndnotifyd deployment/usr/pandora/scripts/* deployment/etc/sudoers deployment/etc/init.d/pndnotifyd bin/pndvalidator
        ${RM} -rf deployment/media
        find . -name "*~*" -exec rm {} \; -print
 
@@ -41,9 +41,16 @@ libpnd.so.1: ${ALLOBJ} ${XMLOBJ}
        ${CC} -shared -Wl,-soname,${SOLIB} -o ${SOLIB1} ${ALLOBJ} ${XMLOBJ}
        ln -f -s ${SOLIB1} ${SOLIB}
 
+${SOLIB1}:     ${ALLOBJ} ${XMLOBJ}
+       ${CC} -shared -Wl,-soname,${SOLIB} -o ${SOLIB1} ${ALLOBJ} ${XMLOBJ}
+       ln -f -s ${SOLIB1} ${SOLIB}
+
 pndnotifyd:    pndnotifyd.o ${SOLIB1}
        ${CC} -lstdc++ -o bin/pndnotifyd pndnotifyd.o ${SOLIB1}
 
+pndvalidator:  pndvalidator.o ${SOLIB1}
+       ${CC} -lstdc++ -o bin/pndvalidator pndvalidator.o ${SOLIB1}
+
 # deployment and assembly components
 #
 
index b4eb678..b1afc4c 100644 (file)
@@ -27,6 +27,7 @@
 #include "../lib/pnd_pathiter.h"
 #include "pnd_discovery.h"
 #include "pnd_locate.h"
+#include "pnd_pxml.h"
 #include "pnd_utility.h"
 #include "pnd_desktop.h"
 
index f54b9b7..693b26a 100644 (file)
@@ -138,6 +138,8 @@ typedef struct
        char *clockspeed;
        char *background;
        char *startdir;
+       char *package_name;
+       char *package_release_date;
 
 }  pnd_pxml_t;
 
index 5076736..2aef7a4 100644 (file)
@@ -81,8 +81,13 @@ extern "C" {
 #define PND_PXML_ENAME_CLOCK "clockspeed"
 #define PND_PXML_ATTRNAME_CLOCKFREQ "frequency"
 
+/* <package name="foo" released="1/1/0001"/> */
+#define PND_PXML_ENAME_PACKAGE "package"
+#define PND_PXML_ATTRNAME_PACKAGE_NAME "name"
+#define PND_PXML_ATTRNAME_PACKAGE_DATE "released"
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
 
-#endif /* ifndef h_pnd_pxml_names_h */
\ No newline at end of file
+#endif /* ifndef h_pnd_pxml_names_h */
index 81c5f9d..a9638ce 100644 (file)
@@ -13,6 +13,12 @@ char *pnd_expand_tilde ( char *freeable_buffer );
 // arbtrary execute function; fire and forget really
 void pnd_exec_no_wait_1 ( char *fullpath, char *arg1 );
 
+// pnd_pxml_get_always() will work against a PXML.xml file or a foo.pnd app-bundle and return
+// the resulting PXML structure, or fail; ie: It should be handy to avoid the user having to
+// do the 'what type is this, and if-this-or-that' themselves.
+//   NOTE: Does _NOT_ automatically pick up PXML-overrides; you can call that function if you want
+pnd_pxml_handle pnd_pxml_get_by_path ( char *fullpath );
+
 #ifdef __cplusplus
 } /* "C" */
 #endif
index 9fbb25f..c8e42c9 100644 (file)
@@ -305,6 +305,13 @@ unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int
                app->clockspeed = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_CLOCKFREQ);
        }
 
+       // Package
+       pElem = hRoot.FirstChild ( PND_PXML_ENAME_PACKAGE ).Element();
+       if ( pElem ) {  
+         app -> package_name = pnd_pxml_get_attribute ( pElem, PND_PXML_ATTRNAME_PACKAGE_NAME );
+         app -> package_release_date = pnd_pxml_get_attribute ( pElem, PND_PXML_ATTRNAME_PACKAGE_DATE );
+       }
+
        return (1);
 }
 
index d66b9d3..a0452ab 100644 (file)
@@ -1,10 +1,15 @@
 
 #include <stdio.h> /* for FILE etc */
 #include <stdlib.h> /* for malloc */
+#define __USE_GNU /* for strcasestr */
 #include <string.h> /* for making ftw.h happy */
 #include <unistd.h> /* for fork exec */
 
+#include "pnd_pxml.h"
+#include "pnd_container.h"
 #include "pnd_utility.h"
+#include "pnd_pndfiles.h"
+#include "pnd_discovery.h"
 
 // a generalized variable-substitution routine might be nice; for now we need a quick tilde one,
 // so here goes. Brute force ftw!
@@ -58,3 +63,56 @@ void pnd_exec_no_wait_1 ( char *fullpath, char *arg1 ) {
 
   return;
 }
+
+pnd_pxml_handle pnd_pxml_get_by_path ( char *fullpath ) {
+  unsigned char valid = pnd_object_type_unknown;
+  pnd_pxml_handle pxmlh = 0;
+
+  // WARN: this is way too close to callback in pnd_disco .. should be refactored!
+
+  if ( strcasestr ( fullpath, PXML_FILENAME ) ) {
+    valid = pnd_object_type_directory;
+  } else if ( strcasestr ( fullpath, PND_PACKAGE_FILEEXT "\0" ) ) {
+    valid = pnd_object_type_pnd;
+  }
+
+  // if not a file of interest, just keep looking until we run out
+  if ( ! valid ) {
+    return ( 0 );
+  }
+
+  // potentially a valid application
+  if ( valid == pnd_object_type_directory ) {
+    pxmlh = pnd_pxml_fetch ( (char*) fullpath );
+
+  } else if ( valid == pnd_object_type_pnd ) {
+    FILE *f;
+    char pxmlbuf [ 32 * 1024 ]; // TBD: assuming 32k pxml accrual buffer is a little lame
+
+    // open it up..
+    f = fopen ( fullpath, "r" );
+
+    // try to locate the PXML portion
+    if ( ! pnd_pnd_seek_pxml ( f ) ) {
+      fclose ( f );
+      return ( 0 ); // pnd or not, but not to spec. Pwn'd the pnd?
+    }
+
+    // accrue it into a buffer
+    if ( ! pnd_pnd_accrue_pxml ( f, pxmlbuf, 32 * 1024 ) ) {
+      fclose ( f );
+      return ( 0 );
+    }
+
+    // by now, we have <PXML> .. </PXML>, try to parse..
+    pxmlh = pnd_pxml_fetch_buffer ( (char*) fullpath, pxmlbuf );
+
+    // done with file
+    fclose ( f );
+
+  }
+
+  // ..
+
+  return ( pxmlh );
+}