00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00140
00141
00142 #define MAX_KEYMAPS 10
00143 #define MAX_KEYS 256
00144
00145 #define FSN_CAM_ID_FIXED 50630
00146 #define FSN_HSHIEXP_FIXED 163852
00147 #define FSN_TAI_FIXED 1000000
00148
00149
00150 #define TABLE_PATH "proj/lev0/apps/data/"
00151
00152
00153 #define UPDATE_CONFIG_PROG "proj/lev0/scripts/hmi_ground/set_config_by_time.csh"
00154
00155
00156 #define CONFIG_SERIES "hmi_ground.lev0_config"
00157
00158
00159 #include "jsoc_main.h"
00160 #include "drms.h"
00161 #include "drms_names.h"
00162
00163
00164
00165 #include "dr.h"
00166
00167
00168 #include <string.h>
00169 #include <stdlib.h>
00170
00171 #define NOT_SPECIFIED "***Not Specified***"
00172 #define DIE(msg) {fprintf(stderr,"$$$$ %s: %s\n",module_name,msg); return 1;}
00173
00174
00175
00176 ModuleArgs_t module_args[] =
00177 {
00178 {ARG_STRING, "in", NOT_SPECIFIED, "Path to DSDS hmi_ground lev0 file"},
00179 {ARG_STRING, "out", NOT_SPECIFIED, "drms series for lev0 data"},
00180 {ARG_STRING, "fsn_key", "HSQFGSN", "Filtergram number keyword name"},
00181 {ARG_STRING, "time_key", "HOBITSEC", "Filtergram time keyword name"},
00182 {ARG_STRING, "t_obs", NOT_SPECIFIED, "Filtergram time override"},
00183 {ARG_STRING, "keymap", NOT_SPECIFIED, "Keyword mapping table"},
00184 {ARG_STRING, "dsds", NOT_SPECIFIED, "DSDS source dataset name"},
00185 {ARG_FLAG, "r", "0", "RAL EGSE data expected"},
00186 {ARG_FLAG, "R", "0", "Re-ingest from DRMS lev0 file"},
00187 {ARG_FLAG, "h", "0", "Print usage message and quit"},
00188 {ARG_FLAG, "v", "0", "verbose flag"},
00189 {ARG_END}
00190 };
00191
00192 char *module_name = "import_egse_lev0";
00193
00194
00195
00196
00197 int verbose = 0;
00198 int nice_intro(int help)
00199 {
00200 int usage = cmdparams_get_int(&cmdparams, "h", NULL) != 0;
00201 verbose = cmdparams_get_int(&cmdparams, "v", NULL) != 0;
00202 if (usage || help)
00203 {
00204 printf("import_egse_lev0 in='fits file' out='jsoc series' {keymap='keymap file'} {dsds='dsds dataset'} {-h} {-r} {-v} "
00205 " -h: print this message\n"
00206 " -r: RAL data input, no external config info needed\n"
00207 " -R: Re-ingest mode, fixes HCAMID back to egse version\n"
00208 " -v: verbose\n"
00209 "keymap=<key map file> - optional\n"
00210 "t_obs=<time over-ride value\n"
00211 "dsds=<dsds dataset name for source file\n"
00212 "in=<lev0 fits file> - required\n"
00213 "out=<drms lev0 series> - required\n");
00214 return(1);
00215 }
00216 return(0);
00217 }
00218
00219
00220
00221 TIME SDO_to_DRMS_time(int sdo_s, int sdo_ss);
00222 int set_mech_values(DRMS_Record_t *rec, DR *dr, int fsn);
00223 int init_keymaps(char *keymaps[MAX_KEYS][MAX_KEYMAPS], int *nkeys, char *key_map_file);
00224 void sprint_time_ISO (char *tstring, TIME t);
00225
00226
00227
00228 int DoIt(void)
00229 {
00230 int status = 0;
00231 int RALmode = 0;
00232 int fsn;
00233 TIME t_obs, t_obs_force;
00234 char *t_obs_override;
00235 char *in, *out;
00236 char *in_filename;
00237 char tmpfile[1024];
00238 char tmpdir[1024];
00239 char *dsdsname;
00240 char *keymap;
00241 DRMS_Record_t *rec;
00242 DRMS_RecordSet_t *rs;
00243 HIterator_t key_hit;
00244 DRMS_Keyword_t *key;
00245 DR *lev0, *tmpdr;
00246 char *keymaps[MAX_KEYS][MAX_KEYMAPS];
00247 int keytarg, keytargs, newkey;
00248 ATTRIBUTES *fits_attr;
00249 TIME TIME2006Jan = sscan_time("2006.01.01_00:00:00");
00250 int re_ingest_from_drms;
00251
00252 if (nice_intro(0))
00253 return(0);
00254
00255 printf("Import ground test lev0 data:\n");
00256
00257
00258 in = strdup(cmdparams_get_str(&cmdparams, "in", NULL));
00259 if (strcmp(in,NOT_SPECIFIED)==0)
00260 DIE("in argument is required");
00261 printf(" in=%s\n", in);
00262
00263 out = strdup(cmdparams_get_str(&cmdparams, "out", NULL));
00264 if (strcmp(out,NOT_SPECIFIED)==0)
00265 DIE("out argument is required");
00266 printf(" out=%s\n", out);
00267
00268 dsdsname = cmdparams_get_str(&cmdparams, "dsds", NULL);
00269 if (strcmp(dsdsname,NOT_SPECIFIED)==0)
00270 dsdsname = "n.a.";
00271 printf(" dsds=%s\n", dsdsname);
00272
00273 keymap = cmdparams_get_str(&cmdparams, "keymap", NULL);
00274 if (strcmp(keymap,NOT_SPECIFIED)==0)
00275 printf(" keymap not used\n");
00276 else
00277 printf(" keymap=%s\n", keymap);
00278 if (init_keymaps(keymaps, &keytargs, keymap))
00279 DIE("Key Mapping File not found");
00280 printf(" keymap count=%d\n",keytargs);
00281
00282 RALmode = cmdparams_get_int(&cmdparams, "r", NULL);
00283 printf(" %s\n", (RALmode ? "RAL mode" : "DCHRI mode"));
00284
00285 re_ingest_from_drms = cmdparams_get_int(&cmdparams, "R", NULL) != 0;
00286 if (re_ingest_from_drms)
00287 printf(" Re-ingest from previous DRMS lev0 file.\n");
00288
00289 t_obs_override = cmdparams_get_str(&cmdparams, "t_obs", NULL);
00290 if (strcmp(t_obs_override,NOT_SPECIFIED)==0)
00291 t_obs_force = 0.0;
00292 else
00293 {
00294 char t_obs_str[1024];
00295 t_obs_force = sscan_time(t_obs_override);
00296 sprint_ut(t_obs_str, t_obs_force);
00297 printf(" ** WARNING ** T_OBS over-ride from command line is %s\n", t_obs_str);
00298 }
00299
00300
00301
00302 rs = drms_create_records(drms_env, 1, out, DRMS_PERMANENT, &status);
00303 if (status)
00304 DIE("cant create records in output series");
00305 rec = rs->records[0];
00306
00307
00308
00309 lev0 = dr_get_fits(in);
00310 if (!lev0)
00311 DIE("Failed to read fits header");
00312 tmpdr = lev0;
00313
00314
00315
00316 drms_setkey_string(rec, "DSDS_SRC", dsdsname);
00317 dr_setkey_str(tmpdr, "DSDS_SRC", dsdsname);
00318 drms_setkey_string(rec, "CONFIG", (RALmode ? "RAL" : "CIF"));
00319 dr_setkey_str(tmpdr, "CONFIG", (RALmode ? "RAL" : "CIF"));
00320
00321
00322
00323 hiter_new(&key_hit, &rec->keywords);
00324 while( (key = (DRMS_Keyword_t *)hiter_getnext(&key_hit)) )
00325 {
00326 char describe[DRMS_MAXCOMMENTLEN];
00327 char *shortname;
00328 char *usename;
00329 char *keyname = key->info->name;
00330 strcpy(describe, key->info->description);
00331 shortname = strtok(describe," \t,:");
00332 if (!shortname)
00333 shortname = keyname;
00334 if (strlen(shortname) > 8)
00335 DIE("shortname too long\n");
00336
00337 if (dr_search_attr(lev0, shortname) != NULL)
00338 {
00339 usename = shortname;
00340
00341 }
00342 else
00343 {
00344 usename = shortname;
00345
00346
00347 for (keytarg = 0; keytarg < keytargs; keytarg++)
00348 {
00349 if (strcmp(shortname, keymaps[keytarg][0]) == 0)
00350 {
00351 int trykey;
00352
00353 for (trykey=1; trykey < MAX_KEYMAPS && keymaps[keytarg][trykey] != NULL; trykey++)
00354 if (fits_attr = dr_search_attr(lev0, keymaps[keytarg][trykey]))
00355 {
00356 usename = keymaps[keytarg][trykey];
00357
00358 break;
00359 }
00360 break;
00361 }
00362 }
00363
00364 }
00365
00366 if (strcmp(keyname, "T_OBS") == 0)
00367 {
00368 char t_obs_str[40];
00369 int t_obs_s;
00370 char *time_key = strdup(cmdparams_get_str(&cmdparams, "time_key", NULL));
00371 if (t_obs_force > 0.0)
00372 t_obs = t_obs_force;
00373 else if (RALmode)
00374 {
00375 char *filename = DR_getkey_str(lev0, "FILENAME");
00376 int y,M,d,h,m,s;
00377 sscanf(filename, "i_%2d%2d%2d_%2d%2d%2d", &y, &M, &d, &h, &m, &s);
00378 sprintf(t_obs_str, "20%02d.%02d.%02d_%02d:%02d:%02d_UTC", y, M, d, h, m, s);
00379 t_obs = sscan_time(t_obs_str);
00380 }
00381 else
00382 {
00383 t_obs_s = dr_getkey_int(lev0, time_key);
00384 if (is_I_MISSING(t_obs_s) || t_obs_s < TIME2006Jan )
00385 {
00386 t_obs_s = dr_getkey_int(lev0, "SHS");
00387 if (is_I_MISSING(t_obs_s))
00388 DIE("Failed to find either time keyword");
00389 }
00390 t_obs = SDO_to_DRMS_time(t_obs_s, 0);
00391 }
00392 drms_setkey_double(rec, "T_OBS", t_obs);
00393 dr_setkey_time(tmpdr, "T_OBS", t_obs);
00394 sprint_ut(t_obs_str, t_obs);
00395 printf(" T_OBS=%s\n", t_obs_str);
00396 }
00397 else if (strcmp(keyname, "FSN")==0)
00398 {
00399 char *fsn_key = strdup(cmdparams_get_str(&cmdparams, "fsn_key", NULL));
00400 fsn = dr_getkey_int(lev0, fsn_key);
00401 if (is_I_MISSING(fsn))
00402 DIE("Failed to find FSN keyword");
00403 drms_setkey_int(rec, "FSN", fsn);
00404 dr_setkey_int(tmpdr, "FSN", fsn);
00405 printf(" FSN=%d\n", fsn);
00406 }
00407 if (strcmp(keyname, "TELEM_T") == 0)
00408
00409 {
00410 int t = dr_getkey_int(lev0, "SHS");
00411 int tf = dr_getkey_int(lev0, "SHSS");
00412 if (!is_I_MISSING(t) && !is_I_MISSING(tf))
00413 {
00414 TIME telem_t = SDO_to_DRMS_time(t, tf);
00415 drms_setkey_double(rec, keyname, telem_t);
00416 dr_setkey_time(tmpdr, shortname, telem_t);
00417 }
00418 }
00419 else if (usename)
00420 {
00421 if (fits_attr = dr_search_attr(lev0, usename))
00422 {
00423 char *fits_val_str = dr_attrvalue_str(fits_attr);
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440 int fixversion = dr_getkey_int(tmpdr, "HVN00F");
00441 int newfixversion = dr_getkey_int(tmpdr, "HVNISP");
00442 if ((newfixversion >= 435 || fixversion >= 435) &&
00443 (strcmp(usename,"HSHMICLB") == 0 ||
00444 strcmp(usename,"HSHMICLM") == 0 ||
00445 strcmp(usename,"HSHMICLT") == 0 ||
00446 strcmp(usename,"HSHMIOPB") == 0 ||
00447 strcmp(usename,"HSHMIOPM") == 0 ||
00448 strcmp(usename,"HSHMIOPT") == 0 ))
00449 {
00450 double dv = atof(fits_val_str);
00451 int iv = 1000*dv;
00452 printf("XXX fix version = %d, in string = %s\n", fixversion, fits_val_str);
00453 printf("XXX iv = %d\n", iv);
00454 drms_setkey_int(rec, keyname, iv);
00455 dr_setkey_int(tmpdr, usename, iv);
00456 }
00457 else
00458
00459 drms_setkey_string(rec, keyname, fits_val_str);
00460 if (strcmp(usename, shortname) != 0)
00461 {
00462 free(fits_attr->name);
00463 fits_attr->name = strdup(shortname);
00464 }
00465 if (RALmode)
00466 {
00467 if (!strcmp(shortname,"HPCUPOLR") ||
00468 !strcmp(shortname,"HPCUPOLM") ||
00469 !strcmp(shortname,"HPCURETR") ||
00470 !strcmp(shortname,"HPCURETM") )
00471 dr_setkey_double(tmpdr, shortname, strtod(fits_val_str, NULL));
00472 }
00473 free(fits_val_str);
00474 }
00475 else
00476 {
00477
00478 fprintf(stderr, " using default value for %s\n", shortname);
00479 dr_setkey_drmstype(tmpdr, shortname, key);
00480 }
00481 }
00482 }
00483
00484
00485 if (!RALmode)
00486 {
00487 char cmdline[1024], t_obs_str[1024];
00488 int status;
00489 char config_ds[1024];
00490 DRMS_Record_t *config_rec;
00491 DRMS_RecordSet_t *config_rs;
00492 HIterator_t config_key_hit;
00493 DRMS_Keyword_t *config_key;
00494
00495 if (fsn < FSN_TAI_FIXED)
00496 {
00497 t_obs += 33.0;
00498 drms_setkey_double(rec, "T_OBS", t_obs);
00499 dr_setkey_time(tmpdr, "T_OBS", t_obs);
00500 sprint_ut(t_obs_str, t_obs);
00501 printf(" CORRECTED T_OBS=%s\n", t_obs_str);
00502 }
00503
00504 sprint_time(t_obs_str, t_obs, "UTC", 0);
00505 sprintf(cmdline, "%s/%s '%s' %d %s", cmdparams_get_str(&cmdparams, "JSOCROOT", NULL),
00506 UPDATE_CONFIG_PROG, t_obs_str, fsn, cmdparams_get_str(&cmdparams, "DRMSSESSION", NULL));
00507 status = system(cmdline);
00508 if (status)
00509 {
00510 fprintf(stderr, "Failed to execute %s\n", cmdline);
00511 DIE("Failed to get config info\n");
00512 }
00513
00514 sprintf(config_ds, "%s[%d]", CONFIG_SERIES, fsn);
00515 config_rs = drms_open_records(drms_env, config_ds, &status);
00516 if (status == 0)
00517 {
00518 if (config_rs->n < 1)
00519 {
00520 fprintf(stderr, "Failed to get config record for fsn '%d'.\n", fsn);
00521 DIE("Quitting now.");
00522 }
00523 config_rec = config_rs->records[0];
00524 hiter_new(&config_key_hit, &config_rec->keywords);
00525 while( (config_key = (DRMS_Keyword_t *)hiter_getnext(&config_key_hit)) )
00526 {
00527 int stat = drms_setkey(rec, config_key->info->name, config_key->info->type, &config_key->value);
00528
00529 dr_setkey_drmstype(tmpdr, config_key->info->name, config_key);
00530 }
00531 drms_close_records(config_rs, DRMS_FREE_RECORD);
00532 }
00533 else
00534 fprintf(stderr,"cant open config records for %s\n",config_ds);
00535
00536
00537 status = set_mech_values(rec, tmpdr, fsn);
00538 if (status)
00539 DIE("Mech table failure");
00540 }
00541
00542
00543 {
00544 char tmpstr[100];
00545 sprint_time_ISO(tmpstr,CURRENT_SYSTEM_TIME);
00546 drms_setkey_string(rec, "DATE", tmpstr);
00547 dr_setkey_str(tmpdr, "DATE", tmpstr);
00548 }
00549
00550
00551 if (in_filename = strrchr(in,'/'))
00552 in_filename++;
00553 else
00554 in_filename = in;
00555 status = dr_write_fits_to_drms_segment(tmpdr, in_filename, rec, 0);
00556 if (status)
00557 DIE("FITS save in segment failure");
00558 dr_free(&lev0);
00559 status = drms_close_records(rs, DRMS_INSERT_RECORD);
00560 if (status)
00561 DIE("close failure");
00562 return 0;
00563 }
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576 TIME SDO_to_DRMS_time(int sdo_s, int sdo_ss)
00577 {
00578 static int firstcall = 1;
00579 static TIME sdo_epoch;
00580 if (firstcall)
00581 {
00582 firstcall = 0;
00583 sdo_epoch = sscan_time("1958.01.01_00:00:00_TAI");
00584 }
00585 return(sdo_epoch + (TIME)sdo_s + ((TIME)sdo_ss)/65536.0);
00586 }
00587
00588
00589
00590 int set_mech_values(DRMS_Record_t *rec, DR *lev0, int fsn)
00591 {
00592 static int called = 0;
00593
00594 #define MAXROWS 10000
00595 static int pol[MAXROWS*4];
00596 static int tuning[MAXROWS*5];
00597 static int focus[MAXROWS*3];
00598 static int expose[MAXROWS*3];
00599
00600 static char *pol_keys[] = {"HPL1POS", "HPL2POS", "HPL3POS"};
00601 static char *pol_longkeys[] = {"HPL1POS", "HPL2POS", "HPL3POS"};
00602 static char *tuning_keys[] = {"HWL1POS", "HWL2POS", "HWL3POS", "HWL4POS"};
00603 static char *tuning_longkeys[] = {"HWL1POS", "HWL2POS", "HWL3POS", "HWL4POS"};
00604 static char *focus_keys[] = {"HCF1POS", "HCF2POS"};
00605 static char *focus_longkeys[] = {"HCF1POS", "HCF2POS"};
00606 static char *expose_keys[] = {"HSHIEXP", "HSHIEXP"};
00607 static char *expose_longkeys[] = {"HMI_FSW_IMG_CMDED_EXPOSURE", "HMI_FSW_IMG_CMDED_EXPOSURE"};
00608
00609 static char *camkey = "HCAMID";
00610 static char *camkey_longname = "HMI_SEQ_ID_EXP_PATH";
00611
00612 typedef struct tabinf
00613 {
00614 char *filename;
00615 char *index;
00616 char **keys;
00617 char **longkeys;
00618 int *table;
00619 int cols;
00620 char *longname;
00621 } TABINFO;
00622 static TABINFO tabinfo[] = {"in_air_cal3.p", "HPLTID", pol_keys, pol_longkeys, pol, 3,"HMI_SEQ_ID_PST",
00623 "in_air_cal3.w", "HWLTID", tuning_keys, tuning_longkeys, tuning, 4,"HMI_SEQ_ID_WLT",
00624 "in_air_cal.c", "HCFTID", focus_keys, focus_longkeys, focus, 2,"HMI_SEQ_ID_FOCUS",
00625 "in_air_cal.e", "HSQEIDX", expose_keys, expose_longkeys, expose, 2,"HMI_SEQ_EXPOSURE_INDX"};
00626 int tab;
00627 int status;
00628 int camera = dr_getkey_int(lev0, camkey);
00629 int re_ingest_from_drms = cmdparams_get_int(&cmdparams, "R", NULL) != 0;
00630
00631 if (camera < 0 || camera > 3)
00632 {
00633 fprintf(stderr,"XX camera=%d outside range, use camera 1 exposures\n",camera);
00634 camera=1;
00635 }
00636
00637 if (re_ingest_from_drms)
00638 {
00639 int exposure = dr_getkey_int(lev0, expose_keys[0]);
00640 if (exposure > 0)
00641 camera += 2;
00642 }
00643
00644 if (!called)
00645 {
00646 called = 1;
00647 for (tab=0; tab<4; tab++)
00648 {
00649 char tablepath[1024];
00650 int idx, *res, val, vals;
00651 FILE *fp;
00652 char line[1024];
00653 strcpy(tablepath, cmdparams_get_str(&cmdparams, "JSOCROOT", NULL));
00654 strcat(tablepath, "/");
00655 strcat(tablepath, TABLE_PATH);
00656 strcat(tablepath, tabinfo[tab].filename);
00657 fp = fopen(tablepath, "r");
00658 if (!fp)
00659 {
00660 fprintf(stderr,"Failed to open mech table %s, die.\n",tablepath);
00661 return(1);
00662 }
00663 res = tabinfo[tab].table;
00664 vals = tabinfo[tab].cols;
00665 for (idx=0; idx<MAXROWS; idx++)
00666 for (val=0; val<vals+1; val++)
00667 res[val + (vals+1)*idx] = -1;
00668 for (idx=0; fgets(line,1024,fp); )
00669 {
00670 if (*line != '#')
00671 {
00672 char *e, *p=line;
00673 int d;
00674 for (val=0; val<vals+1; val++)
00675 {
00676 d = strtod(p, &e);
00677 if (e == p)
00678 break;
00679 else
00680 {
00681 p = e;
00682 res[val + (vals+1)*idx] = d;
00683 }
00684 }
00685 if (res[(vals+1)*idx] >= 0)
00686 idx++;
00687 }
00688 }
00689 fclose(fp);
00690 }
00691 }
00692
00693 for (tab=0; tab<4; tab++)
00694 {
00695 int found_index;
00696 int row, index;
00697 int status;
00698 int val, vals = tabinfo[tab].cols;
00699 int *res = tabinfo[tab].table;
00700 char **keys = tabinfo[tab].keys;
00701 char **longkeys = tabinfo[tab].longkeys;
00702 found_index = 0;
00703 index = dr_getkey_int(lev0, tabinfo[tab].index);
00704 if (tab == 3)
00705 {
00706 if (fsn < FSN_CAM_ID_FIXED)
00707 index += 1;
00708 dr_setkey_int(lev0, tabinfo[tab].index, index);
00709 drms_setkey_int(rec, tabinfo[tab].longname, index);
00710 }
00711 if (is_I_MISSING(index))
00712 {
00713 fprintf(stderr,"Mech Index %s not found.\n",tabinfo[tab].index);
00714 continue;
00715 }
00716 for (row=0; row<MAXROWS; row++)
00717 if (index == res[(vals+1)*row])
00718 {
00719 found_index = 1;
00720 if (tab<3)
00721 {
00722 for (val=0; val<vals; val++)
00723 {
00724 drms_setkey_int(rec, longkeys[val], res[val+1+(vals+1)*row]);
00725 dr_setkey_int(lev0, keys[val], res[val+1+(vals+1)*row]);
00726 }
00727 break;
00728 }
00729 else
00730 {
00731 int exposure;
00732 if (camera <= 1)
00733 exposure = 0;
00734 else
00735 {
00736 camera -= 2;
00737 if (fsn <= FSN_HSHIEXP_FIXED)
00738 exposure = res[camera+1+(vals+1)*row];
00739 else
00740 exposure = dr_getkey_int(lev0, "HSHIEXP");
00741 }
00742 drms_setkey_int(rec, longkeys[0], exposure);
00743 dr_setkey_int(lev0, keys[0], exposure);
00744 drms_setkey_int(rec, camkey_longname, camera);
00745 dr_setkey_int(lev0, camkey, camera);
00746 break;
00747 }
00748 }
00749 if (!found_index)
00750 {
00751 fprintf(stderr,"Mech Index %d not found in mech table %s.\n",index,tabinfo[tab].filename);
00752 if (index > 0)
00753 return(1);
00754 }
00755 }
00756 return(0);
00757 }
00758
00759
00760
00761 int init_keymaps(char *keymaps[MAX_KEYS][MAX_KEYMAPS], int *nkeys, char *key_map_file)
00762 {
00763 int key, map;
00764 for (key=0; key<MAX_KEYS; key++)
00765 for (map=0; map<MAX_KEYMAPS; map++)
00766 keymaps[key][map] = NULL;
00767 key = 0;
00768 if (strcmp(key_map_file, NOT_SPECIFIED) != 0)
00769 {
00770 FILE *km = fopen(key_map_file,"r");
00771 char line[1024];
00772 if (!km)
00773 return(1);
00774 key=0;
00775 while (fgets(line, 1024, km))
00776 {
00777 char *tok;
00778 for (map=0, tok = strtok(line, " \t,:\n"); map<MAX_KEYMAPS && tok; map++, tok=strtok(NULL, " \t,\n"))
00779 {
00780 keymaps[key][map] = strdup(tok);
00781 }
00782 key++;
00783 }
00784 }
00785 *nkeys = key;
00786 return(0);
00787 }
00788
00789 void sprint_time_ISO (char *tstring, TIME t)
00790 {
00791 sprint_at(tstring,t);
00792 tstring[4] = tstring[7] = '-';
00793 tstring[10] = 'T';
00794 tstring[19] = '\0';
00795 }