erbrowser/src/metaDataParser.cpp File Reference

Go to the source code of this file.

Functions

int manifest_get_page_count (char *type)
static void getPagelistInfo (xmlChar *type)
int erBrXmlParseManifest (char *szFilename)
void erBrXmlFreeManifest ()
static int url_compare (char *manifest, char *full_path, char *relative_file)

Variables

static xmlDoc * theManifest = NULL


Function Documentation

void erBrXmlFreeManifest (  ) 

Definition at line 95 of file metaDataParser.cpp.

00096 {
00097     /* free the document */
00098     xmlFreeDoc(theManifest);
00099 
00100     /* Free the global variables that may have been allocated by the parser */
00101     xmlCleanupParser();
00102 }

int erBrXmlParseManifest ( char *  szFilename  ) 

Definition at line 54 of file metaDataParser.cpp.

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     /* Get the root element node */
00068     rootElement = xmlDocGetRootElement(theManifest);
00069 
00070     // Check whether we have a document with the correct root (i.e. package)
00071     if (xmlStrcmp(rootElement->name, (const xmlChar *) "package"))
00072     {
00073         CL_ERRORPRINTF("Document of the wrong type, root node != package");
00074         xmlFreeDoc(theManifest);
00075         // return ER_MDS_XML_FORMAT;
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 }

static void getPagelistInfo ( xmlChar *  type  )  [static]

Definition at line 35 of file metaDataParser.cpp.

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 }

int manifest_get_page_count ( char *  type  ) 

Definition at line 28 of file metaDataParser.cpp.

00029 {
00030     parseIndexdata()
00031 }

static int url_compare ( char *  manifest,
char *  full_path,
char *  relative_file 
) [static]

Definition at line 108 of file metaDataParser.cpp.

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 /* TODO: 
00119      Need to work on this code some more... */
00120 /*
00121   result = strtok(relative_file, "/");
00122   printf("(before)result=\"%s\"\n", result);
00123   while (strcmp(result, "..") == 0)
00124   {
00125     printf("(in while)result=\"%s\"\n", result);
00126     result = strtok(NULL, "/");
00127   }
00128   printf("(after)result=\"%s\"\n", result);
00129 */
00130   
00131   len1 = strlen(relative_file);
00132   len2 = strlen(prefix_path);
00133   
00134   // Remove ./ from beginning of relative_file
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     // files are equal
00148     return 0;
00149   }
00150   else
00151   {
00152     // files are not equal
00153     return -1;
00154   }
00155 }


Variable Documentation

xmlDoc* theManifest = NULL [static]

Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.

Definition at line 24 of file metaDataParser.cpp.


Generated on Sun Dec 14 17:14:51 2008 by  doxygen 1.5.6