2 #include <stdio.h> /* for printf, NULL */
3 #include <stdlib.h> /* for free */
4 #include <string.h> /* for strdup */
7 #include "pnd_container.h"
9 #include "pnd_discovery.h"
10 #include "pnd_locate.h"
11 #include "pnd_pndfiles.h"
14 static void usage ( char *argv[] ) {
15 printf ( "%s\tObtain a description, install guide or other info about a pnd-file\n", argv [ 0 ] );
17 printf ( "%s path-to-pndfile [section] [section-2...]\n", argv [ 0 ] );
19 printf ( "section\tOptional. If not specified, general description is shown. (Section 'description')\n" );
20 printf ( "\tIf present, show the named section of the PXML -- such as to obtain install instructions etc.\n" );
21 printf ( "pndfile\tRequired. Full path to the pnd-file to execute.\n" );
25 #define SECTIONMAX 100
27 int main ( int argc, char *argv[] ) {
29 char *section [ SECTIONMAX ];
30 unsigned char sections = 0;
33 for ( i = 1; i < argc; i++ ) {
40 section [ sections++ ] = argv [ i ];
42 if ( sections == SECTIONMAX ) {
54 section [ sections++ ] = "description";
58 printf ( "Pndfile\t%s\n", pndfile );
59 printf ( "Sections to include:\n" );
60 for ( i = 0; i < sections; i++ ) {
61 printf ( "- %s\n", section [ i ] );
66 unsigned int pxmlbuflen = 96 * 1024; // lame, need to calculate it
67 char *pxmlbuf = malloc ( pxmlbuflen );
69 printf ( "ERROR: RAM exhausted!\n" );
72 memset ( pxmlbuf, '\0', pxmlbuflen );
74 FILE *f = fopen ( pndfile, "r" );
76 printf ( "ERROR: Couldn't open pndfile %s!\n", pndfile );
80 pnd_pxml_handle h = NULL;
81 pnd_pxml_handle *apps = NULL;
82 if ( pnd_pnd_seek_pxml ( f ) ) {
83 if ( pnd_pnd_accrue_pxml ( f, pxmlbuf, pxmlbuflen ) ) {
84 apps = pnd_pxml_fetch_buffer ( "pnd_run", pxmlbuf );
91 printf ( "ERROR: Couldn't pull PXML.xml from the pndfile.\n" );
95 // iterate across apps
100 for ( i = 0; i < sections; i++ ) {
103 if ( strcasecmp ( section [ i ], "description" ) == 0 ) {
105 printf ( "Section: %s\n", section [ i ] );
107 if ( ( t = pnd_pxml_get_description_en ( h ) ) ) {
108 printf ( "%s\n", t );
110 printf ( "Not supplied by PXML.xml in the pnd-file\n" );