// // ipv2_data.cc // // Copyright (C) 1996 Limit Point Systems, Inc. // // Author: Curtis Janssen // Maintainer: LPS // // This file is part of the SC Toolkit. // // The SC Toolkit is free software; you can redistribute it and/or modify // it under the terms of the GNU Library General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // The SC Toolkit 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 Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with the SC Toolkit; see the file COPYING.LIB. If not, write to // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. // // The U.S. Government is granted a limited license as per AL 91-7. // #include #include #include #include #include using namespace std; using namespace sc; IPV2::Status IPV2::boolean(const char *keyword,int *boolean,int n,...) { va_list args; int i; int *v; Status r; if (n==0) { return boolean_v(keyword,boolean,n,NULL); } else { v = (int *) malloc(sizeof(int)*n); if (!v) return Malloc; va_start(args, n); for (i=0; i='a' && *s <='z') *s = *s + 'A' - 'a'; } if (!strcmp(copy,"YES")) *boolean = 1; else if (!strcmp(copy,"NO")) *boolean = 0; else if (!strcmp(copy,"1")) *boolean = 1; else if (!strcmp(copy,"0")) *boolean = 0; else if (!strcmp(copy,"TRUE")) *boolean = 1; else if (!strcmp(copy,"FALSE")) *boolean = 0; else if (!strcmp(copy,"ON")) *boolean = 1; else if (!strcmp(copy,"OFF")) *boolean = 0; else return Type; return OK; } /* n should always be zero in this version of libip. */ int IPV2::exist(const char *keyword,int n,...) { va_list args; int i; int *v; int r; if (n==0) { return exist_v(keyword,n,NULL); } else { v = (int *) malloc(sizeof(int)*n); if (!v) { warn("IPV2::exist: problem malloc"); return 0; } va_start(args, n); for (i=0; ikeyword,currentname); free(currentname); } else newname = strcpy((char*)malloc(strlen(kt->keyword)+1),kt->keyword); return get_name(kt->up,newname); } char* IPV2::get_truename(ip_keyword_tree_t*kt) { return get_name(kt,0); } IPV2::Status IPV2::truekeyword_v(const char* keyword,const char** name,int n,int *v) { ip_keyword_tree_t *kt; static char newkey[KEYWORD_LENGTH]; Status errcod; if ((errcod = construct_key_v(keyword,newkey,n,v))!=OK) return errcod; kt = ip_cwk_descend_tree(newkey); if (!kt) { ip_lastkeyword(keyword); *name = 0; return KeyNotFound; } ip_lastkeywordtree(kt); if (!kt->truename) { kt->truename = get_truename(kt); } *name = kt->truename; return OK; } IPV2::Status IPV2::string(const char *keyword,char **value,int n,...) { va_list args; int i; int *v; Status r; if (n==0) { return string_v(keyword,value,n,NULL); } else { v = (int *) malloc(sizeof(int)*n); if (!v) return Malloc; va_start(args, n); for (i=0; ivalue; if (*value == NULL) return HasNoValue; return OK; } IPV2::Status IPV2::construct_key_v(const char* keyword,char *newkey,int n,int*v) { int i; char index[11]; int count; Status errcod; /* Construct the new keyword. */ strcpy(newkey,keyword); for (i=0; i=count) return OutOfBounds; sprintf(index,":%d",v[i]); strcat(newkey,index); } return OK; }