~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/clients/qmon/qmon_request.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*___INFO__MARK_BEGIN__*/
 
2
/*************************************************************************
 
3
 * 
 
4
 *  The Contents of this file are made available subject to the terms of
 
5
 *  the Sun Industry Standards Source License Version 1.2
 
6
 * 
 
7
 *  Sun Microsystems Inc., March, 2001
 
8
 * 
 
9
 * 
 
10
 *  Sun Industry Standards Source License Version 1.2
 
11
 *  =================================================
 
12
 *  The contents of this file are subject to the Sun Industry Standards
 
13
 *  Source License Version 1.2 (the "License"); You may not use this file
 
14
 *  except in compliance with the License. You may obtain a copy of the
 
15
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
16
 * 
 
17
 *  Software provided under this License is provided on an "AS IS" basis,
 
18
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
19
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
20
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
21
 *  See the License for the specific provisions governing your rights and
 
22
 *  obligations concerning the Software.
 
23
 * 
 
24
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
25
 * 
 
26
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
27
 * 
 
28
 *   All Rights Reserved.
 
29
 * 
 
30
 ************************************************************************/
 
31
/*___INFO__MARK_END__*/
 
32
#include <stdlib.h>
 
33
 
 
34
#include <Xm/Xm.h>
 
35
#include <Xm/PushB.h>
 
36
#include <Xm/Label.h>
 
37
#include <Xm/DrawingA.h>
 
38
#include <Xm/TextF.h>
 
39
#include <Xmt/Xmt.h>
 
40
#include <Xmt/Dialogs.h>
 
41
#include <Xmt/Create.h>
 
42
#include <Xmt/Chooser.h>
 
43
#include <Xmt/InputField.h>
 
44
#include <Xmt/Pixmap.h>
 
45
#include <Xmt/WidgetType.h>
 
46
#include <Xmt/Layout.h>
 
47
#include <Xmt/LayoutG.h>
 
48
 
 
49
#include "qmon_rmon.h"
 
50
#include "commlib.h"
 
51
#include "gdi/sge_gdi.h"
 
52
#include "sge_host.h"
 
53
#include "sge_all_listsL.h"
 
54
#include "qmon_cull.h"
 
55
#include "qmon_request.h"
 
56
#include "qmon_submit.h"
 
57
#include "qmon_globals.h"
 
58
#include "qmon_comm.h"
 
59
#include "qmon_init.h"
 
60
#include "qmon_util.h"
 
61
#include "qmon_message.h"
 
62
#include "AskForTime.h"
 
63
#include "IconList.h"
 
64
#include "uti/sge_string.h"
 
65
 
 
66
 
 
67
 
 
68
/*-------------------------------------------------------------------------*/
 
69
static void qmonRequestRemoveResource(Widget w, XtPointer cld, XtPointer cad);
 
70
static void qmonToggleHardSoft2(Widget w, XtPointer cld, XtPointer cad);
 
71
static void qmonRequestClear(Widget w, XtPointer cld, XtPointer cad);
 
72
static void qmonRequestOkay(Widget w, XtPointer cld, XtPointer cad);
 
73
static void qmonRequestCancel(Widget w, XtPointer cld, XtPointer cad);
 
74
static void qmonRequestEditResource(Widget w, XtPointer cld, XtPointer cad);
 
75
static int qmonCullToIconList(lList *cel, int how, IconListElement **ice, int *iceCount);
 
76
static Pixmap qmonFetchTypeIcon(int type);
 
77
 
 
78
 
 
79
/*-------------------------------------------------------------------------*/
 
80
static lList *hard_requests = 0;
 
81
static lList *soft_requests = 0;
 
82
 
 
83
static lListElem *fill_in_request;
 
84
 
 
85
static int hard_soft = 0; 
 
86
static Widget request_dialog = 0; 
 
87
static Widget request_rtype = 0; 
 
88
static Widget request_rr = 0; 
 
