Mercurial > mplayer.hg
comparison cfgparser.c @ 153:8e55121885b2
new configfile/cmdline parser
author | arpi_esp |
---|---|
date | Mon, 19 Mar 2001 03:45:49 +0000 |
parents | 372a9a836e86 |
children | 05e9c8083922 |
comparison
equal
deleted
inserted
replaced
152:372a9a836e86 | 153:8e55121885b2 |
---|---|
101 if (!isdigit(*param)) | 101 if (!isdigit(*param)) |
102 return ERR_MISSING_PARAM; | 102 return ERR_MISSING_PARAM; |
103 | 103 |
104 tmp_int = atoi(param); | 104 tmp_int = atoi(param); |
105 | 105 |
106 if (config[i].flags & CONF_CHK_MIN) | 106 if (config[i].flags & CONF_MIN) |
107 if (tmp_int < config[i].min) | 107 if (tmp_int < config[i].min) |
108 return ERR_OUT_OF_RANGE; | 108 return ERR_OUT_OF_RANGE; |
109 | 109 |
110 if (config[i].flags & CONF_CHK_MAX) | 110 if (config[i].flags & CONF_MAX) |
111 if (tmp_int > config[i].max) | 111 if (tmp_int > config[i].max) |
112 return ERR_OUT_OF_RANGE; | 112 return ERR_OUT_OF_RANGE; |
113 | 113 |
114 *((int *) config[i].p) = tmp_int; | 114 *((int *) config[i].p) = tmp_int; |
115 need_param = 1; | 115 need_param = 1; |
120 if (!isdigit(*param)) | 120 if (!isdigit(*param)) |
121 return ERR_MISSING_PARAM; | 121 return ERR_MISSING_PARAM; |
122 | 122 |
123 tmp_float = atof(param); | 123 tmp_float = atof(param); |
124 | 124 |
125 if (config[i].flags & CONF_CHK_MIN) | 125 if (config[i].flags & CONF_MIN) |
126 if (tmp_float < config[i].min) | 126 if (tmp_float < config[i].min) |
127 return ERR_OUT_OF_RANGE; | 127 return ERR_OUT_OF_RANGE; |
128 | 128 |
129 if (config[i].flags & CONF_CHK_MAX) | 129 if (config[i].flags & CONF_MAX) |
130 if (tmp_float > config[i].max) | 130 if (tmp_float > config[i].max) |
131 return ERR_OUT_OF_RANGE; | 131 return ERR_OUT_OF_RANGE; |
132 | 132 |
133 *((float *) config[i].p) = tmp_float; | 133 *((float *) config[i].p) = tmp_float; |
134 need_param = 1; | 134 need_param = 1; |
135 break; | 135 break; |
136 case CONF_TYPE_STRING: | 136 case CONF_TYPE_STRING: |
137 if (param == NULL) | 137 if (param == NULL) |
138 return ERR_MISSING_PARAM; | 138 return ERR_MISSING_PARAM; |
139 | 139 |
140 if (config[i].flags & CONF_CHK_MIN) | 140 if (config[i].flags & CONF_MIN) |
141 if (strlen(param) < config[i].min) | 141 if (strlen(param) < config[i].min) |
142 return ERR_OUT_OF_RANGE; | 142 return ERR_OUT_OF_RANGE; |
143 | 143 |
144 if (config[i].flags & CONF_CHK_MAX) | 144 if (config[i].flags & CONF_MAX) |
145 if (strlen(param) > config[i].max) | 145 if (strlen(param) > config[i].max) |
146 return ERR_OUT_OF_RANGE; | 146 return ERR_OUT_OF_RANGE; |
147 | 147 |
148 *((char **) config[i].p) = strdup(param); | 148 *((char **) config[i].p) = strdup(param); |
149 need_param = 1; | 149 need_param = 1; |