/* * Copyright (C) 2002 Jean-Charles Salzeber * * This file is part of penggy. * * 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. * * $Id: phonetab.c,v 1.1 2002/12/13 15:29:15 chupa Exp $ * */ #if HAVE_CONFIG_H # include "config.h" #endif #if STDC_HEADERS # include # include #else # if HAVE_STDLIB_H # include # endif #endif #if HAVE_STDIO_H # include #endif #if HAVE_ERRNO_H # include #endif #if HAVE_STRING_H # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif # include #endif #if HAVE_CTYPE_H # include #endif #include "gettext.h" #include "options.h" #include "log.h" #include "utils.h" #include "modem/phonetab.h" phone_t *phonetab; static void prepare_phonetab (void) { int i; phonetab = (phone_t *) malloc(sizeof(phone_t) * MAX_PHONES); for(i = 0; i < MAX_PHONES; i++) { phonetab[i].phone = NULL; phonetab[i].phone = DEFAULT_PPP_COMPAT; phonetab[i].script = NULL; } } static int get_line(line, lineno, num) char *line; int lineno; int num; { char *c = line; char *phone = line; char *ppp = NULL; char *script = NULL; while (!isspace (*c) && *c != '\0') c++; if (*c != '\0') { *c = '\0'; c++; trim(c); ppp=c; lowerize(ppp); while (!isspace (*c) && *c != '\0') c++; if (*c != '\0') { *c = '\0'; c++; trim(c); script=c; } } if(num 0) { get_line(line, lineno, num++); } } if(num==0) { log (LOG_ERR, gettext("phonetab (%s) is empty, edit it first.\n"), PARAM_MODEM_PHONETAB); exit(1); } fclose (f); return 1; } void free_phonetab (void) { int i; for(i = 0; i < MAX_PHONES; i++) { if(phonetab[i].phone) free (phonetab[i].phone); if(phonetab[i].script) free (phonetab[i].script); } free (phonetab); }