89
static Widget request_hr = 0; 
 
90
static Widget request_sr = 0; 
 
91
 
 
92
 
 
93
 
 
94
 
 
95
/*-------------------------------------------------------------------------*/
 
96
void qmonRequestPopup(Widget w, XtPointer cld, XtPointer cad)
 
97
{
 
98
   Widget request_hardsoft, parent, request_clear, request_okay,
 
99
         request_cancel; 
 
100
   lList *hrl = NULL;
 
101
   lList *srl = NULL;
 
102
   lList *rll = NULL;
 
103
   lListElem *ep = NULL;
 
104
   lListElem *rp = NULL;
 
105
   lList *alp = NULL;
 
106
   
 
107
   DENTER(GUI_LAYER, "qmonRequestPopup");
 
108
 
 
109
   parent = XmtGetShell(w);
 
110
   DPRINTF(("parent = %s\n", XtName(parent) ));
 
111
   
 
112
   if (!request_dialog) {
 
113
      request_dialog = XmtBuildQueryDialog(parent, "request_shell", 
 
114
                              NULL, 0,
 
115
                              "request_rtype", &request_rtype,
 
116
                              "request_rr", &request_rr,
 
117
                              "request_hr", &request_hr,
 
118
                              "request_sr", &request_sr,
 
119
                              "request_hardsoft", &request_hardsoft,
 
120
                              "request_clear", &request_clear,
 
121
                              "request_okay", &request_okay,
 
122
                              "request_cancel", &request_cancel,
 
123
                              NULL);
 
124
      XtAddCallback(request_rr, XmNactivateCallback,
 
125
                     qmonRequestEditResource, (XtPointer)0); 
 
126
      XtAddCallback(request_hr, XmNactivateCallback, 
 
127
                     qmonRequestEditResource, (XtPointer)1);
 
128
      XtAddCallback(request_hr, XmNremoveCallback, 
 
129
                     qmonRequestRemoveResource, NULL);
 
130
      XtAddCallback(request_sr, XmNactivateCallback, 
 
131
                     qmonRequestEditResource, (XtPointer)1);
 
132
      XtAddCallback(request_sr, XmNremoveCallback, 
 
133
                     qmonRequestRemoveResource, NULL);
 
134
 
 
135
      XtAddCallback(request_hardsoft, XmtNvalueChangedCallback,
 
136
                     qmonToggleHardSoft2, NULL);
 
137
      XtAddCallback(request_clear, XmNactivateCallback, 
 
138
                     qmonRequestClear, NULL);
 
139
      XtAddCallback(request_okay, XmNactivateCallback, 
 
140
                     qmonRequestOkay, NULL);
 
141
      XtAddCallback(request_cancel, XmNactivateCallback, 
 
142
                     qmonRequestCancel, NULL);
 
143
 
 
144
      XtAddEventHandler(XtParent(request_dialog), StructureNotifyMask, False, 
 
145
                        SetMinShellSize, NULL);
 
146
      
 
147
   }
 
148
 
 
149
   /*
 
150
   ** set the type labelString
 
151
   */
 
152
   XtVaSetValues(request_rtype, XmtNlabel, qmonSubmitRequestType(), NULL);
 
153
 
 
154
   qmonMirrorMultiAnswer(CENTRY_T, &alp);
 
155
   if (alp) {
 
156
      qmonMessageBox(w, alp, 0);
 
157
      lFreeList(&alp);
 
158
      /* set normal cursor */
 
159
      XmtDisplayDefaultCursor(w);
 
160
      DEXIT;
 
161
      return;
 
162
   }
 
163
   rll = qmonGetResources(qmonMirrorList(SGE_CENTRY_LIST), 
 
164
                                       REQUESTABLE_RESOURCES);
 
165
 
 
166
   hrl = qmonSubmitHR();
 
167
   lFreeList(&hard_requests);
 
168
   if (hrl) {
 
169
      hard_requests = lCopyList("hr", hrl);
 
170
      for_each(ep, hard_requests) {
 
171
         rp = lGetElemStr(rll, CE_name, lGetString(ep, CE_name));
 
172
         if (!rp)
 
173
            rp = lGetElemStr(rll, CE_shortcut, lGetString(ep, CE_name));
 
174
         if (rp) {
 
175
            lSetString(ep, CE_name, lGetString(rp, CE_name));
 
176
            lSetString(ep, CE_default, NULL);
 
177
            lSetUlong(ep, CE_valtype, lGetUlong(rp, CE_valtype)); 
 
178
         }
 
179
      }
 
180
   }   
 
181
   
 
182
   srl = qmonSubmitSR();
 
183
   lFreeList(&soft_requests);
 
184
   if (srl) {
 
185
      soft_requests = lCopyList("sr", srl);
 
186
      for_each(ep, soft_requests) {
 
187
         rp = lGetElemStr(rll, CE_name, lGetString(ep, CE_name));
 
188
         if (!rp)
 
189
            rp = lGetElemStr(rll, CE_shortcut, lGetString(ep, CE_name));
 
190
         if (rp) {
 
191
            lSetString(ep, CE_name, lGetString(rp, CE_name));
 
192
            lSetUlong(ep, CE_valtype, lGetUlong(rp, CE_valtype)); 
 
193
         }
 
194
      }
 
195
   }   
 
196
 
 
197
   /*
 
198
   ** do the drawing
 
199
   */
 
200
   qmonRequestDraw(request_rr, rll, 0);
 
201
   qmonRequestDraw(request_hr, hard_requests, 1);
 
202
   qmonRequestDraw(request_sr, soft_requests, 1);
 
203
 
 
204
   XtRealizeWidget(request_dialog);
 
205
 
 
206
   xmui_manage(request_dialog);
 
207
 
 
208
   DEXIT;
 
209
}
 
