
Go to the source code of this file.
Classes | |
| struct | _PageTypeInfo |
| struct | _PageNmbrInfo |
| struct | _PageUrlInfo |
| struct | _PageInfo |
| struct | _pagelistItem |
| struct | _IndexInfo |
Defines | |
| #define | INVALID_PAGE_COUNT (-1) |
| #define | INVALID_PAGE_NMBR (-1) |
| #define | DEFAULT_PAGE_COUNT 1 |
| #define | DEFAULT_PAGE 1 |
| #define | DEFAULT_PAGE_OFFSET 100 |
| #define | INVALID_PAGE_TYPE "unknown" |
| #define | INIT_PAGE_TYPE "init" |
| #define | ONE_PAGE_TYPE "one_page" |
Typedefs | |
| typedef struct _PageTypeInfo | PageTypeInfo |
| typedef struct _PageNmbrInfo | PageNmbrInfo |
| typedef struct _PageUrlInfo | PageUrlInfo |
| typedef struct _PageInfo | PageInfo |
| typedef struct _pagelistItem | PageListItem |
| typedef struct _IndexInfo | IndexInfo |
Functions | |
| void | index_file_close (IndexInfo *index) |
| int | index_file_init (const char *file, IndexInfo *index) |
| int | index_file_get_page_count (IndexInfo *index, const char *type) |
| int | index_file_get_page_number (IndexInfo *index, const char *type, const char *url) |
| char * | index_file_get_page_location (IndexInfo *index, const char *type, const int number) |
| void | dump (IndexInfo *index) |
| #define DEFAULT_PAGE 1 |
Definition at line 36 of file indexFileHandler.h.
| #define DEFAULT_PAGE_COUNT 1 |
Definition at line 35 of file indexFileHandler.h.
| #define DEFAULT_PAGE_OFFSET 100 |
Definition at line 37 of file indexFileHandler.h.
| #define INIT_PAGE_TYPE "init" |
Definition at line 39 of file indexFileHandler.h.
| #define INVALID_PAGE_COUNT (-1) |
Definition at line 33 of file indexFileHandler.h.
| #define INVALID_PAGE_NMBR (-1) |
Definition at line 34 of file indexFileHandler.h.
| #define INVALID_PAGE_TYPE "unknown" |
Definition at line 38 of file indexFileHandler.h.
| #define ONE_PAGE_TYPE "one_page" |
Definition at line 40 of file indexFileHandler.h.
| typedef struct _IndexInfo IndexInfo |
| typedef struct _pagelistItem PageListItem |
| typedef struct _PageNmbrInfo PageNmbrInfo |
| typedef struct _PageTypeInfo PageTypeInfo |
| typedef struct _PageUrlInfo PageUrlInfo |
| void dump | ( | IndexInfo * | index | ) |
Dump IndexInfo information, for debug
| IndexInfo | reference to the current inde file |
Definition at line 830 of file indexFileHandler.cpp.
00831 { 00832 if (NULL == index) return; 00833 00834 printf("=======================Index file information=======================\n"); 00835 printf("length %d\n", index->length); 00836 for(int i = 0; i <index->length; ++i) 00837 { 00838 PageListItem *pItem = index->pagelist[i]; 00839 printf("\titem type: %s\tcount: %d\n", pItem->type, pItem->count); 00840 00841 for(int j = 0; j < pItem->count; ++j) 00842 { 00843 PageInfo *pInf = pItem->page[j]; 00844 printf("\t\tpage number: %d\turl: %s\n", pInf->number, pInf->url); 00845 } 00846 } 00847 printf("====================================================================\n"); 00848 }
| void index_file_close | ( | IndexInfo * | index | ) |
Close the index/manifest file
| IndexInfo | pointer |
Definition at line 678 of file indexFileHandler.cpp.
00679 { 00680 if (NULL == index) 00681 { 00682 TRACE("Invalid IndexInfo pointer!"); 00683 return; 00684 } 00685 00686 if (NULL == index->pagelist || 0 >= index->length) 00687 { 00688 // not initialized 00689 return; 00690 } 00691 00692 // release all memory 00693 for(int i = 0; i < index->length; ++i) 00694 { 00695 pageListItem_release(index->pagelist[i]); 00696 } 00697 free(index->pagelist); 00698 }

| int index_file_get_page_count | ( | IndexInfo * | index, | |
| const char * | type | |||
| ) |
Retrieve the page count from the index file, given the page type
| FILE | reference to the current inde file | |
| type | page type |
Definition at line 733 of file indexFileHandler.cpp.
00734 { 00735 if (NULL == index) 00736 { 00737 TRACE("Invalid index pointer!"); 00738 return INVALID_PAGE_COUNT; 00739 } 00740 00741 if (NULL == type) 00742 { 00743 TRACE("Invalid type pointer!"); 00744 return INVALID_PAGE_COUNT; 00745 } 00746 00747 for(int i = 0; i < index->length; ++i) 00748 { 00749 if (0 == strcmp(index->pagelist[i]->type, type)) 00750 { 00751 return index->pagelist[i]->count; 00752 } 00753 } 00754 return INVALID_PAGE_COUNT; 00755 }
| char* index_file_get_page_location | ( | IndexInfo * | index, | |
| const char * | type, | |||
| const int | number | |||
| ) |
Retrieve the page number from the index file, given the page type and the url
| IndexInfo | reference to the current inde file | |
| type | page type | |
| number | page number |
Definition at line 798 of file indexFileHandler.cpp.
00799 { 00800 if (NULL == index) 00801 { 00802 TRACE("Invalid index pointer!"); 00803 return NULL; 00804 } 00805 00806 if (NULL == type) 00807 { 00808 TRACE("Invalid type pointer!"); 00809 return NULL; 00810 } 00811 00812 00813 for(int i = 0; i < index->length; ++i) 00814 { 00815 if (0 == strcmp(index->pagelist[i]->type, type)) 00816 { 00817 PageListItem *pItem = index->pagelist[i]; 00818 for(int j = 0; j < pItem->count; ++j) 00819 { 00820 if (number == pItem->page[j]->number) 00821 { 00822 return pItem->page[j]->url; 00823 } 00824 } 00825 } 00826 } 00827 return NULL; 00828 }
| int index_file_get_page_number | ( | IndexInfo * | index, | |
| const char * | type, | |||
| const char * | url | |||
| ) |
Retrieve the page number from the index file, given the page type and the url
| IndexInfo | reference to the current index struct | |
| type | page type | |
| url | page url |
Definition at line 760 of file indexFileHandler.cpp.
00761 { 00762 if (NULL == index) 00763 { 00764 TRACE("Invalid index pointer!"); 00765 return INVALID_PAGE_COUNT; 00766 } 00767 00768 if (NULL == type) 00769 { 00770 TRACE("Invalid type pointer!"); 00771 return INVALID_PAGE_COUNT; 00772 } 00773 00774 if (NULL == url) 00775 { 00776 TRACE("Invalid url pointer!"); 00777 return INVALID_PAGE_COUNT; 00778 } 00779 00780 for(int i = 0; i < index->length; ++i) 00781 { 00782 if (0 == strcmp(index->pagelist[i]->type, type)) 00783 { 00784 PageListItem *pItem = index->pagelist[i]; 00785 for(int j = 0; j < pItem->count; ++j) 00786 { 00787 // should use contain_url. 00788 if (contain_url(url, pItem->page[j]->url)) 00789 { 00790 return pItem->page[j]->number; 00791 } 00792 } 00793 } 00794 } 00795 return INVALID_PAGE_NMBR; 00796 }

| int index_file_init | ( | const char * | file, | |
| IndexInfo * | index | |||
| ) |
Open the index/manifest file
| file | name |
Definition at line 700 of file indexFileHandler.cpp.
00701 { 00702 pIndex->pagelist = NULL; 00703 pIndex->length = 0; 00704 erManifest manifest; 00705 if (RET_OK != ermXmlOpenFile(pathName, &manifest)) 00706 { 00707 TRACE("Could not open manifest file %s", pathName); 00708 return -1; 00709 } 00710 00711 pIndex->length = get_pagelist_length(&manifest); 00712 if (0 >= pIndex->length) 00713 { 00714 TRACE("No Pagelist item!"); 00715 return 0; 00716 } 00717 00718 // construct one by one 00719 pIndex->pagelist = (PageListItem **)malloc(pIndex->length * sizeof(PageListItem *)); 00720 for(int i = 0; i < pIndex->length; ++i) 00721 { 00722 pIndex->pagelist[i] = pageListItem_create(&manifest, i + 1); 00723 } 00724 ermXmlClose(&manifest); 00725 00726 #if (INDEX_DEBUG) 00727 dump(pIndex); 00728 #endif 00729 00730 return 0; 00731 }

1.5.6