Main Page   Compound List   File List   Compound Members   File Members  

read_sun.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_sun.h"
00027 
00028 /*
00029   Line parser for Sun's cflow
00030   return:
00031   - 1 OK
00032   - 0 KO
00033 */
00034 int scan_sun(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   /* Suppress the trailing ":" */
00058   line_info->fct[strlen(line_info->fct)-1] = '\0';
00059 
00060   /* */
00061   line = line + pos;
00062 
00063   /* Creation d'un noeud */
00064   if (strstr(line,"<>") != NULL)
00065     line_info->type = EXTERNAL;
00066   else if (strchr(line,',') != NULL)
00067     {
00068       line_info->type = INTERNAL;
00069       lu = sscanf(line, "%[^,]%n, <%s %d>",
00070                   line_info->fct_type, &pos, line_info->src, &(line_info->line_src));
00071       if (lu != 3)
00072         return 0;
00073       line_info->fct_type[pos]='\0';
00074     }
00075   else
00076     {
00077       line_info->type = REFERENCE;
00078       lu = sscanf(line, " %d", &(line_info->id));
00079       if (lu != 1)
00080         return 0;
00081     }
00082 
00083   /* Line scanned */
00084   return 1;
00085 }

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