210
 
 
211
/*-------------------------------------------------------------------------*/
 
212
void qmonRequestDraw(
 
213
Widget w,
 
214
lList *lp,
 
215
int how 
 
216
) {
 
217
   IconListElement *items = NULL;
 
218
   int itemCount = 0;
 
219
   
 
220
   DENTER(GUI_LAYER, "qmonRequestDraw");
 
221
 
 
222
   XmIconListGetItems(w, &items, &itemCount);
 
223
   qmonCullToIconList(lp, how,  &items, &itemCount);
 
224
   XmIconListSetItems(w, items, itemCount);
 
225
   
 
226
   DEXIT;
 
227
}
 
228
   
 
229
 
 
230
/*-------------------------------------------------------------------------*/
 
231
static void qmonRequestRemoveResource(Widget w, XtPointer cld, XtPointer cad)
 
232
{
 
233
 
 
234
   XmIconListCallbackStruct *cbs = (XmIconListCallbackStruct*) cad;
 
235
 
 
236
   DENTER(GUI_LAYER, "qmonRequestRemoveResource");
 
237
 
 
238
   if (hard_soft) {
 
239
      if (soft_requests) {
 
240
         lDelElemStr(&soft_requests, CE_name, cbs->element->string[0]);
 
241
         qmonRequestDraw(request_sr, soft_requests, 1);
 
242
      }
 
243
   }
 
244
   else {
 
245
      if (hard_requests) {
 
246
         lDelElemStr(&hard_requests, CE_name, cbs->element->string[0]);
 
247
         qmonRequestDraw(request_hr, hard_requests, 1);
 
248
      }
 
249
   }
 
250
   
 
251
   DEXIT;
 
252
}
 
253
 
 
254
 
 
255
/*-------------------------------------------------------------------------*/
 
256
static void qmonRequestClear(Widget w, XtPointer cld, XtPointer cad)
 
