Changeset 164 for trunk/src/sh_readconf.c
- Timestamp:
- Feb 6, 2008, 10:31:00 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_readconf.c
r160 r164 742 742 { N_("opencommand"), SH_SECTION_EXTERNAL, SH_SECTION_NONE, 743 743 sh_ext_setcommand }, 744 { N_("closecommand"), SH_SECTION_EXTERNAL, SH_SECTION_NONE, 745 sh_ext_close_command }, 744 746 { N_("setcommandline"), SH_SECTION_EXTERNAL, SH_SECTION_NONE, 745 747 sh_ext_add_argv }, … … 1108 1110 1109 1111 static int sh_readconfig_line (char * line) 1110 { 1111 char * c; 1112 { 1113 char * key; 1114 char * value; 1112 1115 char * tmp; 1113 1116 int i; … … 1117 1120 int modnum, modkey; 1118 1121 #endif 1122 1123 static char *dummy = N_("dummy"); 1124 1125 static char *closing[] = { 1126 N_("closecommand"), 1127 NULL 1128 }; 1119 1129 1120 1130 static char *ident[] = { … … 1157 1167 SL_ENTER(_("sh_readconf_line")); 1158 1168 1169 /* convert to lowercase */ 1170 1171 tmp = line; 1172 while (*tmp != '=' && *tmp != '\0') 1173 { 1174 *tmp = tolower( (int) *tmp); 1175 ++tmp; 1176 } 1177 1178 key = line; 1179 1159 1180 /* interpret line */ 1160 1181 1161 c = strchr(line, '='); 1162 if (c == NULL || (*c) == '\0') 1163 { 1164 if (line != NULL) 1182 value = strchr(line, '='); 1183 1184 if (value == NULL || (*value) == '\0') 1185 { 1186 if (key != NULL) 1187 { 1188 i = 0; 1189 while (closing[i] != NULL) 1190 { 1191 if (sl_strncmp(key,_(closing[i]),sl_strlen(closing[i])-1) == 0) 1192 { 1193 value = dummy; 1194 goto ok_novalue; 1195 } 1196 ++i; 1197 } 1198 1199 TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: not key=value: %s>\n"), 1200 line)); 1201 } 1202 SL_RETURN(good_opt, _("sh_readconf_line")); 1203 } 1204 else 1205 ++value; 1206 1207 /* skip leading whitespace 1208 */ 1209 while ((*value) == ' ' || (*value) == '\t') 1210 ++value; 1211 1212 if ((*value) == '\0') /* no value */ 1213 { 1214 if (key != NULL) 1165 1215 { 1166 1216 TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: not key=value: %s>\n"), … … 1169 1219 SL_RETURN(good_opt, _("sh_readconf_line")); 1170 1220 } 1171 else 1172 ++c; 1173 1174 /* skip leading whitespace 1175 */ 1176 while ((*c) == ' ' || (*c) == '\t') 1177 ++c; 1178 1179 if ((*c) == '\0') /* no value */ 1180 { 1181 if (line != NULL) 1182 { 1183 TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: not key=value: %s>\n"), 1184 line)); 1185 } 1186 SL_RETURN(good_opt, _("sh_readconf_line")); 1187 } 1188 1189 /* convert to lowercase */ 1190 1191 tmp = line; 1192 while (*tmp != '=') 1193 { 1194 *tmp = tolower( (int) *tmp); 1195 ++tmp; 1196 } 1221 1222 ok_novalue: 1197 1223 1198 1224 if (!sl_is_suid()) … … 1210 1236 ++modkey) 1211 1237 { 1212 if (sl_strncmp ( line,1238 if (sl_strncmp (key, 1213 1239 _(modList[modnum].conf_table[modkey].the_opt), 1214 1240 sl_strlen(modList[modnum].conf_table[modkey].the_opt) ) == 0) 1215 1241 { 1216 1242 good_opt = 0; 1217 if (0 != modList[modnum].conf_table[modkey].func( c))1243 if (0 != modList[modnum].conf_table[modkey].func(value)) 1218 1244 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EINVALS, 1219 _(modList[modnum].conf_table[modkey].the_opt), c);1245 _(modList[modnum].conf_table[modkey].the_opt), value); 1220 1246 if (!sl_is_suid()) 1221 1247 { … … 1237 1263 i = 0; 1238 1264 while (ident[i] != NULL) { 1239 if (sl_strncmp ( line, _(ident[i]), sl_strlen(ident[i])-1) == 0)1265 if (sl_strncmp (key, _(ident[i]), sl_strlen(ident[i])-1) == 0) 1240 1266 { 1241 1267 good_opt = 0; 1242 sh_error_set_iv (identnum[i], c);1268 sh_error_set_iv (identnum[i], value); 1243 1269 break; 1244 1270 } … … 1253 1279 if ((ext_table[i].section == read_mode || 1254 1280 ext_table[i].alt_section == read_mode) && 1255 sl_strncmp ( line, _(ext_table[i].optname),1281 sl_strncmp (key, _(ext_table[i].optname), 1256 1282 sl_strlen(ext_table[i].optname)) == 0) 1257 1283 { 1258 1284 good_opt = 0; 1259 if (0 != ext_table[i].func ( c))1285 if (0 != ext_table[i].func (value)) 1260 1286 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EINVALS, 1261 _(ext_table[i].optname), c);1287 _(ext_table[i].optname), value); 1262 1288 break; 1263 1289 }
Note:
See TracChangeset
for help on using the changeset viewer.