void Fl_Type::label(const char *n) { if(storestring(n,label_,1)) { setlabel(label_); widget_browser->redraw(); } }
/* Return the string ID of the given set name. If the set name is not * already in the list, then if add is TRUE the set name is added to * the list; otherwise zero is returned. */ static int lookupsetname(char const *name, int add) { int i; for (i = 0 ; i < namescount ; ++i) if (!strcmp(getstring(names[i]), name)) return names[i]; if (!add) return 0; if (namescount >= namesallocated) { namesallocated = namesallocated ? 2 * namesallocated : 8; xalloc(names, namesallocated * sizeof *names); } names[namescount] = storestring(name); return names[namescount++]; }
static int Pgetgroup(lua_State *L) /** getgroup(name or id) */ { struct group *g=NULL; if (lua_isnumber(L, 1)) g = getgrgid((gid_t)lua_tonumber(L, 1)); else if (lua_isstring(L, 1)) g = getgrnam(lua_tostring(L, 1)); else luaL_typerror(L, 1, "string or number"); if (g==NULL) lua_pushnil(L); else { int i; lua_newtable(L); storestring(L, "name", g->gr_name); storenumber(L, "gid", g->gr_gid); for (i=0; g->gr_mem[i] != NULL; i++) storeindex(L, i+1, g->gr_mem[i]); } return 1; }
/* Add the information in the given file to the list of unsolvable * levels. Errors in the file are flagged but do not prevent the * function from reading the rest of the file. */ static int readunslist(fileinfo *file) { char buf[256], token[256]; char const *p; unsigned long hashval; int setid, size; int lineno, levelnum, n; setid = 0; for (lineno = 1 ; ; ++lineno) { n = sizeof buf - 1; if (!filegetline(file, buf, &n, NULL)) break; for (p = buf ; isspace(*p) ; ++p) ; if (!*p || *p == '#') continue; if (sscanf(p, "[%[^]]]", token) == 1) { setid = lookupsetname(token, TRUE); continue; } n = sscanf(p, "%d: %04X%08lX: %[^\n\r]", &levelnum, &size, &hashval, token); if (n > 0 && levelnum > 0 && levelnum < 65536 && setid) { if (n == 1) { n = sscanf(p, "%*d: %s", token); if (n > 0 && !strcmp(token, "ok")) { removefromunslist(setid, levelnum); continue; } } else if (n >= 3) { addtounslist(setid, levelnum, size, hashval, n == 4 ? storestring(token) : 0); continue; } } warn("%s:%d: syntax error", file->name, lineno); } return TRUE; }
void Fl_Type::user_data_type(const char *n) { storestring(n,user_data_type_); }
void Fl_Type::callback(const char *n) { storestring(n,callback_); }
void Fl_Type::tooltip(const char *n) { storestring(n,tooltip_,1); }
void Fl_Type::name(const char *n) { if (storestring(n, name_)) { widget_browser->redraw(); } }