source: trunk/FACT++/dim_v19r15/src/did/did.c@ 10305

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