void par_sets(char *block, char *name, char *sval, char *comment) { Block *bp = add_block(block); /* find or add a block with this name */ add_par(bp,name,sval,comment); /* Add the name = value pair Parameter */ return; }
void par_setd(char *block, char *name, char *fmt, double dval, char *comment) { Block *bp = add_block(block); /* find or add a block with this name */ char sval[MAXLEN]; sprintf(sval,fmt,dval); add_par(bp,name,sval,comment); /* Add the name = value pair Parameter */ return; }
static void add_par_line(Block *bp, char *line) { char *cp; char *name, *equal=NULL, *value=NULL, *hash=NULL, *comment=NULL, *nul; if(bp == NULL) ath_error("[add_par_line]: (no block name) while parsing line \n%s\n",line); name = skipwhite(line); /* name */ for(cp = name; *cp != '\0'; cp++){/* Find the first '=' and '#' */ if(*cp == '='){ if(equal == NULL){ equal = cp; /* store the equals sign location */ value = skipwhite(cp + 1); /* value */ } } if(*cp == '#'){ hash = cp; /* store the hash sign location */ comment = skipwhite(cp + 1); /* comment */ break; } } while(*cp != '\0') cp++; /* Find the NUL terminator */ nul = cp; if(equal == NULL) ath_error("No '=' found in line \"%s\"\n",line); str_term(equal); /* Terminate the name string */ if(hash == NULL){ str_term(nul); /* Terminate the value string */ } else{ str_term(hash); /* Terminate the value string */ if(*comment == '\0') comment = NULL; /* Comment field is empty */ else str_term(nul); /* Terminate the comment string */ } add_par(bp,name,value,comment); }
void InitTime(void) { time_t raw_time; struct tm *now; FULL_CHAR buff[20]; OBJECT par, tmp, sym, env; OBJECT tag, second, minute, hour, weekday, monthday, yearday, month, year, century, dst; debug0(DTK, D, "InitTime()"); /* define @Moment symbol with its host of named parameters */ MomentSym = load(KW_MOMENT, LOCAL, StartSym); tag = load(KW_TAG, NPAR, MomentSym); second = load(KW_SECOND, NPAR, MomentSym); minute = load(KW_MINUTE, NPAR, MomentSym); hour = load(KW_HOUR, NPAR, MomentSym); monthday = load(KW_DAY, NPAR, MomentSym); month = load(KW_MONTH, NPAR, MomentSym); year = load(KW_YEAR, NPAR, MomentSym); century = load(KW_CENTURY, NPAR, MomentSym); weekday = load(KW_WEEKDAY, NPAR, MomentSym); yearday = load(KW_YEARDAY, NPAR, MomentSym); dst = load(KW_DAYLIGHTSAVING, NPAR, MomentSym); /* get current time and convert to ASCII */ if( time(&raw_time) == -1 ) Error(35, 1, "unable to obtain the current time", WARN, no_fpos); now = localtime(&raw_time); StringCopy(time_string, AsciiToFull(asctime(now))); time_string[StringLength(time_string) - 1] = '\0'; /* start of current_moment */ New(current_moment, CLOSURE); actual(current_moment) = MomentSym; /* attach its many parameters */ add_par("%s", KW_NOW, tag); add_par("%.2d", now->tm_sec, second); add_par("%.2d", now->tm_min, minute); add_par("%.2d", now->tm_hour, hour); add_par("%d", now->tm_mday, monthday); add_par("%d", now->tm_mon + 1, month); add_par("%.2d", now->tm_year % 100, year); add_par("%d", (now->tm_year+1900) / 100, century); add_par("%d", now->tm_wday + 1, weekday); add_par("%d", now->tm_yday, yearday); add_par("%d", now->tm_isdst, dst); /* add a null environment */ New(env, ENV); AttachEnv(env, current_moment); debug0(DTK, D, "InitTime() returning."); debug0(DTK, DD, "current_moment ="); ifdebug(DTK, DD, DebugObject(current_moment)); } /* end InitTime */