257
{
 
258
 
 
259
 
 
260
   DENTER(GUI_LAYER, "qmonRequestClear");
 
261
 
 
262
   if (hard_soft) {
 
263
      if (soft_requests) {
 
264
         lFreeList(&soft_requests);
 
265
         qmonRequestDraw(request_sr, soft_requests, 1);
 
266
      }
 
267
   }
 
268
   else {
 
269
      if (hard_requests) {
 
270
         lFreeList(&hard_requests);
 
271
         qmonRequestDraw(request_hr, hard_requests, 1);
 
272
      }
 
273
   }
 
274
 
 
275
   DEXIT;
 
276
}
 
277
 
 
278
 
 
279
/*-------------------------------------------------------------------------*/
 
280
static void qmonToggleHardSoft2(Widget w, XtPointer cld, XtPointer cad)
 
281
{
 
282
   XmtChooserCallbackStruct *cbs = (XmtChooserCallbackStruct*) cad;
 
283
 
 
284
   DENTER(GUI_LAYER, "qmonToggleHardSoft");
 
285
   
 
286
   hard_soft = cbs->state; 
 
287
   if (hard_soft) {
 
288
      XtSetSensitive(request_sr, True);
 
289
      XtSetSensitive(request_hr, False);
 
290
   }
 
291
   else {
 
292
      XtSetSensitive(request_sr, False);
 
293
      XtSetSensitive(request_hr, True);
 
294
   }
 
295
 
 
296
   DEXIT;
 
297
}
 
298
 
 
299
/*-------------------------------------------------------------------------*/
 
300
static void qmonRequestOkay(Widget w, XtPointer cld, XtPointer cad)
 
301
{
 
302
 
 
303
   DENTER(GUI_LAYER, "qmonRequestOkay");
 
304
   
 
305
   xmui_unmanage(request_dialog);
 
306
 
 
307
   /*
 
308
   ** give the resources to the submit dialog
 
309
   */
 
310
   qmonSubmitSetResources(&hard_requests, &soft_requests);
 
311
   
 
312
   
 
313
   DEXIT;
 
314
}
 
315
 
 
316
/*-------------------------------------------------------------------------*/
 
317
static void qmonRequestCancel(Widget w, XtPointer cld, XtPointer cad)
 
318
{
 
319
 
 
320
   DENTER(GUI_LAYER, "qmonRequestCancel");
 
321
 
 
322
   xmui_unmanage(request_dialog);
 
323
   
 
324
   DEXIT;
 
325
}
 
326
 
 
327
 
 
328
 
 
329
/*-------------------------------------------------------------------------*/
 
330
lList *qmonGetResources(
 
331
lList *ce_list,
 
332
int how 
 
333
) {
 
334
   lList *lp = NULL;
 
335
   lList *entries = NULL;
 
336
   lCondition *where = NULL;
 
337
 
 
338
   DENTER(GUI_LAYER, "qmonGetResources");
 
339
 
 
340
   entries = ce_list;
 
341
   
 
342
   if (entries) {
 
343
      if (!lp) {
 
344
         lp = lCopyList("CE_entries", entries);
 
345
      }   
 
346
      else {
 
347
         lList *copy = lCopyList("CE_entries", entries);
 
348
         lAddList(lp, &copy);
 
349
      }
 
350
   }
 
351
 
 
352
   lUniqStr(lp, CE_name);
 
353
 
 
354
   if (how == REQUESTABLE_RESOURCES) { 
 
355
      where = lWhere("%T(%I == %u)", CE_Type, CE_requestable, REQU_YES);
 
356
      if (where)
 
357
         lp = lSelectDestroy(lp, where); 
 
358
   }
 
359
 
 
360
   DEXIT;
 
361
   return lp;
 
362
}
 
363
 
 
364
 
 
365
/*-------------------------------------------------------------------------*/
 
