/*-------------------------------------------------------------------------*/ static void set_CE_Type( Widget w, XtPointer address, XrmQuark type, Cardinal size ) { lList *lp = NULL; if (type != QmonQCE_Type) { XmtWarningMsg("XmtDialogSetDialogValues", "XbaeMatrix", "Type Mismatch: Widget '%s':\n\tCan't set widget values" " from a resource of type '%s'; QmonQCE_Type expected.", XtName(w), XrmQuarkToString(type)); return; } if (size == sizeof(lList*)) lp = *(lList**) address; else return; qmonSetCE_Type(w, lp, CE_TYPE_REDUCED); }
/*-------------------------------------------------------------------------*/ static void set_Spinbox( Widget w, XtPointer address, XrmQuark type, Cardinal size ) { int value; /* * Here special Qmon Quarks are used. Does it work ? */ if (type != QmonQInt) { XmtWarningMsg("XmtDialogSetDialogValues", "Spinbox", "Type Mismatch: Widget '%s':\n\tCan't set widget values" " from a resource of type '%s'; QmonQInt expected.", XtName(w), XrmQuarkToString(type)); return; } if (size == sizeof(int)) value = *(int *) address; else return; XmpSpinboxSetValue(w, (long)value, True); }
/*-------------------------------------------------------------------------*/ static void get_TimeInput( Widget w, XtPointer address, XrmQuark type, Cardinal size ) { Cardinal value = 0; String str = NULL; if (type != QmonQCardinal ) { XmtWarningMsg("XmtDialogGetDialogValues", "TimeInput", "Type Mismatch: Widget '%s':\n\tCan't get widget values" " from a resource of type '%s'", XtName(w), XrmQuarkToString(type)); return; } str = XmtInputFieldGetString(w); if (str && str[0] != '\0') { u_long32 tmp_date_time; ulong_parse_date_time_from_string(&tmp_date_time, NULL, str); value = (Cardinal)tmp_date_time; } *(Cardinal*)address = value; }
/*-------------------------------------------------------------------------*/ static void set_StrListField( Widget w, XtPointer address, XrmQuark type, Cardinal size ) { lList *list = NULL; String str = NULL; static char buf[100 * BUFSIZ]; lListElem *ep = NULL; /* * Here special Qmon Quarks are used. Does it work ? */ if (type != QmonQENV_Type && type != QmonQST_Type && type != QmonQRN_Type && type != QmonQTRN_Type && type != QmonQPN_Type && type != QmonQMR_Type && type != QmonQQR_Type && type != QmonQJRE_Type && type != QmonQCTX_Type && type != QmonQPE_Type && type != QmonQARA_Type) { XmtWarningMsg("XmtDialogSetDialogValues", "StrListField", "Type Mismatch: Widget '%s':\n\tCan't set widget values" " from a resource of type '%s'.", XtName(w), XrmQuarkToString(type)); return; } buf[0] = '\0'; if (size == sizeof(lList*) || size == sizeof(String)) { if (type == QmonQPE_Type) str = *(String*) address; else list = *(lList**) address; } else return; if (type == QmonQENV_Type || type == QmonQCTX_Type) { str = write_pair_list(list, VARIABLE_TYPE); } if (type == QmonQST_Type) { int first_time = 1; strcpy(buf, ""); for_each(ep, list) { if (first_time) { strcpy(buf, lGetString(ep, ST_name)); first_time = 0; } else snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %s", lGetString(ep, ST_name)); } str = buf; }
/*-------------------------------------------------------------------------*/ static void get_2xN( Widget w, XtPointer address, XrmQuark type, Cardinal size ) { lList *lp = NULL; if (type != QmonQVA_Type && type != QmonQCE2_Type && type != QmonQHS_Type && type != QmonQMR_Type && type != QmonQPN_Type && type != QmonQAT_Type && type != QmonQSO_Type && type != QmonQUA_Type) { XmtWarningMsg("XmtDialogGetDialogValues", "XbaeMatrix", "Type Mismatch: Widget '%s':\n\tCan't get widget values" " from a resource of type '%s'", XtName(w), XrmQuarkToString(type)); return; } if (type == QmonQVA_Type) lp = qmonGet2xN(w, VA_Type, VA_variable, VA_value); else if ( type == QmonQCE2_Type ) lp = qmonGet2xN(w, CE_Type, CE_name, CE_stringval); else if ( type == QmonQHS_Type ) lp = qmonGet2xN(w, HS_Type, HS_name, HS_value); else if ( type == QmonQMR_Type ) lp = qmonGet2xN(w, MR_Type, MR_user, MR_host); else if ( type == QmonQPN_Type ) lp = qmonGet2xN(w, PN_Type, PN_path, PN_host); else if ( type == QmonQAT_Type ) lp = qmonGet2xN(w, AT_Type, AT_account, AT_cell); else if ( type == QmonQSO_Type ) lp = qmonGet2xN(w, SO_Type, SO_name, SO_threshold); else if ( type == QmonQUA_Type ) lp = qmonGet2xN(w, UA_Type, UA_name, UA_value); #if 0 /* * AA-2009-02-12 * leads to crash reverting memory leak fix in qmon_qaction.c */ if (*(lList**)address != NULL) { lFreeList((lList**)address); } #endif *(lList**)address = lp; }
/*-------------------------------------------------------------------------*/ static void get_StringList( Widget w, XtPointer address, XrmQuark type, Cardinal size ) { lList *lp = NULL; /* * Here special Qmon Quarks are used. Does it work ? */ if (type != QmonQUS_Type && type != QmonQMR_Type && type != QmonQPR_Type && type != QmonQSTR_Type && type != QmonQSTU_Type && type != QmonQHR_Type) { XmtWarningMsg("XmtDialogSetDialogValues", "XbaeMatrix", "Type Mismatch: Widget '%s':\n\tCan't get widget values" " from a resource of type '%s'", XtName(w), XrmQuarkToString(type)); return; } if (type == QmonQUS_Type) { lp = XmStringToCull(w, US_Type, US_name, ALL_ITEMS); } if (type == QmonQPR_Type) { lp = XmStringToCull(w, PR_Type, PR_name, ALL_ITEMS); } if (type == QmonQMR_Type) { lp = XmStringToCull(w, MR_Type, MR_user, ALL_ITEMS); } if (type == QmonQSTR_Type) { lp = XmStringToCull(w, ST_Type, ST_name, ALL_ITEMS); } if (type == QmonQSTU_Type) { lp = XmStringToCull(w, STU_Type, STU_name, ALL_ITEMS); } if (type == QmonQHR_Type) { lp = XmStringToCull(w, HR_Type, HR_name, ALL_ITEMS); } *(lList**)address = lp; }
/*-------------------------------------------------------------------------*/ static void set_2xN( Widget w, XtPointer address, XrmQuark type, Cardinal size ) { lList *lp = NULL; if (type != QmonQVA_Type && type != QmonQCE2_Type && type != QmonQHS_Type && type != QmonQMR_Type && type != QmonQPN_Type && type != QmonQAT_Type && type != QmonQSO_Type && type != QmonQUA_Type) { XmtWarningMsg("XmtDialogSetDialogValues", "XbaeMatrix", "Type Mismatch: Widget '%s':\n\tCan't set widget values" " from a resource of type '%s'", XtName(w), XrmQuarkToString(type)); return; } if (size == sizeof(lList*)) lp = *(lList**) address; else return; if (type == QmonQVA_Type) qmonSet2xN(w, lp, VA_variable, VA_value); else if ( type == QmonQCE2_Type ) qmonSet2xN(w, lp, CE_name, CE_stringval); else if ( type == QmonQHS_Type ) qmonSet2xN(w, lp, HS_name, HS_value); else if ( type == QmonQMR_Type ) qmonSet2xN(w, lp, MR_user, MR_host); else if ( type == QmonQPN_Type ) qmonSet2xN(w, lp, PN_path, PN_host); else if ( type == QmonQAT_Type ) qmonSet2xN(w, lp, AT_account, AT_cell); else if ( type == QmonQSO_Type ) qmonSet2xN(w, lp, SO_name, SO_threshold); else if ( type == QmonQUA_Type ) qmonSet2xN(w, lp, UA_name, UA_value); }
/*-------------------------------------------------------------------------*/ static void set_Ulong32Field( Widget w, XtPointer address, XrmQuark type, Cardinal size ) { static char buf[BUFSIZ]; if (type != QmonQUlong32) { XmtWarningMsg("XmtDialogSetDialogValues", "Ulong32Field", "Type Mismatch: Widget '%s':\n\tCan't set widget values" " from a resource of type '%s'.", XtName(w), XrmQuarkToString(type)); } (void)sprintf(buf, "%u", *(unsigned int *)address); XmtInputFieldSetString(w, buf); }
/*-------------------------------------------------------------------------*/ static void get_Spinbox( Widget w, XtPointer address, XrmQuark type, Cardinal size ) { int value; if (type != QmonQInt) { XmtWarningMsg("XmtDialogSetDialogValues", "Spinbox", "Type Mismatch: Widget '%s':\n\tCan't get widget values" " from a resource of type '%s'; QmonQInt expected.", XtName(w), XrmQuarkToString(type)); return; } value = XmpSpinboxGetValue(w); *(int*)address = value; }
/*-------------------------------------------------------------------------*/ static void set_DurationInput( Widget w, XtPointer address, XrmQuark type, Cardinal size ) { Cardinal time_val = 0; /* Cardinal day_val = 0; */ Cardinal hour_val = 0; Cardinal minute_val = 0; Cardinal second_val = 0; char buffer[256]; if (type != QmonQCardinal ) { XmtWarningMsg("XmtDialogSetDialogValues", "DurationInput", "Type Mismatch: Widget '%s':\n\tCan't set widget values" " from a resource of type '%s'", XtName(w), XrmQuarkToString(type)); return; } if (size == sizeof(Cardinal)) time_val = *(Cardinal*) address; else return; if (time_val == 0) { sprintf(buffer, "%02d:%02d:%02d", 0, 0, 0); } else { /* day_val = time_val/(24*3600); */ /* time_val %= 24*3600; */ hour_val = time_val/3600; time_val %= 3600; minute_val = time_val/60; second_val = time_val % 60; sprintf(buffer, "%02d:%02d:%02d", hour_val, minute_val, second_val); } XmtInputFieldSetString(w, buffer); }
/*-------------------------------------------------------------------------*/ static void get_CX_Type( Widget w, XtPointer address, XrmQuark type, Cardinal size ) { lList *lp = NULL; if (type != QmonQCX_Type) { XmtWarningMsg("XmtDialogSetDialogValues", "XbaeMatrix", "Type Mismatch: Widget '%s':\n\tCan't get widget values" " from a resource of type '%s'; QmonQCX_Type expected.", XtName(w), XrmQuarkToString(type)); return; } lp = qmonGetCE_Type(w); *(lList**)address = lp; }
/*-------------------------------------------------------------------------*/ static void get_Ulong32Field( Widget w, XtPointer address, XrmQuark type, Cardinal size ) { static u_long32 uv = 0; unsigned long lv = 0; String s = NULL; if (type != QmonQUlong32) { XmtWarningMsg("XmtDialogGetDialogValues", "Ulong32Field", "Type Mismatch: Widget '%s':\n\tCan't get widget values" " from a resource of type '%s'.", XtName(w), XrmQuarkToString(type)); } s = XmtInputFieldGetString(w); if (s && s[0] != '\0') { lv = strtoul(s, NULL, 10); } else { lv = 0; } if (lv > U_LONG32_MAX) { uv = U_LONG32_MAX; } else { uv = (u_long32)lv; } if (type == QmonQUlong32) { *(u_long32 *)address = uv; } }
/*-------------------------------------------------------------------------*/ static void set_TimeInput( Widget w, XtPointer address, XrmQuark type, Cardinal size ) { int value = 0; String str = NULL; dstring ds; char buffer[128]; sge_dstring_init(&ds, buffer, sizeof(buffer)); if (type != QmonQCardinal ) { XmtWarningMsg("XmtDialogSetDialogValues", "TimeInput", "Type Mismatch: Widget '%s':\n\tCan't set widget values" " from a resource of type '%s'", XtName(w), XrmQuarkToString(type)); return; } if (size == sizeof(Cardinal)) value = *(Cardinal*) address; else return; if (value != 0 && sge_at_time(value, &ds)!=NULL) str = buffer; if (str) XmtInputFieldSetString(w, str); else XmtInputFieldSetString(w, ""); }
/*-------------------------------------------------------------------------*/ static void set_StringList( Widget w, XtPointer address, XrmQuark type, Cardinal size ) { lList *lp = NULL; Widget parent; /* * Here special Qmon Quarks are used. Does it work ? */ if (type != QmonQUS_Type && type != QmonQMR_Type && type != QmonQPR_Type && type != QmonQSTR_Type && type != QmonQSTU_Type && type != QmonQHR_Type) { XmtWarningMsg("XmtDialogSetDialogValues", "XbaeMatrix", "Type Mismatch: Widget '%s':\n\tCan't set widget values" " from a resource of type '%s'", XtName(w), XrmQuarkToString(type)); return; } if (size == sizeof(lList*)) lp = *(lList**) address; else return; /* if our parent is a layout widget disable/reenable it */ parent = XtParent(w); while (parent && !XtIsSubclass(parent, xmtLayoutWidgetClass)) parent = XtParent(parent); XmtLayoutDisableLayout(parent); if (type == QmonQUS_Type) { UpdateXmListFromCull(w, XmFONTLIST_DEFAULT_TAG, lp, US_name); } if (type == QmonQPR_Type) { UpdateXmListFromCull(w, XmFONTLIST_DEFAULT_TAG, lp, PR_name); } if (type == QmonQHR_Type) { UpdateXmListFromCull(w, XmFONTLIST_DEFAULT_TAG, lp, HR_name); } if (type == QmonQMR_Type) { String *str_table = NULL; Cardinal itemCount; StringConst str1, str2; int size, i; char buf[BUFSIZ]; lListElem *ep = NULL; XtVaGetValues(w, XmNitemCount, &itemCount, NULL); if (!lp) { if (itemCount) XmListDeleteAllItems(w); return; } if ((size = lGetNumberOfElem(lp)) <=0) { return; } if (!(str_table = (String *)XtMalloc(sizeof(String)*size))) { return; } for (ep=lFirst(lp), i=0; ep; ep=lNext(ep), i++) { str1 = (StringConst)lGetString(ep, MR_user); str2 = (StringConst)lGetHost(ep, MR_host); if (str1) { if (!str2) sge_strlcpy(buf, str1, BUFSIZ); else snprintf(buf, BUFSIZ, "%s@%s", str1, str2); str_table[i] = XtNewString(buf); } else str_table[i] = NULL; } UpdateXmList(w, str_table, size, XmFONTLIST_DEFAULT_TAG); StringTableFree(str_table, size); } if (type == QmonQSTR_Type) { UpdateXmListFromCull(w, XmFONTLIST_DEFAULT_TAG, lp, ST_name); } if (type == QmonQSTU_Type) { UpdateXmListFromCull(w, XmFONTLIST_DEFAULT_TAG, lp, STU_name); } XmtLayoutEnableLayout(parent); }