Homepage
Demos
Overview
Downloads
Tutorials
Reference
Credits

Config.cc

Go to the documentation of this file.
00001 #include "Shared/Config.h"
00002 #include "Behaviors/Mon/RawCamBehavior.h"
00003 #include "Vision/RawCameraGenerator.h"
00004 #include <stdio.h>
00005 #include <string>
00006 #include <cstring>
00007 #include <ctype.h>
00008 #include "Wireless/Socket.h"
00009 #ifdef PLATFORM_APERIOS
00010 #  include <OPENR/OPrimitiveControl.h>
00011 #  include <OPENR/OPENRAPI.h>
00012 #else
00013   typedef unsigned int OSpeakerVolume;
00014   const OSpeakerVolume ospkvolinfdB = 0x8000;
00015   const OSpeakerVolume ospkvol25dB  = 0xe700;
00016   const OSpeakerVolume ospkvol18dB  = 0xee00;
00017   const OSpeakerVolume ospkvol10dB  = 0xf600;
00018 #endif
00019 
00020 Config* config=NULL;
00021 
00022 void* Config::setValue(section_t section, const char *key, const char *value,
00023                        bool /*updated*/) {
00024   switch (section) {
00025     case sec_wireless:
00026       if (strncasecmp(key,"id",29)==0) {
00027         wireless.id=atoi(value);
00028         return &wireless.id;
00029       }
00030       break;
00031     case sec_vision:
00032       if (strncasecmp(key,"white_balance",29)==0) {
00033         if (strncasecmp(value,"indoor",49)==0) {
00034           vision.white_balance=1;
00035         } else if (strncasecmp(value,"flourescent",49)==0) {
00036           vision.white_balance=3;
00037         } else if (strncasecmp(value,"outdoor",49)==0) {
00038           vision.white_balance=2;
00039         }
00040 #ifdef PLATFORM_APERIOS
00041         //this will actually send the new setting to the system
00042         OPrimitiveID fbkID = 0;
00043         if(OPENR::OpenPrimitive(CameraLocator, &fbkID) != oSUCCESS){
00044           std::cout << "Open FbkImageSensor failure." << std::endl;
00045         } else {
00046           OPrimitiveControl_CameraParam owb(vision.white_balance);
00047           if(OPENR::ControlPrimitive(fbkID, oprmreqCAM_SET_WHITE_BALANCE, &owb, sizeof(owb), 0, 0) != oSUCCESS){
00048             std::cout << "CAM_SET_WHITE_BALANCE : Failed!" << std::endl;
00049           }
00050           OPENR::ClosePrimitive(fbkID);
00051         }
00052 #endif
00053         return &vision.white_balance;
00054       } else if (strncasecmp(key,"gain",29)==0) {
00055         if (strncasecmp(value,"low",49)==0) {
00056           vision.gain=1;
00057         } else if (strncasecmp(value,"mid",49)==0) {
00058           vision.gain=2;
00059         } else if (strncasecmp(value,"high",49)==0) {
00060           vision.gain=3;
00061         }
00062 #ifdef PLATFORM_APERIOS
00063         //this will actually send the new setting to the system
00064         OPrimitiveID fbkID = 0;
00065         if(OPENR::OpenPrimitive(CameraLocator, &fbkID) != oSUCCESS){
00066           std::cout << "Open FbkImageSensor failure." << std::endl;
00067         } else {
00068           OPrimitiveControl_CameraParam ogain(vision.gain);
00069           if(OPENR::ControlPrimitive(fbkID, oprmreqCAM_SET_GAIN, &ogain, sizeof(ogain), 0, 0) != oSUCCESS)
00070             std::cout << "CAM_SET_GAIN : Failed!" << std::endl;
00071           OPENR::ClosePrimitive(fbkID);
00072         }
00073 #endif
00074         return &vision.gain;
00075       } else if (strncasecmp(key,"shutter_speed",29)==0) {
00076         if (strncasecmp(value,"slow",49)==0) {
00077           vision.shutter_speed=1;
00078         } else if (strncasecmp(value,"mid",49)==0) {
00079           vision.shutter_speed=2;
00080         } else if (strncasecmp(value,"fast",49)==0) {
00081           vision.shutter_speed=3;
00082         }
00083 #ifdef PLATFORM_APERIOS
00084         //this will actually send the new setting to the system
00085         OPrimitiveID fbkID = 0;
00086         if(OPENR::OpenPrimitive(CameraLocator, &fbkID) != oSUCCESS){
00087           std::cout << "Open FbkImageSensor failure." << std::endl;
00088         } else {
00089           OPrimitiveControl_CameraParam oshutter(vision.shutter_speed);
00090           if(OPENR::ControlPrimitive(fbkID,oprmreqCAM_SET_SHUTTER_SPEED, &oshutter, sizeof(oshutter), 0, 0) != oSUCCESS)
00091             std::cout << "CAM_SET_SHUTTER_SPEED : Failed!" << std::endl;
00092           OPENR::ClosePrimitive(fbkID);
00093         }
00094 #endif
00095         return &vision.shutter_speed;
00096       } else if (strncasecmp(key,"resolution",29)==0) {
00097         if (strncasecmp(value,"full",49)==0) {
00098           vision.resolution=1;
00099         } else if (strncasecmp(value,"half",49)==0) {
00100           vision.resolution=2;
00101         } else if (strncasecmp(value,"quarter",49)==0) {
00102           vision.resolution=3;
00103         }
00104         return &vision.resolution;
00105       } else if (strncasecmp(key,"horizFOV",29)==0) {
00106         vision.horizFOV=atof(value)*M_PI/180;
00107         return &vision.horizFOV;
00108       } else if (strncasecmp(key,"vertFOV",29)==0) {
00109         vision.vertFOV=atof(value)*M_PI/180;
00110         return &vision.vertFOV;
00111       } else if (strncasecmp(key,"focal_length",29)==0) {
00112         vision.focal_length=atof(value);
00113         return &vision.focal_length;
00114       } else if (strncasecmp(key,"thresh",29)==0) {
00115         vision.thresh.push_back(value);
00116         return &vision.thresh;
00117       } else if (strncasecmp(key,"colors",29)==0) {
00118         strncpy(vision.colors,value,49);
00119         return &vision.colors;
00120       } else if (strncasecmp(key,"raw_port",29)==0) {
00121         vision.rawcam_port=atoi(value);
00122         return &vision.rawcam_port;
00123       } else if (strncasecmp(key,"raw_transport",29)==0) {
00124         if (strncasecmp(value,"udp",49)==0)
00125           vision.rawcam_transport=0;
00126         else if (strncasecmp(value,"tcp",49)==0)
00127           vision.rawcam_transport=1;
00128         return &vision.rawcam_transport;
00129       } else if (strncasecmp(key,"rle_port",29)==0) {
00130         vision.rle_port=atoi(value);
00131         return &vision.rle_port;
00132       } else if (strncasecmp(key,"rle_transport",29)==0) {
00133         if (strncasecmp(value,"udp",49)==0)
00134           vision.rle_transport=0;
00135         else if (strncasecmp(value,"tcp",49)==0)
00136           vision.rle_transport=1;
00137         return &vision.rle_transport;
00138       } else if (strncasecmp(key,"obj_port",29)==0) {
00139         vision.obj_port=atoi(value);
00140         return &vision.obj_port;
00141       } else if (strncasecmp(key,"restore_image",29)==0) {
00142         vision.restore_image=atoi(value);
00143         return &vision.obj_port;
00144       } else if (strncasecmp(key,"jpeg_dct_method",29)==0) {
00145         if (strncasecmp(value,"islow",49)==0) {
00146           vision.jpeg_dct_method=JDCT_ISLOW;
00147         } else if (strncasecmp(value,"ifast",49)==0) {
00148           vision.jpeg_dct_method=JDCT_IFAST;
00149         } else if (strncasecmp(value,"float",49)==0) {
00150           vision.jpeg_dct_method=JDCT_FLOAT;
00151     }
00152     return &vision.jpeg_dct_method;
00153       } else if (strncasecmp(key,"rawcam_encoding",29)==0) {
00154         if (strncasecmp(value,"color",49)==0) {
00155           vision.rawcam_encoding=vision_config::ENCODE_COLOR;
00156           vision.rawcam_channel=RawCameraGenerator::CHAN_Y;
00157         } else if (strncasecmp(value,"y_only",49)==0) {
00158           vision.rawcam_encoding=vision_config::ENCODE_SINGLE_CHANNEL;
00159           vision.rawcam_channel=RawCameraGenerator::CHAN_Y;
00160         } else if (strncasecmp(value,"uv_only",49)==0) {
00161           vision.rawcam_encoding=vision_config::ENCODE_COLOR;
00162           vision.rawcam_channel=-1;
00163         } else if (strncasecmp(value,"u_only",49)==0) {
00164           vision.rawcam_encoding=vision_config::ENCODE_SINGLE_CHANNEL;
00165           vision.rawcam_channel=RawCameraGenerator::CHAN_U;
00166         } else if (strncasecmp(value,"v_only",49)==0) {
00167           vision.rawcam_encoding=vision_config::ENCODE_SINGLE_CHANNEL;
00168           vision.rawcam_channel=RawCameraGenerator::CHAN_V;
00169         } else if (strncasecmp(value,"y_dx_only",49)==0) {
00170           vision.rawcam_encoding=vision_config::ENCODE_SINGLE_CHANNEL;
00171           vision.rawcam_channel=RawCameraGenerator::CHAN_Y_DX;
00172         } else if (strncasecmp(value,"y_dy_only",49)==0) {
00173           vision.rawcam_encoding=vision_config::ENCODE_SINGLE_CHANNEL;
00174           vision.rawcam_channel=RawCameraGenerator::CHAN_Y_DY;
00175         } else if (strncasecmp(value,"y_dxdy_only",49)==0) {
00176           vision.rawcam_encoding=vision_config::ENCODE_SINGLE_CHANNEL;
00177           vision.rawcam_channel=RawCameraGenerator::CHAN_Y_DXDY;
00178         }
00179         return &vision.rawcam_encoding;
00180       } else if (strncasecmp(key,"rawcam_compression",29)==0) {
00181         if (strncasecmp(value,"none",49)==0) {
00182           vision.rawcam_compression=vision_config::COMPRESS_NONE;
00183         } else if (strncasecmp(value,"jpeg",49)==0) {
00184           vision.rawcam_compression=vision_config::COMPRESS_JPEG;
00185         }
00186         return &vision.rawcam_compression;
00187       } else if (strncasecmp(key,"rawcam_compress_quality",29)==0) {
00188         vision.rawcam_compress_quality=atoi(value);
00189         return &vision.rawcam_compress_quality;
00190       } else if (strncasecmp(key,"rawcam_y_skip",29)==0) {
00191         vision.rawcam_y_skip=atoi(value);
00192         return &vision.rawcam_y_skip;
00193       } else if (strncasecmp(key,"rawcam_uv_skip",29)==0) {
00194         vision.rawcam_uv_skip=atoi(value);
00195         return &vision.rawcam_uv_skip;
00196       } else if (strncasecmp(key,"rlecam_skip",29)==0) {
00197         vision.rlecam_skip=atoi(value);
00198         return &vision.rlecam_skip;
00199       } else if (strncasecmp(key,"rlecam_channel",29)==0) {
00200         vision.rlecam_channel=atoi(value);
00201         return &vision.rlecam_channel;
00202       } else if (strncasecmp(key,"rlecam_compression",29)==0) {
00203         if (strncasecmp(value,"none",49)==0) {
00204           vision.rlecam_compression=vision_config::COMPRESS_NONE;
00205         } else if (strncasecmp(value,"rle",49)==0) {
00206           vision.rlecam_compression=vision_config::COMPRESS_RLE;
00207         }
00208         return &vision.rlecam_compression;
00209       }
00210       break;
00211     case sec_main:
00212       if (strncasecmp(key,"console_port",29)==0) {
00213         main.console_port=atoi(value);
00214         return &main.console_port;
00215       } else if (strncasecmp(key,"stderr_port",29)==0) {
00216         main.stderr_port=atoi(value);
00217         return &main.stderr_port;
00218       } else if (strncasecmp(key,"error_level",29)==0) {
00219         main.error_level=atoi(value);
00220         return &main.error_level;
00221       } else if (strncasecmp(key,"debug_level",29)==0) {
00222         main.debug_level=atoi(value);
00223         return &main.debug_level;
00224       } else if (strncasecmp(key,"verbose_level",29)==0) {
00225         main.verbose_level=atoi(value);
00226         return &main.verbose_level;
00227       } else if (strncasecmp(key,"wsjoints_port",29)==0) {
00228         main.wsjoints_port=atoi(value);
00229         return &main.wsjoints_port;
00230       } else if (strncasecmp(key,"wspids_port",29)==0) {
00231         main.wspids_port=atoi(value);
00232         return &main.wspids_port;
00233       } else if (strncasecmp(key,"headControl_port",29)==0) {
00234         main.headControl_port=atoi(value);
00235         return &main.headControl_port;
00236       } else if (strncasecmp(key,"walkControl_port",29)==0) {
00237         main.walkControl_port=atoi(value);
00238         return &main.walkControl_port;
00239       } else if (strncasecmp(key,"estopControl_port",29)==0) {
00240         main.estopControl_port=atoi(value);
00241         return &main.estopControl_port;
00242       } else if (strncasecmp(key,"aibo3d_port",29)==0) {
00243         main.aibo3d_port=atoi(value);
00244         return &main.aibo3d_port;
00245       } else if (strncasecmp(key,"wmmonitor_port",29)==0) {
00246         main.wmmonitor_port=atoi(value);
00247         return &main.wmmonitor_port;
00248       } else if (strncasecmp(key,"use_VT100",29)==0) {
00249         main.use_VT100=extractBool(value);
00250         return &main.use_VT100;
00251       }
00252       break;
00253     case sec_behaviors:
00254       if (strncasecmp(key,"flash_bytes",29)==0) {
00255         behaviors.flash_bytes = atoi(value);
00256         return &behaviors.flash_bytes;
00257       } else if (strncasecmp(key,"flash_on_start",29)==0) {
00258         behaviors.flash_on_start = atoi(value);
00259         return &behaviors.flash_on_start;
00260       }
00261       break;
00262     case sec_controller:
00263       if (strncasecmp(key,"gui_port",29)==0) {
00264         controller.gui_port = atoi(value);
00265         return &controller.gui_port ;
00266       } else if (strncasecmp(key,"select_snd",29)==0) {
00267         strncpy(controller.select_snd,value,49);
00268         return &controller.select_snd;
00269       } else if (strncasecmp(key,"next_snd",29)==0) {
00270         strncpy(controller.next_snd,value,49);
00271         return &controller.next_snd;
00272       } else if (strncasecmp(key,"prev_snd",29)==0) {
00273         strncpy(controller.prev_snd,value,49);
00274         return &controller.prev_snd;
00275       } else if (strncasecmp(key,"read_snd",29)==0) {
00276         strncpy(controller.read_snd,value,49);
00277         return &controller.read_snd;
00278       } else if (strncasecmp(key,"cancel_snd",29)==0) {
00279         strncpy(controller.cancel_snd,value,49);
00280         return &controller.cancel_snd;
00281       } else if (strncasecmp(key,"error_snd",29)==0) {
00282         strncpy(controller.error_snd,value,49);
00283         return &controller.error_snd;
00284       }
00285       break;
00286     case sec_motion:
00287       if (strncasecmp(key,"root",29)==0) {
00288         motion.root=value;
00289         return &motion.root;
00290       } else if (strncasecmp(key,"walk",29)==0) {
00291         motion.walk=value;
00292         return &motion.walk;
00293       } else if (strncasecmp(key,"kinematics",29)==0) {
00294         motion.kinematics=value;
00295         return &motion.walk;
00296       } else if (strncasecmp(key,"kinematic_chains",29)==0) {
00297         motion.kinematic_chains.push_back(value);
00298         return &motion.kinematic_chains;
00299       } else if (strncasecmp(key,"calibrate:",10)==0) {
00300         for(unsigned int i=PIDJointOffset; i<PIDJointOffset+NumPIDJoints; i++)
00301           if(strncasecmp(&key[10],outputNames[i],outputNameLen+1)==0) { //+1 to ensure full match
00302             motion.calibration[i-PIDJointOffset] = atof(value);
00303             return &motion.calibration[i];
00304           }
00305         std::cout << "WARNING: Could not match '" << (strlen(key)>10?&key[10]:key) << "' as calibration parameter" << std::endl;
00306         return NULL;
00307       } else if (strncasecmp(key,"estop_on_snd",29)==0) {
00308         strncpy(motion.estop_on_snd,value,49);
00309         return &motion.estop_on_snd;
00310       } else if (strncasecmp(key,"estop_off_snd",29)==0) {
00311         strncpy(motion.estop_off_snd,value,49);
00312         return &motion.estop_off_snd;
00313       } else if (strncasecmp(key,"max_head_tilt_speed",29)==0) {
00314         motion.max_head_tilt_speed=atof(value);
00315         return &motion.max_head_tilt_speed;
00316       } else if (strncasecmp(key,"max_head_pan_speed",29)==0) {
00317         motion.max_head_pan_speed=atof(value);
00318         return &motion.max_head_pan_speed;
00319       } else if (strncasecmp(key,"max_head_roll_speed",29)==0) {
00320         motion.max_head_roll_speed=atof(value);
00321         return &motion.max_head_roll_speed;
00322       } else if (strncasecmp(key,"inf_walk_accel",29)==0) {
00323         motion.inf_walk_accel = atoi(value);
00324         return &motion.inf_walk_accel;
00325       } else if (strncasecmp(key,"console_port",29)==0) {
00326         motion.console_port = atoi(value);
00327         return &motion.console_port;
00328       } else if (strncasecmp(key,"stderr_port",29)==0) {
00329         motion.stderr_port = atoi(value);
00330         return &motion.stderr_port ;
00331       }
00332       break;
00333     case sec_sound:
00334       if (strncasecmp(key,"root",29)==0) {
00335         sound.root=value;
00336         return &sound.root;
00337       } else if (strncasecmp(key,"volume",29)==0) {
00338         if(strncasecmp(value,"mute",49)==0)
00339           sound.volume=ospkvolinfdB;
00340         else if(strncasecmp(value,"level_1",49)==0)
00341           sound.volume=ospkvol25dB;
00342         else if(strncasecmp(value,"level_2",49)==0)
00343           sound.volume=ospkvol18dB;
00344         else if(strncasecmp(value,"level_3",49)==0)
00345           sound.volume=ospkvol10dB;
00346         else
00347           sound.volume=strtol(value,NULL,0);
00348         return &sound.volume;
00349       } else if (strncasecmp(key,"sample_rate",29)==0) {
00350         sound.sample_rate = atoi(value);
00351         return &sound.sample_rate ;
00352       } else if (strncasecmp(key,"sample_bits",29)==0) {
00353         sound.sample_bits = atoi(value);
00354         return &sound.sample_bits ;
00355       } else if (strncasecmp(key,"preload",29)==0) {
00356         sound.preload.push_back(value);
00357         return &sound.preload ;
00358       } else if (strncasecmp(key,"streaming.mic_port",29)==0) {
00359         sound.streaming.mic_port = atoi(value);
00360         return &sound.streaming.mic_port;
00361       } else if (strncasecmp(key,"streaming.mic_sample_rate",29)==0) {
00362         sound.streaming.mic_sample_rate = atoi(value);
00363         return &sound.streaming.mic_sample_rate;
00364       } else if (strncasecmp(key,"streaming.mic_sample_bits",29)==0) {
00365         sound.streaming.mic_sample_bits = atoi(value);
00366         return &sound.streaming.mic_sample_bits;
00367       } else if (strncasecmp(key,"streaming.mic_stereo",29)==0) {
00368         sound.streaming.mic_stereo = extractBool(value);
00369         return &sound.streaming.mic_stereo;
00370       } else if (strncasecmp(key,"streaming.speaker_port",29)==0) {
00371         sound.streaming.speaker_port = atoi(value);
00372         return &sound.streaming.speaker_port;
00373       } else if (strncasecmp(key,"streaming.speaker_frame_length",30)==0) {
00374         sound.streaming.speaker_frame_length = atoi(value);
00375         return &sound.streaming.speaker_frame_length;
00376       } else if (strncasecmp(key,"streaming.speaker_max_delay",29)==0) {
00377         sound.streaming.speaker_max_delay = atoi(value);
00378         return &sound.streaming.speaker_max_delay;
00379       }
00380       break;
00381     default:
00382       break;
00383   }
00384   return NULL;
00385 }
00386 
00387 Config::section_t Config::parseSection(const char* key) {
00388   if (strncasecmp(key,"wireless",29)==0) {
00389     return sec_wireless;
00390   } else if (strncasecmp(key,"vision",29)==0) {
00391     return sec_vision;
00392   } else if (strncasecmp(key,"main",29)==0) {
00393     return sec_main;
00394   } else if (strncasecmp(key,"behaviors",29)==0) {
00395     return sec_behaviors;
00396   } else if (strncasecmp(key,"controller",29)==0) {
00397     return sec_controller;
00398   } else if (strncasecmp(key,"motion",29)==0) {
00399     return sec_motion;
00400   } else if (strncasecmp(key,"sound",29)==0) {
00401     return sec_sound;
00402   } else {
00403     return sec_invalid;
00404   }
00405 }
00406 
00407 void Config::readConfig(const char* filename) {
00408   FILE* fp = fopen(filename, "r");
00409   char buf[80], key[30], value[50];
00410   section_t section=sec_invalid;
00411   if (fp==NULL) return;
00412 
00413   bool ignoring=false;
00414   std::vector<std::string> curmodel;
00415 #ifdef PLATFORM_APERIOS
00416   char rdStr[orobotdesignNAME_MAX + 1];
00417   memset(rdStr, 0, sizeof(rdStr));
00418   if (OPENR::GetRobotDesign(rdStr) != oSUCCESS) {
00419     printf("OPENR::GetRobotDesign() failed.\n");
00420     rdStr[0]='\0';
00421   }
00422 #else
00423 #  if TGT_ERS7
00424   char rdStr[]="ERS-7";
00425 #  elif TGT_ERS210
00426   char rdStr[]="ERS-210";
00427 #  elif TGT_ERS220
00428   char rdStr[]="ERS-220";
00429 #  elif TGT_ERS2xx
00430 #    warning "TGT_2xx is not specific for simulation purposes - defaulting to ERS210"
00431   char rdStr[]="ERS-210";
00432 #  else
00433 #    warning "TGT_<model> undefined - defaulting to ERS210"
00434   char rdStr[]="ERS-210";
00435 #  endif
00436 #endif
00437 
00438 
00439   unsigned int lineno=0;
00440   while (fscanf(fp,"%79[^\n]\n", buf)!=EOF) {
00441     lineno++;
00442     if (sscanf(buf,"<%29[^>]>",key)>0) {
00443       if(key[0]=='/') {
00444         if(curmodel.size()==0) {
00445           printf("WARNING: not in a model specific section, line %d\n",lineno);
00446           continue;
00447         }
00448         bool subset=matchNoCase(&key[1],curmodel.back());
00449         bool superset=matchNoCase(curmodel.back(),&key[1]);
00450         if(subset && superset) {
00451           //printf("leaving modelsection %s\n",curmodel.back().c_str());
00452           curmodel.pop_back();
00453         } else if(superset) {
00454           while(curmodel.size()>0) {
00455             //printf("leaving modelsection %s (==%s)\n",curmodel.back().c_str(),&key[1]);
00456             curmodel.pop_back();
00457             if(!matchNoCase(curmodel.back(),&key[1]))
00458               break;
00459           }
00460         } else
00461           printf("WARNING: config model mismatch, line %d\n",lineno);
00462         
00463         ignoring=false; //scan through current model selection stack, see if we're still ignoring
00464         for(unsigned int i=0; i<curmodel.size(); i++)
00465           if(!matchNoCase(rdStr,curmodel[i])) {
00466             ignoring=true;
00467             break;
00468           }
00469         //printf("ignoring==%d\n",ignoring);
00470         
00471       } else {
00472         curmodel.push_back(key);
00473         //printf("entering section %s\n",curmodel.back().c_str());
00474         ignoring=ignoring || !matchNoCase(rdStr,key);
00475         //printf("ignoring==%d\n",ignoring);
00476       }
00477     } else if(!ignoring) {
00478       if (sscanf(buf,"[%29[^]]]",key)>0) {
00479         section=parseSection(key);
00480         //std::cout << "now parsing section " << section << std::endl;
00481       } else if (sscanf(buf,"%29[^=]=%49s",key,value)>1) {
00482         //printf("setValue(%d,'%s','%s');\n",section,key,value);
00483         setValue(section, key, value);    
00484       }
00485     }
00486   }
00487   fclose(fp);
00488 }
00489 
00490 bool Config::matchNoCase(const std::string& model, const std::string& pattern) {
00491   unsigned int i=0;
00492   if(i==pattern.size() && i==model.size())
00493     return true;
00494   if(i==pattern.size() || i==model.size())
00495     return false;
00496   while(pattern[i]!='*') {
00497     if(toupper(pattern[i])!=toupper(model[i]))
00498       return false;
00499     i++;
00500     if(i==pattern.size() && i==model.size())
00501       return true;
00502     if(i==pattern.size() || i==model.size())
00503       return false;
00504   }
00505   i=pattern.size()-1;
00506   unsigned int j=model.size()-1;
00507   while(pattern[i]!='*') {
00508     if(toupper(pattern[i])!=toupper(model[j]))
00509       return false;
00510     i--; j--;
00511   }
00512   return true;
00513 }
00514 
00515 bool Config::extractBool(const char * value) {
00516   int i=0;
00517   while(isspace(value[i])) i++;
00518   if(strncasecmp(&value[i],"t",29)==0)
00519     return true;
00520   else if(strncasecmp(&value[i],"f",29)==0)
00521     return false;
00522   else if(strncasecmp(&value[i],"true",29)==0)
00523     return true;
00524   else if(strncasecmp(&value[i],"false",29)==0)
00525     return false;
00526   else if(strncasecmp(&value[i],"y",29)==0)
00527     return true;
00528   else if(strncasecmp(&value[i],"n",29)==0)
00529     return false;
00530   else if(strncasecmp(&value[i],"yes",29)==0)
00531     return true;
00532   else if(strncasecmp(&value[i],"no",29)==0)
00533     return false;
00534   else
00535     return atoi(value);
00536 }
00537 
00538 /*! @file
00539  * @brief Implements Config, which provides global access to system configuration information
00540  * @author alokl (Creator)
00541  *
00542  * $Author: ejt $
00543  * $Name: tekkotsu-2_3 $
00544  * $Revision: 1.42 $
00545  * $State: Exp $
00546  * $Date: 2005/01/20 23:18:43 $
00547  */
00548 

Tekkotsu v2.3
Generated Sat Jan 29 02:25:21 2005 by Doxygen 1.4.0