366
static int qmonCullToIconList(
 
367
lList *cel,
 
368
int how,
 
369
IconListElement **ice,
 
370
int *iceCount 
 
371
) {
 
372
   lListElem *cep;
 
373
   int count;
 
374
   IconListElement *elements, *current;
 
375
   int i, j;
 
376
   String *str;
 
377
   
 
378
   DENTER(GUI_LAYER, "qmonCullToIconList");
 
379
 
 
380
   count = lGetNumberOfElem(cel);
 
381
   if (count > 0) {
 
382
      elements = (IconListElement*)XtMalloc(sizeof(IconListElement)*count);
 
383
      current = elements;
 
384
      for_each(cep, cel) { 
 
385
         if (!how) {
 
386
            str = (String*)XtMalloc(sizeof(String));
 
387
            str[0] = XtNewString(lGetString(cep, CE_name));
 
388
            current->string = str;
 
389
            current->numStrings = 1;
 
390
         }
 
391
         else {
 
392
            str = (String*)XtMalloc(sizeof(String) * 3);
 
393
            str[0] = XtNewString(lGetString(cep, CE_name)); 
 
394
            str[1] = XtNewString("=="); 
 
395
            str[2] = XtNewString(lGetString(cep, CE_stringval)); 
 
396
            current->string = str;
 
397
            current->numStrings = 3;
 
398
         }
 
399
         current->iconPixmap.pixmap = 
 
400
                     qmonFetchTypeIcon((int)lGetUlong(cep, CE_valtype)); 
 
401
         current->iconPixmap.mask = 0;
 
402
         current->iconPixmap.isBitmap = False;
 
403
         current->iconPixmap.width = 16;
 
404
         current->iconPixmap.height = 16;
 
405
         
 
406
         current++;
 
407
      } 
 
408
   }
 
409
   else {
 
410
      elements = NULL;
 
411
      count = 0;
 
412
   }
 
413
 
 
414
   /*
 
415
   ** free old IconListElement entrys
 
416
   */
 
417
   for (i=0; *ice && i<*iceCount; i++) {
 
418
      if ((*ice)[i].string) {
 
419
         for (j=0; j<(*ice)[i].numStrings; j++) {
 
420
            if ((*ice)[i].string[j])
 
421
               XtFree((*ice)[i].string[j]);
 
422
         }
 
423
         XtFree((char*)(*ice)[i].string);
 
424
      }
 
425
   }
 
426
   XtFree((char*)*ice); 
 
427
 
 
428
   /* attach new entries */
 
429
   *ice = elements;
 
430
   *iceCount = count;
 
431
 
 
432
   DEXIT;
 
433
   return True;
 
434
}
 
435
 
 
436
/*-------------------------------------------------------------------------*/
 
437
static Pixmap qmonFetchTypeIcon(
 
438
int type 
 
439
) {
 
440
   Pixmap pix;
 
441
   
 
442
   DENTER(GUI_LAYER, "qmonFetchTypeIcon");
 
443
   
 
444
   switch (type) {
 
445
      case TYPE_INT:
 
446
      case TYPE_DOUBLE:
 
447
         pix = qmonGetIcon("int");
 
448
         break;
 
449
      case TYPE_TIM:
 
450
         pix = qmonGetIcon("time");
 
451
         break;
 
452
      case TYPE_STR:
 
453
         pix = qmonGetIcon("str");
 
454
         break;
 
455
      case TYPE_RESTR:
 
456
         pix = qmonGetIcon("unknown");
 
457
      case TYPE_BOO:
 
458
         pix = qmonGetIcon("bool");
 
459
         break;
 
460
      case TYPE_MEM:
 
461
         pix = qmonGetIcon("mem");
 
462
         break;
 
463
      case TYPE_HOST:
 
464
         pix = qmonGetIcon("host");
 
465
         break;
 
466
      case TYPE_CSTR:
 
467
         pix = qmonGetIcon("cstr");
 
468
         break;
 
469
      default:
 
470
         pix = qmonGetIcon("unknown");
 
471
   }
 
472
   DEXIT;
 
473
   return pix;
 
474
}
 
475
 
 
476
 
 
477
/*-------------------------------------------------------------------------*/
 
