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

Linux Cross Reference
Tina4/src/file/geom/ffg_new_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 
 12 Match_cliche *match_cliche_new_read(List * list, FILE * stream, const char *pathname)
 13 {
 14     int     label;
 15     void   *geom_getbylabel();
 16     List   *focus = NULL;
 17     List   *group = NULL;
 18     int     i, fthres, gthres, count;
 19 
 20     if (fscanf(stream, "%d %d", &count, &fthres) == EOF)
 21     {
 22         errorf(non_fatal, "unexpected end of file: %s\n", pathname);
 23         return (NULL);
 24     }
 25     for (i = 0; i < count; ++i)
 26     {
 27         void   *feature;
 28         int     type;
 29 
 30         if (fscanf(stream, "%d", &label) == EOF)
 31         {
 32             errorf(non_fatal, "unexpected end of file: %s\n", pathname);
 33             return (NULL);
 34         }
 35         feature = geom_getbylabel(list, label, &type);
 36         focus = ref_addtostart(focus, feature, type);
 37     }
 38 
 39     if (fscanf(stream, "%d %d", &count, &gthres) == EOF)
 40     {
 41         error("unexpected end of file", non_fatal);
 42         return (NULL);
 43     }
 44     for (i = 0; i < count; ++i)
 45     {
 46         void   *feature;
 47         int     type;
 48 
 49         if (fscanf(stream, "%d", &label) == EOF)
 50         {
 51             errorf(non_fatal, "unexpected end of file: %s\n", pathname);
 52             return (NULL);
 53         }
 54         feature = geom_getbylabel(list, label, &type);
 55         group = ref_addtostart(group, feature, type);
 56     }
 57 
 58     return (match_cliche_make(focus, fthres, group, gthres));
 59 }
 60 
 61 List   *ffg_new_read_file_stream(List * list, FILE * stream, const char *pathname)
 62 {
 63     List   *cliche_list = NULL;
 64     int     i, count;
 65 
 66     if (fscanf(stream, "%d", &count) == EOF)
 67     {
 68         errorf(non_fatal, "unexpected end of file: %s\n", pathname);
 69         return (NULL);
 70     }
 71     for (i = 0; i < count; ++i)
 72     {
 73         Match_cliche *cliche = match_cliche_new_read(list, stream, pathname);
 74 
 75         if (cliche == NULL)
 76         {
 77             errorf(non_fatal, "problem reading ffg file: %s\n", pathname);
 78             list_rm(cliche_list, match_cliche_free);
 79             return (NULL);
 80         }
 81         cliche_list = ref_addtostart(cliche_list, (void *) cliche, MATCH_CLICHE);
 82     }
 83     return (list_reverse(cliche_list));
 84 }
 85 
 86 List   *ffg_new_read_file(char *pathname, List * list)
 87 {
 88     List   *cliche_list;
 89     FILE   *stream = fopen(pathname, "r");
 90 
 91     if (stream)
 92     {
 93         cliche_list = ffg_new_read_file_stream(list, stream, pathname);
 94         (void) fclose_2(stream, pathname);
 95     }
 96     return (cliche_list);
 97 }
 98 

~ [ 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.