~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/file/geom/ffg_read.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)
  2   */
  3 #include <stdio.h>
  4 #include <tina/sys.h>
  5 #include <tina/sysfuncs.h>
  6 #include <tina/math.h>
  7 #include <tina/vision.h>
  8 #include <tina/visionfuncs.h>
  9 
 10 extern Bool fclose_2(FILE * stream, const char *pathname);
 11 extern FILE *fopen_2(const char *pathname, const char *mode);
 12 
 13 Match_cliche *match_cliche_read(FILE * stream, List * list)
 14 {
 15     int     label;
 16     void   *focus;
 17     void   *geom_getbylabel();
 18     int     ftype;
 19     List   *group = NULL;
 20     int     i, count;
 21 
 22     if (fscanf(stream, "%d %d", &label, &count) == EOF)
 23     {
 24         error("unexpected end of file", non_fatal);
 25         return (NULL);
 26     }
 27     focus = geom_getbylabel(list, label, &ftype);
 28     if (focus == NULL)
 29         return (NULL);
 30 
 31     for (i = 0; i < count; ++i)
 32     {
 33         void   *feature;
 34         int     type;
 35 
 36         if (fscanf(stream, "%d", &label) == EOF)
 37         {
 38             error("unexpected end of file", non_fatal);
 39             return (NULL);
 40         }
 41         feature = geom_getbylabel(list, label, &type);
 42         group = ref_addtostart(group, feature, type);
 43     }
 44     return (match_cliche_make(link_alloc(focus, ftype), 1, group, 5));
 45 }
 46 
 47 List   *ffg_read_file_fp(FILE * stream, List * list)
 48 {
 49     List   *cliche_list = NULL;
 50     int     i, count;
 51 
 52     if (fscanf(stream, "%d", &count) == EOF)
 53     {
 54         error("unexpected end of file", non_fatal);
 55         return (NULL);
 56     }
 57     for (i = 0; i < count; ++i)
 58     {
 59         Match_cliche *cliche = match_cliche_read(stream, list);
 60 
 61         if (cliche == NULL)
 62         {
 63             error("problem reading ffg file", non_fatal);
 64             list_rm(cliche_list, match_cliche_free);
 65             return (NULL);
 66         }
 67         cliche_list = ref_addtostart(cliche_list, (void *) cliche, MATCH_CLICHE);
 68     }
 69     return (list_reverse(cliche_list));
 70 }
 71 
 72 List   *ffg_read_file(char *pathname, List * list)
 73 {
 74     List   *cliche_list = NULL;
 75     FILE   *stream = fopen_2(pathname, "r");
 76 
 77     if (stream)
 78     {
 79         cliche_list = ffg_read_file_fp(stream, list);
 80         (void) fclose_2(stream, pathname);
 81     }
 82     return (cliche_list);
 83 }
 84 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.