1 /* 2 * binkleyforce -- unix FTN mailer project 3 * 4 * Copyright (c) 1998-2000 Alexander Belkin, 2:5020/1398.11 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * $Id: conf_get.c,v 1.1.1.1 2004/09/09 09:52:37 kstepanenkov Exp $ 12 */ 13 14 #include "includes.h" 15 #include "confread.h" 16 #include "logger.h" 17 #include "util.h" 18 conf_first(bforce_config_keyword keyword)19s_cval_entry *conf_first(bforce_config_keyword keyword) 20 { 21 s_cval_entry *ptrl; 22 23 for( ptrl = bforce_config[keyword].data; ptrl; ptrl = ptrl->next ) 24 if( !ptrl->expr.expr || eventexpr(&ptrl->expr) ) 25 return ptrl; 26 27 return NULL; 28 } 29 conf_next(s_cval_entry * ptrl)30s_cval_entry *conf_next(s_cval_entry *ptrl) 31 { 32 ASSERT(ptrl); 33 34 for( ptrl = ptrl->next; ptrl; ptrl = ptrl->next ) 35 if( !ptrl->expr.expr || eventexpr(&ptrl->expr) ) 36 return ptrl; 37 38 return NULL; 39 } 40 conf_boolean(bforce_config_keyword keyword)41bool conf_boolean(bforce_config_keyword keyword) 42 { 43 s_cval_entry *ptrl = conf_first(keyword); 44 45 return ptrl ? ptrl->d.boolean.istrue : FALSE; 46 } 47 conf_filemode(bforce_config_keyword keyword)48mode_t conf_filemode(bforce_config_keyword keyword) 49 { 50 s_cval_entry *ptrl = conf_first(keyword); 51 52 return ptrl ? ptrl->d.filemode.mode : (mode_t)0; 53 } 54 conf_options(bforce_config_keyword keyword)55long conf_options(bforce_config_keyword keyword) 56 { 57 long result = 0L; 58 s_cval_entry *ptrl; 59 60 for( ptrl = conf_first(keyword); ptrl; ptrl = conf_next(ptrl) ) 61 result = ((~ptrl->d.options.mask) & result) | ptrl->d.options.value; 62 63 return result; 64 } 65 conf_connlist(bforce_config_keyword keyword,long speed)66long conf_connlist(bforce_config_keyword keyword, long speed) 67 { 68 s_cval_entry *ptrl; 69 70 for( ptrl = conf_first(keyword); ptrl; ptrl = conf_next(ptrl) ) 71 if( ptrl->d.connlist.speed == speed ) 72 return ptrl->d.connlist.value; 73 74 return 0; 75 } 76 conf_string(bforce_config_keyword keyword)77char *conf_string(bforce_config_keyword keyword) 78 { 79 s_cval_entry *ptrl = conf_first(keyword); 80 81 return ptrl ? ptrl->d.string.str : (char*)NULL; 82 } 83 conf_number(bforce_config_keyword keyword)84long conf_number(bforce_config_keyword keyword) 85 { 86 s_cval_entry *ptrl = conf_first(keyword); 87 88 return ptrl ? ptrl->d.number.num : (long)0L; 89 } 90 conf_override(bforce_config_keyword keyword,s_faddr addr)91s_override *conf_override(bforce_config_keyword keyword, s_faddr addr) 92 { 93 s_cval_entry *ptrl; 94 95 for( ptrl = conf_first(keyword); ptrl; ptrl = conf_next(ptrl) ) 96 if( !ftn_addrcomp(ptrl->d.override.addr, addr) ) 97 return &ptrl->d.override; 98 99 return NULL; 100 } 101 conf_tries(bforce_config_keyword keyword)102s_tries *conf_tries(bforce_config_keyword keyword) 103 { 104 s_cval_entry *ptrl = conf_first(keyword); 105 106 return ptrl ? &ptrl->d.tries : NULL; 107 } 108 109