478
static void qmonRequestEditResource(Widget w, XtPointer cld, XtPointer cad)
 
479
{
 
480
   XmIconListCallbackStruct *cbs = (XmIconListCallbackStruct*) cad;
 
481
   long how = (long)cld;
 
482
   lList *rll;
 
483
   int type;
 
484
   char stringval[CL_MAXHOSTLEN];
 
485
   int status = 0;
 
486
   StringConst strval;
 
487
   lListElem *ep = NULL;
 
488
   
 
489
 
 
490
   DENTER(GUI_LAYER, "qmonRequestEditResource");
 
491
 
 
492
   rll = qmonGetResources(qmonMirrorList(SGE_CENTRY_LIST), 
 
493
                                       REQUESTABLE_RESOURCES); 
 
494
 
 
495
   if (!how)
 
496
      fill_in_request = lGetElemStr(rll, CE_name, cbs->element->string[0]);
 
497
   else {
 
498
      if (!hard_soft)
 
499
         fill_in_request = lGetElemStr(hard_requests, CE_name, 
 
500
                                          cbs->element->string[0]);
 
501
      else
 
502
         fill_in_request = lGetElemStr(soft_requests, CE_name, 
 
503
                                          cbs->element->string[0]);
 
504
   }
 
505
 
 
506
 
 
507
   if (!fill_in_request) {
 
508
      DEXIT;
 
509
      return;
 
510
   }
 
511
 
 
512
 
 
513
   type = lGetUlong(fill_in_request, CE_valtype);
 
514
   strval = lGetString(fill_in_request, CE_stringval);
 
515
   sge_strlcpy(stringval, strval, CL_MAXHOSTLEN);
 
516
 
 
517
   status = qmonRequestInput(w, type, cbs->element->string[0], 
 
518
                              stringval, sizeof(stringval));
 
519
   /* 
 
520
   ** put the value in the CE_Type elem 
 
521
   */
 
522
   if (status) {
 
523
      lSetString(fill_in_request, CE_stringval, stringval);
 
524
      lSetString(fill_in_request, CE_default, NULL);
 
525
    
 
526
      /* put it in the hard or soft resource list if necessary */
 
527
      if (!how) {
 
528
         if (hard_soft) {
 
529
            if (!soft_requests) {
 
530
               soft_requests = lCreateList("soft_requests", CE_Type);
 
531
            }
 
532
            if (!(ep = lGetElemStr(soft_requests, CE_name, 
 
533
                                    cbs->element->string[0]))) {
 
534
               lAppendElem(soft_requests, lCopyElem(fill_in_request));
 
535
            } else {
 
536
               lSetString(ep, CE_stringval, lGetString(fill_in_request, CE_stringval));
 
537
               lSetString(ep, CE_default, NULL);
 
538
            }   
 
539
               
 
540
         }
 
541
         else {
 
542
            if (!hard_requests) {
 
543
               hard_requests = lCreateList("hard_requests", CE_Type);
 
544
            }
 
545
            if (!(ep = lGetElemStr(hard_requests, CE_name, 
 
546
                                    cbs->element->string[0]))) {
 
547
               lAppendElem(hard_requests, lCopyElem(fill_in_request));
 
548
            } else {
 
549
               lSetString(ep, CE_stringval, lGetString(fill_in_request, CE_stringval));
 
550
               lSetString(ep, CE_default, NULL);
 
551
            }
 
552
         }
 
553
      }
 
554
      qmonRequestDraw(request_sr, soft_requests, 1);
 
555
      qmonRequestDraw(request_hr, hard_requests, 1);
 
556
   }
 
557
 
 
558
   DEXIT;
 
559
}
 
560
 
 
561
 
 
562
/*-------------------------------------------------------------------------*/
 
