ccstruct/rwpoly.cpp

Go to the documentation of this file.
00001 
00021 #include "mfcpch.h"
00022 #include          "pageblk.h"
00023 #include          "rwpoly.h"
00024 
00025 #include          "hpddef.h"     //must be last (handpd.dll)
00026 
00027 #define EXTERN
00028 
00029 EXTERN DLLSYM PAGE_BLOCK_LIST *page_block_list;
00030 EXTERN PAGE_BLOCK_IT page_block_it;
00031 
00034 EXTERN BOOL_VAR (blocks_read_asc, TRUE, "Read blocks in ascii format");
00035 EXTERN BOOL_VAR (blocks_write_asc, TRUE, "Write blocks in ascii format");
00038 DLLSYM void write_poly_blocks(FILE *blfile, PAGE_BLOCK_LIST *blocks) { 
00039   if (blocks_write_asc)
00040     blocks->serialise_asc (blfile);
00041   else
00042     blocks->serialise (blfile);
00043 
00044   return;
00045 }
00046 
00047 
00051 DLLSYM PAGE_BLOCK_LIST *read_poly_blocks(                  //read file
00052                                          const char *name  //file to read
00053                                         ) {
00054   FILE *infp;
00055   int c;
00056   INT16 number_of_pblocks;
00057                                  //output list
00058   PAGE_BLOCK_LIST *pb_list = NULL;
00059   PAGE_BLOCK *page_block;        //new block for list
00060   INT32 len;                     /*length to retrive */
00061   PAGE_BLOCK_IT it;
00062 
00063   if ((infp = fopen (name, "r")) != NULL) {
00064     if (((c = fgetc (infp)) != EOF) && (ungetc (c, infp) != EOF)) {
00065       if (blocks_read_asc) {
00066         pb_list = new PAGE_BLOCK_LIST;
00067 
00068         len = de_serialise_INT32 (infp);
00069         it.set_to_list (pb_list);
00070         for (; len > 0; len--) {
00071           page_block = PAGE_BLOCK::new_de_serialise_asc (infp);
00072                                  /*put on the list */
00073           it.add_to_end (page_block);
00074         }
00075       }
00076       else
00077         pb_list = PAGE_BLOCK_LIST::de_serialise (infp);
00078       page_block_list = pb_list; //set global for now
00079     }
00080     fclose(infp); 
00081   }
00082   else {
00083                                  //can't open file
00084     CANTOPENFILE.error ("read_poly_blocks", LOG, name);
00085     pb_list = new PAGE_BLOCK_LIST;
00086     page_block_list = pb_list;   //set global for now
00087   }
00088   page_block_it.set_to_list (pb_list);
00089   number_of_pblocks = pb_list->length ();
00090 
00091   printf ("%d page blocks read\n", number_of_pblocks);
00092   return pb_list;
00093 
00094 }

Generated on Wed Feb 28 19:49:08 2007 for Tesseract by  doxygen 1.5.1