readcfg.c

Go to the documentation of this file.
00001 
00011 #include "edtinc.h"
00012 #include "initcam.h"
00013 
00014 #define COMPARE(str1, str2) (strcasecmp(str1, str2) == 0)
00015 
00016 /* shorthand debug level */
00017 #define DEBUG0 PDVLIB_MSG_FATAL
00018 #define DEBUG1 PDVLIB_MSG_INFO_1
00019 #define DEBUG2 PDVLIB_MSG_INFO_2
00020 
00021 u_char *xilinx;                 /* pointer to programmable Xilinx area */
00022 static char xilinx_file[512];
00023 static char xilinx_link[512];
00024 int     nser = 0;
00025 
00026 void clear_dependent(Dependent * dd_p);
00027 int check_method_param(char *s, Dependent * dd_p, Edtinfo * ei_p, char *cfgfile);
00028 int check_other_param(char *s, Dependent * dd_p, char *cfgfile);
00029 int check_xilinx_param(char *s, Dependent * dd_p, char *cfgfile);
00030 int check_cls_param(char *s, Dependent * dd_p, char *cfgfile);
00031 int is_method(char *method_type, char *name);
00032 void strip_ctrlm(char *s);
00033 void strip_extra_whitespace(char *s);
00034 int resolve_cameratype(Dependent *dd_p);
00035 
00036 
00037 /* utility routine for embedded (nofs) config file arrays -- copies and changes '\"' to '"'*/
00038 char *
00039 get_next_string(int nofs_cfg, FILE *cfg_fp, char *ss, char *ds)
00040 {
00041     char *dp = ds;
00042 #ifdef NO_FS
00043     char *sp ;
00044 #endif
00045 
00046 #ifdef NO_FS
00047     if (nofs_cfg)
00048     {
00049         sp = ss;
00050         if (!*sp)
00051             return 0;
00052 
00053         while(*sp)
00054         {
00055             if ((*sp == '\\') && (*(sp+1) == '\"'))
00056                 ++sp;
00057             *dp++ = *sp++;
00058         }
00059         *dp = '\0';
00060 
00061         return 1;
00062     }
00063     else
00064 #endif
00065     
00066     return fgets(ds, 255, cfg_fp);
00067 }
00068 
00069 
00070 #ifdef NO_FS
00071 /*
00072  * embedded config files, for 
00073  */
00074 #include "nofs_config.h"
00075 #endif
00076 
00077 
00078 char *dmy_cfg[] = {""};
00079 
00080 void
00081 dep_set_default(PdvDependent * dd_p)
00082 
00083 {
00084     int i;
00085 
00086    /*
00087      * clear dependent struct and set defaults to nonsense values
00088      */
00089     clear_dependent(dd_p);
00090     dd_p->rbtfile[0] = '\0';
00091     dd_p->cameratype[0] = '\0';
00092     dd_p->shutter_speed = NOT_SET;
00093     dd_p->default_shutter_speed = NOT_SET;
00094     dd_p->default_gain = NOT_SET;
00095     dd_p->default_offset = NOT_SET;
00096     dd_p->default_aperture = NOT_SET;
00097     dd_p->binx = 1;
00098     dd_p->biny = 1;
00099     dd_p->byteswap = NOT_SET;
00100     dd_p->serial_timeout = 1000;
00101     dd_p->serial_response[0] = '\r';
00102     dd_p->xilinx_rev = NOT_SET;
00103     dd_p->timeout = NOT_SET;
00104     dd_p->user_timeout = NOT_SET;
00105     dd_p->mode_cntl_norm = NOT_SET;
00106     dd_p->mc4 = 0;
00107     dd_p->pulnix = 0;
00108     dd_p->dbl_trig = 0;
00109     dd_p->shift = NOT_SET;
00110     dd_p->mask = 0xffff;
00111     dd_p->mode16 = NOT_SET;
00112     dd_p->serial_baud = NOT_SET;
00113     dd_p->serial_waitc = NOT_SET ;
00114     dd_p->serial_format = SERIAL_ASCII;
00115     strcpy(dd_p->serial_term, "\r");    /* term for most ASCII exc. ES4.0 */
00116     
00117     dd_p->kbs_red_row_first = 1;
00118     dd_p->kbs_green_pixel_first = 0;
00119   
00120 
00121     dd_p->htaps = 1;
00122     dd_p->vtaps = 1;
00123 
00124     dd_p->cameralink = 0;
00125     dd_p->start_delay = 0;
00126     dd_p->frame_period = NOT_SET;
00127     dd_p->frame_timing = NOT_SET;
00128 
00129     dd_p->strobe_enabled = NOT_SET;
00130     dd_p->register_wrap = 0;
00131     dd_p->serial_init_delay = NOT_SET;
00132 
00133 
00134     /*
00135      * xregwrite registers can be 0-ff. We need a way to flag the
00136      * end of the array, so just waste ff and call that "not set"
00137      */
00138     for (i=0; i<32; i++)
00139         dd_p->xilinx_flag[i] = 0xff;
00140 
00141 }
00142 
00143 int
00144 readcfg(char *cfgfile, Dependent * dd_p, Edtinfo * ei_p, int nofs_cfg)
00145 {
00146 
00147 
00148     int     pdv_unit = 0;
00149     int     ret;
00150     char    **vx_p = dmy_cfg;
00151     FILE   *cfg_fp;
00152     char    s[256];
00153     char    *sp;
00154     int     lineno = 0;
00155 #ifdef NO_FS
00156     char    *cf;
00157 #endif
00158 
00159     edt_msg(DEBUG2, "Reading/processing config file %s:\n\n", cfgfile);
00160 
00161     if (!nofs_cfg)
00162     {
00163         /*
00164          * Read and process the configuration file for this camera.
00165          */
00166         if ((cfg_fp = fopen(cfgfile, "r")) == NULL)
00167         {
00168             perror(cfgfile);
00169             return -1;
00170         }
00171     }
00172 
00173     dep_set_default(dd_p);
00174 
00175     ei_p->startdma = NOT_SET;
00176     ei_p->enddma = NOT_SET;
00177     ei_p->flushdma = NOT_SET;
00178 
00179      dd_p->startdma = NOT_SET;
00180     dd_p->enddma = NOT_SET;
00181     dd_p->flushdma = NOT_SET;
00182    
00183 
00184     strncpy(dd_p->cfgname, cfgfile, sizeof(dd_p->cfgname) - 1);
00185  
00186 #ifdef NO_FS
00187     if (nofs_cfg)
00188     {
00189         char *p;
00190 
00191         if ((cf = strrchr(cfgfile, '/')) != NULL)
00192             ++cf;
00193         else cf = cfgfile;
00194         p = cf;
00195 
00196         if ((strlen(cf) > 4) && (strcasecmp(&cf[strlen(cf)-4], ".cfg") == 0))
00197             cf[strlen(cf)-4] = '\0';
00198 
00199         /*
00200          * change dashes to underscores in name, to match variable names
00201          */
00202         do
00203         {
00204             if (*p == '-')
00205                 (*p = '_');
00206         } while(*(++p));
00207         MAPCONFIG(cf, vx_p); /* macro in nofs_config.h */
00208 
00209         if (vx_p == NULL)
00210         {
00211             printf("embedded specified, but no header file for '%s' included in source (nofs_config.h)\n", cf);
00212             exit(1);
00213         }
00214     }
00215 #endif
00216 
00217     while (get_next_string(nofs_cfg, cfg_fp, *vx_p, s))
00218     {
00219         char tmpstr[256];
00220         if (nofs_cfg)
00221             ++vx_p;
00222 
00223         lineno++;
00224 
00225         /* debug string printf */
00226         if (s[strlen(s)-1] == '\n')
00227             strcpy(tmpstr, s);
00228         else sprintf(tmpstr, "%s\n", s);
00229         edt_msg(DEBUG2, tmpstr);
00230 
00231         if (*s == '#' || *s == '\n' || *s == '\r')
00232             continue;
00233 
00234         strip_ctrlm(s);
00235         strip_extra_whitespace(s);
00236 
00237         if (*s == '#' || *s == '\n' || *s == '\r')
00238             continue;
00239 
00240         if ((ret = check_method_param(s, dd_p, ei_p, cfgfile)) < 0)
00241             return -1;
00242         if (ret == 1)
00243             continue;
00244 
00245         if ((ret = check_xilinx_param(s, dd_p, cfgfile)) < 0)
00246             return -1;
00247         if (ret == 1)
00248             continue;
00249 
00250         if ((ret = check_other_param(s, dd_p, cfgfile)) < 0)
00251             return -1;
00252 
00253         if (ret == 1)
00254             continue;
00255 
00256         if ((ret = check_cls_param(s, dd_p, cfgfile)) < 0)
00257             return -1;
00258 
00259         if (ret == 1)
00260             continue;
00261 
00262         {
00263             char    kw[256];
00264 
00265             sscanf(s, "%s", kw);
00266             edt_msg(DEBUG0, "WARNING: unrecognized argument \"%s\" line %d (ignored)\n", kw, lineno);
00267         }
00268     }
00269 
00270 #ifndef NO_FS
00271     fclose(cfg_fp);
00272 #endif
00273 
00274     /*
00275      * the cameratype directive (not the parameter though) is obsolete
00276      * so make it up from class and model if they are present (should be!)
00277      */
00278     resolve_cameratype(dd_p);
00279 
00280     /*
00281      * pdv uses .bit files, not .rbt files, but some older config
00282      * might still reference the old extension
00283      */
00284     if (dd_p->rbtfile[0])
00285     {
00286         if ((sp = strrchr(dd_p->rbtfile, '.')) == NULL)
00287             sp = strchr(dd_p->rbtfile, '\0');
00288         if ((sp != NULL) && ((strcmp(sp, ".rbt") == 0) || (*sp == '\0')))
00289             sprintf(sp, ".bit");
00290     }
00291 
00292     return 0;
00293 }
00294 
00312 int
00313 pdv_readcfg(char *cfgfile, Dependent * dd_p, Edtinfo *ei_p)
00314 {
00315     return readcfg(cfgfile, dd_p, ei_p, 0);
00316 }
00317 
00318 int
00319 pdv_readcfg_emb(char *cfgfile, Dependent * dd_p, Edtinfo *ei_p)
00320 {
00321     return readcfg(cfgfile, dd_p, ei_p, 1);
00322 }
00323 
00324 
00325 translate_method_arg(char *method_arg, int *method_number)
00326 {
00327     /* Translate the method_arg to a method number */
00328     if (COMPARE(method_arg, "AIA_MCL_100US"))
00329         *method_number = AIA_MCL_100US;
00330     else if (COMPARE(method_arg, "AIA_MCL"))
00331         *method_number = AIA_MCL;
00332     else if (COMPARE(method_arg, "AIA_TRIG"))
00333         *method_number = AIA_TRIG;
00334     else if (COMPARE(method_arg, "KODAK_AIA_MCL"))
00335         *method_number = KODAK_AIA_MCL;
00336     else if (COMPARE(method_arg, "AIA_MC4"))
00337         *method_number = AIA_MC4;
00338     else if (COMPARE(method_arg, "HAMAMATSU_4880_8X"))
00339         *method_number = HAM_4880_8X;
00340     else if (COMPARE(method_arg, "HAMAMATSU_4880_SER"))
00341         *method_number = HAM_4880_SER;
00342     else if (COMPARE(method_arg, "SU320_SERIAL"))
00343         *method_number = SU320_SERIAL;
00344     else if (COMPARE(method_arg, "BASLER202K_SERIAL"))
00345         *method_number = BASLER202K_SERIAL;
00346     else if (COMPARE(method_arg, "ADIMEC_SERIAL"))
00347         *method_number = ADIMEC_SERIAL;
00348     else if (COMPARE(method_arg, "TIMC1001_SERIAL"))
00349         *method_number = TIMC1001_SERIAL;
00350     else if (COMPARE(method_arg, "PTM6710_SERIAL"))
00351         *method_number = PTM6710_SERIAL;
00352     else if (COMPARE(method_arg, "PTM1020_SERIAL"))
00353         *method_number = PTM1020_SERIAL;
00354     else if (COMPARE(method_arg, "PULNIX_TM1000"))
00355         *method_number = PULNIX_TM1000;
00356     else if (COMPARE(method_arg, "PULNIX_TM9700"))
00357         *method_number = PULNIX_TM9700;
00358     else if (COMPARE(method_arg, "IRC_160"))
00359         *method_number = IRC_160;
00360     else if (COMPARE(method_arg, "KODAK_AIA_SER_CTRL"))
00361         *method_number = KODAK_AIA_SER_CTRL;
00362     else if (COMPARE(method_arg, "AIA_SER_CTRL"))
00363         *method_number = AIA_SER_CTRL;
00364     else if (COMPARE(method_arg, "KODAK_AIA_SER"))
00365         *method_number = KODAK_AIA_SER;
00366     else if (COMPARE(method_arg, "SMD_SERIAL"))
00367         *method_number = SMD_SERIAL;
00368     else if (COMPARE(method_arg, "AIA_SER_ES40"))
00369         *method_number = AIA_SERIAL_ES40;
00370     else if (COMPARE(method_arg, "AIA_SER"))
00371         *method_number = AIA_SERIAL;
00372     else if (COMPARE(method_arg, "KODAK_SER_14I"))
00373         *method_number = KODAK_SER_14I;
00374     else if (COMPARE(method_arg, "SER_14I"))
00375         *method_number = KODAK_SER_14I;
00376     else if (COMPARE(method_arg, "SPECINST_SERIAL"))
00377         *method_number = SPECINST_SERIAL;
00378     else if (COMPARE(method_arg, "KODAK_XHF_INTLC"))
00379         *method_number = PDV_BYTE_INTLV;
00380     else if (COMPARE(method_arg, "BYTE_INTLV"))
00381         *method_number = PDV_BYTE_INTLV;
00382     else if (COMPARE(method_arg, "FIELD_INTLC"))
00383         *method_number = PDV_FIELD_INTLC;
00384     else if (COMPARE(method_arg, "BYTE_TEST1"))
00385         *method_number = PDV_BYTE_TEST1;
00386     else if (COMPARE(method_arg, "BYTE_TEST2"))
00387         *method_number = PDV_BYTE_TEST2;
00388     else if (COMPARE(method_arg, "BYTE_TEST3"))
00389         *method_number = PDV_BYTE_TEST3;
00390     else if (COMPARE(method_arg, "WORD_INTLV_HILO"))
00391         *method_number = PDV_WORD_INTLV_HILO;
00392     else if (COMPARE(method_arg, "WORD_INTLV_ODD"))
00393         *method_number = PDV_WORD_INTLV_ODD;
00394     else if (COMPARE(method_arg, "ES10_WORD_INTLC"))
00395         *method_number = PDV_WORD_INTLV;
00396     else if (COMPARE(method_arg, "WORD_INTLV"))
00397         *method_number = PDV_WORD_INTLV;
00398     else if (COMPARE(method_arg, "DALSA_4CH_INTLV"))
00399         *method_number = PDV_DALSA_4CH_INTLV;
00400     else if (COMPARE(method_arg, "PIRANHA_4CH_INTLV"))
00401         *method_number = PDV_PIRANHA_4CH_INTLV;
00402     else if (COMPARE(method_arg, "PIRANHA_4CH_HWINTLV"))
00403         *method_number = PDV_PIRANHA_4CH_HWINTLV;
00404     else if (COMPARE(method_arg, "SPECINST_4PORT_INTLV"))
00405         *method_number = PDV_SPECINST_4PORT_INTLV;
00406     else if (COMPARE(method_arg, "ILLUNIS_INTLV"))
00407         *method_number = PDV_ILLUNIS_INTLV;
00408     else if (COMPARE(method_arg, "ES10_BGGR_INTLV"))
00409         *method_number = PDV_ES10_BGGR;
00410     else if (COMPARE(method_arg, "ES10_WORD_BGGR_INTLV"))
00411         *method_number = PDV_ES10_WORD_BGGR;
00412     else if (COMPARE(method_arg, "ES10_WORD_ODD_BGGR_INTLV"))
00413         *method_number = PDV_ES10_WORD_ODD_BGGR;
00414     else if (COMPARE(method_arg, "ILLUNIS_BGGR"))
00415         *method_number = PDV_ILLUNIS_BGGR;
00416     else if (COMPARE(method_arg, "QUADRANT_INTLV"))
00417         *method_number = PDV_QUADRANT_INTLV;
00418     else if (COMPARE(method_arg, "DALSA_2CH_INTLV"))
00419         *method_number = PDV_DALSA_2CH_INTLV;
00420     else if (COMPARE(method_arg, "INVERT_RIGHT_INTLV_24_12"))
00421         *method_number = PDV_INV_RT_INTLV_24_12;
00422     else if (COMPARE(method_arg, "INTLV_24_12"))
00423         *method_number = PDV_INTLV_24_12;
00424    else if (COMPARE(method_arg, "INTLV_1_8_MSB7"))
00425         *method_number = PDV_INTLV_1_8_MSB7;
00426    else if (COMPARE(method_arg, "INTLV_1_8_MSB0"))
00427         *method_number = PDV_INTLV_1_8_MSB0;
00428     else if (COMPARE(method_arg, "INVERT_RIGHT_INTLV"))
00429         *method_number = PDV_INVERT_RIGHT_INTLV;
00430     else if (COMPARE(method_arg, "INVERT_RIGHT_BGGR_INTLV"))
00431         *method_number = PDV_INVERT_RIGHT_BGGR_INTLV;
00432     else if (COMPARE(method_arg, "DALSA_2M30_INTLV"))
00433         *method_number = PDV_DALSA_2M30_INTLV;
00434     else if (COMPARE(method_arg, "EVEN_RIGHT_INTLV"))
00435         *method_number = PDV_EVEN_RIGHT_INTLV;
00436     else if (COMPARE(method_arg, "BGGR_DUAL"))
00437         *method_number = PDV_BGGR_DUAL;
00438     else if (COMPARE(method_arg, "BGGR_WORD"))
00439         *method_number = PDV_BGGR_WORD;
00440     else if (COMPARE(method_arg, "BGGR"))
00441         *method_number = PDV_BGGR;
00442     else if (COMPARE(method_arg, "BGR_2_RGB"))
00443         *method_number = PDV_INTLV_BGR_2_RGB;
00444     else if (COMPARE(method_arg, "KODAK_XHF_SKIP"))
00445         *method_number = PDV_BYTE_INTLV_SKIP;
00446     else if (COMPARE(method_arg, "BYTE_INTLV_SKIP"))
00447         *method_number = PDV_BYTE_INTLV_SKIP;
00448     else if (COMPARE(method_arg, "HW_ONLY"))
00449         *method_number = HW_ONLY;
00450     else if (COMPARE(method_arg, "FMRATE_ENABLE"))
00451         *method_number = PDV_FMRATE_ENABLE;
00452     else if (COMPARE(method_arg, "FVAL_ADJUST"))
00453         *method_number = PDV_FVAL_ADJUST;
00454     else if (COMPARE(method_arg, "BASLER_202K"))
00455         *method_number = BASLER_202K;
00456     else if (COMPARE(method_arg, "DUNCAN_2131"))
00457         *method_number = DUNCAN_2131;
00458 
00459     else if (COMPARE(method_arg, "FOI_REMOTE_AIA"))
00460         *method_number = FOI_REMOTE_AIA;
00461 
00462     else if (COMPARE(method_arg, "DALSA_CONTINUOUS"))
00463         *method_number = DALSA_CONTINUOUS;
00464 
00465     else if (COMPARE(method_arg, "EDT_ACT_NEVER"))
00466         *method_number = EDT_ACT_NEVER;
00467     else if (COMPARE(method_arg, "EDT_ACT_ONCE"))
00468         *method_number = EDT_ACT_ONCE;
00469     else if (COMPARE(method_arg, "EDT_ACT_ALWAYS"))
00470         *method_number = EDT_ACT_ALWAYS;
00471     else if (COMPARE(method_arg, "EDT_ACT_ONELEFT"))
00472         *method_number = EDT_ACT_ONELEFT;
00473     else if (COMPARE(method_arg, "EDT_ACT_CYCLE"))
00474         *method_number = EDT_ACT_CYCLE;
00475     else if (COMPARE(method_arg, "EDT_ACT_KBS"))
00476         *method_number = EDT_ACT_KBS;
00477 
00478     else if (COMPARE(method_arg, "BINARY"))
00479         *method_number = SERIAL_BINARY;
00480     else if (COMPARE(method_arg, "ASCII_HEX"))
00481         *method_number = SERIAL_ASCII_HEX;
00482     else if (COMPARE(method_arg, "ASCII"))
00483         *method_number = SERIAL_ASCII;
00484     else if (COMPARE(method_arg, "PULNIX_1010"))
00485         *method_number = SERIAL_PULNIX_1010;
00486     else if (COMPARE(method_arg, "DALSA_LS"))
00487         *method_number = PDV_DALSA_LS;
00488     else if (COMPARE(method_arg, "HEADER_BEFORE"))
00489         *method_number = PDV_HEADER_BEFORE;
00490     else if (COMPARE(method_arg, "HEADER_AFTER"))
00491         *method_number = PDV_HEADER_AFTER;
00492     else if (COMPARE(method_arg, "HEADER_WITHIN"))
00493         *method_number = PDV_HEADER_WITHIN;
00494     else if (COMPARE(method_arg, "DDCAM"))
00495         *method_number = PDV_DDCAM;
00496     else if (COMPARE(method_arg, "RS232"))
00497         *method_number = PDV_SERIAL_RS232;
00498     else if (COMPARE(method_arg, "BASLER_FRAMING"))
00499         *method_number = SERIAL_BASLER_FRAMING;
00500     else if (COMPARE(method_arg, "DUNCAN_FRAMING"))
00501         *method_number = SERIAL_DUNCAN_FRAMING;
00502     else
00503         return 0;
00504 
00505     return 1;
00506 }
00507 
00508 check_label(char *str, char *label)
00509 {
00510     char    tmplabel[64];
00511 
00512     sprintf(tmplabel, "%s:", label);
00513     if (strncmp(str, tmplabel, strlen(tmplabel)) == 0)
00514         return 1;
00515     return 0;
00516 }
00517 
00518 set_method(Dependent * dd_p, Edtinfo * ei_p, char *method_type, int method_number)
00519 {
00520     /* new for speed only */
00521     if (is_method(method_type, "camera_shutter_speed"))
00522         dd_p->camera_shutter_speed = method_number;
00523 
00524     /* ALERT: OBSOLETE */
00525     else if (is_method(method_type, "shutter_speed"))
00526         dd_p->camera_shutter_timing = method_number;
00527 
00528     else if (is_method(method_type, "camera_shutter_timing"))
00529         dd_p->camera_shutter_timing = method_number;
00530 
00531     else if (is_method(method_type, "lock_shutter"))
00532         dd_p->lock_shutter = method_number;
00533 
00534     else if (is_method(method_type, "camera_continuous"))
00535         dd_p->camera_continuous = method_number;
00536 
00537     else if (is_method(method_type, "camera_binning"))
00538         dd_p->camera_binning = method_number;
00539 
00540     else if (is_method(method_type, "camera_data_rate"))
00541         dd_p->camera_data_rate = method_number;
00542 
00543     else if (is_method(method_type, "pixelclock_speed")) /* alias */
00544         dd_p->camera_data_rate = method_number;
00545 
00546     else if (is_method(method_type, "camera_download"))
00547         dd_p->camera_download = method_number;
00548 
00549     else if (is_method(method_type, "get_gain"))
00550         dd_p->get_gain = method_number;
00551 
00552     else if (is_method(method_type, "get_offset"))
00553         dd_p->get_offset = method_number;
00554 
00555     else if (is_method(method_type, "set_gain"))
00556         dd_p->set_gain = method_number;
00557 
00558     else if (is_method(method_type, "set_offset"))
00559         dd_p->set_offset = method_number;
00560 
00561     else if (is_method(method_type, "first_open"))
00562         dd_p->first_open = method_number;
00563 
00564     else if (is_method(method_type, "last_close"))
00565         dd_p->last_close = method_number;
00566 
00567     else if (is_method(method_type, "interlace"))
00568     {
00569         if (method_number == PDV_PIRANHA_4CH_HWINTLV) /* special case hardware methods */
00570             dd_p->hwinterlace = method_number;
00571         else dd_p->swinterlace = method_number;
00572     }
00573     else if (is_method(method_type, "pingpong_varsize"))
00574         dd_p->pingpong_varsize = method_number;
00575 
00576     else if (is_method(method_type, "serial_format"))
00577         dd_p->serial_format = method_number;
00578 
00579     else if (is_method(method_type, "serial_mode"))
00580         dd_p->serial_mode = method_number;
00581 
00582     else if (is_method(method_type, "frame_timing"))
00583         dd_p->frame_timing = method_number;
00584 
00585     else if (is_method(method_type, "startdma"))
00586     {
00587         ei_p->startdma = method_number;
00588         dd_p->startdma = method_number;
00589     }
00590     else if (is_method(method_type, "enddma"))
00591     {
00592         ei_p->enddma = method_number;
00593         dd_p->enddma = method_number;
00594     }
00595 
00596     else if (is_method(method_type, "flushdma"))
00597     {
00598         ei_p->flushdma = method_number;
00599         dd_p->flushdma = method_number;
00600      }
00601 
00602     else if (is_method(method_type, "header_position"))
00603         dd_p->header_position = method_number;
00604 
00605 
00606 
00607     else
00608     {
00609         edt_msg(DEBUG0, "WARNING: unknown method direcive \"%s\" (ignored)\n", method_type);
00610         return 0;
00611     }
00612     return 1;
00613 }
00614 
00615 int
00616 is_method(char *method_type, char *name)
00617 {
00618     char    method_name[64];
00619 
00620     sprintf(method_name, "method_%s", name);
00621     if (COMPARE(method_name, method_type))
00622         return 1;
00623     return 0;
00624 }
00625 
00626 /*
00627  * clear dependent struct
00628  */
00629 void
00630 clear_dependent(Dependent * dd_p)
00631 {
00632     memset(dd_p, 0, sizeof(Dependent));
00633 }
00634 
00635 
00636 /*
00637  * check_xx_method return 1 if found, 0 if not found, -1 (and print msg) if
00638  * error.
00639  */
00640 int
00641 check_int_method(char *line, char *label, int *arg, char *cfgfile)
00642 {
00643     char    format[32];
00644     int     ret = 0;
00645     int     n;
00646 
00647     if (check_label(line, label))
00648     {
00649         sprintf(format, "%s: %%d", label);
00650         if ((n = sscanf(line, format, arg)) != 1)
00651         {
00652             edt_msg(DEBUG2,
00653                     "Error in parsing %s.\nExpected:\n\n\t%s: <parameter>\n",
00654                     cfgfile, label);
00655             edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", line);
00656             ret = -1;
00657         }
00658         else
00659             ret = 1;
00660     }
00661 
00662     return ret;
00663 }
00664 
00665 int
00666 check_ulong_method(char *line, char *label, u_long * arg, char *cfgfile)
00667 {
00668     char    format[32];
00669     int     ret = 0;
00670     int     n;
00671 
00672     if (check_label(line, label))
00673     {
00674         sprintf(format, "%s: %%lu", label);
00675         if ((n = sscanf(line, format, arg)) != 1)
00676         {
00677             edt_msg(DEBUG2,
00678                     "Error in parsing %s.\nExpected:\n\n\t%s: <parameter>\n",
00679                     cfgfile, label);
00680             edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", line);
00681             ret = -1;
00682         }
00683         else
00684             ret = 1;
00685     }
00686 
00687     return ret;
00688 }
00689 
00690 int
00691 check_float_method(char *line, char *label, float * arg, char *cfgfile)
00692 {
00693     char    format[32];
00694     int     ret = 0;
00695     int     n;
00696 
00697     if (check_label(line, label))
00698     {
00699         sprintf(format, "%s: %%f", label);
00700         if ((n = sscanf(line, format, arg)) != 1)
00701         {
00702             edt_msg(DEBUG2,
00703                     "Error in parsing %s.\nExpected:\n\n\t%s: <parameter>\n",
00704                     cfgfile, label);
00705             edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", line);
00706             ret = -1;
00707         }
00708         else
00709             ret = 1;
00710     }
00711 
00712     return ret;
00713 }
00714 
00715 int
00716 check_ushort_method(char *line, char *label, u_short * arg, char *cfgfile)
00717 {
00718     char    format[32];
00719     int     ret = 0;
00720     int     n;
00721     int     v;
00722 
00723     if (check_label(line, label))
00724     {
00725         sprintf(format, "%s: %%u", label);
00726         if ((n = sscanf(line, format, &v)) != 1)
00727         {
00728             edt_msg(DEBUG2,
00729                     "Error in parsing %s.\nExpected:\n\n\t%s: <parameter>\n",
00730                     cfgfile, label);
00731             edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", line);
00732             ret = -1;
00733         }
00734         else
00735         {
00736             *arg = v;
00737             ret = 1;
00738         }
00739     }
00740 
00741     return ret;
00742 }
00743 
00744 int
00745 check_byte_method(char *line, char *label, u_short * arg, char *cfgfile)
00746 {
00747     char    format[32];
00748     int     ret = 0;
00749     int     n;
00750     int     v;
00751 
00752     if (check_label(line, label))
00753     {
00754         sprintf(format, "%s: %%u", label);
00755         if ((n = sscanf(line, format, &v)) != 1)
00756         {
00757             edt_msg(DEBUG2,
00758                     "Error in parsing %s.\nExpected:\n\n\t%s: <parameter>\n",
00759                     cfgfile, label);
00760             edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", line);
00761             ret = -1;
00762         }
00763         else
00764         {
00765             *arg = v;
00766             ret = 1;
00767         }
00768     }
00769 
00770     return ret;
00771 }
00772 
00773 /*
00774  * parse a hex string -- 2 digit bytes separated by spaces, put into
00775  * char buffer
00776  */
00777 parse_hex_str(char *str, char *buf)
00778 {
00779     int i = 0;
00780     u_int ibyte;
00781     char *sp = str;
00782 
00783     while ((*(sp+2) == ' ') || (*(sp+2) == '\0'))
00784     {
00785         sscanf(sp, "%02x ", &ibyte);
00786         buf[i++] = (char)ibyte;
00787         if (*(sp+2) == '\0')
00788             break;
00789         sp += 3;
00790     }
00791     buf[i] = '\0';
00792     return 1;
00793 }
00794 
00795 /*
00796  * check string method -- return 0 on failure, 1 on success
00797  */
00798 check_str_method(char *line, char *label, char *arg, int max, char *cfgfile)
00799 {
00800     int     ret = 1;
00801     char   *p = NULL;
00802     char   *sp = NULL;
00803     char   *ep;
00804     char    endchar;
00805     char    tmp_arg[MAXINIT];
00806 
00807     p = strchr(line, ':');
00808     if (!p)
00809         return (0);
00810 
00811     if ((sp = strchr(p, '"')) != NULL)
00812         endchar = '"';
00813     else if ((sp = strchr(p, '<')) != NULL)
00814         endchar = '>';
00815     else return 0;
00816 
00817     ep = strrchr(sp, endchar);
00818 
00819     if (!check_label(line, label))
00820         return 0;
00821 
00822     if ((int) strlen(sp) > max)
00823     {
00824         edt_msg(DEBUG0,
00825                 "WARNING parsing %s: '%s' arg exceeds %d char max (truncating)\n",
00826                 cfgfile, label, max - 3);
00827     }
00828 
00829     if ((p == NULL)
00830         || (sp == NULL)
00831         || (ep == NULL)
00832         || (ep == p))
00833 
00834     {
00835         edt_msg(DEBUG2,
00836                 "Error in parsing %s.\nExpected:\n\n\t%s: \"command\" (up to %d chars);\n",
00837                 cfgfile, label, max - 2);
00838         if (sp)
00839             edt_msg(DEBUG2, "\nGot:\n\n\t%s, %d chars\n", sp, strlen(sp));
00840         else
00841             edt_msg(DEBUG2, "\nGot: Nothing\n");
00842         return 0;
00843     }
00844 
00845     strcpy(tmp_arg, ++sp);
00846     if ((int) strlen(sp) > max)
00847         tmp_arg[max-1] = '\0';
00848 
00849     /*
00850      * find last double quote, get rid of it
00851      */
00852     if ((ep = strrchr(tmp_arg, endchar)) != NULL)
00853         *ep = '\0';
00854 
00855     if (endchar == '>')
00856         ret = parse_hex_str(tmp_arg, arg);
00857     else strncpy(arg, tmp_arg, max);
00858 
00859     return ret;
00860 }
00861 
00862 
00863 check_path_method(char *line, char *label, char *arg, char *cfgfile)
00864 {
00865     int     ret = 0;
00866     int     n;
00867     char    format[32];
00868 
00869     if (check_label(line, label))
00870     {
00871         sprintf(format, "%s: %%s", label);
00872         if ((n = sscanf(line, format, arg)) != 1)
00873         {
00874             edt_msg(DEBUG2,
00875                     "Error in parsing %s.\nExpected:\n\n\t%s: <parameter>\n",
00876                     cfgfile, label);
00877             edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", line);
00878             ret = -1;
00879         }
00880         else
00881             ret = 1;
00882     }
00883 
00884     return ret;
00885 }
00886 
00887 
00888 /* ALERT: check if this is same as check_foi_init -- hopefully so */
00889 check_serial_init_method(char *line, char *label, char *cmd, char *cfgfile)
00890 {
00891     int     ret = 0;
00892     char   *p = NULL;
00893     char   *sp = NULL;
00894     char   *ep;
00895     char    tmp_arg[128];
00896 
00897     p = strchr(line, ':');
00898     if (!p)
00899         return 0;
00900     sp = strchr(p, '"');
00901     if (!sp)
00902         return 0;
00903     if (!check_label(line, label))
00904         return 0;
00905 
00906     if ((p == NULL)
00907         || (*(p + 1) == '\0')
00908         || (sp == NULL)
00909         || (strlen(sp) > (MAXINIT - 2))
00910         || ((ep = strrchr(sp, '"')) == NULL))
00911 
00912     {
00913         edt_msg(DEBUG2,
00914                 "Error in parsing %s.\nExpected:\n\n\t%s: \"command\" (up to %d chars);\n",
00915                 cfgfile, label, MAXINIT - 2);
00916         if (sp)
00917             edt_msg(DEBUG2, "\nGot:\n\n\t%s, %d chars\n", sp, strlen(sp));
00918         else edt_msg(DEBUG2, "\nGot: Nothing\n");
00919         return 0;
00920     }
00921 
00922     strcpy(tmp_arg, ++sp);
00923 
00924     /* find last double quote, get rid of it  */
00925     /* also tack on trailing ':' if not there  */
00926     ep = strrchr(tmp_arg, '"');
00927     if ((*(ep - 1) != ':') || (*(ep - 2) == '\\'))
00928         *ep++ = ':';
00929     *ep = '\0';
00930 
00931     strncpy(cmd, tmp_arg, MAXINIT);
00932     return 1;
00933 }
00934 
00935 /*
00936  * return 1 on success, 0 on failure.
00937  */
00938 check_hex_method(char *line, char *label, u_int * method, char *cfgfile)
00939 {
00940     char    format[32];
00941     char    hexstr[32];
00942 
00943     if (!check_label(line, label))
00944         return 0;
00945 
00946     sprintf(format, "%s: %%s", label);
00947     if (sscanf(line, format, hexstr) != 1)
00948     {
00949         edt_msg(DEBUG2, "Error in parsing %s.  Expected:\n\n\t%s: <hex_parameter>\n", cfgfile, label);
00950         edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", line);
00951         return 0;
00952     }
00953     *method = strtol(hexstr, NULL, 16);
00954     return 1;
00955 }
00956 
00957 /*
00958  * check int, long, hex, string methods
00959  * 
00960  * return 1 if found, 0 if not found, -1 if error
00961  */
00962 check_other_param(char *s, Dependent * dd_p, char *cfgfile)
00963 {
00964     int     ret;
00965     int     tr;
00966     char    tmpstr[256];
00967 
00968     /*
00969      * integer methods
00970      */
00971     if (ret = check_int_method(s, "width", &dd_p->width, cfgfile))
00972         return ret;
00973     if (ret = check_int_method(s, "height", &dd_p->height, cfgfile))
00974         return ret;
00975     if (ret = check_int_method(s, "cam_width", &dd_p->cam_width, cfgfile))
00976         return ret;
00977     if (ret = check_int_method(s, "cam_height", &dd_p->cam_height, cfgfile))
00978         return ret;
00979     if (ret = check_int_method(s, "depth", &dd_p->depth, cfgfile))
00980         return ret;
00981     if (ret = check_int_method(s, "extdepth", &dd_p->extdepth, cfgfile))
00982         return ret;
00983     if (ret = check_int_method(s, "slop", &dd_p->slop, cfgfile))
00984         return ret;
00985     if (ret = check_int_method(s, "hwpad", &dd_p->hwpad, cfgfile))
00986         return ret;
00987     /* rgb 30 bit overloaded on hwpad register bits if PIR */
00988     if (ret = check_int_method(s, "rgb30", &dd_p->hwpad, cfgfile))
00989         return ret;
00990     if (ret = check_int_method(s, "irris_strip", &dd_p->hwpad, cfgfile))
00991         return ret;
00992     if (ret = check_int_method(s, "byteswap", &dd_p->byteswap, cfgfile))
00993         return ret;
00994     if (ret = check_int_method(s, "shortswap", &dd_p->shortswap, cfgfile))
00995         return ret;
00996     if (ret = check_int_method(s, "skip", &dd_p->skip, cfgfile))
00997         return ret;
00998     if (ret = check_int_method(s, "gendata", &dd_p->gendata, cfgfile))
00999         return ret;
01000     if (ret = check_int_method(s, "skipfrm", &dd_p->gendata, cfgfile))
01001         return ret;
01002     if (ret = check_int_method(s, "fixedlen", &dd_p->fixedlen, cfgfile))
01003         return ret;
01004     if (ret = check_int_method(s, "interlace", &dd_p->interlace, cfgfile))
01005         return ret;
01006     if (ret = check_int_method(s, "pdv_type", &dd_p->pdv_type, cfgfile))
01007         return ret;
01008     if (ret = check_int_method(s, "simulator_speed", &dd_p->sim_speed, cfgfile))
01009         return ret;
01010     if (ret = check_int_method(s, "cameratest", &dd_p->cameratest, cfgfile))
01011         return ret;
01012     if (ret = check_int_method(s, "genericsim", &dd_p->genericsim, cfgfile))
01013         return ret;
01014     if (ret = check_int_method(s, "disable_mdout", &dd_p->disable_mdout, cfgfile))
01015         return ret;
01016     if (ret = check_int_method(s, "sim_width", &dd_p->sim_width, cfgfile))
01017         return ret;
01018     if (ret = check_int_method(s, "sim_height", &dd_p->sim_height, cfgfile))
01019         return ret;
01020     if (ret = check_int_method(s, "sim_ctl", (int *) (&dd_p->sim_ctl), cfgfile))
01021         return ret;
01022     if (ret = check_int_method(s, "line_delay", &dd_p->line_delay, cfgfile))
01023         return ret;
01024     if (ret = check_int_method(s, "frame_delay", &dd_p->frame_delay, cfgfile))
01025         return ret;
01026     if (ret = check_int_method(s, "frame_height", &dd_p->frame_height, cfgfile))
01027         return ret;
01028     if (ret = check_int_method(s, "fv_once", &dd_p->fv_once, cfgfile))
01029         return ret;
01030     if (ret = check_int_method(s, "fval_once", &dd_p->fv_once, cfgfile)) /* alias */
01031         return ret;
01032     if (ret = check_int_method(s, "fval_done", &dd_p->fval_done, cfgfile))
01033         return ret;
01034     if (ret = check_int_method(s, "fv_done", &dd_p->fval_done, cfgfile)) /* alias */
01035         return ret;
01036     if (ret = check_int_method(s, "pingpong_varsize", &dd_p->pingpong_varsize, cfgfile))
01037         return ret;
01038     if (ret = check_int_method(s, "continuous", &dd_p->continuous, cfgfile))
01039         return ret;
01040     if (ret = check_int_method(s, "clr_continuous_end", &dd_p->clr_cont_end, cfgfile))
01041         return ret;
01042     if (ret = check_int_method(s, "clr_continuous_start", &dd_p->clr_cont_start,
01043                                cfgfile))
01044         return ret;
01045     if (ret = check_int_method(s, "cnt_continuous", (int *) (&dd_p->cnt_continuous), cfgfile))
01046         return ret;
01047 
01048     if (ret = check_int_method(s, "shutter_speed_frontp", &dd_p->shutter_speed_frontp, cfgfile))
01049         return ret;
01050     if (ret = check_int_method(s, "shutter_speed", &dd_p->shutter_speed, cfgfile))
01051         return ret;
01052     if (ret = check_int_method(s, "shutter_speed_min", &dd_p->shutter_speed_min, cfgfile))
01053         return ret;
01054     if (ret = check_int_method(s, "shutter_speed_max", &dd_p->shutter_speed_max, cfgfile))
01055         return ret;
01056 
01057     if (ret = check_int_method(s, "aperture_min", &dd_p->aperture_min, cfgfile))
01058         return ret;
01059     if (ret = check_int_method(s, "aperture_max", &dd_p->aperture_max, cfgfile))
01060         return ret;
01061     if (ret = check_int_method(s, "default_shutter_speed", &dd_p->default_shutter_speed, cfgfile))
01062         return ret;
01063     if (ret = check_int_method(s, "default_exposure", &dd_p->default_shutter_speed, cfgfile))
01064         return ret;
01065     if (ret = check_int_method(s, "default_aperture", &dd_p->default_aperture, cfgfile))
01066         return ret;
01067 
01068     if (ret = check_int_method(s, "gain_min", &dd_p->gain_min, cfgfile))
01069         return ret;
01070     if (ret = check_int_method(s, "gain_max", &dd_p->gain_max, cfgfile))
01071         return ret;
01072     if (ret = check_int_method(s, "default_gain", &dd_p->default_gain, cfgfile))
01073         return ret;
01074     if (ret = check_int_method(s, "gain_frontp", &dd_p->gain_frontp, cfgfile))
01075         return ret;
01076 
01077     if (ret = check_int_method(s, "offset_min", &dd_p->offset_min, cfgfile))
01078         return ret;
01079     if (ret = check_int_method(s, "offset_max", &dd_p->offset_max, cfgfile))
01080         return ret;
01081     if (ret = check_int_method(s, "offset_frontp", &dd_p->offset_frontp, cfgfile))
01082         return ret;
01083     if (ret = check_int_method(s, "default_offset", &dd_p->default_offset, cfgfile))
01084         return ret;
01085     if (ret = check_int_method(s, "serial_baud", &dd_p->serial_baud, cfgfile))
01086         return ret;
01087     if (ret = check_int_method(s, "DUAL_CHANNEL", &dd_p->dual_channel, cfgfile))
01088         return ret;
01089     if (ret = check_int_method(s, "DOUBLE_RATE", &dd_p->double_rate, cfgfile))
01090         return ret;
01091     if (ret = check_int_method(s, "ENABLE_DALSA", &dd_p->enable_dalsa, cfgfile))
01092         return ret;
01093     if (ret = check_int_method(s, "INV_SHUTTER", &dd_p->inv_shutter, cfgfile))
01094         return ret;
01095     if (ret = check_int_method(s, "INV_PTRIG", &dd_p->inv_ptrig, cfgfile))
01096         return ret;
01097     /* OBSOLETE */
01098     if (ret = check_int_method(s, "INV_LVALID", &dd_p->inv_ptrig, cfgfile))
01099         return ret;
01100     /* OBSOLETE */
01101     if (ret = check_int_method(s, "INV_FVALID", &dd_p->inv_fvalid, cfgfile))
01102         return ret;
01103     if (ret = check_int_method(s, "TRIG_PULSE", &dd_p->trig_pulse, cfgfile))
01104         return ret;
01105     if (ret = check_int_method(s, "DIS_SHUTTER", &dd_p->dis_shutter, cfgfile))
01106         return ret;
01107 
01108     if (ret = check_int_method(s, "image_offset", &dd_p->image_offset, cfgfile))
01109         return ret;
01110 
01111     if (ret = check_int_method(s, "markras", &dd_p->markras, cfgfile))
01112         return ret;
01113     if (ret = check_int_method(s, "markbin", &dd_p->markbin, cfgfile))
01114         return ret;
01115     if (ret = check_int_method(s, "markrx", &dd_p->markrasx, cfgfile))
01116         return ret;
01117     if (ret = check_int_method(s, "markry", &dd_p->markrasy, cfgfile))
01118         return ret;
01119     if (ret = check_int_method(s, "xilinx_rev", &dd_p->xilinx_rev, cfgfile))
01120         return ret;
01121     if (ret = check_int_method(s, "timeout_multiplier", &dd_p->timeout_multiplier, cfgfile))
01122         return ret;
01123     if (ret = check_int_method(s, "user_timeout", &dd_p->user_timeout, cfgfile))
01124         return ret;
01125     if (ret = check_int_method(s, "timeout", &dd_p->timeout, cfgfile))
01126         return ret;
01127     if (ret = check_int_method(s, "linerate", &dd_p->linerate, cfgfile))
01128         return ret;
01129     if (ret = check_int_method(s, "header_size", &dd_p->header_size, cfgfile))
01130         return ret;
01131     if (ret = check_int_method(s, "photo_trig", &dd_p->photo_trig, cfgfile))
01132         return ret;
01133     if (ret = check_int_method(s, "fieldid_trig", &dd_p->fieldid_trig, cfgfile))
01134         return ret;
01135     if (ret = check_int_method(s, "slaved_trig", &tr, cfgfile))
01136     {
01137         dd_p->photo_trig = 1;
01138         dd_p->fieldid_trig = 1;
01139         return ret;
01140     }
01141     if (ret = check_int_method(s, "acquire_mult", &dd_p->acquire_mult, cfgfile))
01142         return ret;
01143     if (ret = check_int_method(s, "sim_enable", &dd_p->sim_enable, cfgfile))
01144         return ret;
01145     if (ret = check_int_method(s, "xilinx_clk", &dd_p->xilinx_clk, cfgfile))
01146         return ret;
01147     if (ret = check_int_method(s, "serial_timeout", &dd_p->serial_timeout, cfgfile))
01148         return ret;
01149     if (ret = check_int_method(s, "strobe_count", &dd_p->strobe_count, cfgfile))
01150         return ret;
01151     if (ret = check_int_method(s, "strobe_interval", &dd_p->strobe_interval, cfgfile))
01152         return ret;
01153     if (ret = check_int_method(s, "mc4", &dd_p->mc4, cfgfile))
01154         return ret;
01155     if (ret = check_int_method(s, "expexsync", &dd_p->mc4, cfgfile))
01156         return ret;
01157     if (ret = check_int_method(s, "sel_mc4", &dd_p->sel_mc4, cfgfile))
01158         return ret;
01159     if (ret = check_int_method(s, "dbl_trig", &dd_p->dbl_trig, cfgfile))
01160         return ret;
01161     if (ret = check_int_method(s, "pulnix", &dd_p->pulnix, cfgfile))
01162         return ret;
01163     if (ret = check_int_method(s, "interlace", &dd_p->interlace, cfgfile))
01164         return ret;
01165     if (ret = check_int_method(s, "image_offset", &dd_p->image_offset, cfgfile))
01166         return ret;
01167     if (ret = check_int_method(s, "hskip", &dd_p->hskip, cfgfile))
01168         return ret;
01169     if (ret = check_int_method(s, "hactv", &dd_p->hactv, cfgfile))
01170         return ret;
01171     if (ret = check_int_method(s, "vskip", &dd_p->vskip, cfgfile))
01172         return ret;
01173     if (ret = check_int_method(s, "vactv", &dd_p->vactv, cfgfile))
01174         return ret;
01175     if (ret = check_int_method(s, "cameralink", &dd_p->cameralink, cfgfile))
01176         return ret;
01177     if (ret = check_int_method(s, "start_delay", &dd_p->start_delay, cfgfile))
01178         return ret;
01179     if (ret = check_int_method(s, "pclock_speed", &dd_p->pclock_speed, cfgfile))
01180         return ret;
01181     if (ret = check_int_method(s, "frame_period", &dd_p->frame_period, cfgfile))
01182         return ret;
01183 
01184     /* kbs stuff */
01185     if (ret = check_int_method(s, "kbs_red_row_first", &dd_p->kbs_red_row_first, cfgfile))
01186         return ret;
01187     if (ret = check_int_method(s, "kbs_green_pixel_first", &dd_p->kbs_green_pixel_first, cfgfile))
01188         return ret;
01189 
01190     if (ret = check_int_method(s, "force_single", &dd_p->force_single, cfgfile))
01191         return ret;
01192     if (ret = check_int_method(s, "pause_for_serial", &dd_p->pause_for_serial, cfgfile))
01193         return ret;
01194     if (ret = check_int_method(s, "variable_size", &dd_p->variable_size, cfgfile))
01195         return ret;
01196     if (ret = check_int_method(s, "header_dma", &dd_p->header_dma, cfgfile))
01197         return ret;
01198     if (ret = check_int_method(s, "header_offset", &dd_p->header_offset, cfgfile))
01199         return ret;
01200 
01201     if (ret = check_int_method(s, "htaps", &dd_p->htaps, cfgfile))
01202         return ret;
01203     if (ret = check_int_method(s, "vtaps", &dd_p->vtaps, cfgfile))
01204         return ret;
01205 
01206     if (ret = check_int_method(s, "serial_init_delay", &dd_p->serial_init_delay, cfgfile))
01207         return ret;
01208 
01209     if (ret = check_int_method(s, "mode16", &dd_p->mode16, cfgfile))
01210         return ret;
01211 
01212     /*
01213      * hexidecimal methods
01214      */
01215     if (ret = check_hex_method(s, "DIRECTION", (u_int *) &dd_p->direction, cfgfile))
01216         return ret;
01217     if (ret = check_hex_method(s, "MODE_CNTL_NORM", (u_int *) &dd_p->mode_cntl_norm, cfgfile))
01218         return ret;
01219 
01220     if (ret = check_hex_method(s, "CL_DATA_PATH_NORM", (u_int *) &dd_p->cl_data_path, cfgfile))
01221     {
01222         dd_p->cameralink = 1;
01223         return ret;
01224     }
01225     if (ret = check_hex_method(s, "CL_CFG_NORM", (u_int *) &dd_p->cl_cfg, cfgfile))
01226     {
01227         dd_p->cameralink = 1;
01228         return ret;
01229     }
01230     if (ret = check_hex_method(s, "CL_CFG2_NORM", (u_int *) &dd_p->cl_cfg2, cfgfile))
01231     {
01232         dd_p->cameralink = 1;
01233         return ret;
01234     }
01235     if (ret = check_hex_method(s, "CL_HMAX_NORM", (u_int *) &dd_p->cl_hmax, cfgfile))
01236     {
01237         dd_p->cameralink = 1;
01238         return ret;
01239     }
01240     
01241     if (ret = check_hex_method(s, "trigdiv", (u_int *) &dd_p->trigdiv, cfgfile))
01242         return ret;
01243     if (ret = check_hex_method(s, "maxdmasize", (u_int *) &dd_p->maxdmasize, cfgfile))
01244         return ret;
01245     if (ret = check_hex_method(s, "util2", (u_int *) &dd_p->util2, cfgfile))
01246         return ret;
01247     if (ret = check_hex_method(s, "shift", (u_int *) &dd_p->shift, cfgfile))
01248         return ret;
01249     if (ret = check_hex_method(s, "UTIL24", (u_int *) &dd_p->shift, cfgfile))
01250         return ret;
01251     if (ret = check_hex_method(s, "mask", (u_int *) &dd_p->mask, cfgfile))
01252         return ret;
01253    
01254 
01255     if (ret = check_hex_method(s, "serial_waitc", &dd_p->serial_waitc, cfgfile))
01256         return ret;
01257 
01258     /* alias */
01259     if (ret = check_hex_method(s, "serial_waitchar", &dd_p->serial_waitc, cfgfile))
01260         return ret;
01261 
01262     /*
01263      * path methods (no quotes or spaces)
01264      */
01265     if (ret = check_path_method(s, "rbtfile", dd_p->rbtfile, cfgfile))
01266         return ret;
01267 
01268     /*
01269      * if (ret = check_path_method(s, "foi_rbtfile", dd_p->foi_rbtfile,
01270      * cfgfile)) return ret;
01271      */
01272 
01273     if (ret = check_path_method(s, "interlace_module", dd_p->interlace_module, cfgfile))
01274         {
01275                 dd_p->swinterlace = PDV_INTLV_USER;
01276                 return ret;
01277         }
01278     if (ret = check_path_method(s, "foi_remote_rbtfile", dd_p->foi_remote_rbtfile, cfgfile))
01279         return ret;
01280 
01281       /*
01282      * NOTE: to conserve space, we overload kbs_ccm_file with some
01283      * other non-conflicting #defined names
01284      */
01285 
01286     if (ret = check_path_method(s, "camera_download_file", dd_p->camera_download_file, cfgfile))
01287         return ret;
01288 
01289     if (ret = check_path_method(s, "camera_command_file", dd_p->camera_command_file, cfgfile))
01290         return ret;
01291 
01292      /*
01293      * serial_init_method (quoted, colon sep. and terminated, w/spaces)
01294      */
01295     if (ret = check_serial_init_method(s, "serial_init", tmpstr, cfgfile))
01296     {
01297         if (strlen(tmpstr) + strlen(dd_p->serial_init) > 255)
01298         {
01299             edt_msg(DEBUG2, "Error in parsing %s.\nSerial initialization exceeds max of %s chars\n", s, MAXINIT);
01300             dd_p->serial_init[0] = 0;
01301             return 0;
01302         }
01303         strcat(dd_p->serial_init, tmpstr);
01304         return ret;
01305     }
01306     if (ret = check_serial_init_method(s, "foi_init", dd_p->foi_init, cfgfile))
01307         return ret;
01308     if (ret = check_serial_init_method(s, "xilinx_init", dd_p->xilinx_init, cfgfile))
01309         return ret;
01310 
01311     if (ret = check_str_method(s, "serial_init_hex", dd_p->serial_init, MAXINIT, cfgfile))
01312     {
01313         dd_p->serial_binit = dd_p->serial_init; 
01314         dd_p->serial_format = SERIAL_BINARY;
01315         return ret;
01316     }
01317 
01318     /* old label, now using serial_init_hex */
01319     if (ret = check_str_method(s, "serial_binit", dd_p->serial_init, MAXINIT, cfgfile))
01320     {
01321         dd_p->serial_binit = dd_p->serial_init; 
01322         dd_p->serial_format = SERIAL_BINARY;
01323         return ret;
01324     }
01325     if (ret = check_str_method(s, "serial_init_baslerf", dd_p->serial_init, MAXINIT, cfgfile))
01326     {
01327         dd_p->serial_format = SERIAL_BASLER_FRAMING;
01328         return ret;
01329     }
01330     if (ret = check_str_method(s, "serial_init_duncanf", dd_p->serial_init, MAXINIT, cfgfile))
01331     {
01332         dd_p->serial_format = SERIAL_DUNCAN_FRAMING;
01333         return ret;
01334     }
01335     if (ret = check_str_method(s, "cameratype", dd_p->cameratype, CAMNAMELEN, cfgfile))
01336         return ret;
01337     if (ret = check_str_method(s, "camera_class", dd_p->camera_class, CAMCLASSLEN, cfgfile))
01338         return ret;
01339     if (ret = check_str_method(s, "camera_model", dd_p->camera_model, MAXSER, cfgfile))
01340         return ret;
01341     if (ret = check_str_method(s, "camera_info", dd_p->camera_info, MAXSER*2, cfgfile))
01342         return ret;
01343     if (ret = check_str_method(s, "serial_gain", dd_p->serial_gain, MAXSER, cfgfile))
01344         return ret;
01345     if (ret = check_str_method(s, "serial_offset", dd_p->serial_offset, MAXSER, cfgfile))
01346         return ret;
01347     if (ret = check_str_method(s, "serial_exposure", dd_p->serial_exposure, MAXSER, cfgfile))
01348         return ret;
01349     if (ret = check_str_method(s, "serial_prefix", dd_p->serial_prefix, MAXSER, cfgfile))
01350         return ret;
01351     if (ret = check_str_method(s, "serial_binning", dd_p->serial_binning, MAXSER, cfgfile))
01352         return ret;
01353     if (ret = check_str_method(s, "serial_term", dd_p->serial_term, MAXSER, cfgfile))
01354         return ret;
01355     if (ret = check_str_method(s, "serial_response", dd_p->serial_response, MAXSER, cfgfile))
01356         return ret;
01357     if (ret = check_str_method(s, "serial_trigger", dd_p->serial_trigger, MAXSER, cfgfile))
01358         return ret;
01359 
01360     {
01361         char line_interleave[81];
01362         if (ret = check_str_method(s, "line_interleave", line_interleave, 80, cfgfile))
01363         {
01364         /* parse line */
01365             int i;
01366             char *tok = strtok(line_interleave, " \t");
01367             dd_p->n_intlv_taps = atoi(tok);
01368             for (i=0;i<dd_p->n_intlv_taps;i++)
01369             {
01370                 char *tok1 = strtok(NULL," \t");
01371                 char *tok2 = strtok(NULL," \t");
01372 
01373                 if (tok1 == NULL || tok2 == NULL)
01374                 {
01375                     edt_msg(DEBUG2,
01376                         "Error in parsing interleave in %s.\nNot Enough arguments for %d channels\n",
01377                             cfgfile, dd_p->n_intlv_taps);
01378                     return -1;
01379                 }
01380                 else
01381                 {
01382                     dd_p->intlv_taps[i].startx = atoi(tok1);
01383                     dd_p->intlv_taps[i].dx = atoi(tok2);
01384                 }
01385             }
01386 
01387             dd_p->swinterlace = PDV_LINE_INTLV;
01388 
01389             return ret;
01390         }
01391     }
01392 
01393     return 0;
01394 }
01395 
01396 int
01397 check_cls_param(char *s, PdvDependent *dd_p, char *cfgfile)
01398 
01399 {
01400     int ret;
01401 
01402     int val;
01403 
01404     if (ret = check_int_method(s, "cls_linescan", &val, cfgfile))
01405     {
01406         dd_p->cls.flags.Cfg.linescan = val;
01407         return ret;
01408     }
01409     if (ret = check_int_method(s, "cls_lvcont", &val, cfgfile))
01410     {
01411         dd_p->cls.flags.Cfg.lvcont = val;
01412         return ret;
01413     }
01414     if (ret = check_int_method(s, "cls_rven", &val, cfgfile))
01415     {
01416         dd_p->cls.flags.Cfg.rven = val;
01417         return ret;
01418     }
01419     if (ret = check_int_method(s, "cls_uartloop", &val, cfgfile))
01420     {
01421         dd_p->cls.flags.Cfg.uartloop = val;
01422         return ret;
01423     }
01424     if (ret = check_int_method(s, "cls_smallok", &val, cfgfile))
01425     {
01426         dd_p->cls.flags.Cfg.smallok = val;
01427         return ret;
01428     }
01429     if (ret = check_int_method(s, "cls_intlven", &val, cfgfile))
01430     {
01431         dd_p->cls.flags.Cfg.intlven = val;
01432         return ret;
01433     }
01434     if (ret = check_int_method(s, "cls_firstfc", &val, cfgfile))
01435     {
01436         dd_p->cls.flags.Cfg.firstfc = val;
01437         return ret;
01438     }
01439     if (ret = check_int_method(s, "cls_datacnt", &val, cfgfile))
01440     {
01441         dd_p->cls.flags.Cfg.datacnt = val;
01442         return ret;
01443     }
01444 
01445     if (ret = check_int_method(s, "cls_dvskip", &val, cfgfile))
01446     {
01447         dd_p->cls.flags.Cfg.dvskip = val;
01448         return ret;
01449     }
01450 
01451     if (ret = check_int_method(s, "cls_dvmode", &val, cfgfile))
01452     {
01453         dd_p->cls.flags.Cfg.dvmode = val;
01454         return ret;
01455     }
01456    if (ret = check_int_method(s, "cls_led", &val, cfgfile))
01457     {
01458         dd_p->cls.flags.Cfg.led = val;
01459         return ret;
01460     }
01461    if (ret = check_int_method(s, "cls_trigsrc", &val, cfgfile))
01462     {
01463         dd_p->cls.flags.Cfg.trigsrc = val;
01464         return ret;
01465     }
01466    if (ret = check_int_method(s, "cls_trigpol", &val, cfgfile))
01467     {
01468         dd_p->cls.flags.Cfg.trigpol = val;
01469         return ret;
01470     }
01471    if (ret = check_int_method(s, "cls_trigframe", &val, cfgfile))
01472     {
01473         dd_p->cls.flags.Cfg.trigframe = val;
01474         return ret;
01475     }
01476 
01477    if (ret = check_int_method(s, "cls_trigline", (int *) &val, cfgfile))
01478     {
01479         dd_p->cls.flags.Cfg.trigline = val;
01480         return ret;
01481     }
01482 
01483     if (ret = check_hex_method(s, "cls_filla", (u_int *)&val, cfgfile))
01484     {
01485         dd_p->cls.FillA = val;
01486         return ret;
01487     }   
01488 
01489     if (ret = check_hex_method(s, "cls_fillb", (u_int *)&val, cfgfile))
01490     {
01491         dd_p->cls.FillB = val;
01492         return ret;
01493     }
01494 
01495     if (ret = check_ushort_method(s, "cls_hgap", &dd_p->cls.hblank, cfgfile))
01496         return ret;
01497     if (ret = check_ushort_method(s, "cls_hcntmax", 
01498             &dd_p->cls.Hcntmax, cfgfile))
01499         return ret;
01500 
01501     if (ret = check_ulong_method(s, "cls_vgap", (u_long *)&dd_p->cls.vblank, cfgfile))
01502         return ret;
01503     if (ret = check_ulong_method(s, "cls_vcntmax", (u_long *)&dd_p->cls.Vcntmax, cfgfile))
01504         return ret;
01505 
01506     if (ret = check_ushort_method(s, "cls_hfvstart", &dd_p->cls.Hfvstart, cfgfile))
01507         return ret;
01508     if (ret = check_ushort_method(s, "cls_hfvend", &dd_p->cls.Hfvend, cfgfile))
01509         return ret;
01510  
01511     if (ret = check_ushort_method(s, "cls_hlvstart", &dd_p->cls.Hlvstart, cfgfile))
01512         return ret;
01513     if (ret = check_ushort_method(s, "cls_hlvend", &dd_p->cls.Hlvend, cfgfile))
01514         return ret;
01515   
01516     if (ret = check_ushort_method(s, "cls_hrvstart", &dd_p->cls.Hrvstart, cfgfile))
01517         return ret;
01518     if (ret = check_ushort_method(s, "cls_hrvend", &dd_p->cls.Hrvend, cfgfile))
01519         return ret;
01520 
01521     if (ret = check_float_method(s, "cls_pixel_clock", &dd_p->cls.pixel_clock, cfgfile))
01522         return ret;
01523   
01524 
01525     return 0;
01526 }
01527 
01528 check_xilinx_param(char *s, Dependent * dd_p, char *cfgfile)
01529 {
01530     int     index = 0;
01531     u_int   reg = 0;
01532     u_int   value = 0;
01533     char    hexstr[10];
01534 
01535     if (strncmp(s, "xregwrite_", 10) == 0)
01536     {
01537         if (sscanf(s, "xregwrite_%d: %s", &reg, hexstr) != 2)
01538         {
01539             edt_msg(DEBUG2,
01540                 "Error in parsing %s.  Expected:\n\n\txregwrite_<reg>: <hex_parameter>\n", cfgfile);
01541             edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", s);
01542             return 0;
01543         }
01544 
01545         if (reg > 0xfe)
01546         {
01547             edt_msg(DEBUG2,
01548             "Error in parsing %s.  Address %d is out of range for xilinx_%d.\n",
01549                         cfgfile, reg, reg);
01550             edt_msg(DEBUG2, "Legal values are 0 through 254\n");
01551             return -1;
01552         }
01553 
01554         value = strtol(hexstr, NULL, 16);
01555 
01556         if (value > 0xff)
01557         {
01558             edt_msg(DEBUG2,
01559                     "Error in parsing %s.  Value %x is out of range for xilinx_%d.\n",
01560                     cfgfile, value, reg);
01561             edt_msg(DEBUG2, "Legal values are 0 through ff\n");
01562             return -1;
01563         }
01564 
01565         /*
01566          * xilinx_flag used to just be just a flag 0 or 1, now it's the actual
01567          * address of the register, 0-254
01568          */
01569         while ((index < 32) && dd_p->xilinx_flag[index] != 0xff)
01570             ++index;
01571 
01572         if (index >= 32)
01573             printf("Error! Too_many xregwrite_ directives (max 32)\n");
01574         else
01575         {
01576             dd_p->xilinx_flag[index] = reg;
01577             dd_p->xilinx_value[index] = value;
01578         }
01579         return 1;
01580     }
01581     else return 0;
01582 
01583 }
01584 
01585 check_method_param(char *s, Dependent * dd_p, Edtinfo * ei_p, char *cfgfile)
01586 {
01587     int     ret = 0;
01588     int     method_number;
01589     char    method_type[64], method_arg[128];
01590     int     n;
01591 
01592     if (strncmp(s, "method_", 7) == 0)
01593     {
01594         if ((n = sscanf(s, "%s %s", method_type, method_arg)) != 2)
01595         {
01596             edt_msg(DEBUG2,
01597             "Error in parsing %s.\nExpected:\n\n\t%s: <method>: <parameter>\n",
01598                         cfgfile, method_type);
01599             edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", s);
01600             return -1;
01601         }
01602         method_type[strlen(method_type) - 1] = '\0';    /* strip off ':' */
01603 
01604         if (translate_method_arg(method_arg, &method_number))
01605         {
01606             ret = set_method(dd_p, ei_p, method_type, method_number);
01607         }
01608         else
01609             ret = 0;
01610     }
01611     return ret;
01612 }
01613 
01614 int
01615 printcfg(Dependent * dd_p)
01616 {
01617     edt_msg(DEBUG2, "\nDependent Struct -- %d bytes (max %d)\n", sizeof(dd_p));
01618     edt_msg(DEBUG2, "-------------------------------------------\n");
01619     edt_msg(DEBUG2, "cameratype '%s'\n", dd_p->cameratype);
01620     edt_msg(DEBUG2, "rbtfile '%s'\n", dd_p->rbtfile);
01621     edt_msg(DEBUG2, "cfgname '%s'\n", dd_p->cfgname);
01622     edt_msg(DEBUG2, "foi_remote_rbtfile '%s'\n", dd_p->foi_remote_rbtfile);
01623     edt_msg(DEBUG2, "interlace_module '%s'\n", dd_p->interlace_module);
01624     edt_msg(DEBUG2, "width %d\n", dd_p->width);
01625     edt_msg(DEBUG2, "height %d\n", dd_p->height);
01626     edt_msg(DEBUG2, "depth %d\n", dd_p->depth);
01627     edt_msg(DEBUG2, "extdepth %d\n", dd_p->extdepth);
01628     edt_msg(DEBUG2, "slop %d\n", dd_p->slop);
01629     edt_msg(DEBUG2, "image_offset %d\n", dd_p->image_offset);
01630     edt_msg(DEBUG2, "interlace %d\n", dd_p->interlace);
01631     edt_msg(DEBUG2, "swinterlace %d\n", dd_p->swinterlace);
01632     edt_msg(DEBUG2, "default_shutter_speed %d\n", dd_p->default_shutter_speed);
01633     edt_msg(DEBUG2, "shutter_speed_frontp %d\n", dd_p->shutter_speed_frontp);
01634     edt_msg(DEBUG2, "shutter_speed_min %d\n", dd_p->shutter_speed_min);
01635     edt_msg(DEBUG2, "shutter_speed_max %d\n", dd_p->shutter_speed_max);
01636     edt_msg(DEBUG2, "shutter_speed %d\n", dd_p->shutter_speed);
01637     edt_msg(DEBUG2, "default_aperture %d\n", dd_p->default_aperture);
01638     edt_msg(DEBUG2, "aperture_min %d\n", dd_p->aperture_min);
01639     edt_msg(DEBUG2, "aperture_max %d\n", dd_p->aperture_max);
01640     edt_msg(DEBUG2, "aperture %d\n", dd_p->aperture);
01641     edt_msg(DEBUG2, "default_gain %d\n", dd_p->default_gain);
01642     edt_msg(DEBUG2, "gain_frontp %d\n", dd_p->gain_frontp);
01643     edt_msg(DEBUG2, "gain_min %d\n", dd_p->gain_min);
01644     edt_msg(DEBUG2, "gain_max %d\n", dd_p->gain_max);
01645     edt_msg(DEBUG2, "default_offset %d\n", dd_p->default_offset);
01646     edt_msg(DEBUG2, "offset_frontp %d\n", dd_p->offset_frontp);
01647     edt_msg(DEBUG2, "offset_min %d\n", dd_p->offset_min);
01648     edt_msg(DEBUG2, "offset_max %d\n", dd_p->offset_max);
01649     edt_msg(DEBUG2, "continuous %d\n", dd_p->continuous);
01650     edt_msg(DEBUG2, "inv_shutter %d\n", dd_p->inv_shutter);
01651     edt_msg(DEBUG2, "trig_pulse %d\n", dd_p->trig_pulse);
01652     edt_msg(DEBUG2, "dis_shutter %d\n", dd_p->dis_shutter);
01653     edt_msg(DEBUG2, "mode_cntl_norm %04x\n", dd_p->mode_cntl_norm);
01654     edt_msg(DEBUG2, "trigdiv %d\n", dd_p->trigdiv);
01655     edt_msg(DEBUG2, "maxdmasize %d\n", dd_p->maxdmasize);
01656     edt_msg(DEBUG2, "direction %04x\n", dd_p->direction);
01657     edt_msg(DEBUG2, "cameratest %d\n", dd_p->cameratest);
01658     edt_msg(DEBUG2, "genericsim %d\n", dd_p->genericsim);
01659     edt_msg(DEBUG2, "sim_width %d\n", dd_p->sim_width);
01660     edt_msg(DEBUG2, "sim_height %d\n", dd_p->sim_height);
01661     edt_msg(DEBUG2, "line_delay %d\n", dd_p->line_delay);
01662     edt_msg(DEBUG2, "frame_delay %d\n", dd_p->frame_delay);
01663     edt_msg(DEBUG2, "frame_height %d\n", dd_p->frame_height);
01664     edt_msg(DEBUG2, "fv_once %d\n", dd_p->fv_once);
01665     edt_msg(DEBUG2, "enable_dalsa %d\n", dd_p->enable_dalsa);
01666     edt_msg(DEBUG2, "lock_shutter %d\n", dd_p->lock_shutter);
01667     edt_msg(DEBUG2, "camera_shutter_timing %d\n", dd_p->camera_shutter_timing);
01668     edt_msg(DEBUG2, "camera_continuous %d\n", dd_p->camera_continuous);
01669     edt_msg(DEBUG2, "camera_binning %d\n", dd_p->camera_binning);
01670     edt_msg(DEBUG2, "camera_data_rate %d\n", dd_p->camera_data_rate);
01671     edt_msg(DEBUG2, "camera_download %d\n", dd_p->camera_download);
01672     edt_msg(DEBUG2, "get_gain %d\n", dd_p->get_gain);
01673     edt_msg(DEBUG2, "get_offset %d\n", dd_p->get_offset);
01674     edt_msg(DEBUG2, "set_gain %d\n", dd_p->set_gain);
01675     edt_msg(DEBUG2, "set_offset %d\n", dd_p->set_offset);
01676     edt_msg(DEBUG2, "first_open %d\n", dd_p->first_open);
01677     edt_msg(DEBUG2, "last_close %d\n", dd_p->last_close);
01678     edt_msg(DEBUG2, "image_depth %d\n", dd_p->image_depth);
01679     edt_msg(DEBUG2, "remote_interface %d\n", dd_p->remote_interface);
01680     edt_msg(DEBUG2, "interlace_offset %d\n", dd_p->interlace_offset);
01681     edt_msg(DEBUG2, "serial_init %s", dd_p->serial_init);
01682     edt_msg(DEBUG2, "serial_exposure %s", dd_p->serial_exposure);
01683     edt_msg(DEBUG2, "serial_gain '%s'", dd_p->serial_gain);
01684     edt_msg(DEBUG2, "serial_offset '%s'x'\n", dd_p->serial_offset);
01685     edt_msg(DEBUG2, "serial_prefix %s'x\n", dd_p->serial_prefix);
01686     edt_msg(DEBUG2, "serial_term %s'x\n", dd_p->serial_term);
01687     edt_msg(DEBUG2, "timeout_multiplier %d\n", dd_p->timeout_multiplier);
01688     edt_msg(DEBUG2, "datapath_reg %04x\n", dd_p->datapath_reg);
01689     edt_msg(DEBUG2, "config_reg %04x\n", dd_p->config_reg);
01690     edt_msg(DEBUG2, "pdv_type %d\n", dd_p->pdv_type);
01691     edt_msg(DEBUG2, "markras %04x\n", dd_p->markras);
01692     edt_msg(DEBUG2, "markrasx %04x\n", dd_p->markrasx);
01693     edt_msg(DEBUG2, "markrasy %04x\n", dd_p->markrasy);
01694     edt_msg(DEBUG2, "markbin %04x\n", dd_p->markbin);
01695     edt_msg(DEBUG2, "disable_mdout %d\n", dd_p->disable_mdout);
01696     return (sizeof(Dependent));
01697 }
01698 
01699 
01700 void
01701 strip_ctrlm(char *s)
01702 {
01703     if (s)
01704         if (s[strlen(s) - 1] == '\r')
01705             s[strlen(s) - 1] = '\0';
01706 }
01707 
01708 void
01709 strip_extra_whitespace(char *s)
01710 {
01711     unsigned int i, j=0;
01712     int got_colon = 0;
01713     char tmpstr[256];
01714 
01715     for (i=0; i<strlen(s); i++)
01716     {
01717         if (s[i] == ':')
01718             got_colon = 1;
01719         if (got_colon)
01720             tmpstr[j++] = s[i];
01721         else if ((s[i] != ' ') && (s[i] != '    '))
01722             tmpstr[j++] = s[i];
01723         /* else skip whitespace */
01724     }
01725     tmpstr[j] = '\0';
01726     strcpy(s, tmpstr);
01727 }
01728 
01729 int
01730 resolve_cameratype(Dependent *dd_p)
01731 {
01732     char tmpstr[256];
01733 
01734     if (!(*dd_p->cameratype))
01735     {
01736         sprintf(dd_p->cameratype, "%s%s%s%s%s", dd_p->camera_class,
01737                             *dd_p->camera_model? " ":"", dd_p->camera_model,
01738                             *dd_p->camera_info? " ":"", dd_p->camera_info);
01739     }
01740 
01741     /*
01742      * make sure class (manufacturer)) isn't duplicated
01743      */
01744     if ((*dd_p->cameratype && *dd_p->camera_class))
01745     {
01746         if (strncmp(dd_p->camera_class, dd_p->cameratype,
01747                                         strlen(dd_p->camera_class)) != 0)       
01748         {
01749             sprintf(tmpstr, "%s %s", dd_p->camera_class, dd_p->cameratype);
01750             strcpy(dd_p->cameratype, tmpstr);
01751         }
01752     }
01753 
01754     if (*dd_p->cameratype)
01755         return 1;
01756     return 0;
01757 }

Generated on Mon May 12 16:38:58 2008 by  doxygen 1.5.1