Main Page   Compound List   File List   Compound Members   File Members  

read_free.c

Go to the documentation of this file.
00001 /* 
00002  *  Cflow2VCG
00003  *  Copyright (C) 2001 Guilhem BONNEFILLE
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018  */
00019 
00020 #include <assert.h>
00021 #include <stdlib.h>
00022 #include <stdio.h>
00023 #include <string.h>
00024 #include "cflow_struct.h"
00025 #include "read_tools.h"
00026 #include "read_free.h"
00027 
00028 /*
00029   Line parser for Linux's cflow
00030   return:
00031   - 1 OK
00032   - 0 KO
00033 */
00034 int scan_free(const char *line, LINE_INFO *line_info)
00035 {
00036   int pos;
00037   int lu;
00038 
00039   /* Line id */
00040   lu = sscanf(line, "%d%n",
00041               &(line_info->id), &pos);
00042   if (lu != 1)
00043     return 0;
00044 
00045   /* */
00046   line = line + pos;
00047 
00048   /* Deep */
00049   line_info->depth = str_count_char(line, '\t');
00050 
00051   /* Function name */
00052   lu = sscanf(line, "%s%n",
00053               line_info->fct, &pos);
00054   if (lu != 1)
00055     return 0;
00056 
00057   /* The first field could be "...", not function name */
00058   if (strcmp(line_info->fct, "...") == 0)
00059     {
00060       /* Read the next field */
00061       line = line + pos;
00062       lu = sscanf(line, "%s%n",
00063                   line_info->fct, &pos);
00064       if (lu != 1)
00065         return 0;
00066     }
00067   
00068   /* */
00069   line = line + pos;
00070 
00071   /* Creation d'un noeud */
00072   if (strstr(line,"{}") != NULL)
00073     line_info->type = EXTERNAL;
00074   else if (strstr(line,"...") != NULL)
00075     {
00076       line_info->type = REFERENCE;
00077       /* Now, read the reference */
00078       line = strchr(line,'{');
00079       if (line == NULL)
00080         return 0;
00081       lu = sscanf(line, "{%d}", &(line_info->id));
00082       if (lu != 1)
00083         return 0;
00084     }
00085   else
00086     {
00087       line_info->type = INTERNAL;
00088       lu = sscanf(line, " {%s %d}",
00089                   line_info->src, &(line_info->line_src));
00090       if (lu != 2)
00091         return 0;
00092       line_info->fct_type[0]='\0';
00093     }
00094 
00095   /* Line scanned */
00096   return 1;
00097 }

Generated on Thu Apr 10 21:55:08 2003 for Cflow2VCG by doxygen1.2.15