-------------------------------------------------------------------------*/ @brief Get the string associated to a key, convert to a boolean @param d Dictionary to search @param key Key string to look for @param notfound Value to return in case of error @return integer This function queries a dictionary for a key. A key as read from an ini file is given as "section:key".
| 821 | */ |
| 822 | /*--------------------------------------------------------------------------*/ |
| 823 | int iniparser_getboolean(dictionary * d, char * key, int notfound) |
| 824 | { |
| 825 | char * c ; |
| 826 | int ret ; |
| 827 | |
| 828 | c = iniparser_getstring(d, key, INI_INVALID_KEY); |
| 829 | if (c==INI_INVALID_KEY) return notfound ; |
| 830 | if (c[0]=='y' || c[0]=='Y' || c[0]=='1' || c[0]=='t' || c[0]=='T') { |
| 831 | ret = 1 ; |
| 832 | } else if (c[0]=='n' || c[0]=='N' || c[0]=='0' || c[0]=='f' || c[0]=='F') { |
| 833 | ret = 0 ; |
| 834 | } else { |
| 835 | ret = notfound ; |
| 836 | } |
| 837 | return ret; |
| 838 | } |
| 839 | |
| 840 | |
| 841 | /*-------------------------------------------------------------------------*/ |
nothing calls this directly
no test coverage detected