/* * Cflow2VCG * Copyright (C) 2001 Guilhem BONNEFILLE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include "cflow_struct.h" #include "read_tools.h" #include "read_free.h" /* Line parser for Linux's cflow return: - 1 OK - 0 KO */ int scan_free(const char *line, LINE_INFO *line_info) { int pos; int lu; /* Line id */ lu = sscanf(line, "%d%n", &(line_info->id), &pos); if (lu != 1) return 0; /* */ line = line + pos; /* Deep */ line_info->depth = str_count_char(line, '\t'); /* Function name */ lu = sscanf(line, "%s%n", line_info->fct, &pos); if (lu != 1) return 0; /* The first field could be "...", not function name */ if (strcmp(line_info->fct, "...") == 0) { /* Read the next field */ line = line + pos; lu = sscanf(line, "%s%n", line_info->fct, &pos); if (lu != 1) return 0; } /* */ line = line + pos; /* Creation d'un noeud */ if (strstr(line,"{}") != NULL) line_info->type = EXTERNAL; else if (strstr(line,"...") != NULL) { line_info->type = REFERENCE; /* Now, read the reference */ line = strchr(line,'{'); if (line == NULL) return 0; lu = sscanf(line, "{%d}", &(line_info->id)); if (lu != 1) return 0; } else { line_info->type = INTERNAL; lu = sscanf(line, " {%s %d}", line_info->src, &(line_info->line_src)); if (lu != 2) return 0; line_info->fct_type[0]='\0'; } /* Line scanned */ return 1; }