/* * 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_sun.h" /* Line parser for Sun's cflow return: - 1 OK - 0 KO */ int scan_sun(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; /* Suppress the trailing ":" */ line_info->fct[strlen(line_info->fct)-1] = '\0'; /* */ line = line + pos; /* Creation d'un noeud */ if (strstr(line,"<>") != NULL) line_info->type = EXTERNAL; else if (strchr(line,',') != NULL) { line_info->type = INTERNAL; lu = sscanf(line, "%[^,]%n, <%s %d>", line_info->fct_type, &pos, line_info->src, &(line_info->line_src)); if (lu != 3) return 0; line_info->fct_type[pos]='\0'; } else { line_info->type = REFERENCE; lu = sscanf(line, " %d", &(line_info->id)); if (lu != 1) return 0; } /* Line scanned */ return 1; }