MCPcopy Create free account
hub / github.com/SimHacker/micropolis / Tk_AddOption

Function Tk_AddOption

micropolis-activity/src/tk/tkoption.c:234–367  ·  view source on GitHub ↗
(tkwin, name, value, priority)

Source from the content-addressed store, hash-verified

232 *--------------------------------------------------------------
233 */
234
235void
236Tk_AddOption(tkwin, name, value, priority)
237 Tk_Window tkwin; /* Window token; option will be associated
238 * with main window for this window. */
239 char *name; /* Multi-element name of option. */
240 char *value; /* String value for option. */
241 int priority; /* Overall priority level to use for
242 * this option, such as TK_USER_DEFAULT_PRIO
243 * or TK_INTERACTIVE_PRIO. Must be between
244 * 0 and TK_MAX_PRIO. */
245{
246 TkWindow *winPtr = ((TkWindow *) tkwin)->mainPtr->winPtr;
247 register ElArray **arrayPtrPtr;
248 register Element *elPtr;
249 Element newEl;
250 register char *p;
251 char *field;
252 int count, firstField, length;
253#define TMP_SIZE 100
254 char tmp[TMP_SIZE+1];
255
256 if (winPtr->mainPtr->optionRootPtr == NULL) {
257 OptionInit(winPtr->mainPtr);
258 }
259 cachedWindow = NULL; /* Invalidate the cache. */
260
261 /*
262 * Compute the priority for the new element, including both the
263 * overall level and the serial number (to disambiguate with the
264 * level).
265 */
266
267 if (priority < 0) {
268 priority = 0;
269 } else if (priority > TK_MAX_PRIO) {
270 priority = TK_MAX_PRIO;
271 }
272 newEl.priority = (priority << 24) + serial;
273 serial++;
274
275 /*
276 * Parse the option one field at a time.
277 */
278
279 arrayPtrPtr = &(((TkWindow *) tkwin)->mainPtr->optionRootPtr);
280 p = name;
281 for (firstField = 1; ; firstField = 0) {
282
283 /*
284 * Scan the next field from the name and convert it to a Tk_Uid.
285 * Must copy the field before calling Tk_Uid, so that a terminating
286 * NULL may be added without modifying the source string.
287 */
288
289 if (*p == '*') {
290 newEl.flags = WILDCARD;
291 p++;

Callers 3

Tk_OptionCmdFunction · 0.85
AddFromStringFunction · 0.85
Tk_ParseArgvFunction · 0.85

Calls 2

OptionInitFunction · 0.85
Tk_GetUidFunction · 0.85

Tested by

no test coverage detected