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

Last change on this file since 14064 was 12585, checked in by tbretz, 13 years ago
Updated to v19r26.
File size: 78.1 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,"dns",3)) ||
816 (!strncmp(opt_str,"DNS",3))) {
817 char text[132];
818 sprintf(text,"DIM_DNS_NODE=%s",opt_str+4);
819 putenv(text);
820 dim_set_dns_node(opt_str+4);
821 }
822 else if((!strncmp(opt_str,"service",7)) ||
823 (!strncmp(opt_str,"SERVICE",7)))
824 Curr_view_opt = 2;
825 else if((!strncmp(opt_str,"error",5)) ||
826 (!strncmp(opt_str,"ERROR",5)))
827 Curr_view_opt = 3;
828 else if((!strncmp(opt_str,"help",4)) ||
829 (!strncmp(opt_str,"HELP",4)))
830 {
831 printf("Did - DIM Information Display\n");
832 printf("\t-all Show ALL Servers\n");
833 printf("\t-dns=<str> Show Servers with DIM_DNS_NODE provided by <str>\n");
834 printf("\t-service=<str> Show Servers providing Service <str>\n");
835 printf("\t-node=<nodename> Show Servers on Node <nodename>\n");
836 printf("\t-error Show Servers in Error\n");
837 printf("\t-help Show this message\n\n");
838 exit(0);
839 }
840 else
841 Curr_view_opt = -1;
842 if((Curr_view_opt == 0) || (Curr_view_opt == 2))
843 {
844 if(!(ptr = strchr(argv[1],'=')))
845 {
846 if( (ptr = strchr(argv[2],'=')) )
847 {
848 ptr++;
849 if(!(*ptr))
850 ptr = argv[3];
851 }
852 else
853 ptr++;
854 }
855 else
856 {
857 ptr++;
858 if(!(*ptr))
859 ptr = argv[2];
860 }
861 for(i = 0;*ptr; ptr++, i++)
862 Curr_view_opt_par[i] = toupper(*ptr);
863 Curr_view_opt_par[i] = '\0';
864 }
865 }
866 }
867
868 toplevel_widget = (Widget)gui_initialize(argc, argv);
869 app_initialize();
870 /*
871 * Sit around forever waiting to process X-events. We never leave
872 * XtAppMainLoop. From here on, we only execute our callback routines.
873 */
874
875 while(1)
876 {
877 {
878 DISABLE_AST
879 mask = XtAppPending(app_context);
880 ENABLE_AST
881 }
882 if(mask)
883 {
884 DISABLE_AST
885 XtAppProcessEvent(app_context, mask);
886 if(Got_Service_List)
887 {
888 do_got_service_list(Got_Service_List);
889 Got_Service_List = 0;
890 }
891 if(Got_Client_List)
892 {
893 do_show_clients(Got_Client_List);
894 Got_Client_List = 0;
895 }
896 ENABLE_AST
897 }
898 else
899 {
900 dim_usleep(100000);
901 /*
902 usleep(100000);
903 */
904 }
905 }
906
907}
908
909static char no_link = -1;
910
911void app_initialize(int tag)
912{
913void check_put_label();
914
915void update_servers();
916void update_servers_new();
917void update_show_servers();
918extern void get_all_colors();
919extern void set_title();
920extern void set_icon_title();
921char dns_node[64];
922int dns_port;
923char title[128],icon_title[128];
924
925 if(tag){}
926 dic_get_dns_node(dns_node);
927 dns_port = dic_get_dns_port();
928 if(dns_port != DNS_PORT)
929 {
930 sprintf(title,"DID - DIM Information Display DNS=%s:%d",dns_node,dns_port);
931 }
932 else
933 {
934 sprintf(title,"DID - DIM Information Display DNS=%s",dns_node);
935 }
936 sprintf(icon_title,"DID %s",dns_node);
937 get_all_colors(display,Matrix_id[Curr_matrix]);
938 set_title(toplevel_widget,title);
939 set_icon_title(toplevel_widget,icon_title);
940 Timer_q = dtq_create();
941 dic_info_service("DIS_DNS/SERVER_INFO",MONITORED,0,0,0,update_servers,0,
942 &no_link,1);
943 /*
944 dic_info_service("DIS_DNS/SERVER_LIST",MONITORED,0,0,0,
945 update_servers_new,0, &no_link,1);
946 */
947 /*
948 dtq_add_entry(Timer_q, 2, check_put_label, 0);
949 */
950 XtAppAddTimeOut(app_context, 1000, update_show_servers, 0);
951}
952
953/*
954 * All errors are fatal.
955 */
956void s_error(char *problem_string)
957{
958 printf("%s\n", problem_string);
959 exit(0);
960}
961
962void did_exit(Widget w, int *tag, unsigned long *reason)
963{
964 if(w){}
965 if(tag){}
966 if(reason){}
967 exit(0);
968}
969
970extern Pixel rgb_colors[MAX_COLORS];
971
972void create_main (Widget w, int *tag, unsigned long *reason)
973{
974 if(tag){}
975 if(reason){}
976 Window_id = w;
977/*
978 dtq_start_timer(5, app_initialize, 0);
979*/
980}
981
982void view_opts(Widget w, int tag, unsigned long *reason)
983{
984 void get_server_node(), get_server_service(), show_servers();
985
986 if(w){}
987 if(reason){}
988 Curr_view_opt = tag;
989 switch(tag)
990 {
991 case 0 :
992 get_server_node();
993 break;
994 case 1 :
995 show_servers();
996 break;
997 case 2 :
998 get_server_service();
999 break;
1000 case 3 :
1001 show_servers();
1002 break;
1003 }
1004}
1005
1006void dns_control(Widget w, int tag, unsigned long *reason)
1007{
1008
1009 if(w){}
1010 if(reason){}
1011 switch(tag)
1012 {
1013 case 0 :
1014 dic_cmnd_service("DIS_DNS/PRINT_STATS",0,0);
1015 break;
1016 case 1 :
1017 dic_cmnd_service("DIS_DNS/DEBUG_ON",0,0);
1018 break;
1019 case 2 :
1020 dic_cmnd_service("DIS_DNS/DEBUG_OFF",0,0);
1021 break;
1022 case 3 :
1023 put_selection(DID_KILL_ALL,"Confirmation");
1024 break;
1025 case 4 :
1026 dic_cmnd_service("DIS_DNS/PRINT_HASH_TABLE",0,0);
1027 break;
1028 }
1029}
1030
1031void get_server_node()
1032{
1033Widget id,sel_id;
1034int i, j, n_nodes, curr_index = 0;
1035char nodes_str[MAX_NODE_NAME*MAX_CONNS], max_str[MAX_NODE_NAME];
1036char *ptr, *nodeptrs[MAX_CONNS], *curr_str, *sptr;
1037int get_nodes();
1038
1039 sel_id = put_selection(DID_SEL_NODE,"Node Selection");
1040 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_HELP_BUTTON);
1041 XtUnmanageChild(id);
1042 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_APPLY_BUTTON);
1043 XtUnmanageChild(id);
1044 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST);
1045 XmListDeleteAllItems(id);
1046 n_nodes = get_nodes(nodes_str);
1047 ptr = nodes_str;
1048
1049 for(i=0;i<n_nodes;i++)
1050 {
1051 nodeptrs[i] = ptr;
1052 sptr = ptr;
1053 ptr = strchr(ptr,'\n');
1054 for(j = 0; j < (int)strlen(sptr); j++)
1055 sptr[j] = tolower(sptr[j]);
1056 *ptr++ = '\0';
1057 }
1058 strcpy(max_str,"zzzzzzzzzzzzzzzzzzzzzzzzzzzz");
1059 for(i=0;i<n_nodes; i++)
1060 {
1061 curr_str = max_str;
1062 for(j=0;j<n_nodes; j++)
1063 {
1064 sptr = nodeptrs[j];
1065 if(!sptr)
1066 continue;
1067
1068 if(strcmp(sptr,curr_str) < 0)
1069 {
1070 curr_str = sptr;
1071 curr_index = j;
1072 }
1073 }
1074 nodeptrs[curr_index] = 0;
1075 XmListAddItem(id,create_str(curr_str),i+1);
1076 }
1077 /*
1078 for(i=0;i<n_nodes;i++)
1079 {
1080 node = ptr;
1081 ptr = strchr(ptr,'\n');
1082 *ptr++ = '\0';
1083 XmListAddItem(id,create_str(node),i+1);
1084 }
1085 */
1086 set_something(id,XmNlistItemCount,i);
1087 set_something(id,XmNlistVisibleItemCount,(i < 8) ? i : 8);
1088}
1089
1090void get_server_service()
1091{
1092Widget id,sel_id;
1093
1094 sel_id = put_selection(DID_SEL_SERVICE,"Service Selection");
1095 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_HELP_BUTTON);
1096 XtUnmanageChild(id);
1097 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_APPLY_BUTTON);
1098 XtUnmanageChild(id);
1099
1100 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST);
1101 /*
1102 XtUnmanageChild(id);
1103 */
1104 XtUnmapWidget(id);
1105
1106 /*
1107 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST_LABEL);
1108 XtUnmanageChild(id);
1109 */
1110}
1111
1112int get_nodes(char *node_ptr)
1113{
1114DNS_SERVER_INFO *ptr;
1115int n_nodes = 0;
1116SERVER *servp;
1117
1118 node_ptr[0] = '\0';
1119 servp = Server_head;
1120 while( (servp = (SERVER *)sll_get_next((SLL *)servp)) )
1121 {
1122 ptr = &servp->server;
1123 if(strstr(node_ptr,ptr->node) <= (char *)0)
1124 {
1125 strcat(node_ptr,ptr->node);
1126 strcat(node_ptr,"\n");
1127 n_nodes++;
1128 }
1129 }
1130 return(n_nodes);
1131}
1132
1133void get_service_format()
1134{
1135
1136 char str[256], *ptr, *ptr1;
1137 int rpc_flag;
1138
1139 strcpy(str,Curr_service_name);
1140 rpc_flag = 0;
1141 if( (ptr = strstr(str,"/RpcIn")) )
1142 {
1143 *ptr = '\0';
1144 rpc_flag = 1;
1145 }
1146 if( (ptr = strstr(str,"/RpcOut")) )
1147 {
1148 *ptr = '\0';
1149 rpc_flag = 2;
1150 }
1151 strcat(str,"|");
1152 if( (ptr = strstr(Curr_service_list,str)) )
1153 {
1154 if(!rpc_flag)
1155 {
1156 ptr += strlen(str);
1157 ptr1 = strchr(ptr,'|');
1158 }
1159 else if(rpc_flag == 1)
1160 {
1161 ptr += strlen(str);
1162 ptr1 = strchr(ptr,',');
1163 }
1164 else
1165 {
1166 ptr += strlen(str);
1167 ptr = strchr(ptr,',');
1168 ptr++;
1169 ptr1 = strchr(ptr,'|');
1170 }
1171 strncpy(Curr_service_format,ptr,(int)(ptr1 - ptr));
1172 Curr_service_format[(int)(ptr1-ptr)] = '\0';
1173 }
1174}
1175
1176void recv_service_info(int *tag, int *buffer, int *size)
1177{
1178/*
1179 char str[256], *ptr, *ptr1;
1180 int rpc_flag;
1181*/
1182 void print_service_formatted();
1183
1184 if(tag){}
1185 Service_content_str = malloc(1024 + (*size)*16);
1186 Service_buffer = malloc(*size);
1187 memcpy(Service_buffer, (char *)buffer, *size);
1188 Service_size = *size;
1189 get_service_format();
1190 if((*size == 4 ) && (*buffer == -1))
1191 {
1192 sprintf(Service_content_str,
1193 "Service %s Not Available\n", Curr_service_name);
1194 }
1195 else
1196 {
1197 switch(Curr_service_print_type)
1198 {
1199 case 0:
1200 print_service_formatted(buffer,*size);
1201 break;
1202 /*
1203 case 1:
1204 print_service_float(buffer, ((*size - 1) / 4) + 1);
1205 break;
1206 case 2:
1207 print_service_double(buffer, ((*size - 1) / 4) + 1);
1208 break;
1209 */
1210 }
1211 }
1212 set_something(Content_label_id,XmNlabelString, Service_content_str);
1213 /*
1214 if(Matrix_id[Curr_matrix])
1215 XFlush(XtDisplay(Matrix_id[Curr_matrix]));
1216 */
1217}
1218
1219void print_service_formatted(void *buff, int size)
1220{
1221char type;
1222int num, ret;
1223char str[128];
1224char *ptr;
1225void *buffer_ptr;
1226char timestr[128], aux[10];
1227int quality = 0, secs = 0, mili = 0;
1228int did_write_string(char, int, void **, int);
1229time_t tsecs;
1230
1231 sprintf(Service_content_str,
1232 "Service %s (%s) Contents :\n \n", Curr_service_name,
1233 Curr_service_format);
1234 /*
1235 if(Curr_service_id)
1236 {
1237 */
1238 dic_get_timestamp(0, &secs, &mili);
1239 quality = dic_get_quality(0);
1240/*
1241#ifdef LYNXOS
1242 ctime_r((time_t *)&secs, timestr, 128);
1243#else
1244 ctime_r((time_t *)&secs, timestr);
1245#endif
1246*/
1247 tsecs = secs;
1248 my_ctime(&tsecs, timestr, 128);
1249 ptr = strrchr(timestr,' ');
1250 strcpy(aux, ptr);
1251 sprintf(ptr,".%03d",mili);
1252 strcat(timestr, aux);
1253 timestr[strlen(timestr)-1] = '\0';
1254
1255 sprintf(str," Timestamp: %s Quality: %d\n\n",
1256 timestr, quality);
1257
1258 strcat(Service_content_str,str);
1259 /*
1260 }
1261 */
1262 ptr = Curr_service_format;
1263 buffer_ptr = buff;
1264 while(*ptr)
1265 {
1266 type = *ptr++;
1267 if(*ptr == ':')
1268 {
1269 ptr++;
1270 sscanf(ptr, "%d", &num);
1271 ret = did_write_string(type, num, &buffer_ptr, size);
1272 size -= ret;
1273 if( (ptr = strchr(ptr,';')) )
1274 ptr++;
1275 else
1276 break;
1277 }
1278 else
1279 {
1280 ret = did_write_string(type, 0, &buffer_ptr, size);
1281 size -= ret;
1282 break;
1283 }
1284 }
1285}
1286
1287int did_write_string(char type, int num, void **buffer_ptr, int ssize)
1288{
1289void *ptr;
1290int size, psize;
1291
1292 void print_service_standard();
1293 void print_service_char();
1294 void print_service_short();
1295 void print_service_float();
1296 void print_service_double();
1297
1298 ptr = *buffer_ptr;
1299 switch(type)
1300 {
1301 case 'L':
1302 case 'l':
1303 strcat(Service_content_str," L");
1304 if(!num)
1305 size = ssize/sizeof(int);
1306 else
1307 size = num;
1308 psize = size * sizeof(int);
1309 print_service_standard(ptr, size);
1310 break;
1311 case 'I':
1312 case 'i':
1313 strcat(Service_content_str," I");
1314 if(!num)
1315 size = ssize/sizeof(int);
1316 else
1317 size = num;
1318 psize = size * sizeof(int);
1319 print_service_standard(ptr, size);
1320 break;
1321 case 'S':
1322 case 's':
1323 strcat(Service_content_str," S");
1324 if(!num)
1325 size = ssize/sizeof(short);
1326 else
1327 size = num;
1328 psize = size * sizeof(short);
1329 print_service_short(ptr, size);
1330 break;
1331 case 'F':
1332 case 'f':
1333 strcat(Service_content_str," F");
1334 if(!num)
1335 size = ssize/sizeof(float);
1336 else
1337 size = num;
1338 psize = size * sizeof(float);
1339 print_service_float(ptr, size);
1340 break;
1341 case 'D':
1342 case 'd':
1343 strcat(Service_content_str," D");
1344 if(!num)
1345 size = ssize/sizeof(double);
1346 else
1347 size = num;
1348 psize = size * sizeof(double);
1349 print_service_double(ptr, size);
1350 break;
1351 case 'X':
1352 case 'x':
1353 strcat(Service_content_str," X");
1354 if(!num)
1355 size = ssize/sizeof(longlong);
1356 else
1357 size = num;
1358 psize = size * sizeof(longlong);
1359 print_service_standard(ptr, size*2);
1360 break;
1361 case 'C':
1362 case 'c':
1363 default:
1364 strcat(Service_content_str," C");
1365 if(!num)
1366 size = ssize;
1367 else
1368 size = num;
1369 psize = size;
1370 print_service_char(ptr, size);
1371 }
1372 ptr = (char *)ptr + psize;
1373 *buffer_ptr = ptr;
1374 return psize;
1375}
1376/*
1377print_service(buff, size)
1378int *buff, size;
1379{
1380int i,j, str_flag = 0;
1381char *asc, *ptr, str[80];
1382int last[4];
1383
1384 sprintf(Service_content_str,
1385 "Service %s (%s) Contents :\n \n", Curr_service_name,
1386 Curr_service_format);
1387 asc = (char *)buff;
1388 for( i = 0; i < size; i++)
1389 {
1390 if(i%4 == 0)
1391 {
1392 sprintf(str,"%4d: ",i);
1393 strcat(Service_content_str,str);
1394 }
1395 if(!(i%4))
1396 strcat(Service_content_str,"H");
1397 sprintf(str," %08X ",buff[i]);
1398 strcat(Service_content_str,str);
1399 last[i%4] = buff[i];
1400 if(i%4 == 3)
1401 {
1402 strcat(Service_content_str," '");
1403 for(j = 0; j <16; j++)
1404 {
1405 if(isprint(asc[j]))
1406 {
1407 sprintf(str,"%c",asc[j]);
1408 strcat(Service_content_str,str);
1409 }
1410 else
1411 {
1412 sprintf(str,".");
1413 strcat(Service_content_str,str);
1414 }
1415 }
1416 strcat(Service_content_str,"'\n");
1417 for(j = 0; j <4; j++)
1418 {
1419 if(j == 0)
1420 strcat(Service_content_str," D");
1421 sprintf(str,"%11d ",last[j]);
1422 strcat(Service_content_str,str);
1423 }
1424 strcat(Service_content_str,"\n");
1425 asc = (char *)&buff[i+1];
1426 }
1427 }
1428 if(i%4)
1429 {
1430 for(j = 0; j < 4 - (i%4); j++)
1431 strcat(Service_content_str," ");
1432 strcat(Service_content_str," '");
1433 for(j = 0; j < (i%4) * 4; j++)
1434 {
1435 if(isprint(asc[j]))
1436 {
1437 sprintf(str,"%c",asc[j]);
1438 strcat(Service_content_str,str);
1439 }
1440 else
1441 strcat(Service_content_str,".");
1442 }
1443 strcat(Service_content_str,"'\n");
1444 for(j = 0; j < (i%4); j++)
1445 {
1446 if(j == 0)
1447 strcat(Service_content_str," D");
1448 sprintf(str,"%11d ",last[j]);
1449 strcat(Service_content_str,str);
1450 }
1451 strcat(Service_content_str,"\n");
1452 }
1453}
1454*/
1455
1456void print_service_standard(int *buff, int size)
1457{
1458int i,j;
1459char *asc, *ptr, str[80], tmp[256];
1460int last[4];
1461
1462 asc = (char *)buff;
1463 ptr = Service_content_str;
1464 ptr += strlen(Service_content_str);
1465 for( i = 0; i < size; i++)
1466 {
1467 strcpy(tmp,"");
1468 if(i%4 == 0)
1469 {
1470 if(i != 0)
1471 {
1472 strcat(tmp," ");
1473 }
1474 sprintf(str,"%5d ",i);
1475 strcat(tmp,str);
1476 }
1477 if(!(i%4))
1478 strcat(tmp,"H: ");
1479 sprintf(str," %08X",buff[i]);
1480 strcat(tmp,str);
1481 last[i%4] = buff[i];
1482 if((i%4 == 3) || (i == (size-1)))
1483 {
1484 /*
1485 if(i%4 != 3)
1486 {
1487 for(j = 1; j < 4 - (i%4); j++)
1488 strcat(tmp," ");
1489 }
1490 strcat(tmp," '");
1491 for(j = 0; j < ((i%4)*4)+4 ; j++)
1492 {
1493 if(isprint(asc[j]))
1494 {
1495 sprintf(str,"%c",asc[j]);
1496 strcat(tmp,str);
1497 }
1498 else
1499 {
1500 sprintf(str,".");
1501 strcat(tmp,str);
1502 }
1503 }
1504 */
1505 strcat(tmp,"\n");
1506 for(j = 0; j <= (i%4); j++)
1507 {
1508 if(j == 0)
1509 strcat(tmp," D: ");
1510 sprintf(str,"%12d",last[j]);
1511 strcat(tmp,str);
1512 }
1513 strcat(tmp,"\n");
1514 asc = (char *)&buff[i+1];
1515 }
1516 strcpy(ptr, tmp);
1517 ptr += strlen(tmp);
1518 }
1519 strcpy(tmp,"\n");
1520 strcpy(ptr, tmp);
1521}
1522
1523void print_service_longlong(longlong *buff, int size)
1524{
1525int i,j;
1526char *asc, *ptr, str[80], tmp[256];
1527longlong last[4];
1528
1529 asc = (char *)buff;
1530 ptr = Service_content_str;
1531 ptr += strlen(Service_content_str);
1532 for( i = 0; i < size; i++)
1533 {
1534 strcpy(tmp,"");
1535 if(i%4 == 0)
1536 {
1537 if(i != 0)
1538 {
1539 strcat(tmp," ");
1540 }
1541 sprintf(str,"%5d ",i);
1542 strcat(tmp,str);
1543 }
1544 if(!(i%4))
1545 strcat(tmp,"H: ");
1546 sprintf(str," %08X",(unsigned)buff[i]);
1547 strcat(tmp,str);
1548 last[i%4] = buff[i];
1549 if((i%4 == 3) || (i == (size-1)))
1550 {
1551 strcat(tmp,"\n");
1552 for(j = 0; j <= (i%4); j++)
1553 {
1554 if(j == 0)
1555 strcat(tmp," D: ");
1556 sprintf(str,"%12d",(int)last[j]);
1557 strcat(tmp,str);
1558 }
1559 strcat(tmp,"\n");
1560 asc = (char *)&buff[i+1];
1561 }
1562 strcpy(ptr, tmp);
1563 ptr += strlen(tmp);
1564 }
1565 strcpy(tmp,"\n");
1566 strcpy(ptr, tmp);
1567}
1568
1569void print_service_short(short *buff, int size)
1570{
1571int i,j;
1572char *asc, *ptr, str[80], tmp[256];
1573short last[8];
1574
1575 asc = (char *)buff;
1576 ptr = Service_content_str;
1577 ptr += strlen(Service_content_str);
1578 for( i = 0; i < size; i++)
1579 {
1580 strcpy(tmp,"");
1581 if(i%8 == 0)
1582 {
1583 if(i != 0)
1584 {
1585 strcat(tmp," ");
1586 }
1587 sprintf(str,"%5d ",i);
1588 strcat(tmp,str);
1589 }
1590 if(!(i%8))
1591 strcat(tmp,"H: ");
1592 sprintf(str," %04X",buff[i]);
1593 strcat(tmp,str);
1594 last[i%8] = buff[i];
1595 if((i%8 == 7) || (i == (size-1)))
1596 {
1597 /*
1598 if(i%7 != 7)
1599 {
1600 for(j = 1; j < 8 - (i%8); j++)
1601 strcat(tmp," ");
1602 }
1603 strcat(tmp," '");
1604 for(j = 0; j < ((i%8)*2)+2 ; j++)
1605 {
1606 if(isprint(asc[j]))
1607 {
1608 sprintf(str,"%c",asc[j]);
1609 strcat(tmp,str);
1610 }
1611 else
1612 {
1613 sprintf(str,".");
1614 strcat(tmp,str);
1615 }
1616 }
1617 */
1618 strcat(tmp,"\n");
1619 for(j = 0; j <= (i%8); j++)
1620 {
1621 if(j == 0)
1622 strcat(tmp," D: ");
1623 sprintf(str," %5d",last[j]);
1624 strcat(tmp,str);
1625 }
1626 strcat(tmp,"\n");
1627 asc = (char *)&buff[i+1];
1628 }
1629 strcpy(ptr, tmp);
1630 ptr += strlen(tmp);
1631 }
1632 strcpy(tmp,"\n");
1633 strcpy(ptr, tmp);
1634}
1635
1636void print_service_char(char *buff, int size)
1637{
1638int i,j;
1639char *asc, *ptr, str[80], tmp[256];
1640char last[16];
1641
1642 asc = (char *)buff;
1643 ptr = Service_content_str;
1644 ptr += strlen(Service_content_str);
1645 for( i = 0; i < size; i++)
1646 {
1647 strcpy(tmp,"");
1648 if(i%16 == 0)
1649 {
1650 if(i != 0)
1651 {
1652 strcat(tmp," ");
1653 }
1654 sprintf(str,"%5d ",i);
1655 strcat(tmp,str);
1656 }
1657 if(!(i%16))
1658 strcat(tmp,"H: ");
1659 sprintf(str,"%02X",buff[i]);
1660/* strcat(tmp,str);
1661*/
1662 strcat(tmp," ");
1663 strcat(tmp,&str[strlen(str)-2]);
1664 last[i%16] = buff[i];
1665 /*
1666 if(i%4 == 3)
1667 strcat(tmp," ");
1668 */
1669 if((i%16 == 15) || (i == (size-1)))
1670 {
1671 if(i%16 != 15)
1672 {
1673 for(j = 1; j < 16 - (i%16); j++)
1674 strcat(tmp," ");
1675 }
1676 strcat(tmp," '");
1677 for(j = 0; j <= (i%16) ; j++)
1678 {
1679 if(isprint(asc[j]))
1680 {
1681 sprintf(str,"%c",asc[j]);
1682 strcat(tmp,str);
1683 }
1684 else
1685 {
1686 sprintf(str,".");
1687 strcat(tmp,str);
1688 }
1689 }
1690 strcat(tmp,"'\n");
1691 asc = (char *)&buff[i+1];
1692 }
1693 strcpy(ptr, tmp);
1694 ptr += strlen(tmp);
1695 }
1696 strcpy(tmp,"\n");
1697 strcpy(ptr, tmp);
1698}
1699
1700void print_service_float(float *buff, int size)
1701{
1702int i;
1703char *ptr, str[80], tmp[256];
1704
1705 ptr = Service_content_str;
1706 ptr += strlen(Service_content_str);
1707 for( i = 0; i < size; i++)
1708 {
1709 strcpy(tmp,"");
1710 if(i%4 == 0)
1711 {
1712 if(i != 0)
1713 {
1714 strcat(tmp," ");
1715 }
1716 sprintf(str," %5d: ",i);
1717 strcat(tmp,str);
1718 }
1719 sprintf(str,"%12.3G",*(buff++));
1720 strcat(tmp,str);
1721 if((i%4 == 3) || (i == size-1))
1722 {
1723 strcat(tmp,"\n");
1724 }
1725 strcpy(ptr, tmp);
1726 ptr += strlen(tmp);
1727 }
1728 strcpy(tmp,"\n");
1729 strcpy(ptr, tmp);
1730 ptr += strlen(tmp);
1731}
1732
1733void print_service_double(double *buff, int size)
1734{
1735int i;
1736char *ptr, str[80], tmp[256];
1737
1738 ptr = Service_content_str;
1739 ptr += strlen(Service_content_str);
1740 for( i = 0; i < size; i++)
1741 {
1742 strcpy(tmp,"");
1743 if(i%4 == 0)
1744 {
1745 if(i != 0)
1746 {
1747 strcat(tmp," ");
1748 }
1749 sprintf(str," %5d: ",i);
1750 strcat(tmp,str);
1751 }
1752 sprintf(str,"%12.3G",*(buff++));
1753 strcat(tmp,str);
1754 if((i%4 == 3) || (i == size-1))
1755 {
1756 strcat(tmp,"\n");
1757 }
1758 strcpy(ptr, tmp);
1759 ptr += strlen(tmp);
1760 }
1761 strcpy(tmp,"\n");
1762 strcpy(ptr, tmp);
1763 ptr += strlen(tmp);
1764}
1765
1766void ok_pop_up (Widget w, long tag, unsigned long *reason)
1767{
1768Widget id, sel_id;
1769char *str, *pstr;
1770void recv_service_info();
1771void did_prepare_command();
1772void show_servers();
1773
1774/*
1775 if(tag == 5)
1776 {
1777 id = (Widget)XmSelectionBoxGetChild(w,XmDIALOG_TEXT);
1778 str = (char *)XmTextGetString(id);
1779 if(!str[0])
1780 {
1781 XtFree(str);
1782 return;
1783 }
1784 if( ( fptr = fopen( str, "w" ) ) == (FILE *)0 )
1785 {
1786 printf("Cannot open: %s for writing\n",str);
1787 return;
1788 }
1789 ptr = &Curr_servp->server;
1790 if (ptr->pid > 0x1000000)
1791 fprintf(fptr,"Server %s (pid = %X) on node %s\n provides %d services :\n",
1792 Curr_servp->name, ptr->pid, ptr->node, ptr->n_services);
1793 else
1794 fprintf(fptr,"Server %s (pid = %d) on node %s\n provides %d services :\n",
1795 Curr_servp->name, ptr->pid, ptr->node, ptr->n_services);
1796 service_ptr = Curr_servp->service_ptr;
1797 for(i=0;i<ptr->n_services; i++)
1798 {
1799 sprintf(str,service_ptr->name);
1800 fprintf(fptr," %s\n",service_ptr->name);
1801 service_ptr++;
1802 }
1803 fclose(fptr);
1804 XtFree(str);
1805 return;
1806 }
1807 if(tag == 4)
1808 {
1809 sel_id = put_selection(4, "Printing...");
1810 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_HELP_BUTTON);
1811 XtUnmanageChild(id);
1812
1813 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_APPLY_BUTTON);
1814 XtUnmanageChild(id);
1815 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_TEXT);
1816 str = (char *)XmTextGetString(id);
1817 if(!str[0])
1818 {
1819 XtFree(str);
1820 return;
1821 }
1822 ptr = &Curr_servp->server;
1823 if(pstr = strrchr(str,']'))
1824 *(++pstr) = '\0';
1825 if(pstr = strrchr(str,'/'))
1826 *(++pstr) = '\0';
1827 sprintf(txt_str,"%s%s.TXT",str,Curr_servp->name);
1828 XtFree(str);
1829 XmTextSetString(id, txt_str);
1830 return;
1831 }
1832*/
1833 if(reason){}
1834 if(tag == DID_KILL_ALL)
1835 {
1836 dic_cmnd_service("DIS_DNS/KILL_SERVERS",0,0);
1837 return;
1838 }
1839 id = XmSelectionBoxGetChild(w,XmDIALOG_TEXT);
1840 str = XmTextGetString(id);
1841 if(!str[0])
1842 {
1843 XtFree(str);
1844 return;
1845 }
1846 if ((tag == DID_SEL_NODE) || (tag == DID_SEL_SERVICE))
1847 {
1848 strcpy(Curr_view_opt_par, str);
1849 show_servers();
1850 XtFree(str);
1851 }
1852 if(tag == DID_SERVICES)
1853 {
1854 pstr = strchr(str,' ');
1855 if(!pstr)
1856 {
1857 strcpy(Curr_service_name, str);
1858 strcpy(str,"SVC");
1859 }
1860 else
1861 {
1862 pstr++;
1863 strcpy(Curr_service_name, pstr);
1864 }
1865 if(Curr_service_id)
1866 {
1867 dic_release_service(Curr_service_id);
1868 Curr_service_id = 0;
1869 }
1870 if(str[0] == 'S')
1871 {
1872 /*
1873 if((!strstr(pstr,"/SERVICE_LIST")) &&
1874 (!strstr(pstr,"/CLIENT_LIST")) &&
1875 (!strstr(pstr,"/SERVER_LIST")))
1876 {
1877 Curr_service_id = dic_info_service(Curr_service_name,
1878 MONITORED,5,0,0,
1879 recv_service_info,0,
1880 &no_link_int,4);
1881 }
1882 else
1883 {
1884 */
1885 dic_info_service_stamped(Curr_service_name,
1886 ONCE_ONLY,10,0,0,
1887 recv_service_info,0,
1888 &no_link_int,4);
1889 /*
1890 }
1891 */
1892 put_selection(DID_SERVICE,"Service Contents");
1893 }
1894 else
1895 {
1896 get_service_format();
1897 sel_id = put_selection(DID_COMMAND,"Send Command");
1898 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_HELP_BUTTON);
1899 XtUnmanageChild(id);
1900 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_APPLY_BUTTON);
1901 XtUnmanageChild(id);
1902 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST);
1903 /*
1904 XtUnmanageChild(id);
1905 */
1906 XtUnmapWidget(id);
1907 }
1908 XtFree(str);
1909 }
1910 if(tag == DID_COMMAND)
1911 {
1912 did_prepare_command(str);
1913 XtFree(str);
1914 }
1915}
1916
1917int get_type_size(char type)
1918{
1919 int size;
1920
1921 switch(type)
1922 {
1923 case 'L':
1924 case 'l':
1925 size = sizeof(long);
1926 break;
1927 case 'I':
1928 case 'i':
1929 size = sizeof(int);
1930 break;
1931 case 'S':
1932 case 's':
1933 size = sizeof(short);
1934 break;
1935 case 'F':
1936 case 'f':
1937 size = sizeof(float);
1938 break;
1939 case 'D':
1940 case 'd':
1941 size = sizeof(double);
1942 break;
1943 case 'C':
1944 case 'c':
1945 default:
1946 size = 1;
1947 }
1948 return(size);
1949}
1950
1951void did_prepare_command(char *str)
1952{
1953char type;
1954int num;
1955int size, full_size = 0;
1956char *ptr;
1957static int last_size = 0;
1958static void *last_buffer = 0;
1959void *buffer_ptr;
1960char *str_ptr;
1961void did_read_string(char, int, void **, char **);
1962
1963 str_ptr = str;
1964 ptr = Curr_service_format;
1965 while(*ptr)
1966 {
1967 type = *ptr++;
1968 if(*ptr == ':')
1969 {
1970 ptr++;
1971 size = get_type_size(type);
1972 sscanf(ptr, "%d", &num);
1973 full_size += size * num;
1974 if( (ptr = strchr(ptr,';')) )
1975 ptr++;
1976 else
1977 break;
1978 }
1979 }
1980
1981 full_size += 256;
1982 if(full_size > last_size)
1983 {
1984 if(last_size)
1985 free(last_buffer);
1986 last_buffer = malloc(full_size);
1987 last_size = full_size;
1988 }
1989 buffer_ptr = last_buffer;
1990 ptr = Curr_service_format;
1991 while(*ptr)
1992 {
1993 type = *ptr++;
1994 if(*ptr == ':')
1995 {
1996 ptr++;
1997 sscanf(ptr, "%d", &num);
1998 did_read_string(type, num, &buffer_ptr, &str_ptr);
1999 if(!str_ptr)
2000 break;
2001 if( (ptr = strchr(ptr,';')) )
2002 ptr++;
2003 else
2004 break;
2005 }
2006 else
2007 {
2008 did_read_string(type, 0, &buffer_ptr, &str_ptr);
2009 break;
2010 }
2011 }
2012 full_size = (int) ((char *)buffer_ptr - (char *)last_buffer);
2013 dic_cmnd_service(Curr_service_name,last_buffer,full_size);
2014}
2015
2016int read_str_int(char *str)
2017{
2018 int i;
2019 if((str[0] == '0') && (str[1] == 'x'))
2020 sscanf(str+2,"%x",&i);
2021 else
2022 sscanf(str,"%d",&i);
2023 return(i);
2024}
2025
2026int read_str_char(char *str, char *cc)
2027{
2028
2029 if(str[0] == '\'')
2030 *cc = str[1];
2031 else if(str[0] == '\"')
2032 return(0);
2033 else if((str[0] == '0') && (str[1] == 'x'))
2034 sscanf(str+2,"%x",(int *)cc);
2035 else if(isalpha(str[0]))
2036 return(-1);
2037 else
2038 sscanf(str,"%d",(int *)cc);
2039 return(1);
2040}
2041
2042void did_read_string(char type, int num, void **buffer_ptr, char **str_ptr)
2043{
2044int i, ret = 0;
2045float ff;
2046double dd;
2047void *ptr;
2048char *strp, *ptr1;
2049char cc;
2050 short s;
2051
2052 strp = *str_ptr;
2053 ptr = *buffer_ptr;
2054 if(!num)
2055 num = 1000000;
2056 switch(type)
2057 {
2058 case 'L':
2059 case 'l':
2060 case 'I':
2061 case 'i':
2062 for(i = 0; i<num; i++)
2063 {
2064 *(int *)ptr = read_str_int(strp);
2065 ptr = (int *)ptr +1;
2066 if( (strp = strchr(strp,' ')) )
2067 strp++;
2068 else
2069 break;
2070 }
2071 break;
2072 case 'S':
2073 case 's':
2074 for(i = 0; i<num; i++)
2075 {
2076 s = (short)read_str_int(strp);
2077 *((short *)ptr) = s;
2078 ptr = (short *)ptr +1;
2079 if( (strp = strchr(strp,' ')) )
2080 strp++;
2081 else
2082 break;
2083 }
2084 break;
2085 case 'F':
2086 case 'f':
2087 for(i = 0; i<num; i++)
2088 {
2089 sscanf(strp,"%f",&ff);
2090 *(float *)ptr = ff;
2091 ptr = (float *)ptr +1;
2092 if( (strp = strchr(strp,' ')) )
2093 strp++;
2094 else
2095 break;
2096 }
2097 break;
2098 case 'D':
2099 case 'd':
2100 for(i = 0; i<num; i++)
2101 {
2102 sscanf(strp,"%f",&ff);
2103 dd = (double)ff;
2104 *(double *)ptr = dd;
2105 ptr = (double *)ptr +1;
2106 if( (strp = strchr(strp,' ')) )
2107 strp++;
2108 else
2109 break;
2110 }
2111 break;
2112 case 'C':
2113 case 'c':
2114 default:
2115 for(i = 0; i<num; i++)
2116 {
2117 if((ret = read_str_char(strp, &cc)) <= 0)
2118 break;
2119 *(char *)ptr = cc;
2120 ptr = (char *)ptr +1;
2121 if( (strp = strchr(strp,' ')) )
2122 strp++;
2123 else
2124 break;
2125 }
2126 if(ret <= 0)
2127 {
2128 if(!ret)
2129 {
2130 strp++;
2131 }
2132 num = strlen(strp)+1;
2133 strncpy((char *)ptr,strp,num);
2134 if( (ptr1 = (char *)strchr((char *)ptr,'\"')) )
2135 {
2136 num--;
2137 *ptr1 = '\0';
2138 }
2139 ptr = (char *)ptr + num;
2140 if( (strp = strchr(strp,' ')) )
2141 strp++;
2142 else
2143 break;
2144 }
2145 }
2146 *buffer_ptr = ptr;
2147 *str_ptr = strp;
2148}
2149
2150void cancel_pop_up (Widget w, int tag, unsigned long *reason)
2151{
2152 void print_service_formatted();
2153
2154 if(reason){}
2155 if(tag == MAX_POP_UPS+1)
2156 {
2157 print_service_formatted(Service_buffer,Service_size);
2158 set_something(Content_label_id,XmNlabelString, Service_content_str);
2159 Curr_service_print_type = 0;
2160 }
2161 /*
2162 else if(tag == MAX_POP_UPS+2)
2163 {
2164 print_service_float(Service_buffer, ((Service_size - 1) / 4) + 1);
2165 set_something(Content_label_id,XmNlabelString, Service_content_str);
2166 Curr_service_print_type = 1;
2167 }
2168 else if(tag == MAX_POP_UPS+3)
2169 {
2170 print_service_double(Service_buffer, ((Service_size - 1) / 4) + 1);
2171 set_something(Content_label_id,XmNlabelString, Service_content_str);
2172 Curr_service_print_type = 2;
2173 }
2174 */
2175 else if(tag == MAX_POP_UPS+4)
2176 {
2177
2178 if((!strstr(Curr_service_name,"/SERVICE_LIST")) &&
2179 (!strstr(Curr_service_name,"/CLIENT_LIST")) &&
2180 (!strstr(Curr_service_name,"/SERVER_LIST")))
2181 {
2182 if(Curr_service_id)
2183 {
2184 dic_release_service(Curr_service_id);
2185 Curr_service_id = 0;
2186 }
2187 Curr_service_id = dic_info_service_stamped(Curr_service_name,
2188 MONITORED,10,0,0,
2189 recv_service_info,0,
2190 &no_link_int,4);
2191 }
2192 XtSetSensitive(w, False);
2193 XtSetSensitive(SubscribeButton, True);
2194 }
2195 else if(tag == MAX_POP_UPS+5)
2196 {
2197
2198 if((!strstr(Curr_service_name,"/SERVICE_LIST")) &&
2199 (!strstr(Curr_service_name,"/CLIENT_LIST")) &&
2200 (!strstr(Curr_service_name,"/SERVER_LIST")))
2201 {
2202 if(Curr_service_id)
2203 {
2204 dic_release_service(Curr_service_id);
2205 Curr_service_id = 0;
2206 }
2207 Curr_service_id = dic_info_service_stamped(Curr_service_name,
2208 MONITORED,0,0,0,
2209 recv_service_info,0,
2210 &no_link_int,4);
2211 }
2212 XtSetSensitive(w, False);
2213 XtSetSensitive(Subscribe10Button, True);
2214 }
2215/*
2216 else if(tag == 5)
2217 {
2218 *
2219 XtUnmapWidget(XtParent(pop_widget_id[4]));
2220 *
2221 }
2222*/
2223 else if(tag == DID_SERVICE)
2224 {
2225 if(Curr_service_id)
2226 {
2227 dic_release_service(Curr_service_id);
2228 Curr_service_id = 0;
2229 }
2230 XtUnmanageChild(pop_widget_id[DID_SERVICE]);
2231 free(Service_content_str);
2232 free(Service_buffer);
2233 }
2234}
2235
2236void create_matrix(Widget w, int *tag, unsigned long *reason)
2237{
2238
2239 if(reason){}
2240 Matrix_id[*tag] = w;
2241 if(*tag)
2242 XtUnmanageChild(w);
2243 else
2244 Curr_matrix = 0;
2245}
2246
2247void create_label(Widget w, int *tag, unsigned long *reason)
2248{
2249 if(reason){}
2250 if(!*tag)
2251 Label_id = w;
2252 else
2253 Content_label_id = w;
2254}
2255
2256void switch_matrix()
2257{
2258 /*
2259 XtUnmanageChild(Matrix_id[Curr_matrix]);
2260 Curr_matrix = (Curr_matrix) ? 0 : 1;
2261 XtManageChild(Matrix_id[Curr_matrix]);
2262 */
2263 XmScrolledWindowSetAreas(Window_id,NULL, NULL, Matrix_id[Curr_matrix]);
2264}
2265
2266/*
2267static int curr_allocated_size = 0;
2268static DNS_SERVER_INFO *dns_info_buffer;
2269*/
2270
2271void update_servers_new(int *tag, char *buffer, int *size)
2272{
2273 if(tag){}
2274 if(size){}
2275 printf("Server_list:\n%s\n",buffer);
2276}
2277
2278SERVER *find_server(char *node, int pid)
2279{
2280 SERVER *servp;
2281 DNS_SERVER_INFO *ptr;
2282
2283 servp = Server_head;
2284 while( (servp = (SERVER *)sll_get_next((SLL *)servp)) )
2285 {
2286 ptr = &servp->server;
2287 if((ptr->pid == pid) && (!strcmp(ptr->node,node)))
2288 {
2289 return(servp);
2290 }
2291 }
2292 return ((SERVER *)0);
2293}
2294 /*
2295 if(!(servp = (SERVER *)sll_search((SLL *)Server_head,
2296 (char *)&buffer->server, MAX_NODE_NAME+MAX_TASK_NAME-4)))
2297 */
2298
2299
2300void update_servers(int *tag, DNS_DID *buffer, int *size)
2301{
2302int n_services, service_size;
2303SERVER *servp;
2304int j;
2305char str[MAX_NAME], sname[MAX_NAME], *ptr;
2306
2307 if(tag){}
2308 if(!Server_head)
2309 {
2310 Server_head = (SERVER *)malloc(sizeof(SERVER));
2311 sll_init((SLL *)Server_head);
2312 }
2313 if(First_time)
2314 {
2315 switch_matrix();
2316 First_time = 0;
2317 }
2318
2319 if(!*size)
2320 return;
2321 if(*(char *)buffer == -1)
2322 {
2323 N_servers = 0;
2324 N_services = 0;
2325 return;
2326 }
2327 buffer->server.n_services = vtohl(buffer->server.n_services);
2328 buffer->server.pid = vtohl(buffer->server.pid);
2329 n_services = buffer->server.n_services;
2330
2331 if(n_services == 1)
2332 return;
2333 strcpy(sname, buffer->server.task);
2334 if(n_services > 1)
2335 {
2336 for(j = 0; j < n_services; j++)
2337 {
2338 buffer->services[j].type = vtohl(
2339 buffer->services[j].type);
2340 buffer->services[j].status = vtohl(
2341 buffer->services[j].status);
2342 buffer->services[j].n_clients = vtohl(
2343 buffer->services[j].n_clients);
2344 if(strlen(sname) == MAX_TASK_NAME-4-1)
2345 {
2346 strcpy(str,buffer->services[j].name);
2347 if( (ptr = strstr(str,"/CLIENT_LIST")) )
2348 {
2349 *ptr = '\0';
2350 strcpy(sname,str);
2351 }
2352 }
2353 }
2354 }
2355 if (!(servp = find_server(buffer->server.node,buffer->server.pid)))
2356 /*
2357 if(!(servp = (SERVER *)sll_search((SLL *)Server_head,
2358 (char *)&buffer->server, MAX_NODE_NAME+MAX_TASK_NAME-4)))
2359 */
2360 {
2361 if(n_services)
2362 {
2363 servp = (SERVER *)malloc(sizeof(SERVER));
2364 strcpy(servp->name,sname);
2365 servp->next = 0;
2366 servp->button_id = 0;
2367 servp->pop_widget_id[0] = 0;
2368 servp->pop_widget_id[1] = 0;
2369 servp->busy = 0;
2370 servp->server.n_services = 0;
2371 servp->service_ptr = 0;
2372 sll_insert_queue((SLL *)Server_head,(SLL *)servp);
2373 }
2374 }
2375 if(n_services != 0)
2376 {
2377 if(n_services == servp->server.n_services)
2378 {
2379 return;
2380 }
2381 if(servp->server.n_services == 0)
2382 N_servers++;
2383 if(servp->server.n_services != -1)
2384 N_services -= servp->server.n_services;
2385 memcpy(&servp->server,&buffer->server,sizeof(DNS_SERVER_INFO));
2386 if(servp->service_ptr)
2387 {
2388 free(servp->service_ptr);
2389 servp->service_ptr = 0;
2390 }
2391 if(n_services != -1)
2392 {
2393 service_size = n_services*sizeof(DNS_SERVICE_INFO);
2394 servp->service_ptr = (DNS_SERVICE_INFO *)malloc(service_size);
2395 memcpy(servp->service_ptr, buffer->services, service_size);
2396 N_services += n_services;
2397 }
2398 servp->busy = 1;
2399 }
2400 else
2401 {
2402 if(servp)
2403 {
2404 N_servers--;
2405 if(servp->server.n_services != -1)
2406 {
2407 N_services -= servp->server.n_services;
2408 }
2409 else
2410 Force_update = 1;
2411 servp->server.n_services = 0;
2412 servp->busy = -1;
2413 }
2414 }
2415}
2416
2417void show_servers()
2418{
2419SERVER *servp;
2420void update_show_servers();
2421void remove_all_buttons();
2422void put_label();
2423
2424 if(!Matrix_id[Curr_matrix])
2425 return;
2426 remove_all_buttons();
2427
2428#ifndef linux
2429 switch_matrix();
2430#endif
2431 put_label();
2432 servp = Server_head;
2433 while( (servp = (SERVER *)sll_get_next((SLL *)servp)) )
2434 {
2435 servp->busy = 1;
2436 }
2437 Force_update = 1;
2438}
2439
2440void update_show_servers(void *tag, unsigned long *reason)
2441{
2442DNS_SERVER_INFO *server_ptr;
2443DNS_SERVICE_INFO *service_ptr;
2444int i, j, found, n_done = 0;
2445Widget w, create_button();
2446SERVER *servp, *prevp;
2447static int old_n_services = 0;
2448char node[MAX_NODE_NAME], par[MAX_NODE_NAME], *ptr;
2449void remove_button();
2450void remove_all_buttons();
2451void put_label();
2452
2453 DISABLE_AST
2454 if(tag){}
2455 if(reason){}
2456 if((N_services != old_n_services) || (Force_update))
2457 {
2458 if(!Matrix_id[Curr_matrix])
2459 {
2460 XtAppAddTimeOut(app_context, 1000, update_show_servers, 0);
2461 ENABLE_AST
2462 return;
2463 }
2464 if(!N_servers)
2465 {
2466 remove_all_buttons();
2467 if(! No_link_button_id)
2468 {
2469 No_link_button_id = create_button("DNS is down", 0);
2470 set_color(No_link_button_id, XmNbackground, RED);
2471 get_something(No_link_button_id,XmNuserData,&w);
2472 set_color(w, XmNbackground, RED);
2473 XtSetSensitive(No_link_button_id, False);
2474 }
2475 while(!sll_empty((SLL *)Server_head))
2476 {
2477 servp = (SERVER *)sll_remove_head((SLL *)Server_head);
2478 if(servp->service_ptr)
2479 free(servp->service_ptr);
2480 free(servp);
2481 }
2482 put_label();
2483 old_n_services = N_services;
2484 Force_update = 0;
2485 XtAppAddTimeOut(app_context, 1000, update_show_servers, 0);
2486 ENABLE_AST
2487 return;
2488 }
2489 if(No_link_button_id)
2490 {
2491 XtDestroyWidget(No_link_button_id);
2492 /*
2493 XFlush(XtDisplay(No_link_button_id));
2494 */
2495 No_link_button_id = 0;
2496 }
2497 servp = Server_head;
2498 prevp = 0;
2499 while( (servp = (SERVER *)sll_get_next((SLL *)servp)) )
2500 {
2501 if(prevp)
2502 {
2503 free(prevp);
2504 prevp = 0;
2505 }
2506 if(n_done == 10)
2507 {
2508 if(!Force_update)
2509 put_label();
2510 XtAppAddTimeOut(app_context, 100, update_show_servers, 0);
2511 ENABLE_AST
2512 return;
2513 }
2514 server_ptr = &servp->server;
2515 if(servp->busy == 1)
2516 {
2517 if(!servp->button_id)
2518 {
2519 switch(Curr_view_opt)
2520 {
2521 case 1 :
2522 servp->button_id = create_button(/*server_ptr->task*/servp->name, servp);
2523 n_done++;
2524 break;
2525 case 0 :
2526 strcpy(node, server_ptr->node);
2527 strcpy(par, Curr_view_opt_par);
2528 ptr = strchr(node, '.');
2529 if(ptr)
2530 *ptr = '\0';
2531 ptr = strchr(par,'.');
2532 if(ptr)
2533 *ptr = '\0';
2534 ptr = node;
2535 for(i = 0; i < (int)strlen(ptr); i++)
2536 ptr[i] = tolower(ptr[i]);
2537 ptr = par;
2538 for(i = 0; i < (int)strlen(ptr); i++)
2539 ptr[i] = tolower(ptr[i]);
2540 if(!strcmp(/*server_ptr->*/node, /*Curr_view_opt_*/par))
2541 {
2542 servp->button_id = create_button(/*server_ptr->task*/servp->name, servp);
2543 n_done++;
2544 }
2545 break;
2546 case 2 :
2547 found = 0;
2548 if(!(service_ptr = servp->service_ptr))
2549 break;
2550 for(j = 0; j < server_ptr->n_services; j++)
2551 {
2552 if(strstr(service_ptr->name, Curr_view_opt_par) > (char *)0)
2553 {
2554 found = 1;
2555 break;
2556 }
2557 service_ptr++;
2558 }
2559 if (found)
2560 {
2561 servp->button_id = create_button(/*server_ptr->task*/servp->name, servp);
2562 n_done++;
2563 }
2564 break;
2565 case 3 :
2566 if(server_ptr->n_services == -1)
2567 {
2568 servp->button_id = create_button(/*server_ptr->task*/servp->name, servp);
2569 n_done++;
2570 }
2571 else
2572 {
2573 if(servp->button_id)
2574 remove_button(servp);
2575 }
2576 n_done++;
2577 break;
2578 }
2579 }
2580 servp->busy = 2;
2581 if(servp->button_id)
2582 {
2583 if(Curr_view_opt != -1)
2584 {
2585 if (server_ptr->n_services == -1)
2586 {
2587 set_color(servp->button_id, XmNbackground, RED);
2588 get_something(servp->button_id,XmNuserData,&w);
2589 set_color(w, XmNbackground, RED);
2590 }
2591 else
2592 {
2593 set_color(servp->button_id, XmNbackground, GREEN);
2594 get_something(servp->button_id,XmNuserData,&w);
2595 set_color(w, XmNbackground, GREEN);
2596 }
2597 }
2598 }
2599 }
2600 else if (servp->busy == -1)
2601 {
2602 remove_button(servp);
2603 sll_remove((SLL *)Server_head, (SLL *)servp);
2604 if(servp->service_ptr)
2605 {
2606 free(servp->service_ptr);
2607 servp->service_ptr = 0;
2608 }
2609 prevp = servp;
2610 n_done++;
2611 }
2612 }
2613 if(prevp)
2614 {
2615 free(prevp);
2616 prevp = 0;
2617 }
2618 put_label();
2619 old_n_services = N_services;
2620 Force_update = 0;
2621 }
2622 XtAppAddTimeOut(app_context, 1000, update_show_servers, 0);
2623 ENABLE_AST
2624}
2625
2626Widget create_button(char *name, SERVER *servp)
2627{
2628Arg arglist[10];
2629int n, n_services = -1;
2630Widget w, ww, w_id;
2631void activate_services(), activate_clients();
2632char w_name[MAX_NAME];
2633
2634 w_name[0] = 0;
2635 if(servp)
2636 n_services = servp->server.n_services;
2637 strcpy(w_name,name);
2638 if(strlen(w_name) >= MAX_TASK_NAME - 4)
2639 w_name[16] = '\0';
2640 n = 0;
2641 XtSetArg(arglist[n], XmNorientation, XmVERTICAL); n++;
2642 XtSetArg(arglist[n], XmNentryAlignment, XmALIGNMENT_CENTER); n++;
2643 w_id = w = XmCreateMenuBar(Matrix_id[Curr_matrix],
2644 (String)XmStringCreateLtoR ( w_name,XmSTRING_DEFAULT_CHARSET),
2645 arglist,n);
2646/*
2647 if(n_services == -1)
2648 set_color(w, XmNbackground, RED);
2649 else
2650 set_color(w, XmNbackground, GREEN);
2651*/
2652 XtManageChild(w);
2653 strcat(w_name,"1");
2654 n = 0;
2655 XtSetArg(arglist[n], XmNalignment, XmALIGNMENT_CENTER); n++;
2656 XtSetArg(arglist[n], XmNfontList, did_server_font); n++;
2657 w = XmCreateCascadeButton(w,
2658 (String)XmStringCreateLtoR ( w_name,XmSTRING_DEFAULT_CHARSET),
2659 arglist,n);
2660 set_something(w,XmNlabelString,name);
2661 set_something(w,XmNalignment,XmALIGNMENT_CENTER);
2662/*
2663 if(n_services == -1)
2664 set_color(w, XmNbackground, RED);
2665 else
2666 set_color(w, XmNbackground, GREEN);
2667*/
2668 set_something(w_id,XmNuserData,w);
2669 strcat(w_name,"1");
2670 n = 0;
2671 ww = XmCreatePulldownMenu(w_id,
2672 (String)XmStringCreateLtoR ( w_name,XmSTRING_DEFAULT_CHARSET),
2673 arglist,n);
2674 set_something(w,XmNsubMenuId,ww);
2675 XtManageChild(w);
2676 strcat(w_name,"1");
2677 n = 0;
2678 XtSetArg(arglist[n], XmNfontList, did_default_font); n++;
2679 w = XmCreatePushButton(ww,
2680 (String)XmStringCreateLtoR ( w_name,XmSTRING_DEFAULT_CHARSET),
2681 arglist,n);
2682
2683 set_something(w,XmNlabelString,"Services");
2684 if(servp)
2685 {
2686 XtAddCallback(w,XmNactivateCallback, activate_services, servp);
2687 XtManageChild(w);
2688 strcat(w_name,"1");
2689 n = 0;
2690 XtSetArg(arglist[n], XmNfontList, did_default_font); n++;
2691 w = XmCreatePushButton(ww,
2692 (String)XmStringCreateLtoR ( w_name,XmSTRING_DEFAULT_CHARSET),
2693 arglist,n);
2694
2695 set_something(w,XmNlabelString,"Clients");
2696 XtAddCallback(w,XmNactivateCallback, activate_clients, servp);
2697 XtManageChild(w);
2698 /*
2699 servp->popping = 0;
2700 create_client_popup(servp);
2701 */
2702 }
2703 return(w_id);
2704}
2705
2706void remove_all_buttons()
2707{
2708SERVER *servp;
2709
2710 servp = Server_head;
2711 while( (servp = (SERVER *)sll_get_next((SLL *)servp)) )
2712 {
2713 if(servp->button_id)
2714 {
2715 XtDestroyWidget(servp->button_id);
2716 servp->button_id = 0;
2717 servp->busy = 0;
2718 }
2719 }
2720}
2721
2722void remove_button(SERVER *servp)
2723{
2724
2725 if(servp->button_id)
2726 {
2727 XtDestroyWidget(servp->button_id);
2728 servp->button_id = 0;
2729 servp->busy = 0;
2730 }
2731}
2732
2733void activate_services(Widget w, SERVER *servp, unsigned long *reason)
2734{
2735DNS_SERVER_INFO *ptr;
2736char str[MAX_NAME];
2737Widget id,sel_id;
2738void got_service_list();
2739void kick_it();
2740
2741 if(w){}
2742 if(reason){}
2743 if(servp->pop_widget_id[0])
2744 {
2745 XtDestroyWidget(servp->pop_widget_id[0]);
2746 servp->pop_widget_id[0] = 0;
2747 /*
2748 return;
2749 */
2750 }
2751 Curr_servp = servp;
2752 ptr = &servp->server;
2753
2754 sel_id = put_popup(servp, 0,"Service Info");
2755
2756 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_OK_BUTTON);
2757 XtUnmanageChild(id);
2758
2759 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST_LABEL);
2760 if (ptr->pid > 0x1000000)
2761 sprintf(str,"Server %s (pid = %X) on node %s\n\nprovides %d services :\n",
2762 servp->name, ptr->pid, ptr->node, ptr->n_services);
2763 else
2764 sprintf(str,"Server %s (pid = %d) on node %s\n\nprovides %d services :\n",
2765 servp->name, ptr->pid, ptr->node, ptr->n_services);
2766 set_something(sel_id,XmNlistLabelString,str);
2767
2768 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST);
2769 Curr_service_list_id = id;
2770
2771 XmListAddItem(id,create_str(
2772 "Ordering services alphabeticaly, please be patient..."),1);
2773
2774 set_something(id,XmNlistItemCount,1);
2775 set_something(id,XmNlistVisibleItemCount,1);
2776
2777 sprintf(str,"%s/SERVICE_LIST",/*ptr->task*/servp->name);
2778 dic_info_service(str,ONCE_ONLY,20,0,0,
2779 got_service_list,(long)servp,"None",5);
2780 /*
2781#ifdef solaris
2782 */
2783 /*
2784 XtAppAddTimeOut(app_context, 1000, kick_it, 0);
2785 */
2786 /*
2787#endif
2788 */
2789}
2790
2791void kick_it()
2792{
2793 printf("kick_it\n");
2794}
2795
2796typedef char DID_SLOT[MAX_NAME];
2797
2798void got_service_list(SERVER **servp_ptr, char *buffer, int *size)
2799{
2800SERVER *servp;
2801void do_got_service_list();
2802
2803 if(size){}
2804 servp = *servp_ptr;
2805 if(Curr_service_list)
2806 free(Curr_service_list);
2807 Curr_service_list = malloc(strlen(buffer)+1);
2808 strcpy(Curr_service_list, buffer);
2809 /*
2810#ifdef solaris
2811 */
2812 Got_Service_List = servp;
2813 /*
2814#else
2815 do_got_service_list(servp);
2816#endif
2817 */
2818}
2819
2820void do_got_service_list(SERVER *servp)
2821{
2822char cmd_str[256], svc_str[256];
2823DNS_SERVER_INFO *ptr;
2824DNS_SERVICE_INFO *service_ptr;
2825Widget id;
2826char *curr_str, max_str[MAX_NAME], *sptr;
2827DID_SLOT *service_list;
2828int i, j, curr_index = 0, n_services;
2829XmString xstr;
2830void delete_str();
2831
2832 ptr = &servp->server;
2833 id = Curr_service_list_id;
2834
2835 XmListDeleteAllItems(id);
2836
2837 strcpy(cmd_str,"CMD: ");
2838 strcpy(svc_str,"SVC: ");
2839
2840 service_ptr = servp->service_ptr;
2841 service_list = (DID_SLOT *)malloc(ptr->n_services * MAX_NAME);
2842 n_services = ptr->n_services;
2843
2844 for(i=0;i<n_services; i++)
2845 {
2846 strcpy(service_list[i],service_ptr->name);
2847 service_ptr++;
2848 }
2849 strcpy(max_str,"zzzzzzzzzzzzzzzzzzzzzzzzzzzz");
2850 for(i=0;i<n_services; i++)
2851 {
2852 curr_str = max_str;
2853 for(j=0;j<n_services; j++)
2854 {
2855 sptr = service_list[j];
2856 if(!*sptr)
2857 continue;
2858
2859 if(strcmp(sptr,curr_str) < 0)
2860 {
2861 curr_str = sptr;
2862 curr_index = j;
2863 }
2864 }
2865 service_list[curr_index][0] = '\0';
2866 service_ptr = &(servp->service_ptr[curr_index]);
2867 if(service_ptr->type)
2868 {
2869 strcpy(&cmd_str[5],service_ptr->name);
2870 xstr = create_str(cmd_str);
2871 XmListAddItem(id,xstr,i+1);
2872 delete_str(xstr);
2873 }
2874 else
2875 {
2876 strcpy(&svc_str[5],service_ptr->name);
2877 xstr = create_str(svc_str);
2878 XmListAddItem(id,xstr,i+1);
2879 delete_str(xstr);
2880 }
2881 }
2882 free(service_list);
2883
2884 set_something(id,XmNlistItemCount,i);
2885 set_something(id,XmNlistVisibleItemCount,(i < 20) ? i : 20);
2886}
2887
2888void show_clients(SERVER **servp_ptr, char *buffer, int *size)
2889{
2890SERVER *servp;
2891void do_show_clients();
2892
2893 if(size){}
2894 servp = *servp_ptr;
2895 if(Curr_client_list)
2896 free(Curr_client_list);
2897 Curr_client_list = malloc(strlen(buffer)+1);
2898 strcpy(Curr_client_list, buffer);
2899 /*
2900#ifdef solaris
2901 */
2902 Got_Client_List = servp;
2903 /*
2904#else
2905 do_show_clients(servp);
2906#endif
2907 */
2908}
2909
2910void do_show_clients(SERVER *servp)
2911{
2912int i = 0;
2913char str[2048], *strp, *strp1;
2914DNS_SERVER_INFO *ptr;
2915XmString xstr;
2916void delete_str();
2917
2918 ptr = &servp->server;
2919 /*
2920 sel_id = servp->pop_widget_id[1];
2921 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST_LABEL);
2922 */
2923 if(Curr_client_list[0] == -1)
2924 {
2925 sprintf(str,"Information not available\n");
2926 XmListAddItem(Curr_client_id,create_str(str),i+1);
2927 /*
2928 set_something(sel_id,XmNlistLabelString,str);
2929 */
2930 return;
2931 }
2932 /*
2933 sprintf(str,"Clients of %s are : \n",
2934 ptr->task);
2935 set_something(sel_id,XmNlistLabelString,str);
2936
2937 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST);
2938 XmListDeleteAllItems(id);
2939 */
2940 strp1 = Curr_client_list;
2941 while(strp1)
2942 {
2943 if(!*strp1)
2944 break;
2945 sprintf(str,"Process ");
2946 strp = strp1;
2947 strp1 = strchr(strp,'@');
2948 *strp1 = '\0';
2949 strp1++;
2950 strcat(str,strp);
2951 strcat(str," on node ");
2952 strp = strp1;
2953 if( (strp1 = strchr(strp,'|')) )
2954 {
2955 *strp1 = '\0';
2956 strp1++;
2957 }
2958 strcat(str,strp);
2959 xstr = create_str(str);
2960 XmListAddItem(Curr_client_id,xstr,i+1);
2961 delete_str(xstr);
2962 i++;
2963 }
2964 if(!i)
2965 {
2966 sprintf(str,"NONE");
2967 xstr = create_str(str);
2968 XmListAddItem(Curr_client_id,xstr,i+1);
2969 delete_str(xstr);
2970 }
2971 /*
2972 set_something(id,XmNlistItemCount,i);
2973 */
2974 /*
2975 if(Matrix_id[Curr_matrix])
2976 XFlush(XtDisplay(Matrix_id[Curr_matrix]));
2977 */
2978}
2979
2980void activate_clients(Widget w, SERVER *servp, unsigned long *reason)
2981{
2982DNS_SERVER_INFO *ptr;
2983char str[100];
2984void show_clients();
2985void kick_it_again();
2986Widget id,sel_id;
2987
2988 if(w) {}
2989 if(reason){}
2990 Curr_servp = servp;
2991 ptr = &servp->server;
2992 if(servp->pop_widget_id[1])
2993 {
2994 XtDestroyWidget(servp->pop_widget_id[1]);
2995 servp->pop_widget_id[1] = 0;
2996 }
2997 sel_id = put_popup(servp,1,"Client Info");
2998
2999 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_HELP_BUTTON);
3000 XtUnmanageChild(id);
3001
3002 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_APPLY_BUTTON);
3003 XtUnmanageChild(id);
3004
3005 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_CANCEL_BUTTON);
3006 XtUnmanageChild(id);
3007
3008 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_TEXT);
3009 XtUnmanageChild(id);
3010
3011 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_SELECTION_LABEL);
3012 XtUnmanageChild(id);
3013 /*
3014 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST_LABEL);
3015 */
3016 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST);
3017 XmListDeleteAllItems(id);
3018
3019 Curr_client_id = id;
3020 sprintf(str,"Clients of %s are : \n",
3021 servp->name);
3022 set_something(sel_id,XmNlistLabelString,str);
3023
3024 sprintf(str,"%s/CLIENT_LIST",/*ptr->task*/servp->name);
3025 dic_info_service(str,ONCE_ONLY,10,0,0,
3026 show_clients,(long)servp,&no_link,1);
3027 /*
3028#ifdef solaris
3029 */
3030 /*
3031 XtAppAddTimeOut(app_context, 1000, kick_it_again, 0);
3032 */
3033 /*
3034#endif
3035 */
3036}
3037
3038void kick_it_again()
3039{
3040 printf("kick_it_again\n");
3041}
3042
3043Widget put_popup(SERVER *servp, int type, char *title)
3044{
3045 Widget id;
3046 void activate_services(), activate_clients();
3047 extern void set_title();
3048
3049 if(type)
3050 {
3051 id = create_client_dialog();
3052 /*
3053 XtAddCallback(id,XmNokCallback, activate_clients, servp);
3054 XtAddCallback(id,XmNcancelCallback, activate_clients, servp);
3055 */
3056 }
3057 else
3058 {
3059 id = create_server_dialog();
3060 /*
3061 XtAddCallback(id,XmNcancelCallback, activate_services, servp);
3062 */
3063 }
3064 servp->pop_widget_id[type] = id;
3065 /*
3066 }
3067 */
3068 XtManageChild(id);
3069 set_title(XtParent(id),title);
3070 return(id);
3071}
3072
3073Widget put_selection(int tag, char *title)
3074{
3075 Widget id = 0;
3076 extern void set_title();
3077
3078 if(pop_widget_id[tag])
3079 {
3080 XtDestroyWidget(pop_widget_id[tag]);
3081 }
3082 switch(tag)
3083 {
3084 case DID_SEL_NODE:
3085 id = create_node_selection();
3086 break;
3087 case DID_SEL_SERVICE:
3088 id = create_service_selection();
3089 break;
3090 case DID_KILL_ALL:
3091 id = create_kill_confirmation();
3092 break;
3093 case DID_SERVICE:
3094 id = create_service_dialog();
3095 break;
3096 case DID_COMMAND:
3097 id = create_send_command();
3098 break;
3099 }
3100
3101 pop_widget_id[tag] = id;
3102 XtManageChild(id);
3103 set_title(XtParent(id),title);
3104 return(id);
3105}
3106
3107void check_put_label(int tag)
3108{
3109 static int old_n_services = 0;
3110 static int changing = 0;
3111 void put_label();
3112
3113 if(tag){}
3114 if(N_services != old_n_services)
3115 {
3116 put_label();
3117 if(N_services > old_n_services)
3118 changing = 1;
3119 old_n_services = N_services;
3120
3121#ifdef linux
3122 show_servers();
3123#endif
3124 }
3125/*
3126 else
3127 {
3128 if(changing)
3129 {
3130 show_servers();
3131 changing = 0;
3132 }
3133 }
3134*/
3135}
3136
3137void put_label()
3138{
3139 char str[MAX_NAME], str1[MAX_NAME];
3140
3141 DISABLE_AST
3142 sprintf(str,"%d Servers known - %d Services Available\n",
3143 N_servers,N_services);
3144 switch(Curr_view_opt)
3145 {
3146 case 1 :
3147 strcat(str,"Displaying ALL Servers");
3148 break;
3149 case 0 :
3150 sprintf(str1,"Displaying Servers on node %s",Curr_view_opt_par);
3151 strcat(str,str1);
3152 break;
3153 case 2 :
3154 sprintf(str1,"Displaying Servers providing Service *%s*",
3155 Curr_view_opt_par);
3156 strcat(str,str1);
3157 break;
3158 case 3 :
3159 strcat(str,"Displaying Servers in ERROR");
3160 break;
3161 case -1 :
3162 strcat(str,"Please Select Viewing Option");
3163 break;
3164 }
3165 set_something(Label_id,XmNlabelString,str);
3166 XFlush(XtDisplay(Label_id));
3167 ENABLE_AST
3168}
3169
3170Widget create_client_dialog()
3171{
3172 Widget id;
3173 id = create_selection_dialog("Dismiss","","","","",DID_CLIENTS, 3);
3174 return(id);
3175
3176}
3177
3178Widget create_server_dialog()
3179{
3180 Widget id;
3181 id = create_selection_dialog("","View / Send","Dismiss","",
3182 "Service / Command :",
3183 DID_SERVICES, 20);
3184 return(id);
3185}
3186
3187Widget create_node_selection()
3188{
3189 Widget id;
3190 id = create_selection_dialog("","","","Nodes :","Selected Node :",DID_SEL_NODE, 8);
3191 return(id);
3192
3193}
3194
3195Widget create_service_selection()
3196{
3197 Widget id;
3198 /*
3199 id = create_prompt_dialog("Enter Service Name :",DID_SEL_SERVICE);
3200 */
3201 id = create_selection_dialog("","","","","Enter Service Name (or search string):",DID_SEL_SERVICE, 0);
3202 return(id);
3203
3204}
3205
3206Widget create_send_command()
3207{
3208 Widget id;
3209 char str[256], str1[256];
3210
3211 sprintf(str,"Command to %s (%s)\n\n",
3212 Curr_service_name, Curr_service_format);
3213
3214 id = create_selection_dialog("","","",str,"Command:",DID_COMMAND, 1);
3215
3216 strcpy(str1,"Please enter items separated by spaces:\n(for example: 2 0x123 'A' 23.4 \"a text\")");
3217
3218 set_something(id,XmNselectionLabelString,str1);
3219
3220 return(id);
3221
3222}
3223
3224Widget create_kill_confirmation()
3225{
3226 Widget id;
3227 id = create_question_dialog("Do you really want to kill ALL DIM servers ?",
3228 DID_KILL_ALL);
3229 return(id);
3230
3231}
3232
3233Widget create_selection_dialog(char *ok, char *apply, char *cancel, char *list, char *sel,
3234 long tag, int items)
3235{
3236Widget sd;
3237XmString xmOk, xmApply, xmCancel, xmList, xmSelection;
3238Arg ar[20];
3239int n;
3240
3241 xmList = create_str(list);
3242 xmOk = create_str(ok);
3243 xmApply = create_str(apply);
3244 xmCancel = create_str (cancel);
3245 xmSelection = create_str (sel);
3246
3247 n = 0;
3248 /*
3249 XtSetArg(ar[n],XmNdialogStyle,XmDIALOG_FULL_APPLICATION_MODAL); n++;
3250 XtSetArg(ar[n],XmNmwmFunctions,MWM_FUNC_MOVE); n++;
3251 */
3252 XtSetArg(ar[n],XmNtitle,"Selection"); n++;
3253 XtSetArg(ar[n],XmNlabelFontList, did_default_font); n++;
3254 XtSetArg(ar[n],XmNbuttonFontList, did_default_font); n++;
3255 XtSetArg(ar[n],XmNtextFontList, did_small_font); n++;
3256 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3257 XtSetArg(ar[n],XmNlistLabelString, xmList); n++;
3258 XtSetArg(ar[n],XmNlistVisibleItemCount,items); n++;
3259 if(ok[0])
3260 {
3261 XtSetArg(ar[n],XmNokLabelString, xmOk); n++;
3262 }
3263 if(apply[0])
3264 {
3265 XtSetArg(ar[n],XmNapplyLabelString, xmApply); n++;
3266 }
3267 if(cancel[0])
3268 {
3269 XtSetArg(ar[n],XmNcancelLabelString, xmCancel); n++;
3270 }
3271 if(sel[0])
3272 {
3273 XtSetArg(ar[n],XmNselectionLabelString, xmSelection); n++;
3274 }
3275 sd = XmCreateSelectionDialog ( toplevel_widget, "Selection", ar, n );
3276 XmStringFree(xmList);
3277 XmStringFree(xmOk);
3278 XmStringFree(xmApply);
3279 XmStringFree(xmCancel);
3280 XmStringFree(xmSelection);
3281 if(tag >= 0)
3282 {
3283 XtAddCallback ( sd, XmNcancelCallback,
3284 (XtCallbackProc)cancel_pop_up, (XtPointer)tag );
3285 XtAddCallback ( sd, XmNapplyCallback,
3286 (XtCallbackProc)ok_pop_up, (XtPointer)tag );
3287 XtAddCallback ( sd, XmNokCallback,
3288 (XtCallbackProc)ok_pop_up, (XtPointer)tag );
3289 }
3290 return(sd);
3291}
3292
3293Widget create_file_selection_dialog(long type)
3294{
3295Widget sd;
3296XmString xm1;
3297Arg ar[20];
3298int n;
3299
3300 xm1 = create_str ("");
3301 n = 0;
3302 /*
3303 XtSetArg(ar[n],XmNdialogStyle,XmDIALOG_FULL_APPLICATION_MODAL); n++;
3304 XtSetArg(ar[n],XmNmwmFunctions,MWM_FUNC_MOVE); n++;
3305 */
3306 XtSetArg(ar[n],XmNtitle,"FileSelection"); n++;
3307 XtSetArg(ar[n],XmNlabelFontList, did_default_font); n++;
3308 XtSetArg(ar[n],XmNbuttonFontList, did_default_font); n++;
3309 XtSetArg(ar[n],XmNtextFontList, did_default_font); n++;
3310 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3311 XtSetArg(ar[n],XmNwidth, 500); n++;
3312 XtSetArg(ar[n],XmNdirMask, xm1); n++;
3313 sd = XmCreateFileSelectionDialog ( toplevel_widget, "FileSelection", ar, n );
3314
3315 XmStringFree(xm1);
3316
3317 XtAddCallback ( sd, XmNcancelCallback,
3318 (XtCallbackProc)cancel_pop_up, (XtPointer)type );
3319 XtAddCallback ( sd, XmNokCallback,
3320 (XtCallbackProc)ok_pop_up, (XtPointer)type );
3321
3322 return(sd);
3323}
3324
3325Widget create_prompt_dialog(char *label, long tag)
3326{
3327Widget sd;
3328XmString xm1;
3329Arg ar[20];
3330int n;
3331
3332 xm1 = create_str (label);
3333 n = 0;
3334 XtSetArg(ar[n],XmNlabelFontList, did_default_font); n++;
3335 XtSetArg(ar[n],XmNbuttonFontList, did_default_font); n++;
3336 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3337 /*
3338 XtSetArg(ar[n],XmNwidth, 450); n++;
3339 XtSetArg(ar[n],XmNresizePolicy, XmRESIZE_NONE); n++;
3340 */
3341 XtSetArg(ar[n],XmNselectionLabelString, xm1); n++;
3342 sd = XmCreatePromptDialog ( toplevel_widget, "Prompt", ar, n );
3343
3344 XmStringFree(xm1);
3345
3346 XtAddCallback ( sd, XmNcancelCallback,
3347 (XtCallbackProc)cancel_pop_up, (XtPointer)tag );
3348 XtAddCallback ( sd, XmNokCallback,
3349 (XtCallbackProc)ok_pop_up, (XtPointer)tag );
3350
3351 return(sd);
3352}
3353
3354Widget create_question_dialog(char *label, long tag)
3355{
3356Widget sd;
3357XmString xm1;
3358Arg ar[20];
3359int n;
3360
3361 xm1 = create_str (label);
3362 n = 0;
3363 XtSetArg(ar[n],XmNlabelFontList, did_default_font); n++;
3364 XtSetArg(ar[n],XmNbuttonFontList, did_default_font); n++;
3365 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3366 /*
3367 XtSetArg(ar[n],XmNwidth, 450); n++;
3368 XtSetArg(ar[n],XmNresizePolicy, XmRESIZE_NONE); n++;
3369 */
3370 XtSetArg(ar[n],XmNmessageString, xm1); n++;
3371 sd = XmCreateQuestionDialog ( toplevel_widget, "Question", ar, n );
3372
3373 XmStringFree(xm1);
3374
3375 XtAddCallback ( sd, XmNcancelCallback,
3376 (XtCallbackProc)cancel_pop_up, (XtPointer)tag );
3377 XtAddCallback ( sd, XmNokCallback,
3378 (XtCallbackProc)ok_pop_up, (XtPointer)tag );
3379
3380 return(sd);
3381}
3382
3383Widget create_service_dialog()
3384{
3385Widget fd, rc, sw, lb, rc1;
3386XmString xm1;
3387Arg ar[20];
3388int n, par;
3389unsigned long reason;
3390
3391 n = 0;
3392 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3393 XtSetArg(ar[n],XmNresizePolicy, XmRESIZE_ANY); n++;
3394 fd = XmCreateFormDialog ( toplevel_widget, "Form", ar, n );
3395 XtManageChild(fd);
3396
3397 /* create rowcolumn */
3398 n = 0;
3399 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3400 XtSetArg(ar[n],XmNentryAlignment, XmALIGNMENT_CENTER); n++;
3401 XtSetArg(ar[n],XmNbottomAttachment, XmATTACH_FORM); n++;
3402 XtSetArg(ar[n],XmNbottomOffset, 0); n++;
3403 XtSetArg(ar[n],XmNrightAttachment, XmATTACH_FORM); n++;
3404 XtSetArg(ar[n],XmNrightOffset, 0); n++;
3405 XtSetArg(ar[n],XmNtopAttachment, XmATTACH_FORM); n++;
3406 XtSetArg(ar[n],XmNtopOffset, 0); n++;
3407 XtSetArg(ar[n],XmNleftAttachment, XmATTACH_FORM); n++;
3408 XtSetArg(ar[n],XmNleftOffset, 0); n++;
3409 rc = XmCreateRowColumn ( fd, "rowcol", ar, n );
3410 XtManageChild(rc);
3411
3412 /* create scrolled window */
3413 n = 0;
3414 XtSetArg ( ar[n], XmNwidth, 770); n++;
3415 XtSetArg ( ar[n], XmNheight, 350); n++;
3416 XtSetArg ( ar[n], XmNscrollBarDisplayPolicy, XmAS_NEEDED); n++;
3417 XtSetArg ( ar[n], XmNscrollingPolicy, XmAUTOMATIC); n++;
3418
3419 sw = XmCreateScrolledWindow ( rc, "ScrollWin", ar, n );
3420 XtManageChild ( sw );
3421
3422 /* create label */
3423 n = 0;
3424 xm1 = create_str(" ");
3425 XtSetArg(ar[n],XmNfontList, did_small_font); n++;
3426 XtSetArg(ar[n],XmNlabelString, xm1); n++;
3427 XtSetArg(ar[n],XmNalignment, XmALIGNMENT_BEGINNING); n++;
3428 lb = XmCreateLabel ( sw, "label", ar, n );
3429 XtManageChild(lb);
3430 XmStringFree(xm1);
3431 par = 1;
3432 reason = 0;
3433 create_label(lb, &par, &reason);
3434
3435 /* create button rowcolumn */
3436 n = 0;
3437 XtSetArg(ar[n],XmNborderWidth, 0); n++;
3438 XtSetArg(ar[n],XmNentryAlignment, XmALIGNMENT_CENTER); n++;
3439 XtSetArg(ar[n],XmNorientation, XmVERTICAL); n++;
3440 XtSetArg(ar[n],XmNnumColumns, 3); n++;
3441 XtSetArg(ar[n],XmNpacking, XmPACK_COLUMN); n++;
3442 rc1 = XmCreateRowColumn ( rc, "buttons", ar, n );
3443 XtManageChild(rc1);
3444 /*
3445 create_push_button(rc1,"View Standard",MAX_POP_UPS+1);
3446 create_push_button(rc1,"View Float",MAX_POP_UPS+2);
3447 create_push_button(rc1,"View Double",MAX_POP_UPS+3);
3448 */
3449 SubscribeButton = create_push_button(rc1," Subscribe (On Change) ",
3450 MAX_POP_UPS+5);
3451 Subscribe10Button = create_push_button(rc1," Subscribe (Update Rate 10 seconds) ",
3452 MAX_POP_UPS+4);
3453 create_push_button(rc1,"Dismiss",DID_SERVICE);
3454 Curr_service_print_type = 0;
3455
3456 return(fd);
3457}
3458
3459Widget create_push_button(Widget parent, char *str, long tag)
3460{
3461Widget b;
3462XmString xm1;
3463Arg ar[20];
3464int n;
3465
3466 n = 0;
3467 xm1 = create_str(str);
3468 XtSetArg(ar[n],XmNalignment, XmALIGNMENT_CENTER); n++;
3469 XtSetArg(ar[n],XmNfontList, did_default_font); n++;
3470 XtSetArg(ar[n],XmNlabelString, xm1); n++;
3471 b = XmCreatePushButton ( parent, "button", ar, n );
3472
3473 XtManageChild(b);
3474 XmStringFree(xm1);
3475
3476 XtAddCallback ( b, XmNactivateCallback,
3477 (XtCallbackProc)cancel_pop_up, (XtPointer)tag );
3478 return(b);
3479}
3480
3481
3482
3483
Note: See TracBrowser for help on using the repository browser.