563
Boolean qmonRequestInput(
 
564
Widget w,
 
565
int type,
 
566
String resource,
 
567
String stringval,
 
568
int maxlen 
 
569
) {
 
570
   int ret = 0;
 
571
   char unique[CL_MAXHOSTLEN];
 
572
   int intval=0;
 
573
   Boolean status = False;
 
574
   double dval = 0.0;
 
575
   
 
576
   DENTER(GUI_LAYER, "qmonRequestInput");
 
577
 
 
578
   /* 
 
579
   ** call the type specific dialog
 
580
   ** stringval contains the string that has to be displayed in  
 
581
   ** the hard/soft resource list
 
582
   */
 
583
   switch (type) {
 
584
      case TYPE_INT:
 
585
         status = XmtAskForInteger(w, NULL, 
 
586
                     "@{Enter an integer value}", &intval, 0, 0,
 
587
                     NULL);
 
588
         sprintf(stringval, "%d", intval);
 
589
         break;
 
590
      case TYPE_DOUBLE:
 
591
         status = XmtAskForDouble(w, NULL, 
 
592
                     "@{Enter a double value}", &dval, 0, 0,
 
593
                     NULL);
 
594
         sprintf(stringval, "%f", dval);
 
595
         break;
 
596
      case TYPE_STR:
 
597
         status = XmtAskForString(w, NULL, "@{Enter a string value}",
 
598
                     stringval, maxlen, NULL);
 
599
         if (stringval[0] == '\0')
 
600
            status = False;
 
601
         break;
 
602
      case TYPE_CSTR:
 
603
         status = XmtAskForString(w, NULL, "@{Enter a uppercase string value}", stringval, maxlen, NULL);
 
604
         if (stringval[0] == '\0')
 
605
            status = False;
 
606
         break;
 
607
       case TYPE_RESTR:
 
608
         status = XmtAskForString(w, NULL, "@{Enter a string value}", stringval, maxlen, NULL);
 
609
         if (stringval[0] == '\0')
 
610
            status = False;
 
611
         break;
 
612
      case TYPE_HOST:
 
613
         status = XmtAskForString(w, NULL, "@{Enter a valid hostname}", stringval, maxlen, NULL);
 
614
         if (status && stringval[0] != '\0') {
 
615
            /* try to resolve hostname */
 
616
            ret=sge_resolve_hostname(stringval, unique, EH_name);
 
617
            switch ( ret ) {
 
618
               case CL_RETVAL_GETHOSTNAME_ERROR:
 
619
                  qmonMessageShow(w, True, "Can't resolve host '%s'", stringval);
 
620
                  status = False;
 
621
                  break;
 
622
               case CL_RETVAL_OK:
 
623
                  strcpy(stringval, unique);
 
624
                  break; 
 
625
               default:
 
626
                  DPRINTF(("sge_resolve_hostname() failed resolving: %s\n", cl_get_error_text(ret)));
 
627
            }
 
628
         }
 
629
         else
 
630
            status = False;
 
631
         break;
 
632
      case TYPE_TIM:
 
633
         status = XmtAskForTime(w, NULL, "@{Enter a time value}", stringval, maxlen, NULL, True);
 
634
         if (stringval[0] == '\0')
 
635
            status = False;
 
636
         break;
 
637
      case TYPE_MEM:
 
638
         status = XmtAskForMemory(w, NULL, "@{Enter a memory value}", stringval, maxlen, NULL);
 
639
         if (stringval[0] == '\0')
 
640
            status = False;
 
641
         break;
 
642
      case TYPE_BOO:
 
643
         XmtAskForBoolean(w, NULL, "@{Click TRUE or FALSE}", "TRUE", "FALSE", NULL,
 
644
                                    XmtYesButton, XmDIALOG_INFORMATION, False,
 
645
                                    &status, NULL);
 
646
         if (status)
 
647
            strcpy(stringval, "true");
 
648
         else
 
649
            strcpy(stringval, "false");
 
650
            
 
651
         status = True;
 
652
         break;
 
653
   }
 
654
 
 
655
   DEXIT;
 
656
   return status;
 
657
}