minimenu now has a (lame) 'reveal this normally hidden' category option in the select...
[pandora-libraries.git] / apps / pndvalidator.c
1
2 /* pndvalidator - a really dumb little tool to check a given PXML-app or pnd-app for 'compliance'.
3  * The "PXML spec" is not hard-defined so hopefull yover time this tool will prove useful, if it is
4  * updated to be 'tough enough' on PXML/pnd's and people actually use it
5  */
6
7 #include <stdio.h>     // for stdio
8 #include <string.h>    // for strcmp
9 #include "pnd_conf.h"
10 #include "pnd_apps.h"
11 #include "pnd_pxml.h"
12 #include "pnd_utility.h"
13
14 int main ( int argc, char *argv[] ) {
15   char *fullpath = NULL;
16   unsigned char do_override = 0;
17   unsigned char do_assets = 0;
18
19   if ( argc <= 1 ) {
20     printf ( "usage: %s [options] path-to-file\n", argv [ 0 ] );
21     printf ( "\n" );
22     printf ( "path-to-file\tCan refer to a PXML.xml in a subdir, or can refer to a .pnd-style application bundle\n" );
23     printf ( "\n" );
24     printf ( "Options:\n" );
25     printf ( "\t-a\tattempt to mount and verify assets (executable, icon, screenshots, etc) are present\n" );
26     printf ( "\t-m\tattempt to merge in PXML-overrides and validate against the result\n" );
27     printf ( "\n" );
28     printf ( "By default, the validator will only pick up the PXML and perform checks on field content.\n" );
29     return ( 0 );
30   }
31
32   unsigned char i = 1;
33
34   while ( i < argc ) {
35
36     if ( strncmp ( argv [ i ], "-m", 2 ) == 0 ) {
37       do_override = 1;
38     } else if ( strncmp ( argv [ i ], "-a", 2 ) == 0 ) {
39       do_assets = 1;
40     } else {
41       fullpath = argv [ i ];
42     }
43
44     i++;
45
46   } // while
47
48   // summarize
49
50   if ( do_assets ) {
51     printf ( "Note: Will attempt to examine application assets\n" );
52   }
53
54   if ( do_override ) {
55     printf ( "Note: Will merge PXML-overrides if found (not an error if not found.)\n" );
56   }
57
58   if ( ! fullpath ) {
59     printf ( "ERROR: No path provided.\n" );
60     return ( 0 );
61   }
62
63   printf ( "Path to examine: %s\n", fullpath );
64
65   printf ( "\n" );
66
67   //
68   // actually do useful work
69   //
70
71   pnd_pxml_handle *pxmlapps;
72
73   pxmlapps = pnd_pxml_get_by_path ( fullpath );
74
75   if ( ! pxmlapps ) {
76     printf ( "ERROR: PXML could not be extracted meaningfully.\n" );
77     return ( 0 );
78   }
79
80   printf ( "Got back a meaningful list of PXMLs.\n" );
81
82   pnd_pxml_handle h = *pxmlapps;
83
84   while ( h ) {
85
86     /* check the content
87      */
88
89     // check for required fields
90
91     // exec-path?
92
93     // app name?
94
95     // unique ID
96
97     // package-name (shortname)
98
99     // free up that particular pxml_handle within the return-list
100
101     // next
102     pxmlapps++;
103     h = pxmlapps;
104   } // while
105
106   /* done!
107    */
108   pnd_pxml_delete ( pxmlapps );
109
110   return ( 0 );
111 }