source: branches/FACT++_part_filenames/dim/src/did/did.c@ 18752

Last change on this file since 18752 was 18349, checked in by tbretz, 9 years ago
Updated to v20r15
File size: 78.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,(Cardinal)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, (Cardinal)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,(Cardinal)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, (Cardinal)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] = (char)toupper((int)*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*2], max_str[MAX_NODE_NAME];
1036char *ptr, *nodeptrs[MAX_CONNS*2], *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 *ptr++ = '\0';
1055 for(j = 0; j < (int)strlen(sptr); j++)
1056 sptr[j] = (char)tolower((int)sptr[j]);
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,(size_t)(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((size_t)(1024 + (*size)*16));
1186 Service_buffer = malloc((size_t)*size);
1187 memcpy(Service_buffer, (char *)buffer, (size_t)*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/(int)sizeof(int);
1306 else
1307 size = num;
1308 psize = size * (int)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/(int)sizeof(int);
1316 else
1317 size = num;
1318 psize = size * (int)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/(int)sizeof(short);
1326 else
1327 size = num;
1328 psize = size * (int)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/(int)sizeof(float);
1336 else
1337 size = num;
1338 psize = size * (int)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/(int)sizeof(double);
1346 else
1347 size = num;
1348 psize = size * (int)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/(int)sizeof(longlong);
1356 else
1357 size = num;
1358 psize = size * (int)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 *ptr, str[80], tmp[256];
1460int last[4];
1461/*
1462char *asc;
1463 asc = (char *)buff;
1464*/
1465 ptr = Service_content_str;
1466 ptr += strlen(Service_content_str);
1467 for( i = 0; i < size; i++)
1468 {
1469 strcpy(tmp,"");
1470 if(i%4 == 0)
1471 {
1472 if(i != 0)
1473 {
1474 strcat(tmp," ");
1475 }
1476 sprintf(str,"%5d ",i);
1477 strcat(tmp,str);
1478 }
1479 if(!(i%4))
1480 strcat(tmp,"H: ");
1481 sprintf(str," %08X",buff[i]);
1482 strcat(tmp,str);
1483 last[i%4] = buff[i];
1484 if((i%4 == 3) || (i == (size-1)))
1485 {
1486 /*
1487 if(i%4 != 3)
1488 {
1489 for(j = 1; j < 4 - (i%4); j++)
1490 strcat(tmp," ");
1491 }
1492 strcat(tmp," '");
1493 for(j = 0; j < ((i%4)*4)+4 ; j++)
1494 {
1495 if(isprint(asc[j]))
1496 {
1497 sprintf(str,"%c",asc[j]);
1498 strcat(tmp,str);
1499 }
1500 else
1501 {
1502 sprintf(str,".");
1503 strcat(tmp,str);
1504 }
1505 }
1506 */
1507 strcat(tmp,"\n");
1508 for(j = 0; j <= (i%4); j++)
1509 {
1510 if(j == 0)
1511 strcat(tmp," D: ");
1512 sprintf(str,"%12d",last[j]);
1513 strcat(tmp,str);
1514 }
1515 strcat(tmp,"\n");
1516/*
1517 asc = (char *)&buff[i+1];
1518*/
1519 }
1520 strcpy(ptr, tmp);
1521 ptr += strlen(tmp);
1522 }
1523 strcpy(tmp,"\n");
1524 strcpy(ptr, tmp);
1525}
1526
1527void print_service_longlong(longlong *buff, int size)
1528{
1529int i,j;
1530char *ptr, str[80], tmp[256];
1531longlong last[4];
1532/*
1533char *asc;
1534 asc = (char *)buff;
1535*/
1536 ptr = Service_content_str;
1537 ptr += strlen(Service_content_str);
1538 for( i = 0; i < size; i++)
1539 {
1540 strcpy(tmp,"");
1541 if(i%4 == 0)
1542 {
1543 if(i != 0)
1544 {
1545 strcat(tmp," ");
1546 }
1547 sprintf(str,"%5d ",i);
1548 strcat(tmp,str);
1549 }
1550 if(!(i%4))
1551 strcat(tmp,"H: ");
1552 sprintf(str," %08X",(unsigned)buff[i]);
1553 strcat(tmp,str);
1554 last[i%4] = buff[i];
1555 if((i%4 == 3) || (i == (size-1)))
1556 {
1557 strcat(tmp,"\n");
1558 for(j = 0; j <= (i%4); j++)
1559 {
1560 if(j == 0)
1561 strcat(tmp," D: ");
1562 sprintf(str,"%12d",(int)last[j]);
1563 strcat(tmp,str);
1564 }
1565 strcat(tmp,"\n");
1566/*
1567 asc = (char *)&buff[i+1];
1568*/
1569 }
1570 strcpy(ptr, tmp);
1571 ptr += strlen(tmp);
1572 }
1573 strcpy(tmp,"\n");
1574 strcpy(ptr, tmp);
1575}
1576
1577void print_service_short(short *buff, int size)
1578{
1579int i,j;
1580char *ptr, str[80], tmp[256];
1581short last[8];
1582/*
1583char *asc;
1584 asc = (char *)buff;
1585*/
1586 ptr = Service_content_str;
1587 ptr += strlen(Service_content_str);
1588 for( i = 0; i < size; i++)
1589 {
1590 strcpy(tmp,"");
1591 if(i%8 == 0)
1592 {
1593 if(i != 0)
1594 {
1595 strcat(tmp," ");
1596 }
1597 sprintf(str,"%5d ",i);
1598 strcat(tmp,str);
1599 }
1600 if(!(i%8))
1601 strcat(tmp,"H: ");
1602 sprintf(str," %04X",buff[i]);
1603 strcat(tmp,str);
1604 last[i%8] = buff[i];
1605 if((i%8 == 7) || (i == (size-1)))
1606 {
1607 /*
1608 if(i%7 != 7)
1609 {
1610 for(j = 1; j < 8 - (i%8); j++)
1611 strcat(tmp," ");
1612 }
1613 strcat(tmp," '");
1614 for(j = 0; j < ((i%8)*2)+2 ; j++)
1615 {
1616 if(isprint(asc[j]))
1617 {
1618 sprintf(str,"%c",asc[j]);
1619 strcat(tmp,str);
1620 }
1621 else
1622 {
1623 sprintf(str,".");
1624 strcat(tmp,str);
1625 }
1626 }
1627 */
1628 strcat(tmp,"\n");
1629 for(j = 0; j <= (i%8); j++)
1630 {
1631 if(j == 0)
1632 strcat(tmp," D: ");
1633 sprintf(str," %5d",last[j]);
1634 strcat(tmp,str);
1635 }
1636 strcat(tmp,"\n");
1637/*
1638 asc = (char *)&buff[i+1];
1639*/
1640 }
1641 strcpy(ptr, tmp);
1642 ptr += strlen(tmp);
1643 }
1644 strcpy(tmp,"\n");
1645 strcpy(ptr, tmp);
1646}
1647
1648void print_service_char(char *buff, int size)
1649{
1650int i,j;
1651char *asc, *ptr, str[80], tmp[256];
1652/*
1653char last[16];
1654*/
1655 asc = (char *)buff;
1656 ptr = Service_content_str;
1657 ptr += strlen(Service_content_str);
1658 for( i = 0; i < size; i++)
1659 {
1660 strcpy(tmp,"");
1661 if(i%16 == 0)
1662 {
1663 if(i != 0)
1664 {
1665 strcat(tmp," ");
1666 }
1667 sprintf(str,"%5d ",i);
1668 strcat(tmp,str);
1669 }
1670 if(!(i%16))
1671 strcat(tmp,"H: ");
1672 sprintf(str,"%02X",buff[i]);
1673/* strcat(tmp,str);
1674*/
1675 strcat(tmp," ");
1676 strcat(tmp,&str[strlen(str)-2]);
1677 /*
1678 last[i%16] = buff[i];
1679 if(i%4 == 3)
1680 strcat(tmp," ");
1681 */
1682 if((i%16 == 15) || (i == (size-1)))
1683 {
1684 if(i%16 != 15)
1685 {
1686 for(j = 1; j < 16 - (i%16); j++)
1687 strcat(tmp," ");
1688 }
1689 strcat(tmp," '");
1690 for(j = 0; j <= (i%16) ; j++)
1691 {
1692 if(isprint(asc[j]))
1693 {
1694 sprintf(str,"%c",asc[j]);
1695 strcat(tmp,str);
1696 }
1697 else
1698 {
1699 sprintf(str,".");
1700 strcat(tmp,str);
1701 }
1702 }
1703 strcat(tmp,"'\n");
1704 asc = (char *)&buff[i+1];
1705 }
1706 strcpy(ptr, tmp);
1707 ptr += strlen(tmp);
1708 }
1709 strcpy(tmp,"\n");
1710 strcpy(ptr, tmp);
1711}
1712
1713void print_service_float(float *buff, int size)
1714{
1715int i;
1716char *ptr, str[80], tmp[256];
1717
1718 ptr = Service_content_str;
1719 ptr += strlen(Service_content_str);
1720 for( i = 0; i < size; i++)
1721 {
1722 strcpy(tmp,"");
1723 if(i%4 == 0)
1724 {
1725 if(i != 0)
1726 {
1727 strcat(tmp," ");
1728 }
1729 sprintf(str," %5d: ",i);
1730 strcat(tmp,str);
1731 }
1732 sprintf(str,"%12.3G",*(buff++));
1733 strcat(tmp,str);
1734 if((i%4 == 3) || (i == size-1))
1735 {
1736 strcat(tmp,"\n");
1737 }
1738 strcpy(ptr, tmp);
1739 ptr += strlen(tmp);
1740 }
1741 strcpy(tmp,"\n");
1742 strcpy(ptr, tmp);
1743 ptr += strlen(tmp);
1744}
1745
1746void print_service_double(double *buff, int size)
1747{
1748int i;
1749char *ptr, str[80], tmp[256];
1750
1751 ptr = Service_content_str;
1752 ptr += strlen(Service_content_str);
1753 for( i = 0; i < size; i++)
1754 {
1755 strcpy(tmp,"");
1756 if(i%4 == 0)
1757 {
1758 if(i != 0)
1759 {
1760 strcat(tmp," ");
1761 }
1762 sprintf(str," %5d: ",i);
1763 strcat(tmp,str);
1764 }
1765 sprintf(str,"%12.3G",*(buff++));
1766 strcat(tmp,str);
1767 if((i%4 == 3) || (i == size-1))
1768 {
1769 strcat(tmp,"\n");
1770 }
1771 strcpy(ptr, tmp);
1772 ptr += strlen(tmp);
1773 }
1774 strcpy(tmp,"\n");
1775 strcpy(ptr, tmp);
1776 ptr += strlen(tmp);
1777}
1778
1779void ok_pop_up (Widget w, long tag, unsigned long *reason)
1780{
1781Widget id, sel_id;
1782char *str, *pstr;
1783void recv_service_info();
1784void did_prepare_command();
1785void show_servers();
1786
1787/*
1788 if(tag == 5)
1789 {
1790 id = (Widget)XmSelectionBoxGetChild(w,XmDIALOG_TEXT);
1791 str = (char *)XmTextGetString(id);
1792 if(!str[0])
1793 {
1794 XtFree(str);
1795 return;
1796 }
1797 if( ( fptr = fopen( str, "w" ) ) == (FILE *)0 )
1798 {
1799 printf("Cannot open: %s for writing\n",str);
1800 return;
1801 }
1802 ptr = &Curr_servp->server;
1803 if (ptr->pid > 0x1000000)
1804 fprintf(fptr,"Server %s (pid = %X) on node %s\n provides %d services :\n",
1805 Curr_servp->name, ptr->pid, ptr->node, ptr->n_services);
1806 else
1807 fprintf(fptr,"Server %s (pid = %d) on node %s\n provides %d services :\n",
1808 Curr_servp->name, ptr->pid, ptr->node, ptr->n_services);
1809 service_ptr = Curr_servp->service_ptr;
1810 for(i=0;i<ptr->n_services; i++)
1811 {
1812 sprintf(str,service_ptr->name);
1813 fprintf(fptr," %s\n",service_ptr->name);
1814 service_ptr++;
1815 }
1816 fclose(fptr);
1817 XtFree(str);
1818 return;
1819 }
1820 if(tag == 4)
1821 {
1822 sel_id = put_selection(4, "Printing...");
1823 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_HELP_BUTTON);
1824 XtUnmanageChild(id);
1825
1826 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_APPLY_BUTTON);
1827 XtUnmanageChild(id);
1828 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_TEXT);
1829 str = (char *)XmTextGetString(id);
1830 if(!str[0])
1831 {
1832 XtFree(str);
1833 return;
1834 }
1835 ptr = &Curr_servp->server;
1836 if(pstr = strrchr(str,']'))
1837 *(++pstr) = '\0';
1838 if(pstr = strrchr(str,'/'))
1839 *(++pstr) = '\0';
1840 sprintf(txt_str,"%s%s.TXT",str,Curr_servp->name);
1841 XtFree(str);
1842 XmTextSetString(id, txt_str);
1843 return;
1844 }
1845*/
1846 if(reason){}
1847 if(tag == DID_KILL_ALL)
1848 {
1849 dic_cmnd_service("DIS_DNS/KILL_SERVERS",0,0);
1850 return;
1851 }
1852 id = XmSelectionBoxGetChild(w,XmDIALOG_TEXT);
1853 str = XmTextGetString(id);
1854 if(!str[0])
1855 {
1856 XtFree(str);
1857 return;
1858 }
1859 if ((tag == DID_SEL_NODE) || (tag == DID_SEL_SERVICE))
1860 {
1861 strcpy(Curr_view_opt_par, str);
1862 show_servers();
1863 XtFree(str);
1864 }
1865 if(tag == DID_SERVICES)
1866 {
1867 pstr = strchr(str,' ');
1868 if(!pstr)
1869 {
1870 strcpy(Curr_service_name, str);
1871 strcpy(str,"SVC");
1872 }
1873 else
1874 {
1875 pstr++;
1876 strcpy(Curr_service_name, pstr);
1877 }
1878 if(Curr_service_id)
1879 {
1880 dic_release_service(Curr_service_id);
1881 Curr_service_id = 0;
1882 }
1883 if(str[0] == 'S')
1884 {
1885 /*
1886 if((!strstr(pstr,"/SERVICE_LIST")) &&
1887 (!strstr(pstr,"/CLIENT_LIST")) &&
1888 (!strstr(pstr,"/SERVER_LIST")))
1889 {
1890 Curr_service_id = dic_info_service(Curr_service_name,
1891 MONITORED,5,0,0,
1892 recv_service_info,0,
1893 &no_link_int,4);
1894 }
1895 else
1896 {
1897 */
1898 dic_info_service_stamped(Curr_service_name,
1899 ONCE_ONLY,10,0,0,
1900 recv_service_info,0,
1901 &no_link_int,4);
1902 /*
1903 }
1904 */
1905 put_selection(DID_SERVICE,"Service Contents");
1906 }
1907 else
1908 {
1909 get_service_format();
1910 sel_id = put_selection(DID_COMMAND,"Send Command");
1911 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_HELP_BUTTON);
1912 XtUnmanageChild(id);
1913 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_APPLY_BUTTON);
1914 XtUnmanageChild(id);
1915 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST);
1916 /*
1917 XtUnmanageChild(id);
1918 */
1919 XtUnmapWidget(id);
1920 }
1921 XtFree(str);
1922 }
1923 if(tag == DID_COMMAND)
1924 {
1925 did_prepare_command(str);
1926 XtFree(str);
1927 }
1928}
1929
1930int get_type_size(char type)
1931{
1932 int size;
1933
1934 switch(type)
1935 {
1936 case 'L':
1937 case 'l':
1938 size = sizeof(long);
1939 break;
1940 case 'I':
1941 case 'i':
1942 size = sizeof(int);
1943 break;
1944 case 'S':
1945 case 's':
1946 size = sizeof(short);
1947 break;
1948 case 'F':
1949 case 'f':
1950 size = sizeof(float);
1951 break;
1952 case 'D':
1953 case 'd':
1954 size = sizeof(double);
1955 break;
1956 case 'C':
1957 case 'c':
1958 default:
1959 size = 1;
1960 }
1961 return(size);
1962}
1963
1964void did_prepare_command(char *str)
1965{
1966char type;
1967int num;
1968int size, full_size = 0;
1969char *ptr;
1970static int last_size = 0;
1971static void *last_buffer = 0;
1972void *buffer_ptr;
1973char *str_ptr;
1974void did_read_string(char, int, void **, char **);
1975
1976 str_ptr = str;
1977 ptr = Curr_service_format;
1978 while(*ptr)
1979 {
1980 type = *ptr++;
1981 if(*ptr == ':')
1982 {
1983 ptr++;
1984 size = get_type_size(type);
1985 sscanf(ptr, "%d", &num);
1986 full_size += size * num;
1987 if( (ptr = strchr(ptr,';')) )
1988 ptr++;
1989 else
1990 break;
1991 }
1992 }
1993
1994 full_size += 256;
1995 if(full_size > last_size)
1996 {
1997 if(last_size)
1998 free(last_buffer);
1999 last_buffer = malloc((size_t)full_size);
2000 last_size = full_size;
2001 }
2002 buffer_ptr = last_buffer;
2003 ptr = Curr_service_format;
2004 while(*ptr)
2005 {
2006 type = *ptr++;
2007 if(*ptr == ':')
2008 {
2009 ptr++;
2010 sscanf(ptr, "%d", &num);
2011 did_read_string(type, num, &buffer_ptr, &str_ptr);
2012 if(!str_ptr)
2013 break;
2014 if( (ptr = strchr(ptr,';')) )
2015 ptr++;
2016 else
2017 break;
2018 }
2019 else
2020 {
2021 did_read_string(type, 0, &buffer_ptr, &str_ptr);
2022 break;
2023 }
2024 }
2025 full_size = (int) ((char *)buffer_ptr - (char *)last_buffer);
2026 dic_cmnd_service(Curr_service_name,last_buffer,full_size);
2027}
2028
2029int read_str_int(char *str)
2030{
2031 int i;
2032 if((str[0] == '0') && (str[1] == 'x'))
2033 sscanf(str+2,"%x",&i);
2034 else
2035 sscanf(str,"%d",&i);
2036 return(i);
2037}
2038
2039int read_str_char(char *str, char *cc)
2040{
2041
2042 if(str[0] == '\'')
2043 *cc = str[1];
2044 else if(str[0] == '\"')
2045 return(0);
2046 else if((str[0] == '0') && (str[1] == 'x'))
2047 sscanf(str+2,"%x",(int *)cc);
2048 else if(isalpha(str[0]))
2049 return(-1);
2050 else
2051 sscanf(str,"%d",(int *)cc);
2052 return(1);
2053}
2054
2055void did_read_string(char type, int num, void **buffer_ptr, char **str_ptr)
2056{
2057int i, ret = 0;
2058float ff;
2059double dd;
2060void *ptr;
2061char *strp, *ptr1;
2062char cc;
2063 short s;
2064
2065 strp = *str_ptr;
2066 ptr = *buffer_ptr;
2067 if(!num)
2068 num = 1000000;
2069 switch(type)
2070 {
2071 case 'L':
2072 case 'l':
2073 case 'I':
2074 case 'i':
2075 for(i = 0; i<num; i++)
2076 {
2077 *(int *)ptr = read_str_int(strp);
2078 ptr = (int *)ptr +1;
2079 if( (strp = strchr(strp,' ')) )
2080 strp++;
2081 else
2082 break;
2083 }
2084 break;
2085 case 'S':
2086 case 's':
2087 for(i = 0; i<num; i++)
2088 {
2089 s = (short)read_str_int(strp);
2090 *((short *)ptr) = s;
2091 ptr = (short *)ptr +1;
2092 if( (strp = strchr(strp,' ')) )
2093 strp++;
2094 else
2095 break;
2096 }
2097 break;
2098 case 'F':
2099 case 'f':
2100 for(i = 0; i<num; i++)
2101 {
2102 sscanf(strp,"%f",&ff);
2103 *(float *)ptr = ff;
2104 ptr = (float *)ptr +1;
2105 if( (strp = strchr(strp,' ')) )
2106 strp++;
2107 else
2108 break;
2109 }
2110 break;
2111 case 'D':
2112 case 'd':
2113 for(i = 0; i<num; i++)
2114 {
2115 sscanf(strp,"%f",&ff);
2116 dd = (double)ff;
2117 *(double *)ptr = dd;
2118 ptr = (double *)ptr +1;
2119 if( (strp = strchr(strp,' ')) )
2120 strp++;
2121 else
2122 break;
2123 }
2124 break;
2125 case 'C':
2126 case 'c':
2127 default:
2128 for(i = 0; i<num; i++)
2129 {
2130 if((ret = read_str_char(strp, &cc)) <= 0)
2131 break;
2132 *(char *)ptr = cc;
2133 ptr = (char *)ptr +1;
2134 if( (strp = strchr(strp,' ')) )
2135 strp++;
2136 else
2137 break;
2138 }
2139 if(ret <= 0)
2140 {
2141 if(!ret)
2142 {
2143 strp++;
2144 }
2145 num = (int)strlen(strp)+1;
2146 strncpy((char *)ptr,strp,(size_t)num);
2147 if( (ptr1 = (char *)strchr((char *)ptr,'\"')) )
2148 {
2149 num--;
2150 *ptr1 = '\0';
2151 }
2152 ptr = (char *)ptr + num;
2153 if( (strp = strchr(strp,' ')) )
2154 strp++;
2155 else
2156 break;
2157 }
2158 }
2159 *buffer_ptr = ptr;
2160 *str_ptr = strp;
2161}
2162
2163void cancel_pop_up (Widget w, int tag, unsigned long *reason)
2164{
2165 void print_service_formatted();
2166
2167 if(reason){}
2168 if(tag == MAX_POP_UPS+1)
2169 {
2170 print_service_formatted(Service_buffer,Service_size);
2171 set_something(Content_label_id,XmNlabelString, Service_content_str);
2172 Curr_service_print_type = 0;
2173 }
2174 /*
2175 else if(tag == MAX_POP_UPS+2)
2176 {
2177 print_service_float(Service_buffer, ((Service_size - 1) / 4) + 1);
2178 set_something(Content_label_id,XmNlabelString, Service_content_str);
2179 Curr_service_print_type = 1;
2180 }
2181 else if(tag == MAX_POP_UPS+3)
2182 {
2183 print_service_double(Service_buffer, ((Service_size - 1) / 4) + 1);
2184 set_something(Content_label_id,XmNlabelString, Service_content_str);
2185 Curr_service_print_type = 2;
2186 }
2187 */
2188 else if(tag == MAX_POP_UPS+4)
2189 {
2190
2191 if((!strstr(Curr_service_name,"/SERVICE_LIST")) &&
2192 (!strstr(Curr_service_name,"/CLIENT_LIST")) &&
2193 (!strstr(Curr_service_name,"/SERVER_LIST")))
2194 {
2195 if(Curr_service_id)
2196 {
2197 dic_release_service(Curr_service_id);
2198 Curr_service_id = 0;
2199 }
2200 Curr_service_id = (int)dic_info_service_stamped(Curr_service_name,
2201 MONITORED,10,0,0,
2202 recv_service_info,0,
2203 &no_link_int,4);
2204 }
2205 XtSetSensitive(w, False);
2206 XtSetSensitive(SubscribeButton, True);
2207 }
2208 else if(tag == MAX_POP_UPS+5)
2209 {
2210
2211 if((!strstr(Curr_service_name,"/SERVICE_LIST")) &&
2212 (!strstr(Curr_service_name,"/CLIENT_LIST")) &&
2213 (!strstr(Curr_service_name,"/SERVER_LIST")))
2214 {
2215 if(Curr_service_id)
2216 {
2217 dic_release_service(Curr_service_id);
2218 Curr_service_id = 0;
2219 }
2220 Curr_service_id = (int)dic_info_service_stamped(Curr_service_name,
2221 MONITORED,0,0,0,
2222 recv_service_info,0,
2223 &no_link_int,4);
2224 }
2225 XtSetSensitive(w, False);
2226 XtSetSensitive(Subscribe10Button, True);
2227 }
2228/*
2229 else if(tag == 5)
2230 {
2231 *
2232 XtUnmapWidget(XtParent(pop_widget_id[4]));
2233 *
2234 }
2235*/
2236 else if(tag == DID_SERVICE)
2237 {
2238 if(Curr_service_id)
2239 {
2240 dic_release_service(Curr_service_id);
2241 Curr_service_id = 0;
2242 }
2243 XtUnmanageChild(pop_widget_id[DID_SERVICE]);
2244 free(Service_content_str);
2245 free(Service_buffer);
2246 }
2247}
2248
2249void create_matrix(Widget w, int *tag, unsigned long *reason)
2250{
2251
2252 if(reason){}
2253 Matrix_id[*tag] = w;
2254 if(*tag)
2255 XtUnmanageChild(w);
2256 else
2257 Curr_matrix = 0;
2258}
2259
2260void create_label(Widget w, int *tag, unsigned long *reason)
2261{
2262 if(reason){}
2263 if(!*tag)
2264 Label_id = w;
2265 else
2266 Content_label_id = w;
2267}
2268
2269void switch_matrix()
2270{
2271 /*
2272 XtUnmanageChild(Matrix_id[Curr_matrix]);
2273 Curr_matrix = (Curr_matrix) ? 0 : 1;
2274 XtManageChild(Matrix_id[Curr_matrix]);
2275 */
2276 XmScrolledWindowSetAreas(Window_id,NULL, NULL, Matrix_id[Curr_matrix]);
2277}
2278
2279/*
2280static int curr_allocated_size = 0;
2281static DNS_SERVER_INFO *dns_info_buffer;
2282*/
2283
2284void update_servers_new(int *tag, char *buffer, int *size)
2285{
2286 if(tag){}
2287 if(size){}
2288 printf("Server_list:\n%s\n",buffer);
2289}
2290
2291SERVER *find_server(char *node, int pid)
2292{
2293 SERVER *servp;
2294 DNS_SERVER_INFO *ptr;
2295
2296 servp = Server_head;
2297 while( (servp = (SERVER *)sll_get_next((SLL *)servp)) )
2298 {
2299 ptr = &servp->server;
2300 if((ptr->pid == pid) && (!strcmp(ptr->node,node)))
2301 {
2302 return(servp);
2303 }
2304 }
2305 return ((SERVER *)0);
2306}
2307 /*
2308 if(!(servp = (SERVER *)sll_search((SLL *)Server_head,
2309 (char *)&buffer->server, MAX_NODE_NAME+MAX_TASK_NAME-4)))
2310 */
2311
2312
2313void update_servers(int *tag, DNS_DID *buffer, int *size)
2314{
2315int n_services, service_size;
2316SERVER *servp;
2317int j;
2318char str[MAX_NAME], sname[MAX_NAME], *ptr;
2319
2320 if(tag){}
2321 if(!Server_head)
2322 {
2323 Server_head = (SERVER *)malloc(sizeof(SERVER));
2324 sll_init((SLL *)Server_head);
2325 }
2326 if(First_time)
2327 {
2328 switch_matrix();
2329 First_time = 0;
2330 }
2331
2332 if(!*size)
2333 return;
2334 if(*(char *)buffer == -1)
2335 {
2336 N_servers = 0;
2337 N_services = 0;
2338 return;
2339 }
2340 buffer->server.n_services = vtohl(buffer->server.n_services);
2341 buffer->server.pid = vtohl(buffer->server.pid);
2342 n_services = buffer->server.n_services;
2343 /*
2344printf("received pid %d, nservices %d\n",buffer->server.pid, n_services);
2345 */
2346 if(n_services == 1)
2347 return;
2348 strcpy(sname, buffer->server.task);
2349 /*
2350printf("name = %s\n", sname);
2351 */
2352 if(n_services > 1)
2353 {
2354 for(j = 0; j < n_services; j++)
2355 {
2356 buffer->services[j].type = vtohl(
2357 buffer->services[j].type);
2358 buffer->services[j].status = vtohl(
2359 buffer->services[j].status);
2360 buffer->services[j].n_clients = vtohl(
2361 buffer->services[j].n_clients);
2362 if(strlen(sname) == MAX_TASK_NAME-4-1)
2363 {
2364 strcpy(str,buffer->services[j].name);
2365 if( (ptr = strstr(str,"/CLIENT_LIST")) )
2366 {
2367 *ptr = '\0';
2368 strcpy(sname,str);
2369 }
2370 }
2371 }
2372 }
2373 if (!(servp = find_server(buffer->server.node,buffer->server.pid)))
2374 /*
2375 if(!(servp = (SERVER *)sll_search((SLL *)Server_head,
2376 (char *)&buffer->server, MAX_NODE_NAME+MAX_TASK_NAME-4)))
2377 */
2378 {
2379 if(n_services)
2380 {
2381 servp = (SERVER *)malloc(sizeof(SERVER));
2382 strcpy(servp->name,sname);
2383 servp->next = 0;
2384 servp->button_id = 0;
2385 servp->pop_widget_id[0] = 0;
2386 servp->pop_widget_id[1] = 0;
2387 servp->busy = 0;
2388 servp->server.n_services = 0;
2389 servp->service_ptr = 0;
2390 sll_insert_queue((SLL *)Server_head,(SLL *)servp);
2391 }
2392 }
2393 if(n_services != 0)
2394 {
2395 if(n_services == servp->server.n_services)
2396 {
2397 return;
2398 }
2399 if(servp->server.n_services == 0)
2400 N_servers++;
2401 if(servp->server.n_services != -1)
2402 N_services -= servp->server.n_services;
2403 memcpy(&servp->server,&buffer->server,sizeof(DNS_SERVER_INFO));
2404 if(servp->service_ptr)
2405 {
2406 free(servp->service_ptr);
2407 servp->service_ptr = 0;
2408 }
2409 if(n_services != -1)
2410 {
2411 service_size = n_services*(int)sizeof(DNS_SERVICE_INFO);
2412 servp->service_ptr = (DNS_SERVICE_INFO *)malloc((size_t)service_size);
2413 memcpy(servp->service_ptr, buffer->services, (size_t)service_size);
2414 N_services += n_services;
2415 }
2416 servp->busy = 1;
2417 if(strcmp(servp->name, sname))
2418 {
2419 strcpy(servp->name,sname);
2420 Force_update = 1;
2421 servp->busy = 3;
2422 }
2423 }
2424 else
2425 {
2426 if(servp)
2427 {
2428 N_servers--;
2429 if(servp->server.n_services != -1)
2430 {
2431 N_services -= servp->server.n_services;
2432 }
2433 else
2434 Force_update = 1;
2435 servp->server.n_services = 0;
2436 servp->busy = -1;
2437 }
2438 }
2439}
2440
2441void show_servers()
2442{
2443SERVER *servp;
2444void update_show_servers();
2445void remove_all_buttons();
2446void put_label();
2447
2448 if(!Matrix_id[Curr_matrix])
2449 return;
2450 remove_all_buttons();
2451
2452#ifndef linux
2453 switch_matrix();
2454#endif
2455 put_label();
2456 servp = Server_head;
2457 while( (servp = (SERVER *)sll_get_next((SLL *)servp)) )
2458 {
2459 servp->busy = 1;
2460 }
2461 Force_update = 1;
2462}
2463
2464void update_show_servers(void *tag, unsigned long *reason)
2465{
2466DNS_SERVER_INFO *server_ptr;
2467DNS_SERVICE_INFO *service_ptr;
2468int i, j, found, n_done = 0;
2469Widget w, create_button();
2470SERVER *servp, *prevp;
2471static int old_n_services = 0;
2472char node[MAX_NODE_NAME], par[MAX_NODE_NAME], *ptr;
2473void remove_button();
2474void remove_all_buttons();
2475void put_label();
2476
2477 DISABLE_AST
2478 if(tag){}
2479 if(reason){}
2480 if((N_services != old_n_services) || (Force_update))
2481 {
2482 if(!Matrix_id[Curr_matrix])
2483 {
2484 XtAppAddTimeOut(app_context, 1000, update_show_servers, 0);
2485 ENABLE_AST
2486 return;
2487 }
2488 if(!N_servers)
2489 {
2490 remove_all_buttons();
2491 if(! No_link_button_id)
2492 {
2493 No_link_button_id = create_button("DNS is down", 0);
2494 set_color(No_link_button_id, XmNbackground, RED);
2495 get_something(No_link_button_id,XmNuserData,&w);
2496 set_color(w, XmNbackground, RED);
2497 XtSetSensitive(No_link_button_id, False);
2498 }
2499 while(!sll_empty((SLL *)Server_head))
2500 {
2501 servp = (SERVER *)sll_remove_head((SLL *)Server_head);
2502 if(servp->service_ptr)
2503 free(servp->service_ptr);
2504 free(servp);
2505 }
2506 put_label();
2507 old_n_services = N_services;
2508 Force_update = 0;
2509 XtAppAddTimeOut(app_context, 1000, update_show_servers, 0);
2510 ENABLE_AST
2511 return;
2512 }
2513 if(No_link_button_id)
2514 {
2515 XtDestroyWidget(No_link_button_id);
2516 /*
2517 XFlush(XtDisplay(No_link_button_id));
2518 */
2519 No_link_button_id = 0;
2520 }
2521 servp = Server_head;
2522 prevp = 0;
2523 while( (servp = (SERVER *)sll_get_next((SLL *)servp)) )
2524 {
2525 if(prevp)
2526 {
2527 free(prevp);
2528 prevp = 0;
2529 }
2530 if(n_done == 10)
2531 {
2532 if(!Force_update)
2533 put_label();
2534 XtAppAddTimeOut(app_context, 100, update_show_servers, 0);
2535 ENABLE_AST
2536 return;
2537 }
2538 server_ptr = &servp->server;
2539 if(servp->busy == 3)
2540 {
2541 remove_button(servp);
2542 servp->busy = 1;
2543 }
2544 if(servp->busy == 1)
2545 {
2546 if(!servp->button_id)
2547 {
2548 switch(Curr_view_opt)
2549 {
2550 case 1 :
2551 servp->button_id = create_button(/*server_ptr->task*/servp->name, servp);
2552 n_done++;
2553 break;
2554 case 0 :
2555 strcpy(node, server_ptr->node);
2556 strcpy(par, Curr_view_opt_par);
2557 if(!isdigit(node[0]))
2558 {
2559 ptr = strchr(node, '.');
2560 if(ptr)
2561 *ptr = '\0';
2562 ptr = strchr(par,'.');
2563 if(ptr)
2564 *ptr = '\0';
2565 }
2566 ptr = node;
2567 for(i = 0; i < (int)strlen(ptr); i++)
2568 ptr[i] = (char)tolower((int)ptr[i]);
2569 ptr = par;
2570 for(i = 0; i < (int)strlen(ptr); i++)
2571 ptr[i] = (char)tolower((int)ptr[i]);
2572 if(!strcmp(/*server_ptr->*/node, /*Curr_view_opt_*/par))
2573 {
2574 servp->button_id = create_button(/*server_ptr->task*/servp->name, servp);
2575 n_done++;
2576 }
2577 break;
2578 case 2 :
2579 found = 0;
2580 if(!(service_ptr = servp->service_ptr))
2581 break;
2582 for(j = 0; j < server_ptr->n_services; j++)
2583 {
2584 if(strstr(service_ptr->name, Curr_view_opt_par) > (char *)0)
2585 {
2586 found = 1;
2587 break;
2588 }
2589 service_ptr++;
2590 }
2591 if (found)
2592 {
2593 servp->button_id = create_button(/*server_ptr->task*/servp->name, servp);
2594 n_done++;
2595 }
2596 break;
2597 case 3 :
2598 if(server_ptr->n_services == -1)
2599 {
2600 servp->button_id = create_button(/*server_ptr->task*/servp->name, servp);
2601 n_done++;
2602 }
2603 else
2604 {
2605 if(servp->button_id)
2606 remove_button(servp);
2607 }
2608 n_done++;
2609 break;
2610 }
2611 }
2612 servp->busy = 2;
2613 if(servp->button_id)
2614 {
2615 if(Curr_view_opt != -1)
2616 {
2617 if (server_ptr->n_services == -1)
2618 {
2619 set_color(servp->button_id, XmNbackground, RED);
2620 get_something(servp->button_id,XmNuserData,&w);
2621 set_color(w, XmNbackground, RED);
2622 }
2623 else
2624 {
2625 set_color(servp->button_id, XmNbackground, GREEN);
2626 get_something(servp->button_id,XmNuserData,&w);
2627 set_color(w, XmNbackground, GREEN);
2628 }
2629 }
2630 }
2631 }
2632 else if (servp->busy == -1)
2633 {
2634 remove_button(servp);
2635 sll_remove((SLL *)Server_head, (SLL *)servp);
2636 if(servp->service_ptr)
2637 {
2638 free(servp->service_ptr);
2639 servp->service_ptr = 0;
2640 }
2641 prevp = servp;
2642 n_done++;
2643 }
2644 }
2645 if(prevp)
2646 {
2647 free(prevp);
2648 prevp = 0;
2649 }
2650 put_label();
2651 old_n_services = N_services;
2652 Force_update = 0;
2653 }
2654 XtAppAddTimeOut(app_context, 1000, update_show_servers, 0);
2655 ENABLE_AST
2656}
2657
2658Widget create_button(char *name, SERVER *servp)
2659{
2660Arg arglist[10];
2661int n;
2662/*
2663int n_services = -1;
2664*/
2665Widget w, ww, w_id;
2666void activate_services(), activate_clients();
2667char w_name[MAX_NAME];
2668
2669 w_name[0] = 0;
2670/*
2671 if(servp)
2672 n_services = servp->server.n_services;
2673*/
2674 strcpy(w_name,name);
2675 if(strlen(w_name) >= MAX_TASK_NAME - 4)
2676 w_name[16] = '\0';
2677 n = 0;
2678 XtSetArg(arglist[n], XmNorientation, XmVERTICAL); n++;
2679 XtSetArg(arglist[n], XmNentryAlignment, XmALIGNMENT_CENTER); n++;
2680 w_id = w = XmCreateMenuBar(Matrix_id[Curr_matrix],
2681 (String)XmStringCreateLtoR ( w_name,XmSTRING_DEFAULT_CHARSET),
2682 arglist,(Cardinal)n);
2683/*
2684 if(n_services == -1)
2685 set_color(w, XmNbackground, RED);
2686 else
2687 set_color(w, XmNbackground, GREEN);
2688*/
2689 XtManageChild(w);
2690 strcat(w_name,"1");
2691 n = 0;
2692 XtSetArg(arglist[n], XmNalignment, XmALIGNMENT_CENTER); n++;
2693 XtSetArg(arglist[n], XmNfontList, did_server_font); n++;
2694 w = XmCreateCascadeButton(w,
2695 (String)XmStringCreateLtoR ( w_name,XmSTRING_DEFAULT_CHARSET),
2696 arglist,(Cardinal)n);
2697 set_something(w,XmNlabelString,name);
2698 set_something(w,XmNalignment,XmALIGNMENT_CENTER);
2699/*
2700 if(n_services == -1)
2701 set_color(w, XmNbackground, RED);
2702 else
2703 set_color(w, XmNbackground, GREEN);
2704*/
2705 set_something(w_id,XmNuserData,w);
2706 strcat(w_name,"1");
2707 n = 0;
2708 ww = XmCreatePulldownMenu(w_id,
2709 (String)XmStringCreateLtoR ( w_name,XmSTRING_DEFAULT_CHARSET),
2710 arglist,(Cardinal)n);
2711 set_something(w,XmNsubMenuId,ww);
2712 XtManageChild(w);
2713 strcat(w_name,"1");
2714 n = 0;
2715 XtSetArg(arglist[n], XmNfontList, did_default_font); n++;
2716 w = XmCreatePushButton(ww,
2717 (String)XmStringCreateLtoR ( w_name,XmSTRING_DEFAULT_CHARSET),
2718 arglist,(Cardinal)n);
2719
2720 set_something(w,XmNlabelString,"Services");
2721 if(servp)
2722 {
2723 XtAddCallback(w,XmNactivateCallback, activate_services, servp);
2724 XtManageChild(w);
2725 strcat(w_name,"1");
2726 n = 0;
2727 XtSetArg(arglist[n], XmNfontList, did_default_font); n++;
2728 w = XmCreatePushButton(ww,
2729 (String)XmStringCreateLtoR ( w_name,XmSTRING_DEFAULT_CHARSET),
2730 arglist,(Cardinal)n);
2731
2732 set_something(w,XmNlabelString,"Clients");
2733 XtAddCallback(w,XmNactivateCallback, activate_clients, servp);
2734 XtManageChild(w);
2735 /*
2736 servp->popping = 0;
2737 create_client_popup(servp);
2738 */
2739 }
2740 return(w_id);
2741}
2742
2743void remove_all_buttons()
2744{
2745SERVER *servp;
2746
2747 servp = Server_head;
2748 while( (servp = (SERVER *)sll_get_next((SLL *)servp)) )
2749 {
2750 if(servp->button_id)
2751 {
2752 XtDestroyWidget(servp->button_id);
2753 servp->button_id = 0;
2754 servp->busy = 0;
2755 }
2756 }
2757}
2758
2759void remove_button(SERVER *servp)
2760{
2761
2762 if(servp->button_id)
2763 {
2764 XtDestroyWidget(servp->button_id);
2765 servp->button_id = 0;
2766 servp->busy = 0;
2767 }
2768}
2769
2770void activate_services(Widget w, SERVER *servp, unsigned long *reason)
2771{
2772DNS_SERVER_INFO *ptr;
2773char str[MAX_NAME];
2774Widget id,sel_id;
2775void got_service_list();
2776void kick_it();
2777
2778 if(w){}
2779 if(reason){}
2780 if(servp->pop_widget_id[0])
2781 {
2782 XtDestroyWidget(servp->pop_widget_id[0]);
2783 servp->pop_widget_id[0] = 0;
2784 /*
2785 return;
2786 */
2787 }
2788 Curr_servp = servp;
2789 ptr = &servp->server;
2790
2791 sel_id = put_popup(servp, 0,"Service Info");
2792
2793 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_OK_BUTTON);
2794 XtUnmanageChild(id);
2795
2796 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST_LABEL);
2797 if (ptr->pid > 0x1000000)
2798 sprintf(str,"Server %s (pid = %X) on node %s\n\nprovides %d services :\n",
2799 servp->name, ptr->pid, ptr->node, ptr->n_services);
2800 else
2801 sprintf(str,"Server %s (pid = %d) on node %s\n\nprovides %d services :\n",
2802 servp->name, ptr->pid, ptr->node, ptr->n_services);
2803 set_something(sel_id,XmNlistLabelString,str);
2804
2805 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST);
2806 Curr_service_list_id = id;
2807
2808 XmListAddItem(id,create_str(
2809 "Ordering services alphabeticaly, please be patient..."),1);
2810
2811 set_something(id,XmNlistItemCount,1);
2812 set_something(id,XmNlistVisibleItemCount,1);
2813
2814 sprintf(str,"%s/SERVICE_LIST",/*ptr->task*/servp->name);
2815 dic_info_service(str,ONCE_ONLY,20,0,0,
2816 got_service_list,(long)servp,"None",5);
2817 /*
2818#ifdef solaris
2819 */
2820 /*
2821 XtAppAddTimeOut(app_context, 1000, kick_it, 0);
2822 */
2823 /*
2824#endif
2825 */
2826}
2827
2828void kick_it()
2829{
2830 printf("kick_it\n");
2831}
2832
2833typedef char DID_SLOT[MAX_NAME];
2834
2835void got_service_list(SERVER **servp_ptr, char *buffer, int *size)
2836{
2837SERVER *servp;
2838void do_got_service_list();
2839
2840 if(size){}
2841 servp = *servp_ptr;
2842 if(Curr_service_list)
2843 free(Curr_service_list);
2844 Curr_service_list = malloc(strlen(buffer)+1);
2845 strcpy(Curr_service_list, buffer);
2846 /*
2847#ifdef solaris
2848 */
2849 Got_Service_List = servp;
2850 /*
2851#else
2852 do_got_service_list(servp);
2853#endif
2854 */
2855}
2856
2857void do_got_service_list(SERVER *servp)
2858{
2859char cmd_str[256], svc_str[256];
2860DNS_SERVER_INFO *ptr;
2861DNS_SERVICE_INFO *service_ptr;
2862Widget id;
2863char *curr_str, max_str[MAX_NAME], *sptr;
2864DID_SLOT *service_list;
2865int i, j, curr_index = 0, n_services;
2866XmString xstr;
2867void delete_str();
2868
2869 ptr = &servp->server;
2870 id = Curr_service_list_id;
2871
2872 XmListDeleteAllItems(id);
2873
2874 strcpy(cmd_str,"CMD: ");
2875 strcpy(svc_str,"SVC: ");
2876
2877 service_ptr = servp->service_ptr;
2878 service_list = (DID_SLOT *)malloc((size_t)(ptr->n_services * MAX_NAME));
2879 n_services = ptr->n_services;
2880
2881 for(i=0;i<n_services; i++)
2882 {
2883 strcpy(service_list[i],service_ptr->name);
2884 service_ptr++;
2885 }
2886 strcpy(max_str,"zzzzzzzzzzzzzzzzzzzzzzzzzzzz");
2887 for(i=0;i<n_services; i++)
2888 {
2889 curr_str = max_str;
2890 for(j=0;j<n_services; j++)
2891 {
2892 sptr = service_list[j];
2893 if(!*sptr)
2894 continue;
2895
2896 if(strcmp(sptr,curr_str) < 0)
2897 {
2898 curr_str = sptr;
2899 curr_index = j;
2900 }
2901 }
2902 service_list[curr_index][0] = '\0';
2903 service_ptr = &(servp->service_ptr[curr_index]);
2904 if(service_ptr->type)
2905 {
2906 strcpy(&cmd_str[5],service_ptr->name);
2907 xstr = create_str(cmd_str);
2908 XmListAddItem(id,xstr,i+1);
2909 delete_str(xstr);
2910 }
2911 else
2912 {
2913 strcpy(&svc_str[5],service_ptr->name);
2914 xstr = create_str(svc_str);
2915 XmListAddItem(id,xstr,i+1);
2916 delete_str(xstr);
2917 }
2918 }
2919 free(service_list);
2920
2921 set_something(id,XmNlistItemCount,i);
2922 set_something(id,XmNlistVisibleItemCount,(i < 20) ? i : 20);
2923}
2924
2925void show_clients(SERVER **servp_ptr, char *buffer, int *size)
2926{
2927SERVER *servp;
2928void do_show_clients();
2929
2930 if(size){}
2931 servp = *servp_ptr;
2932 if(Curr_client_list)
2933 free(Curr_client_list);
2934 Curr_client_list = malloc(strlen(buffer)+1);
2935 strcpy(Curr_client_list, buffer);
2936 /*
2937#ifdef solaris
2938 */
2939 Got_Client_List = servp;
2940 /*
2941#else
2942 do_show_clients(servp);
2943#endif
2944 */
2945}
2946
2947void do_show_clients(SERVER *servp)
2948{
2949int i = 0;
2950char str[2048], *strp, *strp1;
2951XmString xstr;
2952void delete_str();
2953
2954/*
2955DNS_SERVER_INFO *ptr;
2956 ptr = &servp->server;
2957 sel_id = servp->pop_widget_id[1];
2958 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST_LABEL);
2959*/
2960 if(servp){}
2961 if(Curr_client_list[0] == -1)
2962 {
2963 sprintf(str,"Information not available\n");
2964 XmListAddItem(Curr_client_id,create_str(str),i+1);
2965 /*
2966 set_something(sel_id,XmNlistLabelString,str);
2967 */
2968 return;
2969 }
2970 /*
2971 sprintf(str,"Clients of %s are : \n",
2972 ptr->task);
2973 set_something(sel_id,XmNlistLabelString,str);
2974
2975 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST);
2976 XmListDeleteAllItems(id);
2977 */
2978 strp1 = Curr_client_list;
2979 while(strp1)
2980 {
2981 if(!*strp1)
2982 break;
2983 sprintf(str,"Process ");
2984 strp = strp1;
2985 strp1 = strchr(strp,'@');
2986 *strp1 = '\0';
2987 strp1++;
2988 strcat(str,strp);
2989 strcat(str," on node ");
2990 strp = strp1;
2991 if( (strp1 = strchr(strp,'|')) )
2992 {
2993 *strp1 = '\0';
2994 strp1++;
2995 }
2996 strcat(str,strp);
2997 xstr = create_str(str);
2998 XmListAddItem(Curr_client_id,xstr,i+1);
2999 delete_str(xstr);
3000 i++;
3001 }
3002 if(!i)
3003 {
3004 sprintf(str,"NONE");
3005 xstr = create_str(str);
3006 XmListAddItem(Curr_client_id,xstr,i+1);
3007 delete_str(xstr);
3008 }
3009 /*
3010 set_something(id,XmNlistItemCount,i);
3011 */
3012 /*
3013 if(Matrix_id[Curr_matrix])
3014 XFlush(XtDisplay(Matrix_id[Curr_matrix]));
3015 */
3016}
3017
3018void activate_clients(Widget w, SERVER *servp, unsigned long *reason)
3019{
3020/*
3021DNS_SERVER_INFO *ptr;
3022*/
3023char str[100];
3024void show_clients();
3025void kick_it_again();
3026Widget id,sel_id;
3027
3028 if(w) {}
3029 if(reason){}
3030 Curr_servp = servp;
3031/*
3032 ptr = &servp->server;
3033*/
3034 if(servp->pop_widget_id[1])
3035 {
3036 XtDestroyWidget(servp->pop_widget_id[1]);
3037 servp->pop_widget_id[1] = 0;
3038 }
3039 sel_id = put_popup(servp,1,"Client Info");
3040
3041 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_HELP_BUTTON);
3042 XtUnmanageChild(id);
3043
3044 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_APPLY_BUTTON);
3045 XtUnmanageChild(id);
3046
3047 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_CANCEL_BUTTON);
3048 XtUnmanageChild(id);
3049
3050 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_TEXT);
3051 XtUnmanageChild(id);
3052
3053 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_SELECTION_LABEL);
3054 XtUnmanageChild(id);
3055 /*
3056 id = (Widget)XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST_LABEL);
3057 */
3058 id = XmSelectionBoxGetChild(sel_id,XmDIALOG_LIST);
3059 XmListDeleteAllItems(id);
3060
3061 Curr_client_id = id;
3062 sprintf(str,"Clients of %s are : \n",
3063 servp->name);
3064 set_something(sel_id,XmNlistLabelString,str);
3065
3066 sprintf(str,"%s/CLIENT_LIST",/*ptr->task*/servp->name);
3067 dic_info_service(str,ONCE_ONLY,10,0,0,
3068 show_clients,(long)servp,&no_link,1);
3069 /*
3070#ifdef solaris
3071 */
3072 /*
3073 XtAppAddTimeOut(app_context, 1000, kick_it_again, 0);
3074 */
3075 /*
3076#endif
3077 */
3078}
3079
3080void kick_it_again()
3081{
3082 printf("kick_it_again\n");
3083}
3084
3085Widget put_popup(SERVER *servp, int type, char *title)
3086{
3087 Widget id;
3088 void activate_services(), activate_clients();
3089 extern void set_title();
3090
3091 if(type)
3092 {
3093 id = create_client_dialog();
3094 /*
3095 XtAddCallback(id,XmNokCallback, activate_clients, servp);
3096 XtAddCallback(id,XmNcancelCallback, activate_clients, servp);
3097 */
3098 }
3099 else
3100 {
3101 id = create_server_dialog();
3102 /*
3103 XtAddCallback(id,XmNcancelCallback, activate_services, servp);
3104 */
3105 }
3106 servp->pop_widget_id[type] = id;
3107 /*
3108 }
3109 */
3110 XtManageChild(id);
3111 set_title(XtParent(id),title);
3112 return(id);
3113}
3114
3115Widget put_selection(int tag, char *title)
3116{
3117 Widget id = 0;
3118 extern void set_title();
3119
3120 if(pop_widget_id[tag])
3121 {
3122 XtDestroyWidget(pop_widget_id[tag]);
3123 }
3124 switch(tag)
3125 {
3126 case DID_SEL_NODE:
3127 id = create_node_selection();
3128 break;
3129 case DID_SEL_SERVICE:
3130 id = create_service_selection();
3131 break;
3132 case DID_KILL_ALL:
3133 id = create_kill_confirmation();
3134 break;
3135 case DID_SERVICE:
3136 id = create_service_dialog();
3137 break;
3138 case DID_COMMAND:
3139 id = create_send_command();
3140 break;
3141 }
3142
3143 pop_widget_id[tag] = id;
3144 XtManageChild(id);
3145 set_title(XtParent(id),title);
3146 return(id);
3147}
3148
3149void check_put_label(int tag)
3150{
3151 static int old_n_services = 0;
3152/*
3153 static int changing = 0;
3154*/
3155 void put_label();
3156
3157 if(tag){}
3158 if(N_services != old_n_services)
3159 {
3160 put_label();
3161/*
3162 if(N_services > old_n_services)
3163 changing = 1;
3164*/
3165 old_n_services = N_services;
3166
3167#ifdef linux
3168 show_servers();
3169#endif
3170 }
3171/*
3172 else
3173 {
3174 if(changing)
3175 {
3176 show_servers();
3177 changing = 0;
3178 }
3179 }
3180*/
3181}
3182
3183void put_label()
3184{
3185 char str[MAX_NAME], str1[MAX_NAME];
3186
3187 DISABLE_AST
3188 sprintf(str,"%d Servers known - %d Services Available\n",
3189 N_servers,N_services);
3190 switch(Curr_view_opt)
3191 {
3192 case 1 :
3193 strcat(str,"Displaying ALL Servers");
3194 break;
3195 case 0 :
3196 sprintf(str1,"Displaying Servers on node %s",Curr_view_opt_par);
3197 strcat(str,str1);
3198 break;
3199 case 2 :
3200 sprintf(str1,"Displaying Servers providing Service *%s*",
3201 Curr_view_opt_par);
3202 strcat(str,str1);
3203 break;
3204 case 3 :
3205 strcat(str,"Displaying Servers in ERROR");
3206 break;
3207 case -1 :
3208 strcat(str,"Please Select Viewing Option");
3209 break;
3210 }
3211 set_something(Label_id,XmNlabelString,str);
3212 XFlush(XtDisplay(Label_id));
3213 ENABLE_AST
3214}
3215
3216Widget create_client_dialog()
3217{
3218 Widget id;
3219 id = create_selection_dialog("Dismiss","","","","",DID_CLIENTS, 3);
3220 return(id);
3221
3222}
3223
3224Widget create_server_dialog()
3225{
3226 Widget id;
3227 id = create_selection_dialog("","View / Send","Dismiss","",
3228 "Service / Command :",
3229 DID_SERVICES, 20);
3230 return(id);
3231}
3232
3233Widget create_node_selection()
3234{
3235 Widget id;
3236 id = create_selection_dialog("","","","Nodes :","Selected Node :",DID_SEL_NODE, 8);
3237 return(id);
3238
3239}
3240
3241Widget create_service_selection()
3242{
3243 Widget id;
3244 /*
3245 id = create_prompt_dialog("Enter Service Name :",DID_SEL_SERVICE);
3246 */
3247 id = create_selection_dialog("","","","","Enter Service Name (or search string):",DID_SEL_SERVICE, 0);
3248 return(id);
3249
3250}
3251
3252Widget create_send_command()
3253{
3254 Widget id;
3255 char str[256], str1[256];
3256
3257 sprintf(str,"Command to %s (%s)\n\n",
3258 Curr_service_name, Curr_service_format);
3259
3260 id = create_selection_dialog("","","",str,"Command:",DID_COMMAND, 1);
3261
3262 strcpy(str1,"Please enter items separated by spaces:\n(for example: 2 0x123 'A' 23.4 \"a text\")");
3263
3264 set_something(id,XmNselectionLabelString,str1);
3265
3266 return(id);
3267
3268}
3269
3270Widget create_kill_confirmation()
3271{
3272 Widget id;
3273 id = create_question_dialog("Do you really want to kill ALL DIM servers ?",
3274 DID_KILL_ALL);
3275 return(id);
3276
3277}
3278
3279Widget create_selection_dialog(char *ok, char *apply, char *cancel, char *list, char *sel,
3280 long tag, int items)
3281{
3282Widget sd;
3283XmString xmOk, xmApply, xmCancel, xmList, xmSelection;
3284Arg ar[20];
3285int n;
3286
3287 xmList = create_str(list);
3288 xmOk = create_str(ok);
3289 xmApply = create_str(apply);
3290 xmCancel = create_str (cancel);
3291 xmSelection = create_str (sel);
3292
3293 n = 0;
3294 /*
3295 XtSetArg(ar[n],XmNdialogStyle,XmDIALOG_FULL_APPLICATION_MODAL); n++;
3296 XtSetArg(ar[n],XmNmwmFunctions,MWM_FUNC_MOVE); n++;
3297 */
3298 XtSetArg(ar[n],XmNtitle,"Selection"); n++;
3299 XtSetArg(ar[n],XmNlabelFontList, did_default_font); n++;
3300 XtSetArg(ar[n],XmNbuttonFontList, did_default_font); n++;
3301 XtSetArg(ar[n],XmNtextFontList, did_small_font); n++;
3302 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3303 XtSetArg(ar[n],XmNlistLabelString, xmList); n++;
3304 XtSetArg(ar[n],XmNlistVisibleItemCount,items); n++;
3305 if(ok[0])
3306 {
3307 XtSetArg(ar[n],XmNokLabelString, xmOk); n++;
3308 }
3309 if(apply[0])
3310 {
3311 XtSetArg(ar[n],XmNapplyLabelString, xmApply); n++;
3312 }
3313 if(cancel[0])
3314 {
3315 XtSetArg(ar[n],XmNcancelLabelString, xmCancel); n++;
3316 }
3317 if(sel[0])
3318 {
3319 XtSetArg(ar[n],XmNselectionLabelString, xmSelection); n++;
3320 }
3321 sd = XmCreateSelectionDialog ( toplevel_widget, "Selection", ar, (Cardinal)n );
3322 XmStringFree(xmList);
3323 XmStringFree(xmOk);
3324 XmStringFree(xmApply);
3325 XmStringFree(xmCancel);
3326 XmStringFree(xmSelection);
3327 if(tag >= 0)
3328 {
3329 XtAddCallback ( sd, XmNcancelCallback,
3330 (XtCallbackProc)cancel_pop_up, (XtPointer)tag );
3331 XtAddCallback ( sd, XmNapplyCallback,
3332 (XtCallbackProc)ok_pop_up, (XtPointer)tag );
3333 XtAddCallback ( sd, XmNokCallback,
3334 (XtCallbackProc)ok_pop_up, (XtPointer)tag );
3335 }
3336 return(sd);
3337}
3338
3339Widget create_file_selection_dialog(long type)
3340{
3341Widget sd;
3342XmString xm1;
3343Arg ar[20];
3344int n;
3345
3346 xm1 = create_str ("");
3347 n = 0;
3348 /*
3349 XtSetArg(ar[n],XmNdialogStyle,XmDIALOG_FULL_APPLICATION_MODAL); n++;
3350 XtSetArg(ar[n],XmNmwmFunctions,MWM_FUNC_MOVE); n++;
3351 */
3352 XtSetArg(ar[n],XmNtitle,"FileSelection"); n++;
3353 XtSetArg(ar[n],XmNlabelFontList, did_default_font); n++;
3354 XtSetArg(ar[n],XmNbuttonFontList, did_default_font); n++;
3355 XtSetArg(ar[n],XmNtextFontList, did_default_font); n++;
3356 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3357 XtSetArg(ar[n],XmNwidth, 500); n++;
3358 XtSetArg(ar[n],XmNdirMask, xm1); n++;
3359 sd = XmCreateFileSelectionDialog ( toplevel_widget, "FileSelection", ar, (Cardinal)n );
3360
3361 XmStringFree(xm1);
3362
3363 XtAddCallback ( sd, XmNcancelCallback,
3364 (XtCallbackProc)cancel_pop_up, (XtPointer)type );
3365 XtAddCallback ( sd, XmNokCallback,
3366 (XtCallbackProc)ok_pop_up, (XtPointer)type );
3367
3368 return(sd);
3369}
3370
3371Widget create_prompt_dialog(char *label, long tag)
3372{
3373Widget sd;
3374XmString xm1;
3375Arg ar[20];
3376int n;
3377
3378 xm1 = create_str (label);
3379 n = 0;
3380 XtSetArg(ar[n],XmNlabelFontList, did_default_font); n++;
3381 XtSetArg(ar[n],XmNbuttonFontList, did_default_font); n++;
3382 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3383 /*
3384 XtSetArg(ar[n],XmNwidth, 450); n++;
3385 XtSetArg(ar[n],XmNresizePolicy, XmRESIZE_NONE); n++;
3386 */
3387 XtSetArg(ar[n],XmNselectionLabelString, xm1); n++;
3388 sd = XmCreatePromptDialog ( toplevel_widget, "Prompt", ar, (Cardinal)n );
3389
3390 XmStringFree(xm1);
3391
3392 XtAddCallback ( sd, XmNcancelCallback,
3393 (XtCallbackProc)cancel_pop_up, (XtPointer)tag );
3394 XtAddCallback ( sd, XmNokCallback,
3395 (XtCallbackProc)ok_pop_up, (XtPointer)tag );
3396
3397 return(sd);
3398}
3399
3400Widget create_question_dialog(char *label, long tag)
3401{
3402Widget sd;
3403XmString xm1;
3404Arg ar[20];
3405int n;
3406
3407 xm1 = create_str (label);
3408 n = 0;
3409 XtSetArg(ar[n],XmNlabelFontList, did_default_font); n++;
3410 XtSetArg(ar[n],XmNbuttonFontList, did_default_font); n++;
3411 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3412 /*
3413 XtSetArg(ar[n],XmNwidth, 450); n++;
3414 XtSetArg(ar[n],XmNresizePolicy, XmRESIZE_NONE); n++;
3415 */
3416 XtSetArg(ar[n],XmNmessageString, xm1); n++;
3417 sd = XmCreateQuestionDialog ( toplevel_widget, "Question", ar, (Cardinal)n );
3418
3419 XmStringFree(xm1);
3420
3421 XtAddCallback ( sd, XmNcancelCallback,
3422 (XtCallbackProc)cancel_pop_up, (XtPointer)tag );
3423 XtAddCallback ( sd, XmNokCallback,
3424 (XtCallbackProc)ok_pop_up, (XtPointer)tag );
3425
3426 return(sd);
3427}
3428
3429Widget create_service_dialog()
3430{
3431Widget fd, rc, sw, lb, rc1;
3432XmString xm1;
3433Arg ar[20];
3434int n, par;
3435unsigned long reason;
3436
3437 n = 0;
3438 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3439 XtSetArg(ar[n],XmNresizePolicy, XmRESIZE_ANY); n++;
3440 fd = XmCreateFormDialog ( toplevel_widget, "Form", ar, (Cardinal)n );
3441 XtManageChild(fd);
3442
3443 /* create rowcolumn */
3444 n = 0;
3445 XtSetArg(ar[n],XmNborderWidth, 1); n++;
3446 XtSetArg(ar[n],XmNentryAlignment, XmALIGNMENT_CENTER); n++;
3447 XtSetArg(ar[n],XmNbottomAttachment, XmATTACH_FORM); n++;
3448 XtSetArg(ar[n],XmNbottomOffset, 0); n++;
3449 XtSetArg(ar[n],XmNrightAttachment, XmATTACH_FORM); n++;
3450 XtSetArg(ar[n],XmNrightOffset, 0); n++;
3451 XtSetArg(ar[n],XmNtopAttachment, XmATTACH_FORM); n++;
3452 XtSetArg(ar[n],XmNtopOffset, 0); n++;
3453 XtSetArg(ar[n],XmNleftAttachment, XmATTACH_FORM); n++;
3454 XtSetArg(ar[n],XmNleftOffset, 0); n++;
3455 rc = XmCreateRowColumn ( fd, "rowcol", ar, (Cardinal)n );
3456 XtManageChild(rc);
3457
3458 /* create scrolled window */
3459 n = 0;
3460 XtSetArg ( ar[n], XmNwidth, 770); n++;
3461 XtSetArg ( ar[n], XmNheight, 350); n++;
3462 XtSetArg ( ar[n], XmNscrollBarDisplayPolicy, XmAS_NEEDED); n++;
3463 XtSetArg ( ar[n], XmNscrollingPolicy, XmAUTOMATIC); n++;
3464
3465 sw = XmCreateScrolledWindow ( rc, "ScrollWin", ar, (Cardinal)n );
3466 XtManageChild ( sw );
3467
3468 /* create label */
3469 n = 0;
3470 xm1 = create_str(" ");
3471 XtSetArg(ar[n],XmNfontList, did_small_font); n++;
3472 XtSetArg(ar[n],XmNlabelString, xm1); n++;
3473 XtSetArg(ar[n],XmNalignment, XmALIGNMENT_BEGINNING); n++;
3474 lb = XmCreateLabel ( sw, "label", ar, (Cardinal)n );
3475 XtManageChild(lb);
3476 XmStringFree(xm1);
3477 par = 1;
3478 reason = 0;
3479 create_label(lb, &par, &reason);
3480
3481 /* create button rowcolumn */
3482 n = 0;
3483 XtSetArg(ar[n],XmNborderWidth, 0); n++;
3484 XtSetArg(ar[n],XmNentryAlignment, XmALIGNMENT_CENTER); n++;
3485 XtSetArg(ar[n],XmNorientation, XmVERTICAL); n++;
3486 XtSetArg(ar[n],XmNnumColumns, 3); n++;
3487 XtSetArg(ar[n],XmNpacking, XmPACK_COLUMN); n++;
3488 rc1 = XmCreateRowColumn ( rc, "buttons", ar, (Cardinal)n );
3489 XtManageChild(rc1);
3490 /*
3491 create_push_button(rc1,"View Standard",MAX_POP_UPS+1);
3492 create_push_button(rc1,"View Float",MAX_POP_UPS+2);
3493 create_push_button(rc1,"View Double",MAX_POP_UPS+3);
3494 */
3495 SubscribeButton = create_push_button(rc1," Subscribe (On Change) ",
3496 MAX_POP_UPS+5);
3497 Subscribe10Button = create_push_button(rc1," Subscribe (Update Rate 10 seconds) ",
3498 MAX_POP_UPS+4);
3499 create_push_button(rc1,"Dismiss",DID_SERVICE);
3500 Curr_service_print_type = 0;
3501
3502 return(fd);
3503}
3504
3505Widget create_push_button(Widget parent, char *str, long tag)
3506{
3507Widget b;
3508XmString xm1;
3509Arg ar[20];
3510int n;
3511
3512 n = 0;
3513 xm1 = create_str(str);
3514 XtSetArg(ar[n],XmNalignment, XmALIGNMENT_CENTER); n++;
3515 XtSetArg(ar[n],XmNfontList, did_default_font); n++;
3516 XtSetArg(ar[n],XmNlabelString, xm1); n++;
3517 b = XmCreatePushButton ( parent, "button", ar, (Cardinal)n );
3518
3519 XtManageChild(b);
3520 XmStringFree(xm1);
3521
3522 XtAddCallback ( b, XmNactivateCallback,
3523 (XtCallbackProc)cancel_pop_up, (XtPointer)tag );
3524 return(b);
3525}
3526
Note: See TracBrowser for help on using the repository browser.