00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00024 static xmlDoc *theManifest = NULL;
00025
00026
00027
00028 int manifest_get_page_count(char* type)
00029 {
00030 parseIndexdata()
00031 }
00032
00033
00034
00035 static void getPagelistInfo(xmlChar *type)
00036 {
00037 cur = indexNode->children;
00038
00039 while (cur != NULL)
00040 {
00041 if (!xmlStrcmp(cur->name, (const xmlChar *) "pagelist"))
00042 {
00043 CL_LOGPRINTF("Found node pagelist");
00044 if (!xmlStrcmp(type, xmlGetProp(cur, (const xmlChar *) "type")))
00045 {
00046 return xmlGetProp(cur, (const xmlChar *) "count");
00047 }
00048 }
00049 cur = cur->next;
00050 }
00051 return;
00052 }
00053
00054 int erBrXmlParseManifest(char *szFilename)
00055 {
00056 xmlNode *rootElement = NULL;
00057 xmlNode *cur = NULL;
00058
00059 theManifest = xmlParseFile(szFilename);
00060
00061 if (theManifest == NULL)
00062 {
00063 CL_ERRORPRINTF("Document not parsed successfully");
00064 return -1;
00065 }
00066
00067
00068 rootElement = xmlDocGetRootElement(theManifest);
00069
00070
00071 if (xmlStrcmp(rootElement->name, (const xmlChar *) "package"))
00072 {
00073 CL_ERRORPRINTF("Document of the wrong type, root node != package");
00074 xmlFreeDoc(theManifest);
00075
00076 return -1;
00077 }
00078
00079 cur = rootElement->children;
00080 while (cur != NULL)
00081 {
00082 if ((!xmlStrcmp(cur->name, (const xmlChar *) "index")))
00083 {
00084 CL_LOGPRINTF("Found node: index");
00085 indexNode = cur;
00086 break;
00087 }
00088
00089 cur = cur->next;
00090 }
00091
00092 return 0;
00093 }
00094
00095 void erBrXmlFreeManifest()
00096 {
00097
00098 xmlFreeDoc(theManifest);
00099
00100
00101 xmlCleanupParser();
00102 }
00103
00104
00105
00106
00107
00108 static int url_compare(char *manifest, char *full_path, char *relative_file)
00109 {
00110 int len1, len2;
00111 char *temp, *prefix_path, *local_path;
00112
00113 BR_MANIFESTPRINTF("Comparing urls: %s and %s\n", full_path, relative_file);
00114
00115 temp = strdup(manifest);
00116 prefix_path = dirname(temp);
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 len1 = strlen(relative_file);
00132 len2 = strlen(prefix_path);
00133
00134
00135 if (strncmp(relative_file, "./", 2) == 0)
00136 {
00137 relative_file+=2;
00138 }
00139
00140 local_path = (char*)malloc(sizeof(char)*(len1+len2+1));
00141 strcpy(local_path, prefix_path);
00142 strcat(local_path, "/");
00143 strcat(local_path, relative_file);
00144
00145 if (strcmp(full_path, local_path) == 0)
00146 {
00147
00148 return 0;
00149 }
00150 else
00151 {
00152
00153 return -1;
00154 }
00155 }