Lines Matching refs:state

76 #define DEFAULT(o)	((state.std||!dynamic[o].ast)?dynamic[o].std:dynamic[o].ast)
77 #define INITIALIZE() do{if(!state.data)synthesize(NiL,NiL,NiL);}while(0)
287 static State_t state = { "getconf", "_AST_FEATURES", dynamic, -1 };
302 * synthesize state for fp
303 * fp==0 initializes from getenv(state.name)
305 * otherwise state is set to value
319 error(-2, "astconf synthesize name=%s path=%s value=%s fp=%p%s", fp->name, path, value, fp, state.synthesizing ? " SYNTHESIZING" : "");
321 if (state.synthesizing)
323 if (!state.data)
329 state.prefix = strlen(state.name) + 1;
330 n = state.prefix + 3 * MAXVAL;
331 if (s = getenv(state.name))
334 if (!(state.data = newof(0, char, n, 0)))
336 state.last = state.data + n - 1;
337 strcpy(state.data, state.name);
338 state.data += state.prefix - 1;
339 *state.data++ = '=';
341 strcpy(state.data, s);
342 ve = state.data;
343 state.synthesizing = 1;
367 state.synthesizing = 0;
370 return state.data;
371 if (!state.last)
380 d = state.data;
407 else if (d != state.data)
433 if (d + n >= state.last)
438 i = d - state.data;
439 state.data -= state.prefix;
440 c = n + state.last - state.data + 3 * MAXVAL;
442 if (!(state.data = newof(state.data, char, c, 0)))
444 state.last = state.data + c - 1;
445 state.data += state.prefix;
446 d = state.data + i;
448 if (d != state.data)
456 error(-3, "astconf synthesize %s", state.data - state.prefix);
458 setenviron(state.data - state.prefix);
459 if (state.notify)
460 (*state.notify)(NiL, NiL, state.data - state.prefix);
492 error(-2, "astconf initialize name=%s path=%s command=%s succeed=%s fail=%s fp=%p%s", fp->name, path, command, succeed, fail, fp, state.synthesizing ? " SYNTHESIZING" : "");
592 error(-1, "AHA#%d state.std=%d %s [%s] std=%s ast=%s value=%s ok=%d", __LINE__, state.std, fp->name, ok ? succeed : fail, fp->std, fp->ast, fp->value, ok);
608 error(-2, "astconf format name=%s path=%s value=%s flags=%04x fp=%p%s", fp->name, path, value, flags, fp, state.synthesizing ? " SYNTHESIZING" : "");
620 n = state.std = streq(fp->value, fp->std);
622 error(-1, "AHA#%d state.std=%d %s [%s] std=%s ast=%s value=%s", __LINE__, state.std, fp->name, value, fp->std, fp->ast, fp->value);
627 error(-1, "AHA#%d state.std=%d %s [%s] std=%s ast=%s value=%s", __LINE__, state.std, fp->name, value, fp->std, fp->ast, fp->value);
631 state.std = 1;
632 for (sp = state.features; sp; sp = sp->next)
637 error(-1, "AHA#%d state.std=%d %s [%s] std=%s ast=%s value=%s", __LINE__, state.std, fp->name, value, fp->std, fp->ast, fp->value);
696 (*conferror)(&state, &state, 2, "%s: %s: universe value too large", fp->name, value);
713 if (state.synthesizing)
760 for (fp = state.features; fp && !streq(fp->name, name); fp = fp->next);
762 error(-2, "astconf feature name=%s path=%s value=%s flags=%04x fp=%p%s", name, path, value, flags, fp, state.synthesizing ? " SYNTHESIZING" : "");
768 if (state.notify && !(*state.notify)(name, path, value))
774 (*conferror)(&state, &state, 2, "%s: out of space", name);
782 fp->next = state.features;
783 state.features = fp;
790 (*conferror)(&state, &state, 2, "%s: cannot set readonly symbol", fp->name);
793 if (state.notify && !streq(fp->value, value) && !(*state.notify)(name, path, value))
797 state.recent = fp;
996 (*conferror)(&state, &state, 2, "%s: path expected", name);
1003 (*conferror)(&state, &state, 2, "%s: path not expected", name);
1017 (*conferror)(&state, &state, 2, "%s: path not expected", name);
1163 (*conferror)(&state, &state, ERROR_SYSTEM|2, "%s: %s error", p->name, call);
1165 (*conferror)(&state, &state, 2, "%s: unknown name", p->name);
1315 cmd[0] = (char*)state.id;
1376 if (state.data)
1381 free(state.data - state.prefix);
1383 state.data = 0;
1384 notify = state.notify;
1385 state.notify = 0;
1387 state.notify = notify;
1396 if (state.recent && streq(name, state.recent->name) && (s = format(state.recent, path, value, flags, conferror)))
1405 (*conferror)(&state, &state, 2, "%s: cannot set value", name);
1445 (*conferror)(&state, &state, 2, "%s: cannot set value", altname);
1475 (*conferror)(&state, &state, 2, "%s: unknown name", name);
1500 old_notify = state.notify;
1501 state.notify = new_notify;
1532 errorf(&state, &state, 2, "%s: not found", path);
1596 sfprintf(sp, "%s %s - %s\n", state.id, f, s);
1609 for (fp = state.features; fp; fp = fp->next)
1644 sfprintf(sp, "%s %s - %s\n", state.id, (flags & ASTCONF_lower) ? fmtlower(fp->name) : fp->name, fmtquote(s, "\"", "\"", strlen(s), FMT_SHELL));