source: trunk/FACT++/dim/src/did/didMarkus.c@ 11069

Last change on this file since 11069 was 10614, checked in by tbretz, 14 years ago
New release V19 r20
File size: 77.7 KB
Line 
1#include <stdio.h>
2#include <ctype.h>
3#include <time.h>
4#include <dim.h>
5#include <dic.h>
6#include <dis.h>
7#include "did.h"
8
9int First_time = 1;
10int Curr_view_opt = -1;
11char Curr_view_opt_par[80];
12char Curr_service_name[132];
13char Curr_service_format[256];
14int Curr_service_print_type = 0;
15int N_servers = 0;
16int N_services = 0;
17int no_link_int = -1;
18FILE *fptr;
19
20char *Service_content_str;
21char *Service_buffer;
22int Service_size;
23char *Curr_service_list = 0;
24char *Curr_client_list = 0;
25int Curr_service_id = 0;
26Widget Curr_client_id;
27Widget Curr_service_list_id;
28SERVER *Got_Service_List = 0;
29SERVER *Got_Client_List = 0;
30
31Widget SubscribeButton;
32Widget Subscribe10Button;
33
34int Timer_q;
35
36int Force_update = 0;
37/*
38 * Global data
39 */
40static XmFontList did_default_font, did_small_font,
41 did_label_font, did_server_font;
42
43/*static MrmType class_id;*/ /* Place to keep class ID*/
44/*static MrmType *dummy_class;*/ /* and class variable. */
45
46/*static char *db_filename_vec[1];*/ /* Mrm.hierachy file list. */
47/*static int db_filename_num;*/
48
49/*
50 * Forward declarations
51 */
52void did_exit();
53void create_main();
54void create_label();
55void create_matrix();
56void view_opts();
57void dns_control();
58void ok_pop_up();
59void cancel_pop_up();
60
61extern void set_something();
62extern void get_something();
63extern void set_color();
64
65/*
66 * Names and addresses of callback routines to register with Mrm
67 */
68/*
69static MrmRegisterArg reglist [] = {
70{"did_exit", (caddr_t)did_exit},
71{"create_main", (caddr_t)create_main},
72{"create_label", (caddr_t)create_label},
73{"create_matrix", (caddr_t)create_matrix},
74{"view_opts", (caddr_t)view_opts},
75{"dns_control", (caddr_t)dns_control},
76{"ok_pop_up", (caddr_t)ok_pop_up},
77{"cancel_pop_up", (caddr_t)cancel_pop_up},
78};
79
80static int reglist_num = (sizeof reglist / sizeof reglist[0]);
81*/
82/*
83 * OS transfer point. The main routine does all the one-time setup and
84 * then calls XtAppMainLoop.
85 */
86
87SERVER *Curr_servp;
88
89XmFontList util_get_font( char *fontname, Widget top )
90{
91XFontStruct * mf;
92XmFontList font;
93/*
94char * fontname;
95
96 if ( size == 'm' ) {
97 fontname = MENU_FONT;
98 }
99 else if ( size == 'b' ) {
100 fontname = LABEL_FONT;
101 }
102 else {
103 fontname = DEFAULT_FONT;
104 }
105*/
106 if ( (mf = XLoadQueryFont(XtDisplay(top),fontname))==NULL) {
107 printf("Couldn't open the following fonts:\n\t%s\n",
108 fontname);
109 XtVaGetValues ( top, XmNdefaultFontList, &font, NULL );
110 }
111 else {
112 font = XmFontListCreate (mf, XmSTRING_DEFAULT_CHARSET);
113 }
114 return font;
115}
116
117void create_matrix_widget()
118{
119Widget row_col_id, top_id;
120Arg arglist[10];
121int n = 0;
122char w_name[MAX_NAME];
123
124 top_id = Window_id;
125 XtSetArg(arglist[n], XmNborderWidth, 0); n++;
126 XtSetArg(arglist[n], XmNorientation, XmVERTICAL); n++;
127 XtSetArg(arglist[n], XmNnumColumns, 4); n++;
128 XtSetArg(arglist[n], XmNpacking, XmPACK_COLUMN); n++;
129 XtSetArg(arglist[n], XmNadjustLast, False); n++;
130 sprintf(w_name,"matrix_row");
131 row_col_id = XmCreateRowColumn(top_id,w_name,arglist,n);
132 XtManageChild(row_col_id);
133 Matrix_id[Curr_matrix] = row_col_id;
134 /*
135 XmScrolledWindowSetAreas(Window_id,NULL, NULL, Matrix_id);
136 */
137}
138
139void gui_create_main_window(Widget parent)
140{
141
142Widget mw;
143Widget mb;
144Widget mf;
145Widget tl;
146Widget sl;
147Widget f;
148XmString xms;
149int par;
150int reason;
151Arg ar[20];
152int n;
153
154 mw = XmCreateMainWindow ( parent, "DidMainWindow", NULL, 0 );
155 XtVaSetValues( mw,
156 XmNresizePolicy, XmRESIZE_ANY,
157
158 XmNfontList, did_default_font,
159 NULL);
160 XtManageChild( mw );
161 /* create menu bar */
162 mb = XmCreateMenuBar ( mw, "DidMenuBar", NULL, 0 );
163 XtVaSetValues( mb,
164 XmNmarginHeight,2,
165 XmNborderWidth, 0,
166 XmNfontList, did_default_font,
167 NULL);
168
169 gui_create_main_menu( mb );
170 XtManageChild ( mb );
171
172 /* create main form */
173 mf = XmCreateForm ( mw, "DidMainForm", NULL, 0 );
174 XtVaSetValues ( mf,
175 XmNresizePolicy, XmRESIZE_NONE,
176
177 NULL );
178 XtManageChild ( mf );
179
180 /* create top label */
181 xms = create_str(" \n ");
182
183 tl = XmCreateLabel ( mf, "DidTitle", NULL, 0 );
184 XtVaSetValues( tl,
185 XmNtopAttachment, XmATTACH_FORM,
186 XmNbottomAttachment, XmATTACH_NONE,
187 XmNleftAttachment, XmATTACH_FORM,
188 XmNrightAttachment, XmATTACH_FORM,
189 XmNleftOffset, 0,
190 XmNtopOffset, 0,
191 XmNbottomOffset, 0,
192 XmNrightOffset, 0,
193 XmNborderWidth, 0,
194 XmNlabelString, xms,
195 XmNshadowThickness, 0,
196 XmNhighlightThickness, 0,
197 XmNheight, 32,
198 XmNalignment, XmALIGNMENT_CENTER,
199 XmNfontList, did_label_font,
200 NULL);
201 XtManageChild( tl );
202/*
203 tl = XtVaCreateManagedWidget( "SmiTitle",
204 xmPushButtonWidgetClass, mw,
205 XmNborderWidth, 0,
206 XmNlabelString, xms,
207 XmNshadowThickness, 0,
208 XmNhighlightThickness, 0,
209 XmNalignment, XmALIGNMENT_CENTER,
210 XmNfontList, smid_label_font,
211 NULL);
212*/
213 XmStringFree ( xms );
214 /*
215 XtAddCallback(tl, MrmNcreateCallback,
216 (XtCallbackProc)create_label, 0);
217 */
218 par = 0;
219 reason = 0;
220 create_label(tl, &par, &reason);
221
222 /* create main form */
223 /*
224 mf = (Widget)XmCreateForm ( mw, "DidMainForm", NULL, 0 );
225 XtVaSetValues ( mf,
226 XmNborderWidth,1,
227 XmNshadowThickness, 2,
228 XmNwidth,806,
229 XmNheight,300,
230
231 XmNresizePolicy, XmRESIZE_NONE, NULL );
232 XtManageChild ( mf );
233 */
234 /*
235 XtAddCallback(mf, MrmNcreateCallback,
236 (XtCallbackProc)create_main, 0);
237 */
238
239 create_main(mf, &par, &reason);
240
241 f = XmCreateForm( mf, "ScrollForm", NULL, 0 );
242 XtVaSetValues ( f,
243 XmNwidth, 806,
244 XmNheight,300,
245 XmNtopAttachment, XmATTACH_WIDGET,
246 XmNbottomAttachment, XmATTACH_FORM,
247 XmNleftAttachment, XmATTACH_FORM,
248 XmNrightAttachment, XmATTACH_FORM,
249 XmNrightOffset, 0,
250 XmNleftOffset, 0,
251 XmNbottomOffset, 0,
252 XmNtopWidget, tl,
253 XmNtopOffset, 0,
254 XmNshadowThickness, 2,
255 XmNbottomOffset, 0,
256 /*
257 XmNshadowType, XmSHADOW_OUT,
258 */
259 XmNborderWidth,0,
260 NULL);
261
262 /*
263 f = XtVaCreateManagedWidget ( "XDScrolledForm",
264 xmFormWidgetClass, mf,
265 XmNtopAttachment, XmATTACH_WIDGET,
266 XmNbottomAttachment, XmATTACH_FORM,
267 XmNleftAttachment, XmATTACH_FORM,
268 XmNrightAttachment, XmATTACH_FORM,
269 XmNrightOffset, 0,
270 XmNleftOffset, 0,
271 XmNbottomOffset, 0,
272 XmNtopWidget, tl,
273 XmNtopOffset, 0,
274 XmNshadowThickness, 2,
275 XmNbottomOffset, 0,
276 XmNshadowType, XmSHADOW_OUT,
277 XmNborderWidth,1,
278 NULL);
279*/
280 /*
281 XtAddCallback(f, MrmNcreateCallback,
282 (XtCallbackProc)create_window, 0);
283 */
284
285 XtManageChild ( f );
286 /* create scrolled list */
287
288 n = 0;
289 XtSetArg ( ar[n], XmNtopAttachment, XmATTACH_FORM); n++;
290 XtSetArg ( ar[n], XmNbottomAttachment, XmATTACH_FORM); n++;
291 XtSetArg ( ar[n], XmNleftAttachment, XmATTACH_FORM); n++;
292 XtSetArg ( ar[n], XmNrightAttachment, XmATTACH_FORM); n++;
293 XtSetArg ( ar[n], XmNrightOffset, 0); n++;
294 XtSetArg ( ar[n], XmNleftOffset, 0); n++;
295 XtSetArg ( ar[n], XmNbottomOffset, 0); n++;
296 XtSetArg ( ar[n], XmNtopOffset, 0); n++;
297 /*
298 XtSetArg ( ar[n], XmNvisualPolicy, XmCONSTANT); n++;
299 */
300 XtSetArg ( ar[n], XmNscrollBarDisplayPolicy, XmAS_NEEDED); n++;
301
302 XtSetArg ( ar[n], XmNscrollingPolicy, XmAUTOMATIC); n++;
303
304 sl = XmCreateScrolledWindow ( f, "ScrollWin", ar, n );
305 /*
306 XtVaSetValues ( sl,
307 XmNtopAttachment, XmATTACH_FORM,
308 XmNbottomAttachment, XmATTACH_FORM,
309 XmNleftAttachment, XmATTACH_FORM,
310 XmNrightAttachment, XmATTACH_FORM,
311 XmNrightOffset, 0,
312 XmNleftOffset, 0,
313 XmNbottomOffset, 0,
314 XmNtopOffset, 0,
315
316 XmNvisualPolicy, XmCONSTANT,
317
318 XmNscrollBarDisplayPolicy, XmSTATIC,
319
320 XmNscrollingPolicy, XmAUTOMATIC,
321
322 NULL);
323 */
324 XtManageChild ( sl );
325 /*
326 create_window(sl, &par, &reason);
327 */
328 Window_id = sl;
329
330 create_matrix_widget();
331
332/*
333 sl = XtVaCreateWidget ( "DidServersScrl",
334 xmScrolledWindowWidgetClass, f,
335 XmNscrollingPolicy, XmAUTOMATIC,
336 XmNscrollBarDisplayPolicy, XmSTATIC,
337 XmNtopAttachment, XmATTACH_FORM,
338 XmNleftAttachment, XmATTACH_FORM,
339 XmNrightAttachment, XmATTACH_FORM,
340 XmNbottomAttachment, XmATTACH_FORM,
341 XmNvisualPolicy, XmCONSTANT,
342 XmNtopOffset, 4,
343 XmNleftOffset, 4,
344 XmNbottomOffset, 4,
345 XmNrightOffset, 4,
346 NULL );
347 XtManageChild ( sl );
348*/
349 /*
350 XtVaSetValues( mw,
351 XmNworkWindow,mf,
352 XmNcommandWindow, tl,
353 NULL);
354 */
355
356}
357
358Widget create_separator(Widget parent_id)
359{
360 Widget w;
361 Arg arglist[10];
362 int n = 0;
363
364 w = XmCreateSeparator(parent_id, "separator",
365 arglist,n);
366 XtManageChild(w);
367 return(w);
368}
369
370void gui_create_main_menu( Widget mb )
371{
372Widget cb;
373Widget mn;
374Widget bt;
375XmString xms;
376 /* File */
377 mn = XmCreatePulldownMenu ( mb, "FileMB", NULL, 0 );
378 cb = XmCreateCascadeButton(mb, "File", NULL, 0);
379 XtVaSetValues ( cb,
380 XmNsubMenuId, mn,
381 NULL);
382 XtManageChild ( cb );
383 /*
384 cb = XtVaCreateManagedWidget ( "File",
385 xmCascadeButtonWidgetClass, mb,
386 XtVaTypedArg, XmNmnemonic, XmRString, "F", 2,
387 XmNsubMenuId, mn,
388 NULL);
389 */
390 XtVaSetValues ( mn,
391 XmNradioAlwaysOne, True,
392 XmNradioBehavior, True,
393 NULL);
394 XtVaSetValues ( cb,
395 XmNfontList, did_default_font,
396 NULL);
397 /* buttons */
398 xms = create_str ("Exit DID");
399 /*
400 bt = XtVaCreateManagedWidget ( "MenuExitButton",
401 xmPushButtonWidgetClass, mn,
402 XmNlabelString, xms,
403 XmNaccelerator, "Ctrl<Key>C",
404 XmNacceleratorText, xma,
405 NULL);
406 */
407 bt = XmCreatePushButton ( mn, "button", NULL, 0 );
408 XtVaSetValues( bt,
409 XmNlabelString, xms,
410 XmNfontList, did_default_font,
411 NULL);
412 XtManageChild( bt );
413 XmStringFree ( xms );
414 XtAddCallback ( bt, XmNactivateCallback, (XtCallbackProc)did_exit, 0 );
415 /*
416 util_recolor ( XtParent(mn) );
417 */
418 /* View */
419 mn = XmCreatePulldownMenu ( mb, "ViewMB", NULL, 0 );
420 cb = XmCreateCascadeButton(mb, "View", NULL, 0);
421 XtVaSetValues ( cb,
422 XmNsubMenuId, mn,
423 NULL);
424 XtVaSetValues ( cb,
425 XmNfontList, did_default_font,
426 NULL);
427 XtManageChild ( cb );
428 /*
429 cb = XtVaCreateManagedWidget ( "View",
430 xmCascadeButtonWidgetClass, mb,
431 XtVaTypedArg, XmNmnemonic, XmRString, "V", 2,
432 XmNsubMenuId, mn,
433 NULL);
434 */
435 XtVaSetValues ( mn,
436 XmNradioAlwaysOne, True,
437 XmNradioBehavior, True,
438 NULL);
439 /* buttons */
440
441 xms = create_str ("All Servers");
442 /*
443 bt = XtVaCreateManagedWidget ( "V_MenuAllButton",
444 xmPushButtonWidgetClass, mn,
445 XmNlabelString, xms,
446 XmNaccelerator, "Ctrl<Key>A",
447 XmNacceleratorText, xma,
448 NULL);
449 */
450 bt = XmCreatePushButton ( mn, "button", NULL, 0 );
451 XtVaSetValues( bt,
452 XmNlabelString, xms,
453 XmNfontList, did_default_font,
454 NULL);
455 XtManageChild( bt );
456 XmStringFree ( xms );
457 XtAddCallback ( bt, XmNactivateCallback, (XtCallbackProc)view_opts,
458 (XtPointer)1 );
459
460 xms = create_str ("Servers by Node");
461 /*
462 bt = XtVaCreateManagedWidget ( "V_MenuNodeButton",
463 xmPushButtonWidgetClass, mn,
464 XmNlabelString, xms,
465 XmNaccelerator, "Ctrl<Key>N",
466 XmNacceleratorText, xma,
467 NULL);
468 XmStringFree ( xms );
469 */
470 bt = XmCreatePushButton ( mn, "button", NULL, 0 );
471 XtVaSetValues( bt,
472 XmNlabelString, xms,
473 XmNfontList, did_default_font,
474 NULL);
475 XtManageChild( bt );
476 XmStringFree ( xms );
477 XtAddCallback ( bt, XmNactivateCallback, (XtCallbackProc)view_opts,
478 (XtPointer)0 );
479
480 xms = create_str ("Servers by Service");
481 /*
482 bt = XtVaCreateManagedWidget ( "V_MenuServiceButton",
483 xmPushButtonWidgetClass, mn,
484 XmNlabelString, xms,
485 XmNaccelerator, "Ctrl<Key>S",
486 XmNacceleratorText, xma,
487 NULL);
488 XmStringFree ( xms );
489 XmStringFree ( xma );
490 */
491 bt = XmCreatePushButton ( mn, "button", NULL, 0 );
492 XtVaSetValues( bt,
493 XmNlabelString, xms,
494 XmNfontList, did_default_font,
495 NULL);
496 XtManageChild( bt );
497 XmStringFree ( xms );
498 XtAddCallback ( bt, XmNactivateCallback, (XtCallbackProc)view_opts,
499 (XtPointer)2 );
500
501 create_separator(mn);
502 /*
503 bt = XtVaCreateManagedWidget ( "W_MenuSep",
504 xmSeparatorGadgetClass, mn,
505 NULL);
506 */
507 xms = create_str ("Servers in Error");
508 /*
509 bt = XtVaCreateManagedWidget ( "V_MenuErrorButton",
510 xmPushButtonWidgetClass, mn,
511 XmNlabelString, xms,
512 XmNaccelerator, "Ctrl<Key>E",
513 XmNacceleratorText, xma,
514 NULL);
515 XmStringFree ( xms );
516 XmStringFree ( xma );
517 */
518 bt = XmCreatePushButton ( mn, "button", NULL, 0 );
519 XtVaSetValues( bt,
520 XmNlabelString, xms,
521 XmNfontList, did_default_font,
522 NULL);
523 XtManageChild( bt );
524 XmStringFree ( xms );
525 XtAddCallback ( bt, XmNactivateCallback, (XtCallbackProc)view_opts,
526 (XtPointer)3 );
527 /*
528 util_recolor ( XtParent(mn) );
529 */
530 /* Commands */
531 mn = XmCreatePulldownMenu ( mb, "CommandMB", NULL, 0 );
532 cb = XmCreateCascadeButton(mb, "Commands", NULL, 0);
533 XtVaSetValues ( cb,
534 XmNsubMenuId, mn,
535 NULL);
536 XtVaSetValues ( cb,
537 XmNfontList, did_default_font,
538 NULL);
539 XtManageChild ( cb );
540 /*
541 cb = XtVaCreateManagedWidget ( "Commands",
542 xmCascadeButtonWidgetClass, mb,
543 XtVaTypedArg, XmNmnemonic, XmRString, "C", 2,
544 XmNsubMenuId, mn,
545 XmNsensitive, commands_enable,
546 NULL);
547 */
548 /* buttons */
549 /* Utils */
550 /*
551 xms = util_create_str ("Show Command Buttons");
552 xma = util_create_str ("Ctrl+B");
553 bt = XtVaCreateManagedWidget ( "C_ShowCmndButt",
554 xmToggleButtonWidgetClass, mn,
555 XmNlabelString, xms,
556 XmNaccelerator, "Ctrl<Key>B",
557 XmNacceleratorText, xma,
558 XmNset, False,
559 XmNindicatorSize,12,
560 XmNvisibleWhenOff, True,
561 NULL);
562 XmStringFree ( xms );
563 XmStringFree ( xma );
564 XtAddCallback ( bt, XmNvalueChangedCallback, (XtCallbackProc)show_command_buttons_callback, NULL );
565
566 bt = XtVaCreateManagedWidget ( "W_MenuSep",
567 xmSeparatorGadgetClass, mn,
568 NULL);
569 */
570
571 xms = create_str ("LOG Connections");
572 /*
573 bt = XtVaCreateManagedWidget ( "C_MenuButtonLOG",
574 xmPushButtonWidgetClass, mn,
575 XmNlabelString, xms,
576 XmNaccelerator, "Ctrl<Key>G",
577 XmNacceleratorText, xma,
578 NULL);
579 XmStringFree ( xms );
580 XmStringFree ( xma );
581 XtAddCallback ( bt, XmNactivateCallback, (XtCallbackProc)dns_control_callback, "log" );
582 */
583 bt = XmCreatePushButton ( mn, "button", NULL, 0 );
584 XtVaSetValues( bt,
585 XmNlabelString, xms,
586 XmNfontList, did_default_font,
587 NULL);
588 XtManageChild( bt );
589 XmStringFree ( xms );
590 XtAddCallback ( bt, XmNactivateCallback, (XtCallbackProc)dns_control,
591 (XtPointer)0 );
592
593 create_separator(mn);
594 /*
595 bt = XtVaCreateManagedWidget ( "W_MenuSep",
596 xmSeparatorGadgetClass, mn,
597 NULL);
598 */
599 xms = create_str ("Set Debug ON");
600 /*
601 bt = XtVaCreateManagedWidget ( "C_MenuButtonDON",
602 xmPushButtonWidgetClass, mn,
603 XmNlabelString, xms,
604 XmNaccelerator, "<Key>F2:",
605 XmNacceleratorText, xma,
606 NULL);
607 XmStringFree ( xms );
608 XmStringFree ( xma );
609 XtAddCallback ( bt, XmNactivateCallback, (XtCallbackProc)dns_control_callback, "on" );
610 */
611 bt = XmCreatePushButton ( mn, "button", NULL, 0 );
612 XtVaSetValues( bt,
613 XmNlabelString, xms,
614 XmNfontList, did_default_font,
615 NULL);
616 XtManageChild( bt );
617 XmStringFree ( xms );
618 XtAddCallback ( bt, XmNactivateCallback, (XtCallbackProc)dns_control,
619 (XtPointer)1 );
620
621 xms = create_str ("Set Debug OFF");
622 /*
623 bt = XtVaCreateManagedWidget ( "C_MenuButtonDOFF",
624 xmPushButtonWidgetClass, mn,
625 XmNlabelString, xms,
626 XmNaccelerator, "<Key>F3:",
627 XmNacceleratorText, xma,
628 NULL);
629 XmStringFree ( xms );
630 XmStringFree ( xma );
631 XtAddCallback ( bt, XmNactivateCallback, (XtCallbackProc)dns_control_callback, "off" );
632 */
633 bt = XmCreatePushButton ( mn, "button", NULL, 0 );
634 XtVaSetValues( bt,
635 XmNlabelString, xms,
636 XmNfontList, did_default_font,
637 NULL);
638 XtManageChild( bt );
639 XmStringFree ( xms );
640 XtAddCallback ( bt, XmNactivateCallback, (XtCallbackProc)dns_control,
641 (XtPointer)2 );
642
643 create_separator(mn);
644 /*
645 bt = XtVaCreateManagedWidget ( "W_MenuSep",
646 xmSeparatorGadgetClass, mn,
647 NULL);
648 */
649 xms = create_str ("Print Hash Table");
650 /*
651 bt = XtVaCreateManagedWidget ( "C_MenuButtonPrint",
652 xmPushButtonWidgetClass, mn,
653 XmNlabelString, xms,
654 XmNaccelerator, "Ctrl<Key>T",
655 XmNacceleratorText, xma,
656 NULL);
657 XmStringFree ( xms );
658 XmStringFree ( xma );
659 XtAddCallback ( bt, XmNactivateCallback, (XtCallbackProc)dns_control_callback, "hash" );
660 */
661 bt = XmCreatePushButton ( mn, "button", NULL, 0 );
662 XtVaSetValues( bt,
663 XmNlabelString, xms,
664 XmNfontList, did_default_font,
665 NULL);
666 XtManageChild( bt );
667 XmStringFree ( xms );
668 XtAddCallback ( bt, XmNactivateCallback, (XtCallbackProc)dns_control,
669 (XtPointer)4 );
670 /* kill
671 create_separator(mn);
672 */
673 /*
674 bt = XtVaCreateManagedWidget ( "W_MenuSep",
675 xmSeparatorGadgetClass, mn,
676 NULL);
677 */
678 /* kill
679 xms = create_str ("Kill DIM Servers");
680 */
681 /*
682 bt = XtVaCreateManagedWidget ( "C_MenuButtonKill",
683 xmPushButtonWidgetClass, mn,
684 XmNlabelString, xms,
685 XmNaccelerator, "Ctrl<Key>K",
686 XmNacceleratorText, xma,
687 NULL);
688 XmStringFree ( xms );
689 XmStringFree ( xma );
690 XtAddCallback ( bt, XmNactivateCallback, (XtCallbackProc)dns_control_callback, "kill" );
691 */
692 /* kill
693 bt = XmCreatePushButton ( mn, "button", NULL, 0 );
694 XtVaSetValues( bt,
695 XmNlabelString, xms,
696 XmNfontList, did_default_font,
697 NULL);
698 XtManageChild( bt );
699 XmStringFree ( xms );
700 XtAddCallback ( bt, XmNactivateCallback, (XtCallbackProc)dns_control,
701 (XtPointer)3 );
702 */
703 /*
704 util_recolor ( XtParent(mn) );
705 */
706 /* Help */
707 mn = XmCreatePulldownMenu ( mb, "HelpMB", NULL, 0 );
708 /*
709 cb = XtVaCreateManagedWidget ( "Help",
710 xmCascadeButtonWidgetClass, mb,
711 XtVaTypedArg, XmNmnemonic, XmRString, "H", 2,
712 XmNsubMenuId, mn,
713 NULL);
714 */
715 cb = XmCreateCascadeButton ( mb, "Help", NULL, 0 );
716 XtVaSetValues( cb,
717 XmNsubMenuId, mn,
718 XmNfontList, did_default_font,
719 NULL);
720 XtManageChild( cb );
721
722 xms = create_str ("Help");
723 /*
724 bt = XtVaCreateManagedWidget ( "C_XDAbout",
725 xmPushButtonWidgetClass, mn,
726 XmNlabelString, xms,
727 XmNaccelerator, "Ctrl<Key>H",
728 XmNacceleratorText, xma,
729 NULL);
730 */
731 bt = XmCreatePushButton ( mn, "button", NULL, 0 );
732 XtVaSetValues( bt,
733 XmNlabelString, xms,
734 XmNfontList, did_default_font,
735 NULL);
736 XtManageChild( bt );
737 XmStringFree ( xms );
738 /*
739 XtAddCallback ( bt, XmNactivateCallback, (XtCallbackProc)about_xd_callback, NULL );
740 */
741 /* set help menu */
742 XtVaSetValues ( mb, XmNmenuHelpWidget, cb, NULL );
743 /*
744 util_recolor ( XtParent(mn) );
745 */
746}
747
748
749Widget gui_toplevel(char **argv)
750{
751int n;
752Arg arglist[6];
753
754 n = 0;
755 XtSetArg ( arglist[n], XmNallowShellResize, True); n++;
756 XtSetArg ( arglist[n], XmNiconName, "DID"); n++;
757 XtSetArg ( arglist[n], XmNtitle, "xDid"); n++;
758 XtSetArg ( arglist[n], XmNtraversalOn,True); n++;
759 return XtAppCreateShell(argv[0], NULL, applicationShellWidgetClass,
760 display, arglist, n);
761
762}
763
764Widget gui_initialize (int argc, char **argv)
765{
766Widget toplevel;
767void gui_create_main_window();
768
769 XtToolkitInitialize();
770 app_context = XtCreateApplicationContext();
771 display = XtOpenDisplay(app_context, NULL, argv[0], "DID",
772 NULL, 0, &argc, argv);
773 if (display == NULL)
774 {
775 printf("%s: Can't open display\n", argv[0]);
776 exit(1);
777 }
778 toplevel = gui_toplevel(argv);
779
780 did_default_font = (XmFontList)util_get_font(DEFAULT_FONT, toplevel);
781 did_small_font = (XmFontList)util_get_font(MENU_FONT, toplevel);
782 did_label_font = (XmFontList)util_get_font(LABEL_FONT, toplevel);
783 did_server_font = (XmFontList)util_get_font(SERVER_FONT, toplevel);
784
785 gui_create_main_window(toplevel);
786
787 XtRealizeWidget ( toplevel );
788 return toplevel;
789}
790
791int main(int argc, char *argv[])
792{
793 int i;
794 char opt_str[20], *ptr;
795 XtInputMask mask;
796 void do_got_service_list();
797 void do_show_clients();
798 void app_initialize();
799
800 dim_no_threads();
801 dic_disable_padding();
802 dis_disable_padding();
803
804 if(argc > 1)
805 {
806 if(argv[1][0] == '-')
807 {
808 sprintf(opt_str,"%s",&argv[1][1]);
809 if((!strncmp(opt_str,"node",4)) ||
810 (!strncmp(opt_str,"NODE",4)))
811 Curr_view_opt = 0;
812 else if((!strncmp(opt_str,"all",3)) ||
813 (!strncmp(opt_str,"ALL",3)))
814 Curr_view_opt = 1;
815 else if((!strncmp(opt_str,"service",7)) ||
816 (!strncmp(opt_str,"SERVICE",7)))
817 Curr_view_opt = 2;
818 else if((!strncmp(opt_str,"error",5)) ||
819 (!strncmp(opt_str,"ERROR",5)))
820 Curr_view_opt = 3;
821 else if((!strncmp(opt_str,"help",4)) ||
822 (!strncmp(opt_str,"HELP",4)))
823 {
824 printf("Did - DIM Information Display\n");
825 printf("\t-all Show ALL Servers\n");
826 printf("\t-service=<str> Show Servers providing Service <str>\n");
827 printf("\t-node=<nodename> Show Servers on Node <nodename>\n");
828 printf("\t-error Show Servers in Error\n");
829 printf("\t-help Show this message\n\n");
830 exit(0);
831 }
832 else
833 Curr_view_opt = -1;
834 if((Curr_view_opt == 0) || (Curr_view_opt == 2))
835 {
836 if(!(ptr = strchr(argv[1],'=')))
837 {
838 if( (ptr = strchr(argv[2],'=')) )
839 {
840 ptr++;
841 if(!(*ptr))
842 ptr = argv[3];
843 }
844 else
845 ptr++;
846 }
847 else
848 {
849 ptr++;
850 if(!(*ptr))
851 ptr = argv[2];
852 }
853 for(i = 0;*ptr; ptr++, i++)
854 Curr_view_opt_par[i] = toupper(*ptr);
855 Curr_view_opt_par[i] = '\0';
856 }
857 }
858 }
859
860 toplevel_widget = (Widget)gui_initialize(argc, argv);
861 app_initialize();
862 /*
863 * Sit around forever waiting to process X-events. We never leave
864 * XtAppMainLoop. From here on, we only execute our callback routines.
865 */
866
867 while(1)
868 {
869 {
870 DISABLE_AST
871 mask = XtAppPending(app_context);
872 ENABLE_AST
873 }
874 if(mask)
875 {
876 DISABLE_AST
877 XtAppProcessEvent(app_context, mask);
878 if(Got_Service_List)
879 {
880 do_got_service_list(Got_Service_List);
881 Got_Service_List = 0;
882 }
883 if(Got_Client_List)
884 {
885 do_show_clients(Got_Client_List);
886 Got_Client_List = 0;
887 }
888 ENABLE_AST
889 }
890 else
891 {
892 dim_usleep(100000);
893 /*
894 usleep(100000);
895 */
896 }
897 }
898
899}
900
901static char no_link = -1;
902
903void app_initialize(int tag)
904{
905void check_put_label();
906
907void update_servers();
908void update_servers_new();
909void update_show_servers();
910extern void get_all_colors();
911extern void set_title();
912extern void set_icon_title();
913
914 char text[128];
915 int len;
916 if(tag){}
917 sprintf(text,"DID - DIM Information Display on ");
918 len = strlen(text);
919 dim_get_dns_node(text+len);
920 len = strlen(text);
921 sprintf(text+len,":%d",dim_get_dns_port());
922 get_all_colors(display,Matrix_id[Curr_matrix]);
923 set_title(toplevel_widget,text);
924 set_icon_title(toplevel_widget,"DID");
925 Timer_q = dtq_create();
926 dic_info_service("DIS_DNS/SERVER_INFO",MONITORED,0,0,0,update_servers,0,
927 &no_link,1);
928 /*
929 dic_info_service("DIS_DNS/SERVER_LIST",MONITORED,0,0,0,
930 update_servers_new,0, &no_link,1);
931 */
932 /*
933 dtq_add_entry(Timer_q, 2, check_put_label, 0);
934 */
935 XtAppAddTimeOut(app_context, 1000, update_show_servers, 0);
936}
937
938/*
939 * All errors are fatal.
940 */
941void s_error(char *problem_string)
942{
943 printf("%s\n", problem_string);
944 exit(0);
945}
946
947void did_exit(Widget w, int *tag, unsigned long *reason)
948{
949 if(w){}
950 if(tag){}
951 if(reason){}
952 exit(0);
953}
954
955extern Pixel rgb_colors[MAX_COLORS];
956
957void create_main (Widget w, int *tag, unsigned long *reason)
958{
959 if(tag){}
960 if(reason){}
961 Window_id = w;
962/*
963 dtq_start_timer(5, app_initialize, 0);
964*/
965}
966
967void view_opts(Widget w, int tag, unsigned long *reason)
968{
969 void get_server_node(), get_server_service(), show_servers();
970
971 if(w){}
972 if(reason){}
973 Curr_view_opt = tag;
974 switch(tag)
975 {
976 case 0 :
977 get_server_node();
978 break;
979 case 1 :
980 show_servers();
981 break;
982 case 2 :
983 get_server_service();
984 break;
985 case 3 :
986 show_servers();
987 break;
988 }
989}
990
991void dns_control(Widget w, int tag, unsigned long *reason)
992{
993
994 if(w){}
995 if(reason){}
996 switch(tag)
997 {
998 case 0 :
999 dic_cmnd_service("DIS_DNS/PRINT_STATS",0,0);
1000 break;
1001 case 1 :
1002 dic_cmnd_service("DIS_DNS/DEBUG_ON",0,0);
1003 break;
1004 case 2 :
1005 dic_cmnd_service("DIS_DNS/DEBUG_OFF",0,0);
1006 break;
1007 case 3 :
1008 put_selection(DID_KILL_ALL,"Confirmation");
1009 break;
1010 case 4 :
1011 dic_cmnd_service("DIS_DNS/PRINT_HASH_TABLE",0,0);
1012 break;
1013 }
1014}
1015
1016void get_server_node()
1017{
1018Widget id,sel_id;
1019int i, j, n_nodes, curr_index = 0;
1020char nodes_str[MAX_NODE_NAME*MAX_CONNS], max_str[MAX_NODE_NAME];
1021char *ptr, *nodeptrs[MAX_CONNS], *curr_str, *sptr;
1022int get_nodes();
1023
1024 sel_id = put_selection(DID_SEL_NODE,"Node Selection");
1025 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_HELP_BUTTON);
1026 XtUnmanageChild(id);
1027 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_APPLY_BUTTON);
1028 XtUnmanageChild(id);
1029 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST);
1030 XmListDeleteAllItems(id);
1031 n_nodes = get_nodes(nodes_str);
1032 ptr = nodes_str;
1033
1034 for(i=0;i<n_nodes;i++)
1035 {
1036 nodeptrs[i] = ptr;
1037 sptr = ptr;
1038 ptr = strchr(ptr,'\n');
1039 for(j = 0; j < (int)strlen(sptr); j++)
1040 sptr[j] = tolower(sptr[j]);
1041 *ptr++ = '\0';
1042 }
1043 strcpy(max_str,"zzzzzzzzzzzzzzzzzzzzzzzzzzzz");
1044 for(i=0;i<n_nodes; i++)
1045 {
1046 curr_str = max_str;
1047 for(j=0;j<n_nodes; j++)
1048 {
1049 sptr = nodeptrs[j];
1050 if(!sptr)
1051 continue;
1052
1053 if(strcmp(sptr,curr_str) < 0)
1054 {
1055 curr_str = sptr;
1056 curr_index = j;
1057 }
1058 }
1059 nodeptrs[curr_index] = 0;
1060 XmListAddItem(id,create_str(curr_str),i+1);
1061 }
1062 /*
1063 for(i=0;i<n_nodes;i++)
1064 {
1065 node = ptr;
1066 ptr = strchr(ptr,'\n');
1067 *ptr++ = '\0';
1068 XmListAddItem(id,create_str(node),i+1);
1069 }
1070 */
1071 set_something(id,XmNlistItemCount,i);
1072 set_something(id,XmNlistVisibleItemCount,(i < 8) ? i : 8);
1073}
1074
1075void get_server_service()
1076{
1077Widget id,sel_id;
1078
1079 sel_id = put_selection(DID_SEL_SERVICE,"Service Selection");
1080 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_HELP_BUTTON);
1081 XtUnmanageChild(id);
1082 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_APPLY_BUTTON);
1083 XtUnmanageChild(id);
1084
1085 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST);
1086 /*
1087 XtUnmanageChild(id);
1088 */
1089 XtUnmapWidget(id);
1090
1091 /*
1092 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST_LABEL);
1093 XtUnmanageChild(id);
1094 */
1095}
1096
1097int get_nodes(char *node_ptr)
1098{
1099DNS_SERVER_INFO *ptr;
1100int n_nodes = 0;
1101SERVER *servp;
1102
1103 node_ptr[0] = '\0';
1104 servp = Server_head;
1105 while( (servp = (SERVER *)sll_get_next((SLL *)servp)) )
1106 {
1107 ptr = &servp->server;
1108 if(strstr(node_ptr,ptr->node) <= (char *)0)
1109 {
1110 strcat(node_ptr,ptr->node);
1111 strcat(node_ptr,"\n");
1112 n_nodes++;
1113 }
1114 }
1115 return(n_nodes);
1116}
1117
1118void get_service_format()
1119{
1120
1121 char str[256], *ptr, *ptr1;
1122 int rpc_flag;
1123
1124 strcpy(str,Curr_service_name);
1125 rpc_flag = 0;
1126 if( (ptr = strstr(str,"/RpcIn")) )
1127 {
1128 *ptr = '\0';
1129 rpc_flag = 1;
1130 }
1131 if( (ptr = strstr(str,"/RpcOut")) )
1132 {
1133 *ptr = '\0';
1134 rpc_flag = 2;
1135 }
1136 strcat(str,"|");
1137 if( (ptr = strstr(Curr_service_list,str)) )
1138 {
1139 if(!rpc_flag)
1140 {
1141 ptr += strlen(str);
1142 ptr1 = strchr(ptr,'|');
1143 }
1144 else if(rpc_flag == 1)
1145 {
1146 ptr += strlen(str);
1147 ptr1 = strchr(ptr,',');
1148 }
1149 else
1150 {
1151 ptr += strlen(str);
1152 ptr = strchr(ptr,',');
1153 ptr++;
1154 ptr1 = strchr(ptr,'|');
1155 }
1156 strncpy(Curr_service_format,ptr,(int)(ptr1 - ptr));
1157 Curr_service_format[(int)(ptr1-ptr)] = '\0';
1158 }
1159}
1160
1161void recv_service_info(int *tag, int *buffer, int *size)
1162{
1163/*
1164 char str[256], *ptr, *ptr1;
1165 int rpc_flag;
1166*/
1167 void print_service_formatted();
1168
1169 if(tag){}
1170 Service_content_str = malloc(1024 + (*size)*16);
1171 Service_buffer = malloc(*size);
1172 memcpy(Service_buffer, (char *)buffer, *size);
1173 Service_size = *size;
1174 get_service_format();
1175 if((*size == 4 ) && (*buffer == -1))
1176 {
1177 sprintf(Service_content_str,
1178 "Service %s Not Available\n", Curr_service_name);
1179 }
1180 else
1181 {
1182 switch(Curr_service_print_type)
1183 {
1184 case 0:
1185 print_service_formatted(buffer,*size);
1186 break;
1187 /*
1188 case 1:
1189 print_service_float(buffer, ((*size - 1) / 4) + 1);
1190 break;
1191 case 2:
1192 print_service_double(buffer, ((*size - 1) / 4) + 1);
1193 break;
1194 */
1195 }
1196 }
1197 set_something(Content_label_id,XmNlabelString, Service_content_str);
1198 /*
1199 if(Matrix_id[Curr_matrix])
1200 XFlush(XtDisplay(Matrix_id[Curr_matrix]));
1201 */
1202}
1203
1204void print_service_formatted(void *buff, int size)
1205{
1206char type;
1207int num, ret;
1208char str[128];
1209char *ptr;
1210void *buffer_ptr;
1211char timestr[128], aux[10];
1212int quality = 0, secs = 0, mili = 0;
1213int did_write_string(char, int, void **, int);
1214time_t tsecs;
1215
1216 sprintf(Service_content_str,
1217 "Service %s (%s) Contents :\n \n", Curr_service_name,
1218 Curr_service_format);
1219 /*
1220 if(Curr_service_id)
1221 {
1222 */
1223 dic_get_timestamp(0, &secs, &mili);
1224 quality = dic_get_quality(0);
1225/*
1226#ifdef LYNXOS
1227 ctime_r((time_t *)&secs, timestr, 128);
1228#else
1229 ctime_r((time_t *)&secs, timestr);
1230#endif
1231*/
1232 tsecs = secs;
1233 my_ctime(&tsecs, timestr, 128);
1234 ptr = strrchr(timestr,' ');
1235 strcpy(aux, ptr);
1236 sprintf(ptr,".%03d",mili);
1237 strcat(timestr, aux);
1238 timestr[strlen(timestr)-1] = '\0';
1239
1240 sprintf(str," Timestamp: %s Quality: %d\n\n",
1241 timestr, quality);
1242
1243 strcat(Service_content_str,str);
1244 /*
1245 }
1246 */
1247 ptr = Curr_service_format;
1248 buffer_ptr = buff;
1249 while(*ptr)
1250 {
1251 type = *ptr++;
1252 if(*ptr == ':')
1253 {
1254 ptr++;
1255 sscanf(ptr, "%d", &num);
1256 ret = did_write_string(type, num, &buffer_ptr, size);
1257 size -= ret;
1258 if( (ptr = strchr(ptr,';')) )
1259 ptr++;
1260 else
1261 break;
1262 }
1263 else
1264 {
1265 ret = did_write_string(type, 0, &buffer_ptr, size);
1266 size -= ret;
1267 break;
1268 }
1269 }
1270}
1271
1272int did_write_string(char type, int num, void **buffer_ptr, int ssize)
1273{
1274void *ptr;
1275int size, psize;
1276
1277 void print_service_standard();
1278 void print_service_char();
1279 void print_service_short();
1280 void print_service_float();
1281 void print_service_double();
1282
1283 ptr = *buffer_ptr;
1284 switch(type)
1285 {
1286 case 'L':
1287 case 'l':
1288 strcat(Service_content_str," L");
1289 if(!num)
1290 size = ssize/sizeof(int);
1291 else
1292 size = num;
1293 psize = size * sizeof(int);
1294 print_service_standard(ptr, size);
1295 break;
1296 case 'I':
1297 case 'i':
1298 strcat(Service_content_str," I");
1299 if(!num)
1300 size = ssize/sizeof(int);
1301 else
1302 size = num;
1303 psize = size * sizeof(int);
1304 print_service_standard(ptr, size);
1305 break;
1306 case 'S':
1307 case 's':
1308 strcat(Service_content_str," S");
1309 if(!num)
1310 size = ssize/sizeof(short);
1311 else
1312 size = num;
1313 psize = size * sizeof(short);
1314 print_service_short(ptr, size);
1315 break;
1316 case 'F':
1317 case 'f':
1318 strcat(Service_content_str," F");
1319 if(!num)
1320 size = ssize/sizeof(float);
1321 else
1322 size = num;
1323 psize = size * sizeof(float);
1324 print_service_float(ptr, size);
1325 break;
1326 case 'D':
1327 case 'd':
1328 strcat(Service_content_str," D");
1329 if(!num)
1330 size = ssize/sizeof(double);
1331 else
1332 size = num;
1333 psize = size * sizeof(double);
1334 print_service_double(ptr, size);
1335 break;
1336 case 'X':
1337 case 'x':
1338 strcat(Service_content_str," X");
1339 if(!num)
1340 size = ssize/sizeof(longlong);
1341 else
1342 size = num;
1343 psize = size * sizeof(longlong);
1344 print_service_standard(ptr, size*2);
1345 break;
1346 case 'C':
1347 case 'c':
1348 default:
1349 strcat(Service_content_str," C");
1350 if(!num)
1351 size = ssize;
1352 else
1353 size = num;
1354 psize = size;
1355 print_service_char(ptr, size);
1356 }
1357 ptr = (char *)ptr + psize;
1358 *buffer_ptr = ptr;
1359 return psize;
1360}
1361/*
1362print_service(buff, size)
1363int *buff, size;
1364{
1365int i,j, str_flag = 0;
1366char *asc, *ptr, str[80];
1367int last[4];
1368
1369 sprintf(Service_content_str,
1370 "Service %s (%s) Contents :\n \n", Curr_service_name,
1371 Curr_service_format);
1372 asc = (char *)buff;
1373 for( i = 0; i < size; i++)
1374 {
1375 if(i%4 == 0)
1376 {
1377 sprintf(str,"%4d: ",i);
1378 strcat(Service_content_str,str);
1379 }
1380 if(!(i%4))
1381 strcat(Service_content_str,"H");
1382 sprintf(str," %08X ",buff[i]);
1383 strcat(Service_content_str,str);
1384 last[i%4] = buff[i];
1385 if(i%4 == 3)
1386 {
1387 strcat(Service_content_str," '");
1388 for(j = 0; j <16; j++)
1389 {
1390 if(isprint(asc[j]))
1391 {
1392 sprintf(str,"%c",asc[j]);
1393 strcat(Service_content_str,str);
1394 }
1395 else
1396 {
1397 sprintf(str,".");
1398 strcat(Service_content_str,str);
1399 }
1400 }
1401 strcat(Service_content_str,"'\n");
1402 for(j = 0; j <4; j++)
1403 {
1404 if(j == 0)
1405 strcat(Service_content_str," D");
1406 sprintf(str,"%11d ",last[j]);
1407 strcat(Service_content_str,str);
1408 }
1409 strcat(Service_content_str,"\n");
1410 asc = (char *)&buff[i+1];
1411 }
1412 }
1413 if(i%4)
1414 {
1415 for(j = 0; j < 4 - (i%4); j++)
1416 strcat(Service_content_str," ");
1417 strcat(Service_content_str," '");
1418 for(j = 0; j < (i%4) * 4; j++)
1419 {
1420 if(isprint(asc[j]))
1421 {
1422 sprintf(str,"%c",asc[j]);
1423 strcat(Service_content_str,str);
1424 }
1425 else
1426 strcat(Service_content_str,".");
1427 }
1428 strcat(Service_content_str,"'\n");
1429 for(j = 0; j < (i%4); j++)
1430 {
1431 if(j == 0)
1432 strcat(Service_content_str," D");
1433 sprintf(str,"%11d ",last[j]);
1434 strcat(Service_content_str,str);
1435 }
1436 strcat(Service_content_str,"\n");
1437 }
1438}
1439*/
1440
1441void print_service_standard(int *buff, int size)
1442{
1443int i,j;
1444char *asc, *ptr, str[80], tmp[256];
1445int last[4];
1446
1447 asc = (char *)buff;
1448 ptr = Service_content_str;
1449 ptr += strlen(Service_content_str);
1450 for( i = 0; i < size; i++)
1451 {
1452 strcpy(tmp,"");
1453 if(i%4 == 0)
1454 {
1455 if(i != 0)
1456 {
1457 strcat(tmp," ");
1458 }
1459 sprintf(str,"%5d ",i);
1460 strcat(tmp,str);
1461 }
1462 if(!(i%4))
1463 strcat(tmp,"H: ");
1464 sprintf(str," %08X",buff[i]);
1465 strcat(tmp,str);
1466 last[i%4] = buff[i];
1467 if((i%4 == 3) || (i == (size-1)))
1468 {
1469 /*
1470 if(i%4 != 3)
1471 {
1472 for(j = 1; j < 4 - (i%4); j++)
1473 strcat(tmp," ");
1474 }
1475 strcat(tmp," '");
1476 for(j = 0; j < ((i%4)*4)+4 ; j++)
1477 {
1478 if(isprint(asc[j]))
1479 {
1480 sprintf(str,"%c",asc[j]);
1481 strcat(tmp,str);
1482 }
1483 else
1484 {
1485 sprintf(str,".");
1486 strcat(tmp,str);
1487 }
1488 }
1489 */
1490 strcat(tmp,"\n");
1491 for(j = 0; j <= (i%4); j++)
1492 {
1493 if(j == 0)
1494 strcat(tmp," D: ");
1495 sprintf(str,"%12d",last[j]);
1496 strcat(tmp,str);
1497 }
1498 strcat(tmp,"\n");
1499 asc = (char *)&buff[i+1];
1500 }
1501 strcpy(ptr, tmp);
1502 ptr += strlen(tmp);
1503 }
1504 strcpy(tmp,"\n");
1505 strcpy(ptr, tmp);
1506}
1507
1508void print_service_longlong(longlong *buff, int size)
1509{
1510int i,j;
1511char *asc, *ptr, str[80], tmp[256];
1512longlong last[4];
1513
1514 asc = (char *)buff;
1515 ptr = Service_content_str;
1516 ptr += strlen(Service_content_str);
1517 for( i = 0; i < size; i++)
1518 {
1519 strcpy(tmp,"");
1520 if(i%4 == 0)
1521 {
1522 if(i != 0)
1523 {
1524 strcat(tmp," ");
1525 }
1526 sprintf(str,"%5d ",i);
1527 strcat(tmp,str);
1528 }
1529 if(!(i%4))
1530 strcat(tmp,"H: ");
1531 sprintf(str," %08X",(unsigned)buff[i]);
1532 strcat(tmp,str);
1533 last[i%4] = buff[i];
1534 if((i%4 == 3) || (i == (size-1)))
1535 {
1536 strcat(tmp,"\n");
1537 for(j = 0; j <= (i%4); j++)
1538 {
1539 if(j == 0)
1540 strcat(tmp," D: ");
1541 sprintf(str,"%12d",(int)last[j]);
1542 strcat(tmp,str);
1543 }
1544 strcat(tmp,"\n");
1545 asc = (char *)&buff[i+1];
1546 }
1547 strcpy(ptr, tmp);
1548 ptr += strlen(tmp);
1549 }
1550 strcpy(tmp,"\n");
1551 strcpy(ptr, tmp);
1552}
1553
1554void print_service_short(short *buff, int size)
1555{
1556int i,j;
1557char *asc, *ptr, str[80], tmp[256];
1558short last[8];
1559
1560 asc = (char *)buff;
1561 ptr = Service_content_str;
1562 ptr += strlen(Service_content_str);
1563 for( i = 0; i < size; i++)
1564 {
1565 strcpy(tmp,"");
1566 if(i%8 == 0)
1567 {
1568 if(i != 0)
1569 {
1570 strcat(tmp," ");
1571 }
1572 sprintf(str,"%5d ",i);
1573 strcat(tmp,str);
1574 }
1575 if(!(i%8))
1576 strcat(tmp,"H: ");
1577 sprintf(str," %04X",buff[i]);
1578 strcat(tmp,str);
1579 last[i%8] = buff[i];
1580 if((i%8 == 7) || (i == (size-1)))
1581 {
1582 /*
1583 if(i%7 != 7)
1584 {
1585 for(j = 1; j < 8 - (i%8); j++)
1586 strcat(tmp," ");
1587 }
1588 strcat(tmp," '");
1589 for(j = 0; j < ((i%8)*2)+2 ; j++)
1590 {
1591 if(isprint(asc[j]))
1592 {
1593 sprintf(str,"%c",asc[j]);
1594 strcat(tmp,str);
1595 }
1596 else
1597 {
1598 sprintf(str,".");
1599 strcat(tmp,str);
1600 }
1601 }
1602 */
1603 strcat(tmp,"\n");
1604 for(j = 0; j <= (i%8); j++)
1605 {
1606 if(j == 0)
1607 strcat(tmp," D: ");
1608 sprintf(str," %5d",last[j]);
1609 strcat(tmp,str);
1610 }
1611 strcat(tmp,"\n");
1612 asc = (char *)&buff[i+1];
1613 }
1614 strcpy(ptr, tmp);
1615 ptr += strlen(tmp);
1616 }
1617 strcpy(tmp,"\n");
1618 strcpy(ptr, tmp);
1619}
1620
1621void print_service_char(char *buff, int size)
1622{
1623int i,j;
1624char *asc, *ptr, str[80], tmp[256];
1625char last[16];
1626
1627 asc = (char *)buff;
1628 ptr = Service_content_str;
1629 ptr += strlen(Service_content_str);
1630 for( i = 0; i < size; i++)
1631 {
1632 strcpy(tmp,"");
1633 if(i%16 == 0)
1634 {
1635 if(i != 0)
1636 {
1637 strcat(tmp," ");
1638 }
1639 sprintf(str,"%5d ",i);
1640 strcat(tmp,str);
1641 }
1642 if(!(i%16))
1643 strcat(tmp,"H: ");
1644 sprintf(str,"%02X",buff[i]);
1645/* strcat(tmp,str);
1646*/
1647 strcat(tmp," ");
1648 strcat(tmp,&str[strlen(str)-2]);
1649 last[i%16] = buff[i];
1650 /*
1651 if(i%4 == 3)
1652 strcat(tmp," ");
1653 */
1654 if((i%16 == 15) || (i == (size-1)))
1655 {
1656 if(i%16 != 15)
1657 {
1658 for(j = 1; j < 16 - (i%16); j++)
1659 strcat(tmp," ");
1660 }
1661 strcat(tmp," '");
1662 for(j = 0; j <= (i%16) ; j++)
1663 {
1664 if(isprint(asc[j]))
1665 {
1666 sprintf(str,"%c",asc[j]);
1667 strcat(tmp,str);
1668 }
1669 else
1670 {
1671 sprintf(str,".");
1672 strcat(tmp,str);
1673 }
1674 }
1675 strcat(tmp,"'\n");
1676 asc = (char *)&buff[i+1];
1677 }
1678 strcpy(ptr, tmp);
1679 ptr += strlen(tmp);
1680 }
1681 strcpy(tmp,"\n");
1682 strcpy(ptr, tmp);
1683}
1684
1685void print_service_float(float *buff, int size)
1686{
1687int i;
1688char *ptr, str[80], tmp[256];
1689
1690 ptr = Service_content_str;
1691 ptr += strlen(Service_content_str);
1692 for( i = 0; i < size; i++)
1693 {
1694 strcpy(tmp,"");
1695 if(i%4 == 0)
1696 {
1697 if(i != 0)
1698 {
1699 strcat(tmp," ");
1700 }
1701 sprintf(str," %5d: ",i);
1702 strcat(tmp,str);
1703 }
1704 sprintf(str,"%12.3G",*(buff++));
1705 strcat(tmp,str);
1706 if((i%4 == 3) || (i == size-1))
1707 {
1708 strcat(tmp,"\n");
1709 }
1710 strcpy(ptr, tmp);
1711 ptr += strlen(tmp);
1712 }
1713 strcpy(tmp,"\n");
1714 strcpy(ptr, tmp);
1715 ptr += strlen(tmp);
1716}
1717
1718void print_service_double(double *buff, int size)
1719{
1720int i;
1721char *ptr, str[80], tmp[256];
1722
1723 ptr = Service_content_str;
1724 ptr += strlen(Service_content_str);
1725 for( i = 0; i < size; i++)
1726 {
1727 strcpy(tmp,"");
1728 if(i%4 == 0)
1729 {
1730 if(i != 0)
1731 {
1732 strcat(tmp," ");
1733 }
1734 sprintf(str," %5d: ",i);
1735 strcat(tmp,str);
1736 }
1737 sprintf(str,"%12.3G",*(buff++));
1738 strcat(tmp,str);
1739 if((i%4 == 3) || (i == size-1))
1740 {
1741 strcat(tmp,"\n");
1742 }
1743 strcpy(ptr, tmp);
1744 ptr += strlen(tmp);
1745 }
1746 strcpy(tmp,"\n");
1747 strcpy(ptr, tmp);
1748 ptr += strlen(tmp);
1749}
1750
1751void ok_pop_up (Widget w, long tag, unsigned long *reason)
1752{
1753Widget id, sel_id;
1754char *str, *pstr;
1755void recv_service_info();
1756void did_prepare_command();
1757void show_servers();
1758
1759/*
1760 if(tag == 5)
1761 {
1762 id = (Widget)XmSelectionBoxGetChild(w,XmDIALOG_TEXT);
1763 str = (char *)XmTextGetString(id);
1764 if(!str[0])
1765 {
1766 XtFree(str);
1767 return;
1768 }
1769 if( ( fptr = fopen( str, "w" ) ) == (FILE *)0 )
1770 {
1771 printf("Cannot open: %s for writing\n",str);
1772 return;
1773 }
1774 ptr = &Curr_servp->server;
1775 if (ptr->pid > 0x1000000)
1776 fprintf(fptr,"Server %s (pid = %X) on node %s\n provides %d services :\n",
1777 Curr_servp->name, ptr->pid, ptr->node, ptr->n_services);
1778 else
1779 fprintf(fptr,"Server %s (pid = %d) on node %s\n provides %d services :\n",
1780 Curr_servp->name, ptr->pid, ptr->node, ptr->n_services);
1781 service_ptr = Curr_servp->service_ptr;
1782 for(i=0;i<ptr->n_services; i++)
1783 {
1784 sprintf(str,service_ptr->name);
1785 fprintf(fptr," %s\n",service_ptr->name);
1786 service_ptr++;
1787 }
1788 fclose(fptr);
1789 XtFree(str);
1790 return;
1791 }
1792 if(tag == 4)
1793 {
1794 sel_id = put_selection(4, "Printing...");
1795 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_HELP_BUTTON);
1796 XtUnmanageChild(id);
1797
1798 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_APPLY_BUTTON);
1799 XtUnmanageChild(id);
1800 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_TEXT);
1801 str = (char *)XmTextGetString(id);
1802 if(!str[0])
1803 {
1804 XtFree(str);
1805 return;
1806 }
1807 ptr = &Curr_servp->server;
1808 if(pstr = strrchr(str,']'))
1809 *(++pstr) = '\0';
1810 if(pstr = strrchr(str,'/'))
1811 *(++pstr) = '\0';
1812 sprintf(txt_str,"%s%s.TXT",str,Curr_servp->name);
1813 XtFree(str);
1814 XmTextSetString(id, txt_str);
1815 return;
1816 }
1817*/
1818 if(reason){}
1819 if(tag == DID_KILL_ALL)
1820 {
1821 dic_cmnd_service("DIS_DNS/KILL_SERVERS",0,0);
1822 return;
1823 }
1824 id = XmSelectionBoxGetChild(w,XmDIALOG_TEXT);
1825 str = XmTextGetString(id);
1826 if(!str[0])
1827 {
1828 XtFree(str);
1829 return;
1830 }
1831 if ((tag == DID_SEL_NODE) || (tag == DID_SEL_SERVICE))
1832 {
1833 strcpy(Curr_view_opt_par, str);
1834 show_servers();
1835 XtFree(str);
1836 }
1837 if(tag == DID_SERVICES)
1838 {
1839 pstr = strchr(str,' ');
1840 if(!pstr)
1841 {
1842 strcpy(Curr_service_name, str);
1843 strcpy(str,"SVC");
1844 }
1845 else
1846 {
1847 pstr++;
1848 strcpy(Curr_service_name, pstr);
1849 }
1850 if(Curr_service_id)
1851 {
1852 dic_release_service(Curr_service_id);
1853 Curr_service_id = 0;
1854 }
1855 if(str[0] == 'S')
1856 {
1857 /*
1858 if((!strstr(pstr,"/SERVICE_LIST")) &&
1859 (!strstr(pstr,"/CLIENT_LIST")) &&
1860 (!strstr(pstr,"/SERVER_LIST")))
1861 {
1862 Curr_service_id = dic_info_service(Curr_service_name,
1863 MONITORED,5,0,0,
1864 recv_service_info,0,
1865 &no_link_int,4);
1866 }
1867 else
1868 {
1869 */
1870 dic_info_service_stamped(Curr_service_name,
1871 ONCE_ONLY,10,0,0,
1872 recv_service_info,0,
1873 &no_link_int,4);
1874 /*
1875 }
1876 */
1877 put_selection(DID_SERVICE,"Service Contents");
1878 }
1879 else
1880 {
1881 get_service_format();
1882 sel_id = put_selection(DID_COMMAND,"Send Command");
1883 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_HELP_BUTTON);
1884 XtUnmanageChild(id);
1885 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_APPLY_BUTTON);
1886 XtUnmanageChild(id);
1887 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST);
1888 /*
1889 XtUnmanageChild(id);
1890 */
1891 XtUnmapWidget(id);
1892 }
1893 XtFree(str);
1894 }
1895 if(tag == DID_COMMAND)
1896 {
1897 did_prepare_command(str);
1898 XtFree(str);
1899 }
1900}
1901
1902int get_type_size(char type)
1903{
1904 int size;
1905
1906 switch(type)
1907 {
1908 case 'L':
1909 case 'l':
1910 size = sizeof(long);
1911 break;
1912 case 'I':
1913 case 'i':
1914 size = sizeof(int);
1915 break;
1916 case 'S':
1917 case 's':
1918 size = sizeof(short);
1919 break;
1920 case 'F':
1921 case 'f':
1922 size = sizeof(float);
1923 break;
1924 case 'D':
1925 case 'd':
1926 size = sizeof(double);
1927 break;
1928 case 'C':
1929 case 'c':
1930 default:
1931 size = 1;
1932 }
1933 return(size);
1934}
1935
1936void did_prepare_command(char *str)
1937{
1938char type;
1939int num;
1940int size, full_size = 0;
1941char *ptr;
1942static int last_size = 0;
1943static void *last_buffer = 0;
1944void *buffer_ptr;
1945char *str_ptr;
1946void did_read_string(char, int, void **, char **);
1947
1948 str_ptr = str;
1949 ptr = Curr_service_format;
1950 while(*ptr)
1951 {
1952 type = *ptr++;
1953 if(*ptr == ':')
1954 {
1955 ptr++;
1956 size = get_type_size(type);
1957 sscanf(ptr, "%d", &num);
1958 full_size += size * num;
1959 if( (ptr = strchr(ptr,';')) )
1960 ptr++;
1961 else
1962 break;
1963 }
1964 }
1965
1966 full_size += 256;
1967 if(full_size > last_size)
1968 {
1969 if(last_size)
1970 free(last_buffer);
1971 last_buffer = malloc(full_size);
1972 last_size = full_size;
1973 }
1974 buffer_ptr = last_buffer;
1975 ptr = Curr_service_format;
1976 while(*ptr)
1977 {
1978 type = *ptr++;
1979 if(*ptr == ':')
1980 {
1981 ptr++;
1982 sscanf(ptr, "%d", &num);
1983 did_read_string(type, num, &buffer_ptr, &str_ptr);
1984 if(!str_ptr)
1985 break;
1986 if( (ptr = strchr(ptr,';')) )
1987 ptr++;
1988 else
1989 break;
1990 }
1991 else
1992 {
1993 did_read_string(type, 0, &buffer_ptr, &str_ptr);
1994 break;
1995 }
1996 }
1997 full_size = (int) ((char *)buffer_ptr - (char *)last_buffer);
1998 dic_cmnd_service(Curr_service_name,last_buffer,full_size);
1999}
2000
2001int read_str_int(char *str)
2002{
2003 int i;
2004 if((str[0] == '0') && (str[1] == 'x'))
2005 sscanf(str+2,"%x",&i);
2006 else
2007 sscanf(str,"%d",&i);
2008 return(i);
2009}
2010
2011int read_str_char(char *str, char *cc)
2012{
2013
2014 if(str[0] == '\'')
2015 *cc = str[1];
2016 else if(str[0] == '\"')
2017 return(0);
2018 else if((str[0] == '0') && (str[1] == 'x'))
2019 sscanf(str+2,"%x",(int *)cc);
2020 else if(isalpha(str[0]))
2021 return(-1);
2022 else
2023 sscanf(str,"%d",(int *)cc);
2024 return(1);
2025}
2026
2027void did_read_string(char type, int num, void **buffer_ptr, char **str_ptr)
2028{
2029int i, ret = 0;
2030float ff;
2031double dd;
2032void *ptr;
2033char *strp, *ptr1;
2034char cc;
2035 short s;
2036
2037 strp = *str_ptr;
2038 ptr = *buffer_ptr;
2039 if(!num)
2040 num = 1000000;
2041 switch(type)
2042 {
2043 case 'L':
2044 case 'l':
2045 case 'I':
2046 case 'i':
2047 for(i = 0; i<num; i++)
2048 {
2049 *(int *)ptr = read_str_int(strp);
2050 ptr = (int *)ptr +1;
2051 if( (strp = strchr(strp,' ')) )
2052 strp++;
2053 else
2054 break;
2055 }
2056 break;
2057 case 'S':
2058 case 's':
2059 for(i = 0; i<num; i++)
2060 {
2061 s = (short)read_str_int(strp);
2062 *((short *)ptr) = s;
2063 ptr = (short *)ptr +1;
2064 if( (strp = strchr(strp,' ')) )
2065 strp++;
2066 else
2067 break;
2068 }
2069 break;
2070 case 'F':
2071 case 'f':
2072 for(i = 0; i<num; i++)
2073 {
2074 sscanf(strp,"%f",&ff);
2075 *(float *)ptr = ff;
2076 ptr = (float *)ptr +1;
2077 if( (strp = strchr(strp,' ')) )
2078 strp++;
2079 else
2080 break;
2081 }
2082 break;
2083 case 'D':
2084 case 'd':
2085 for(i = 0; i<num; i++)
2086 {
2087 sscanf(strp,"%f",&ff);
2088 dd = (double)ff;
2089 *(double *)ptr = dd;
2090 ptr = (double *)ptr +1;
2091 if( (strp = strchr(strp,' ')) )
2092 strp++;
2093 else
2094 break;
2095 }
2096 break;
2097 case 'C':
2098 case 'c':
2099 default:
2100 for(i = 0; i<num; i++)
2101 {
2102 if((ret = read_str_char(strp, &cc)) <= 0)
2103 break;
2104 *(char *)ptr = cc;
2105 ptr = (char *)ptr +1;
2106 if( (strp = strchr(strp,' ')) )
2107 strp++;
2108 else
2109 break;
2110 }
2111 if(ret <= 0)
2112 {
2113 if(!ret)
2114 {
2115 strp++;
2116 }
2117 num = strlen(strp)+1;
2118 strncpy((char *)ptr,strp,num);
2119 if( (ptr1 = (char *)strchr((char *)ptr,'\"')) )
2120 {
2121 num--;
2122 *ptr1 = '\0';
2123 }
2124 ptr = (char *)ptr + num;
2125 if( (strp = strchr(strp,' ')) )
2126 strp++;
2127 else
2128 break;
2129 }
2130 }
2131 *buffer_ptr = ptr;
2132 *str_ptr = strp;
2133}
2134
2135void cancel_pop_up (Widget w, int tag, unsigned long *reason)
2136{
2137 void print_service_formatted();
2138
2139 if(reason){}
2140 if(tag == MAX_POP_UPS+1)
2141 {
2142 print_service_formatted(Service_buffer,Service_size);
2143 set_something(Content_label_id,XmNlabelString, Service_content_str);
2144 Curr_service_print_type = 0;
2145 }
2146 /*
2147 else if(tag == MAX_POP_UPS+2)
2148 {
2149 print_service_float(Service_buffer, ((Service_size - 1) / 4) + 1);
2150 set_something(Content_label_id,XmNlabelString, Service_content_str);
2151 Curr_service_print_type = 1;
2152 }
2153 else if(tag == MAX_POP_UPS+3)
2154 {
2155 print_service_double(Service_buffer, ((Service_size - 1) / 4) + 1);
2156 set_something(Content_label_id,XmNlabelString, Service_content_str);
2157 Curr_service_print_type = 2;
2158 }
2159 */
2160 else if(tag == MAX_POP_UPS+4)
2161 {
2162
2163 if((!strstr(Curr_service_name,"/SERVICE_LIST")) &&
2164 (!strstr(Curr_service_name,"/CLIENT_LIST")) &&
2165 (!strstr(Curr_service_name,"/SERVER_LIST")))
2166 {
2167 if(Curr_service_id)
2168 {
2169 dic_release_service(Curr_service_id);
2170 Curr_service_id = 0;
2171 }
2172 Curr_service_id = dic_info_service_stamped(Curr_service_name,
2173 MONITORED,10,0,0,
2174 recv_service_info,0,
2175 &no_link_int,4);
2176 }
2177 XtSetSensitive(w, False);
2178 XtSetSensitive(SubscribeButton, True);
2179 }
2180 else if(tag == MAX_POP_UPS+5)
2181 {
2182
2183 if((!strstr(Curr_service_name,"/SERVICE_LIST")) &&
2184 (!strstr(Curr_service_name,"/CLIENT_LIST")) &&
2185 (!strstr(Curr_service_name,"/SERVER_LIST")))
2186 {
2187 if(Curr_service_id)
2188 {
2189 dic_release_service(Curr_service_id);
2190 Curr_service_id = 0;
2191 }
2192 Curr_service_id = dic_info_service_stamped(Curr_service_name,
2193 MONITORED,0,0,0,
2194 recv_service_info,0,
2195 &no_link_int,4);
2196 }
2197 XtSetSensitive(w, False);
2198 XtSetSensitive(Subscribe10Button, True);
2199 }
2200/*
2201 else if(tag == 5)
2202 {
2203 *
2204 XtUnmapWidget(XtParent(pop_widget_id[4]));
2205 *
2206 }
2207*/
2208 else if(tag == DID_SERVICE)
2209 {
2210 if(Curr_service_id)
2211 {
2212 dic_release_service(Curr_service_id);
2213 Curr_service_id = 0;
2214 }
2215 XtUnmanageChild(pop_widget_id[DID_SERVICE]);
2216 free(Service_content_str);
2217 free(Service_buffer);
2218 }
2219}
2220
2221void create_matrix(Widget w, int *tag, unsigned long *reason)
2222{
2223
2224 if(reason){}
2225 Matrix_id[*tag] = w;
2226 if(*tag)
2227 XtUnmanageChild(w);
2228 else
2229 Curr_matrix = 0;
2230}
2231
2232void create_label(Widget w, int *tag, unsigned long *reason)
2233{
2234 if(reason){}
2235 if(!*tag)
2236 Label_id = w;
2237 else
2238 Content_label_id = w;
2239}
2240
2241void switch_matrix()
2242{
2243 /*
2244 XtUnmanageChild(Matrix_id[Curr_matrix]);
2245 Curr_matrix = (Curr_matrix) ? 0 : 1;
2246 XtManageChild(Matrix_id[Curr_matrix]);
2247 */
2248 XmScrolledWindowSetAreas(Window_id,NULL, NULL, Matrix_id[Curr_matrix]);
2249}
2250
2251/*
2252static int curr_allocated_size = 0;
2253static DNS_SERVER_INFO *dns_info_buffer;
2254*/
2255
2256void update_servers_new(int *tag, char *buffer, int *size)
2257{
2258 if(tag){}
2259 if(size){}
2260 printf("Server_list:\n%s\n",buffer);
2261}
2262
2263SERVER *find_server(char *node, int pid)
2264{
2265 SERVER *servp;
2266 DNS_SERVER_INFO *ptr;
2267
2268 servp = Server_head;
2269 while( (servp = (SERVER *)sll_get_next((SLL *)servp)) )
2270 {
2271 ptr = &servp->server;
2272 if((ptr->pid == pid) && (!strcmp(ptr->node,node)))
2273 {
2274 return(servp);
2275 }
2276 }
2277 return ((SERVER *)0);
2278}
2279 /*
2280 if(!(servp = (SERVER *)sll_search((SLL *)Server_head,
2281 (char *)&buffer->server, MAX_NODE_NAME+MAX_TASK_NAME-4)))
2282 */
2283
2284
2285void update_servers(int *tag, DNS_DID *buffer, int *size)
2286{
2287int n_services, service_size;
2288SERVER *servp;
2289int j;
2290char str[MAX_NAME], sname[MAX_NAME], *ptr;
2291
2292 if(tag){}
2293 if(!Server_head)
2294 {
2295 Server_head = (SERVER *)malloc(sizeof(SERVER));
2296 sll_init((SLL *)Server_head);
2297 }
2298 if(First_time)
2299 {
2300 switch_matrix();
2301 First_time = 0;
2302 }
2303
2304 if(!*size)
2305 return;
2306 if(*(char *)buffer == -1)
2307 {
2308 N_servers = 0;
2309 N_services = 0;
2310 return;
2311 }
2312 buffer->server.n_services = vtohl(buffer->server.n_services);
2313 buffer->server.pid = vtohl(buffer->server.pid);
2314 n_services = buffer->server.n_services;
2315
2316 if(n_services == 1)
2317 return;
2318 strcpy(sname, buffer->server.task);
2319 if(n_services > 1)
2320 {
2321 for(j = 0; j < n_services; j++)
2322 {
2323 buffer->services[j].type = vtohl(
2324 buffer->services[j].type);
2325 buffer->services[j].status = vtohl(
2326 buffer->services[j].status);
2327 buffer->services[j].n_clients = vtohl(
2328 buffer->services[j].n_clients);
2329 if(strlen(sname) == MAX_TASK_NAME-4-1)
2330 {
2331 strcpy(str,buffer->services[j].name);
2332 if( (ptr = strstr(str,"/CLIENT_LIST")) )
2333 {
2334 *ptr = '\0';
2335 strcpy(sname,str);
2336 }
2337 }
2338 }
2339 }
2340 if (!(servp = find_server(buffer->server.node,buffer->server.pid)))
2341 /*
2342 if(!(servp = (SERVER *)sll_search((SLL *)Server_head,
2343 (char *)&buffer->server, MAX_NODE_NAME+MAX_TASK_NAME-4)))
2344 */
2345 {
2346 if(n_services)
2347 {
2348 servp = (SERVER *)malloc(sizeof(SERVER));
2349 strcpy(servp->name,sname);
2350 servp->next = 0;
2351 servp->button_id = 0;
2352 servp->pop_widget_id[0] = 0;
2353 servp->pop_widget_id[1] = 0;
2354 servp->busy = 0;
2355 servp->server.n_services = 0;
2356 servp->service_ptr = 0;
2357 sll_insert_queue((SLL *)Server_head,(SLL *)servp);
2358 }
2359 }
2360 if(n_services != 0)
2361 {
2362 if(n_services == servp->server.n_services)
2363 {
2364 return;
2365 }
2366 if(servp->server.n_services == 0)
2367 N_servers++;
2368 if(servp->server.n_services != -1)
2369 N_services -= servp->server.n_services;
2370 memcpy(&servp->server,&buffer->server,sizeof(DNS_SERVER_INFO));
2371 if(servp->service_ptr)
2372 {
2373 free(servp->service_ptr);
2374 servp->service_ptr = 0;
2375 }
2376 if(n_services != -1)
2377 {
2378 service_size = n_services*sizeof(DNS_SERVICE_INFO);
2379 servp->service_ptr = (DNS_SERVICE_INFO *)malloc(service_size);
2380 memcpy(servp->service_ptr, buffer->services, service_size);
2381 N_services += n_services;
2382 }
2383 servp->busy = 1;
2384 }
2385 else
2386 {
2387 if(servp)
2388 {
2389 N_servers--;
2390 if(servp->server.n_services != -1)
2391 {
2392 N_services -= servp->server.n_services;
2393 }
2394 else
2395 Force_update = 1;
2396 servp->server.n_services = 0;
2397 servp->busy = -1;
2398 }
2399 }
2400}
2401
2402void show_servers()
2403{
2404SERVER *servp;
2405void update_show_servers();
2406void remove_all_buttons();
2407void put_label();
2408
2409 if(!Matrix_id[Curr_matrix])
2410 return;
2411 remove_all_buttons();
2412
2413#ifndef linux
2414 switch_matrix();
2415#endif
2416 put_label();
2417 servp = Server_head;
2418 while( (servp = (SERVER *)sll_get_next((SLL *)servp)) )
2419 {
2420 servp->busy = 1;
2421 }
2422 Force_update = 1;
2423}
2424
2425void update_show_servers(void *tag, unsigned long *reason)
2426{
2427DNS_SERVER_INFO *server_ptr;
2428DNS_SERVICE_INFO *service_ptr;
2429int i, j, found, n_done = 0;
2430Widget w, create_button();
2431SERVER *servp, *prevp;
2432static int old_n_services = 0;
2433char node[MAX_NODE_NAME], par[MAX_NODE_NAME], *ptr;
2434void remove_button();
2435void remove_all_buttons();
2436void put_label();
2437
2438 DISABLE_AST
2439 if(tag){}
2440 if(reason){}
2441 if((N_services != old_n_services) || (Force_update))
2442 {
2443 if(!Matrix_id[Curr_matrix])
2444 {
2445 XtAppAddTimeOut(app_context, 1000, update_show_servers, 0);
2446 ENABLE_AST
2447 return;
2448 }
2449 if(!N_servers)
2450 {
2451 remove_all_buttons();
2452 if(! No_link_button_id)
2453 {
2454 No_link_button_id = create_button("DNS is down", 0);
2455 set_color(No_link_button_id, XmNbackground, RED);
2456 get_something(No_link_button_id,XmNuserData,&w);
2457 set_color(w, XmNbackground, RED);
2458 XtSetSensitive(No_link_button_id, False);
2459 }
2460 while(!sll_empty((SLL *)Server_head))
2461 {
2462 servp = (SERVER *)sll_remove_head((SLL *)Server_head);
2463 if(servp->service_ptr)
2464 free(servp->service_ptr);
2465 free(servp);
2466 }
2467 put_label();
2468 old_n_services = N_services;
2469 Force_update = 0;
2470 XtAppAddTimeOut(app_context, 1000, update_show_servers, 0);
2471 ENABLE_AST
2472 return;
2473 }
2474 if(No_link_button_id)
2475 {
2476 XtDestroyWidget(No_link_button_id);
2477 /*
2478 XFlush(XtDisplay(No_link_button_id));
2479 */
2480 No_link_button_id = 0;
2481 }
2482 servp = Server_head;
2483 prevp = 0;
2484 while( (servp = (SERVER *)sll_get_next((SLL *)servp)) )
2485 {
2486 if(prevp)
2487 {
2488 free(prevp);
2489 prevp = 0;
2490 }
2491 if(n_done == 10)
2492 {
2493 if(!Force_update)
2494 put_label();
2495 XtAppAddTimeOut(app_context, 100, update_show_servers, 0);
2496 ENABLE_AST
2497 return;
2498 }
2499 server_ptr = &servp->server;
2500 if(servp->busy == 1)
2501 {
2502 if(!servp->button_id)
2503 {
2504 switch(Curr_view_opt)
2505 {
2506 case 1 :
2507 servp->button_id = create_button(/*server_ptr->task*/servp->name, servp);
2508 n_done++;
2509 break;
2510 case 0 :
2511 strcpy(node, server_ptr->node);
2512 strcpy(par, Curr_view_opt_par);
2513 ptr = strchr(node, '.');
2514 if(ptr)
2515 *ptr = '\0';
2516 ptr = strchr(par,'.');
2517 if(ptr)
2518 *ptr = '\0';
2519 ptr = node;
2520 for(i = 0; i < (int)strlen(ptr); i++)
2521 ptr[i] = tolower(ptr[i]);
2522 ptr = par;
2523 for(i = 0; i < (int)strlen(ptr); i++)
2524 ptr[i] = tolower(ptr[i]);
2525 if(!strcmp(/*server_ptr->*/node, /*Curr_view_opt_*/par))
2526 {
2527 servp->button_id = create_button(/*server_ptr->task*/servp->name, servp);
2528 n_done++;
2529 }
2530 break;
2531 case 2 :
2532 found = 0;
2533 if(!(service_ptr = servp->service_ptr))
2534 break;
2535 for(j = 0; j < server_ptr->n_services; j++)
2536 {
2537 if(strstr(service_ptr->name, Curr_view_opt_par) > (char *)0)
2538 {
2539 found = 1;
2540 break;
2541 }
2542 service_ptr++;
2543 }
2544 if (found)
2545 {
2546 servp->button_id = create_button(/*server_ptr->task*/servp->name, servp);
2547 n_done++;
2548 }
2549 break;
2550 case 3 :
2551 if(server_ptr->n_services == -1)
2552 {
2553 servp->button_id = create_button(/*server_ptr->task*/servp->name, servp);
2554 n_done++;
2555 }
2556 else
2557 {
2558 if(servp->button_id)
2559 remove_button(servp);
2560 }
2561 n_done++;
2562 break;
2563 }
2564 }
2565 servp->busy = 2;
2566 if(servp->button_id)
2567 {
2568 if(Curr_view_opt != -1)
2569 {
2570 if (server_ptr->n_services == -1)
2571 {
2572 set_color(servp->button_id, XmNbackground, RED);
2573 get_something(servp->button_id,XmNuserData,&w);
2574 set_color(w, XmNbackground, RED);
2575 }
2576 else
2577 {
2578 set_color(servp->button_id, XmNbackground, GREEN);
2579 get_something(servp->button_id,XmNuserData,&w);
2580 set_color(w, XmNbackground, GREEN);
2581 }
2582 }
2583 }
2584 }
2585 else if (servp->busy == -1)
2586 {
2587 remove_button(servp);
2588 sll_remove((SLL *)Server_head, (SLL *)servp);
2589 if(servp->service_ptr)
2590 {
2591 free(servp->service_ptr);
2592 servp->service_ptr = 0;
2593 }
2594 prevp = servp;
2595 n_done++;
2596 }
2597 }
2598 if(prevp)
2599 {
2600 free(prevp);
2601 prevp = 0;
2602 }
2603 put_label();
2604 old_n_services = N_services;
2605 Force_update = 0;
2606 }
2607 XtAppAddTimeOut(app_context, 1000, update_show_servers, 0);
2608 ENABLE_AST
2609}
2610
2611Widget create_button(char *name, SERVER *servp)
2612{
2613Arg arglist[10];
2614int n, n_services = -1;
2615Widget w, ww, w_id;
2616void activate_services(), activate_clients();
2617char w_name[MAX_NAME];
2618
2619 w_name[0] = 0;
2620 if(servp)
2621 n_services = servp->server.n_services;
2622 strcpy(w_name,name);
2623 if(strlen(w_name) >= MAX_TASK_NAME - 4)
2624 w_name[16] = '\0';
2625 n = 0;
2626 XtSetArg(arglist[n], XmNorientation, XmVERTICAL); n++;
2627 XtSetArg(arglist[n], XmNentryAlignment, XmALIGNMENT_CENTER); n++;
2628 w_id = w = XmCreateMenuBar(Matrix_id[Curr_matrix],
2629 (String)XmStringCreateLtoR ( w_name,XmSTRING_DEFAULT_CHARSET),
2630 arglist,n);
2631/*
2632 if(n_services == -1)
2633 set_color(w, XmNbackground, RED);
2634 else
2635 set_color(w, XmNbackground, GREEN);
2636*/
2637 XtManageChild(w);
2638 strcat(w_name,"1");
2639 n = 0;
2640 XtSetArg(arglist[n], XmNalignment, XmALIGNMENT_CENTER); n++;
2641 XtSetArg(arglist[n], XmNfontList, did_server_font); n++;
2642 w = XmCreateCascadeButton(w,
2643 (String)XmStringCreateLtoR ( w_name,XmSTRING_DEFAULT_CHARSET),
2644 arglist,n);
2645 set_something(w,XmNlabelString,name);
2646 set_something(w,XmNalignment,XmALIGNMENT_CENTER);
2647/*
2648 if(n_services == -1)
2649 set_color(w, XmNbackground, RED);
2650 else
2651 set_color(w, XmNbackground, GREEN);
2652*/
2653 set_something(w_id,XmNuserData,w);
2654 strcat(w_name,"1");
2655 n = 0;
2656 ww = XmCreatePulldownMenu(w_id,
2657 (String)XmStringCreateLtoR ( w_name,XmSTRING_DEFAULT_CHARSET),
2658 arglist,n);
2659 set_something(w,XmNsubMenuId,ww);
2660 XtManageChild(w);
2661 strcat(w_name,"1");
2662 n = 0;
2663 XtSetArg(arglist[n], XmNfontList, did_default_font); n++;
2664 w = XmCreatePushButton(ww,
2665 (String)XmStringCreateLtoR ( w_name,XmSTRING_DEFAULT_CHARSET),
2666 arglist,n);
2667
2668 set_something(w,XmNlabelString,"Services");
2669 if(servp)
2670 {
2671 XtAddCallback(w,XmNactivateCallback, activate_services, servp);
2672 XtManageChild(w);
2673 strcat(w_name,"1");
2674 n = 0;
2675 XtSetArg(arglist[n], XmNfontList, did_default_font); n++;
2676 w = XmCreatePushButton(ww,
2677 (String)XmStringCreateLtoR ( w_name,XmSTRING_DEFAULT_CHARSET),
2678 arglist,n);
2679
2680 set_something(w,XmNlabelString,"Clients");
2681 XtAddCallback(w,XmNactivateCallback, activate_clients, servp);
2682 XtManageChild(w);
2683 /*
2684 servp->popping = 0;
2685 create_client_popup(servp);
2686 */
2687 }
2688 return(w_id);
2689}
2690
2691void remove_all_buttons()
2692{
2693SERVER *servp;
2694
2695 servp = Server_head;
2696 while( (servp = (SERVER *)sll_get_next((SLL *)servp)) )
2697 {
2698 if(servp->button_id)
2699 {
2700 XtDestroyWidget(servp->button_id);
2701 servp->button_id = 0;
2702 servp->busy = 0;
2703 }
2704 }
2705}
2706
2707void remove_button(SERVER *servp)
2708{
2709
2710 if(servp->button_id)
2711 {
2712 XtDestroyWidget(servp->button_id);
2713 servp->button_id = 0;
2714 servp->busy = 0;
2715 }
2716}
2717
2718void activate_services(Widget w, SERVER *servp, unsigned long *reason)
2719{
2720DNS_SERVER_INFO *ptr;
2721char str[MAX_NAME];
2722Widget id,sel_id;
2723void got_service_list();
2724void kick_it();
2725
2726 if(w){}
2727 if(reason){}
2728 if(servp->pop_widget_id[0])
2729 {
2730 XtDestroyWidget(servp->pop_widget_id[0]);
2731 servp->pop_widget_id[0] = 0;
2732 /*
2733 return;
2734 */
2735 }
2736 Curr_servp = servp;
2737 ptr = &servp->server;
2738
2739 sel_id = put_popup(servp, 0,"Service Info");
2740
2741 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_OK_BUTTON);
2742 XtUnmanageChild(id);
2743
2744 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST_LABEL);
2745 if (ptr->pid > 0x1000000)
2746 sprintf(str,"Server %s (pid = %X) on node %s\n\nprovides %d services :\n",
2747 servp->name, ptr->pid, ptr->node, ptr->n_services);
2748 else
2749 sprintf(str,"Server %s (pid = %d) on node %s\n\nprovides %d services :\n",
2750 servp->name, ptr->pid, ptr->node, ptr->n_services);
2751 set_something(sel_id,XmNlistLabelString,str);
2752
2753 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST);
2754 Curr_service_list_id = id;
2755
2756 XmListAddItem(id,create_str(
2757 "Ordering services alphabeticaly, please be patient..."),1);
2758
2759 set_something(id,XmNlistItemCount,1);
2760 set_something(id,XmNlistVisibleItemCount,1);
2761
2762 sprintf(str,"%s/SERVICE_LIST",/*ptr->task*/servp->name);
2763 dic_info_service(str,ONCE_ONLY,20,0,0,
2764 got_service_list,(long)servp,"None",5);
2765 /*
2766#ifdef solaris
2767 */
2768 /*
2769 XtAppAddTimeOut(app_context, 1000, kick_it, 0);
2770 */
2771 /*
2772#endif
2773 */
2774}
2775
2776void kick_it()
2777{
2778 printf("kick_it\n");
2779}
2780
2781typedef char DID_SLOT[MAX_NAME];
2782
2783void got_service_list(SERVER **servp_ptr, char *buffer, int *size)
2784{
2785SERVER *servp;
2786void do_got_service_list();
2787
2788 if(size){}
2789 servp = *servp_ptr;
2790 if(Curr_service_list)
2791 free(Curr_service_list);
2792 Curr_service_list = malloc(strlen(buffer)+1);
2793 strcpy(Curr_service_list, buffer);
2794 /*
2795#ifdef solaris
2796 */
2797 Got_Service_List = servp;
2798 /*
2799#else
2800 do_got_service_list(servp);
2801#endif
2802 */
2803}
2804
2805void do_got_service_list(SERVER *servp)
2806{
2807char cmd_str[256], svc_str[256];
2808DNS_SERVER_INFO *ptr;
2809DNS_SERVICE_INFO *service_ptr;
2810Widget id;
2811char *curr_str, max_str[MAX_NAME], *sptr;
2812DID_SLOT *service_list;
2813int i, j, curr_index = 0, n_services;
2814XmString xstr;
2815void delete_str();
2816
2817 ptr = &servp->server;
2818 id = Curr_service_list_id;
2819
2820 XmListDeleteAllItems(id);
2821
2822 strcpy(cmd_str,"CMD: ");
2823 strcpy(svc_str,"SVC: ");
2824
2825 service_ptr = servp->service_ptr;
2826 service_list = (DID_SLOT *)malloc(ptr->n_services * MAX_NAME);
2827 n_services = ptr->n_services;
2828
2829 for(i=0;i<n_services; i++)
2830 {
2831 strcpy(service_list[i],service_ptr->name);
2832 service_ptr++;
2833 }
2834 strcpy(max_str,"zzzzzzzzzzzzzzzzzzzzzzzzzzzz");
2835 for(i=0;i<n_services; i++)
2836 {
2837 curr_str = max_str;
2838 for(j=0;j<n_services; j++)
2839 {
2840 sptr = service_list[j];
2841 if(!*sptr)
2842 continue;
2843
2844 if(strcmp(sptr,curr_str) < 0)
2845 {
2846 curr_str = sptr;
2847 curr_index = j;
2848 }
2849 }
2850 service_list[curr_index][0] = '\0';
2851 service_ptr = &(servp->service_ptr[curr_index]);
2852 if(service_ptr->type)
2853 {
2854 strcpy(&cmd_str[5],service_ptr->name);
2855 xstr = create_str(cmd_str);
2856 XmListAddItem(id,xstr,i+1);
2857 delete_str(xstr);
2858 }
2859 else
2860 {
2861 strcpy(&svc_str[5],service_ptr->name);
2862 xstr = create_str(svc_str);
2863 XmListAddItem(id,xstr,i+1);
2864 delete_str(xstr);
2865 }
2866 }
2867 free(service_list);
2868
2869 set_something(id,XmNlistItemCount,i);
2870 set_something(id,XmNlistVisibleItemCount,(i < 20) ? i : 20);
2871}
2872
2873void show_clients(SERVER **servp_ptr, char *buffer, int *size)
2874{
2875SERVER *servp;
2876void do_show_clients();
2877
2878 if(size){}
2879 servp = *servp_ptr;
2880 if(Curr_client_list)
2881 free(Curr_client_list);
2882 Curr_client_list = malloc(strlen(buffer)+1);
2883 strcpy(Curr_client_list, buffer);
2884 /*
2885#ifdef solaris
2886 */
2887 Got_Client_List = servp;
2888 /*
2889#else
2890 do_show_clients(servp);
2891#endif
2892 */
2893}
2894
2895void do_show_clients(SERVER *servp)
2896{
2897int i = 0;
2898char str[2048], *strp, *strp1;
2899DNS_SERVER_INFO *ptr;
2900XmString xstr;
2901void delete_str();
2902
2903 ptr = &servp->server;
2904 /*
2905 sel_id = servp->pop_widget_id[1];
2906 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST_LABEL);
2907 */
2908 if(Curr_client_list[0] == -1)
2909 {
2910 sprintf(str,"Information not available\n");
2911 XmListAddItem(Curr_client_id,create_str(str),i+1);
2912 /*
2913 set_something(sel_id,XmNlistLabelString,str);
2914 */
2915 return;
2916 }
2917 /*
2918 sprintf(str,"Clients of %s are : \n",
2919 ptr->task);
2920 set_something(sel_id,XmNlistLabelString,str);
2921
2922 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST);
2923 XmListDeleteAllItems(id);
2924 */
2925 strp1 = Curr_client_list;
2926 while(strp1)
2927 {
2928 if(!*strp1)
2929 break;
2930 sprintf(str,"Process ");
2931 strp = strp1;
2932 strp1 = strchr(strp,'@');
2933 *strp1 = '\0';
2934 strp1++;
2935 strcat(str,strp);
2936 strcat(str," on node ");
2937 strp = strp1;
2938 if( (strp1 = strchr(strp,'|')) )
2939 {
2940 *strp1 = '\0';
2941 strp1++;
2942 }
2943 strcat(str,strp);
2944 xstr = create_str(str);
2945 XmListAddItem(Curr_client_id,xstr,i+1);
2946 delete_str(xstr);
2947 i++;
2948 }
2949 if(!i)
2950 {
2951 sprintf(str,"NONE");
2952 xstr = create_str(str);
2953 XmListAddItem(Curr_client_id,xstr,i+1);
2954 delete_str(xstr);
2955 }
2956 /*
2957 set_something(id,XmNlistItemCount,i);
2958 */
2959 /*
2960 if(Matrix_id[Curr_matrix])
2961 XFlush(XtDisplay(Matrix_id[Curr_matrix]));
2962 */
2963}
2964
2965void activate_clients(Widget w, SERVER *servp, unsigned long *reason)
2966{
2967DNS_SERVER_INFO *ptr;
2968char str[100];
2969void show_clients();
2970void kick_it_again();
2971Widget id,sel_id;
2972
2973 if(w) {}
2974 if(reason){}
2975 Curr_servp = servp;
2976 ptr = &servp->server;
2977 if(servp->pop_widget_id[1])
2978 {
2979 XtDestroyWidget(servp->pop_widget_id[1]);
2980 servp->pop_widget_id[1] = 0;
2981 }
2982 sel_id = put_popup(servp,1,"Client Info");
2983
2984 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_HELP_BUTTON);
2985 XtUnmanageChild(id);
2986
2987 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_APPLY_BUTTON);
2988 XtUnmanageChild(id);
2989
2990 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_CANCEL_BUTTON);
2991 XtUnmanageChild(id);
2992
2993 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_TEXT);
2994 XtUnmanageChild(id);
2995
2996 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_SELECTION_LABEL);
2997 XtUnmanageChild(id);
2998 /*
2999 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST_LABEL);
3000 */
3001 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST);
3002 XmListDeleteAllItems(id);
3003
3004 Curr_client_id = id;
3005 sprintf(str,"Clients of %s are : \n",
3006 servp->name);
3007 set_something(sel_id,XmNlistLabelString,str);
3008
3009 sprintf(str,"%s/CLIENT_LIST",/*ptr->task*/servp->name);
3010 dic_info_service(str,ONCE_ONLY,10,0,0,
3011 show_clients,(long)servp,&no_link,1);
3012 /*
3013#ifdef solaris
3014 */
3015 /*
3016 XtAppAddTimeOut(app_context, 1000, kick_it_again, 0);
3017 */
3018 /*
3019#endif
3020 */
3021}
3022
3023void kick_it_again()
3024{
3025 printf("kick_it_again\n");
3026}
3027
3028Widget put_popup(SERVER *servp, int type, char *title)
3029{
3030 Widget id;
3031 void activate_services(), activate_clients();
3032 extern void set_title();
3033
3034 if(type)
3035 {
3036 id = create_client_dialog();
3037 /*
3038 XtAddCallback(id,XmNokCallback, activate_clients, servp);
3039 XtAddCallback(id,XmNcancelCallback, activate_clients, servp);
3040 */
3041 }
3042 else
3043 {
3044 id = create_server_dialog();
3045 /*
3046 XtAddCallback(id,XmNcancelCallback, activate_services, servp);
3047 */
3048 }
3049 servp->pop_widget_id[type] = id;
3050 /*
3051 }
3052 */
3053 XtManageChild(id);
3054 set_title(XtParent(id),title);
3055 return(id);
3056}
3057
3058Widget put_selection(int tag, char *title)
3059{
3060 Widget id = 0;
3061 extern void set_title();
3062
3063 if(pop_widget_id[tag])
3064 {
3065 XtDestroyWidget(pop_widget_id[tag]);
3066 }
3067 switch(tag)
3068 {
3069 case DID_SEL_NODE:
3070 id = create_node_selection();
3071 break;
3072 case DID_SEL_SERVICE:
3073 id = create_service_selection();
3074 break;
3075 case DID_KILL_ALL:
3076 id = create_kill_confirmation();
3077 break;
3078 case DID_SERVICE:
3079 id = create_service_dialog();
3080 break;
3081 case DID_COMMAND:
3082 id = create_send_command();
3083 break;
3084 }
3085
3086 pop_widget_id[tag] = id;
3087 XtManageChild(id);
3088 set_title(XtParent(id),title);
3089 return(id);
3090}
3091
3092void check_put_label(int tag)
3093{
3094 static int old_n_services = 0;
3095 static int changing = 0;
3096 void put_label();
3097
3098 if(tag){}
3099 if(N_services != old_n_services)
3100 {
3101 put_label();
3102 if(N_services > old_n_services)
3103 changing = 1;
3104 old_n_services = N_services;
3105
3106#ifdef linux
3107 show_servers();
3108#endif
3109 }
3110/*
3111 else
3112 {
3113 if(changing)
3114 {
3115 show_servers();
3116 changing = 0;
3117 }
3118 }
3119*/
3120}
3121
3122void put_label()
3123{
3124 char str[MAX_NAME], str1[MAX_NAME];
3125
3126 DISABLE_AST
3127 sprintf(str,"%d Servers known - %d Services Available\n",
3128 N_servers,N_services);
3129 switch(Curr_view_opt)
3130 {
3131 case 1 :
3132 strcat(str,"Displaying ALL Servers");
3133 break;
3134 case 0 :
3135 sprintf(str1,"Displaying Servers on node %s",Curr_view_opt_par);
3136 strcat(str,str1);
3137 break;
3138 case 2 :
3139 sprintf(str1,"Displaying Servers providing Service *%s*",
3140 Curr_view_opt_par);
3141 strcat(str,str1);
3142 break;
3143 case 3 :
3144 strcat(str,"Displaying Servers in ERROR");
3145 break;
3146 case -1 :
3147 strcat(str,"Please Select Viewing Option");
3148 break;
3149 }
3150 set_something(Label_id,XmNlabelString,str);
3151 XFlush(XtDisplay(Label_id));
3152 ENABLE_AST
3153}
3154
3155Widget create_client_dialog()
3156{
3157 Widget id;
3158 id = create_selection_dialog("Dismiss","","","","",DID_CLIENTS, 3);
3159 return(id);
3160
3161}
3162
3163Widget create_server_dialog()
3164{
3165 Widget id;
3166 id = create_selection_dialog("","View / Send","Dismiss","",
3167 "Service / Command :",
3168 DID_SERVICES, 20);
3169 return(id);
3170}
3171
3172Widget create_node_selection()
3173{
3174 Widget id;
3175 id = create_selection_dialog("","","","Nodes :","Selected Node :",DID_SEL_NODE, 8);
3176 return(id);
3177
3178}
3179
3180Widget create_service_selection()
3181{
3182 Widget id;
3183 /*
3184 id = create_prompt_dialog("Enter Service Name :",DID_SEL_SERVICE);
3185 */
3186 id = create_selection_dialog("","","","","Enter Service Name (or search string):",DID_SEL_SERVICE, 0);
3187 return(id);
3188
3189}
3190
3191Widget create_send_command()
3192{
3193 Widget id;
3194 char str[256], str1[256];
3195
3196 sprintf(str,"Command to %s (%s)\n\n",
3197 Curr_service_name, Curr_service_format);
3198
3199 id = create_selection_dialog("","","",str,"Command:",DID_COMMAND, 1);
3200
3201 strcpy(str1,"Please enter items separated by spaces:\n(for example: 2 0x123 'A' 23.4 \"a text\")");
3202
3203 set_something(id,XmNselectionLabelString,str1);
3204
3205 return(id);
3206
3207}
3208
3209Widget create_kill_confirmation()
3210{
3211 Widget id;
3212 id = create_question_dialog("Do you really want to kill ALL DIM servers ?",
3213 DID_KILL_ALL);
3214 return(id);
3215
3216}
3217
3218Widget create_selection_dialog(char *ok, char *apply, char *cancel, char *list, char *sel,
3219 long tag, int items)
3220{
3221Widget sd;
3222XmString xmOk, xmApply, xmCancel, xmList, xmSelection;
3223Arg ar[20];
3224int n;
3225
3226 xmList = create_str(list);
3227 xmOk = create_str(ok);
3228 xmApply = create_str(apply);
3229 xmCancel = create_str (cancel);
3230 xmSelection = create_str (sel);
3231
3232 n = 0;
3233 /*
3234 XtSetArg(ar[n],XmNdialogStyle,XmDIALOG_FULL_APPLICATION_MODAL); n++;
3235 XtSetArg(ar[n],XmNmwmFunctions,MWM_FUNC_MOVE); n++;
3236 */
3237 XtSetArg(ar[n],XmNtitle,"Selection"); n++;
3238 XtSetArg(ar[n],XmNlabelFontList, did_default_font); n++;
3239 XtSetArg(ar[n],XmNbuttonFontList, did_default_font); n++;
3240 XtSetArg(ar[n],XmNtextFontList, did_small_font); n++;
3241 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3242 XtSetArg(ar[n],XmNlistLabelString, xmList); n++;
3243 XtSetArg(ar[n],XmNlistVisibleItemCount,items); n++;
3244 if(ok[0])
3245 {
3246 XtSetArg(ar[n],XmNokLabelString, xmOk); n++;
3247 }
3248 if(apply[0])
3249 {
3250 XtSetArg(ar[n],XmNapplyLabelString, xmApply); n++;
3251 }
3252 if(cancel[0])
3253 {
3254 XtSetArg(ar[n],XmNcancelLabelString, xmCancel); n++;
3255 }
3256 if(sel[0])
3257 {
3258 XtSetArg(ar[n],XmNselectionLabelString, xmSelection); n++;
3259 }
3260 sd = XmCreateSelectionDialog ( toplevel_widget, "Selection", ar, n );
3261 XmStringFree(xmList);
3262 XmStringFree(xmOk);
3263 XmStringFree(xmApply);
3264 XmStringFree(xmCancel);
3265 XmStringFree(xmSelection);
3266 if(tag >= 0)
3267 {
3268 XtAddCallback ( sd, XmNcancelCallback,
3269 (XtCallbackProc)cancel_pop_up, (XtPointer)tag );
3270 XtAddCallback ( sd, XmNapplyCallback,
3271 (XtCallbackProc)ok_pop_up, (XtPointer)tag );
3272 XtAddCallback ( sd, XmNokCallback,
3273 (XtCallbackProc)ok_pop_up, (XtPointer)tag );
3274 }
3275 return(sd);
3276}
3277
3278Widget create_file_selection_dialog(long type)
3279{
3280Widget sd;
3281XmString xm1;
3282Arg ar[20];
3283int n;
3284
3285 xm1 = create_str ("");
3286 n = 0;
3287 /*
3288 XtSetArg(ar[n],XmNdialogStyle,XmDIALOG_FULL_APPLICATION_MODAL); n++;
3289 XtSetArg(ar[n],XmNmwmFunctions,MWM_FUNC_MOVE); n++;
3290 */
3291 XtSetArg(ar[n],XmNtitle,"FileSelection"); n++;
3292 XtSetArg(ar[n],XmNlabelFontList, did_default_font); n++;
3293 XtSetArg(ar[n],XmNbuttonFontList, did_default_font); n++;
3294 XtSetArg(ar[n],XmNtextFontList, did_default_font); n++;
3295 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3296 XtSetArg(ar[n],XmNwidth, 500); n++;
3297 XtSetArg(ar[n],XmNdirMask, xm1); n++;
3298 sd = XmCreateFileSelectionDialog ( toplevel_widget, "FileSelection", ar, n );
3299
3300 XmStringFree(xm1);
3301
3302 XtAddCallback ( sd, XmNcancelCallback,
3303 (XtCallbackProc)cancel_pop_up, (XtPointer)type );
3304 XtAddCallback ( sd, XmNokCallback,
3305 (XtCallbackProc)ok_pop_up, (XtPointer)type );
3306
3307 return(sd);
3308}
3309
3310Widget create_prompt_dialog(char *label, long tag)
3311{
3312Widget sd;
3313XmString xm1;
3314Arg ar[20];
3315int n;
3316
3317 xm1 = create_str (label);
3318 n = 0;
3319 XtSetArg(ar[n],XmNlabelFontList, did_default_font); n++;
3320 XtSetArg(ar[n],XmNbuttonFontList, did_default_font); n++;
3321 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3322 /*
3323 XtSetArg(ar[n],XmNwidth, 450); n++;
3324 XtSetArg(ar[n],XmNresizePolicy, XmRESIZE_NONE); n++;
3325 */
3326 XtSetArg(ar[n],XmNselectionLabelString, xm1); n++;
3327 sd = XmCreatePromptDialog ( toplevel_widget, "Prompt", ar, n );
3328
3329 XmStringFree(xm1);
3330
3331 XtAddCallback ( sd, XmNcancelCallback,
3332 (XtCallbackProc)cancel_pop_up, (XtPointer)tag );
3333 XtAddCallback ( sd, XmNokCallback,
3334 (XtCallbackProc)ok_pop_up, (XtPointer)tag );
3335
3336 return(sd);
3337}
3338
3339Widget create_question_dialog(char *label, long tag)
3340{
3341Widget sd;
3342XmString xm1;
3343Arg ar[20];
3344int n;
3345
3346 xm1 = create_str (label);
3347 n = 0;
3348 XtSetArg(ar[n],XmNlabelFontList, did_default_font); n++;
3349 XtSetArg(ar[n],XmNbuttonFontList, did_default_font); n++;
3350 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3351 /*
3352 XtSetArg(ar[n],XmNwidth, 450); n++;
3353 XtSetArg(ar[n],XmNresizePolicy, XmRESIZE_NONE); n++;
3354 */
3355 XtSetArg(ar[n],XmNmessageString, xm1); n++;
3356 sd = XmCreateQuestionDialog ( toplevel_widget, "Question", ar, n );
3357
3358 XmStringFree(xm1);
3359
3360 XtAddCallback ( sd, XmNcancelCallback,
3361 (XtCallbackProc)cancel_pop_up, (XtPointer)tag );
3362 XtAddCallback ( sd, XmNokCallback,
3363 (XtCallbackProc)ok_pop_up, (XtPointer)tag );
3364
3365 return(sd);
3366}
3367
3368Widget create_service_dialog()
3369{
3370Widget fd, rc, sw, lb, rc1;
3371XmString xm1;
3372Arg ar[20];
3373int n, par;
3374unsigned long reason;
3375
3376 n = 0;
3377 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3378 XtSetArg(ar[n],XmNresizePolicy, XmRESIZE_ANY); n++;
3379 fd = XmCreateFormDialog ( toplevel_widget, "Form", ar, n );
3380 XtManageChild(fd);
3381
3382 /* create rowcolumn */
3383 n = 0;
3384 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3385 XtSetArg(ar[n],XmNentryAlignment, XmALIGNMENT_CENTER); n++;
3386 XtSetArg(ar[n],XmNbottomAttachment, XmATTACH_FORM); n++;
3387 XtSetArg(ar[n],XmNbottomOffset, 0); n++;
3388 XtSetArg(ar[n],XmNrightAttachment, XmATTACH_FORM); n++;
3389 XtSetArg(ar[n],XmNrightOffset, 0); n++;
3390 XtSetArg(ar[n],XmNtopAttachment, XmATTACH_FORM); n++;
3391 XtSetArg(ar[n],XmNtopOffset, 0); n++;
3392 XtSetArg(ar[n],XmNleftAttachment, XmATTACH_FORM); n++;
3393 XtSetArg(ar[n],XmNleftOffset, 0); n++;
3394 rc = XmCreateRowColumn ( fd, "rowcol", ar, n );
3395 XtManageChild(rc);
3396
3397 /* create scrolled window */
3398 n = 0;
3399 XtSetArg ( ar[n], XmNwidth, 770); n++;
3400 XtSetArg ( ar[n], XmNheight, 350); n++;
3401 XtSetArg ( ar[n], XmNscrollBarDisplayPolicy, XmAS_NEEDED); n++;
3402 XtSetArg ( ar[n], XmNscrollingPolicy, XmAUTOMATIC); n++;
3403
3404 sw = XmCreateScrolledWindow ( rc, "ScrollWin", ar, n );
3405 XtManageChild ( sw );
3406
3407 /* create label */
3408 n = 0;
3409 xm1 = create_str(" ");
3410 XtSetArg(ar[n],XmNfontList, did_small_font); n++;
3411 XtSetArg(ar[n],XmNlabelString, xm1); n++;
3412 XtSetArg(ar[n],XmNalignment, XmALIGNMENT_BEGINNING); n++;
3413 lb = XmCreateLabel ( sw, "label", ar, n );
3414 XtManageChild(lb);
3415 XmStringFree(xm1);
3416 par = 1;
3417 reason = 0;
3418 create_label(lb, &par, &reason);
3419
3420 /* create button rowcolumn */
3421 n = 0;
3422 XtSetArg(ar[n],XmNborderWidth, 0); n++;
3423 XtSetArg(ar[n],XmNentryAlignment, XmALIGNMENT_CENTER); n++;
3424 XtSetArg(ar[n],XmNorientation, XmVERTICAL); n++;
3425 XtSetArg(ar[n],XmNnumColumns, 3); n++;
3426 XtSetArg(ar[n],XmNpacking, XmPACK_COLUMN); n++;
3427 rc1 = XmCreateRowColumn ( rc, "buttons", ar, n );
3428 XtManageChild(rc1);
3429 /*
3430 create_push_button(rc1,"View Standard",MAX_POP_UPS+1);
3431 create_push_button(rc1,"View Float",MAX_POP_UPS+2);
3432 create_push_button(rc1,"View Double",MAX_POP_UPS+3);
3433 */
3434 SubscribeButton = create_push_button(rc1," Subscribe (On Change) ",
3435 MAX_POP_UPS+5);
3436 Subscribe10Button = create_push_button(rc1," Subscribe (Update Rate 10 seconds) ",
3437 MAX_POP_UPS+4);
3438 create_push_button(rc1,"Dismiss",DID_SERVICE);
3439 Curr_service_print_type = 0;
3440
3441 return(fd);
3442}
3443
3444Widget create_push_button(Widget parent, char *str, long tag)
3445{
3446Widget b;
3447XmString xm1;
3448Arg ar[20];
3449int n;
3450
3451 n = 0;
3452 xm1 = create_str(str);
3453 XtSetArg(ar[n],XmNalignment, XmALIGNMENT_CENTER); n++;
3454 XtSetArg(ar[n],XmNfontList, did_default_font); n++;
3455 XtSetArg(ar[n],XmNlabelString, xm1); n++;
3456 b = XmCreatePushButton ( parent, "button", ar, n );
3457
3458 XtManageChild(b);
3459 XmStringFree(xm1);
3460
3461 XtAddCallback ( b, XmNactivateCallback,
3462 (XtCallbackProc)cancel_pop_up, (XtPointer)tag );
3463 return(b);
3464}
3465
3466
3467
3468
Note: See TracBrowser for help on using the repository browser.