/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ main() $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ int main(int argc, char *argv[]) { int i; char window_title[100], work_dir[MAX_PATH_LENGTH], str_line[MAX_INFO_STRING_LENGTH], tmp_str_line[MAX_INFO_STRING_LENGTH]; static String fallback_res[] = { "*mwmDecorations : 42", "*mwmFunctions : 12", ".mon_info.form*background : NavajoWhite2", ".mon_info.form.msa_box.?.?.?.text_wl.background : NavajoWhite1", ".mon_info.form.msa_box.?.?.?.text_wr.background : NavajoWhite1", ".mon_info.form.host_infoSW.host_info.background : NavajoWhite1", ".mon_info.form.buttonbox*background : PaleVioletRed2", ".mon_info.form.buttonbox*foreground : Black", ".mon_info.form.buttonbox*highlightColor : Black", NULL }; Widget form_w, msa_box_w, msa_box1_w, msa_box2_w, msa_text_w, button_w, buttonbox_w, rowcol1_w, rowcol2_w, h_separator1_w, h_separator2_w, v_separator_w; XmFontListEntry entry; XmFontList fontlist; Arg args[MAXARGS]; Cardinal argcount; uid_t euid, /* Effective user ID. */ ruid; /* Real user ID. */ CHECK_FOR_VERSION(argc, argv); /* Initialise global values. */ p_work_dir = work_dir; init_mon_info(&argc, argv); /* * SSH uses wants to look at .Xauthority and with setuid flag * set we cannot do that. So when we initialize X lets temporaly * disable it. After XtAppInitialize() we set it back. */ euid = geteuid(); ruid = getuid(); if (euid != ruid) { if (seteuid(ruid) == -1) { (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n", ruid, strerror(errno)); } } (void)strcpy(window_title, afd_name); (void)strcat(window_title, " Info"); argcount = 0; XtSetArg(args[argcount], XmNtitle, window_title); argcount++; appshell = XtAppInitialize(&app, "AFD", NULL, 0, &argc, argv, fallback_res, args, argcount); disable_drag_drop(appshell); if (euid != ruid) { if (seteuid(euid) == -1) { (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n", euid, strerror(errno)); } } display = XtDisplay(appshell); #ifdef HAVE_XPM /* Setup AFD logo as icon. */ setup_icon(display, appshell); #endif /* Create managing widget. */ form_w = XmCreateForm(appshell, "form", NULL, 0); entry = XmFontListEntryLoad(XtDisplay(form_w), font_name, XmFONT_IS_FONT, "TAG1"); fontlist = XmFontListAppendEntry(NULL, entry); XmFontListEntryFree(&entry); argcount = 0; XtSetArg(args[argcount], XmNtopAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; msa_box_w = XmCreateForm(form_w, "msa_box", args, argcount); XtManageChild(msa_box_w); argcount = 0; XtSetArg(args[argcount], XmNtopAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; msa_box1_w = XmCreateForm(msa_box_w, "msa_box1", args, argcount); XtManageChild(msa_box1_w); rowcol1_w = XtVaCreateWidget("rowcol1", xmRowColumnWidgetClass, msa_box1_w, NULL); for (i = 0; i < NO_OF_MSA_ROWS; i++) { msa_text_w = XtVaCreateWidget("msa_text", xmFormWidgetClass, rowcol1_w, XmNfractionBase, 41, NULL); label_l_widget[i] = XtVaCreateManagedWidget(label_l[i], xmLabelGadgetClass, msa_text_w, XmNfontList, fontlist, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 40, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNalignment, XmALIGNMENT_END, NULL); text_wl[i] = XtVaCreateManagedWidget("text_wl", xmTextWidgetClass, msa_text_w, XmNfontList, fontlist, XmNcolumns, MON_INFO_LENGTH, XmNtraversalOn, False, XmNeditable, False, XmNcursorPositionVisible, False, XmNmarginHeight, 1, XmNmarginWidth, 1, XmNshadowThickness, 1, XmNhighlightThickness, 0, XmNrightAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 22, NULL); XtManageChild(msa_text_w); } XtManageChild(rowcol1_w); /* Fill up the text widget with some values. */ (void)sprintf(str_line, "%*s", MON_INFO_LENGTH, prev.real_hostname[(int)prev.afd_toggle]); XmTextSetString(text_wl[0], str_line); (void)sprintf(str_line, "%*d", MON_INFO_LENGTH, prev.port[(int)prev.afd_toggle]); XmTextSetString(text_wl[1], str_line); (void)strftime(tmp_str_line, MAX_INFO_STRING_LENGTH, "%d.%m.%Y %H:%M:%S", localtime(&prev.last_data_time)); (void)sprintf(str_line, "%*s", MON_INFO_LENGTH, tmp_str_line); XmTextSetString(text_wl[2], str_line); (void)sprintf(str_line, "%*d", MON_INFO_LENGTH, prev.max_connections); XmTextSetString(text_wl[3], str_line); (void)sprintf(str_line, "%*s", MON_INFO_LENGTH, prev.afd_version); XmTextSetString(text_wl[4], str_line); if (prev.top_tr > 1048576) { (void)sprintf(str_line, "%*u MB/s", MON_INFO_LENGTH - 5, prev.top_tr / 1048576); } else if (prev.top_tr > 1024) { (void)sprintf(str_line, "%*u KB/s", MON_INFO_LENGTH - 5, prev.top_tr / 1024); } else { (void)sprintf(str_line, "%*u Bytes/s", MON_INFO_LENGTH - 8, prev.top_tr); } XmTextSetString(text_wl[5], str_line); /* Create the first horizontal separator. */ argcount = 0; XtSetArg(args[argcount], XmNorientation, XmHORIZONTAL); argcount++; XtSetArg(args[argcount], XmNtopAttachment, XmATTACH_WIDGET); argcount++; XtSetArg(args[argcount], XmNtopWidget, msa_box_w); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; h_separator1_w = XmCreateSeparator(form_w, "h_separator1_w", args, argcount); XtManageChild(h_separator1_w); /* Create the vertical separator. */ argcount = 0; XtSetArg(args[argcount], XmNorientation, XmVERTICAL); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_WIDGET); argcount++; XtSetArg(args[argcount], XmNleftWidget, msa_box1_w); argcount++; XtSetArg(args[argcount], XmNtopAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_FORM); argcount++; v_separator_w = XmCreateSeparator(msa_box_w, "v_separator", args, argcount); XtManageChild(v_separator_w); argcount = 0; XtSetArg(args[argcount], XmNtopAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_WIDGET); argcount++; XtSetArg(args[argcount], XmNleftWidget, v_separator_w); argcount++; msa_box2_w = XmCreateForm(msa_box_w, "msa_box2", args, argcount); XtManageChild(msa_box2_w); rowcol2_w = XtVaCreateWidget("rowcol2", xmRowColumnWidgetClass, msa_box2_w, NULL); for (i = 0; i < NO_OF_MSA_ROWS; i++) { msa_text_w = XtVaCreateWidget("msa_text", xmFormWidgetClass, rowcol2_w, XmNfractionBase, 41, NULL); label_r_widget[i] = XtVaCreateManagedWidget(label_r[i], xmLabelGadgetClass, msa_text_w, XmNfontList, fontlist, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 40, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNalignment, XmALIGNMENT_END, NULL); text_wr[i] = XtVaCreateManagedWidget("text_wr", xmTextWidgetClass, msa_text_w, XmNfontList, fontlist, XmNcolumns, MON_INFO_LENGTH, XmNtraversalOn, False, XmNeditable, False, XmNcursorPositionVisible, False, XmNmarginHeight, 1, XmNmarginWidth, 1, XmNshadowThickness, 1, XmNhighlightThickness, 0, XmNrightAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 20, NULL); XtManageChild(msa_text_w); } XtManageChild(rowcol2_w); /* Fill up the text widget with some values. */ get_ip_no(msa[afd_position].hostname[(int)prev.afd_toggle], tmp_str_line); (void)sprintf(str_line, "%*s", MON_INFO_LENGTH, tmp_str_line); XmTextSetString(text_wr[0], str_line); (void)sprintf(str_line, "%*s", MON_INFO_LENGTH, prev.r_work_dir); XmTextSetString(text_wr[1], str_line); (void)sprintf(str_line, "%*d", MON_INFO_LENGTH, prev.poll_interval); XmTextSetString(text_wr[2], str_line); (void)sprintf(str_line, "%*d", MON_INFO_LENGTH, prev.top_not); XmTextSetString(text_wr[3], str_line); (void)sprintf(str_line, "%*d", MON_INFO_LENGTH, prev.no_of_hosts); XmTextSetString(text_wr[4], str_line); (void)sprintf(str_line, "%*u files/s", MON_INFO_LENGTH - 8, prev.top_fr); XmTextSetString(text_wr[5], str_line); argcount = 0; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNfractionBase, 21); argcount++; buttonbox_w = XmCreateForm(form_w, "buttonbox", args, argcount); /* Create the second horizontal separator. */ argcount = 0; XtSetArg(args[argcount], XmNorientation, XmHORIZONTAL); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_WIDGET); argcount++; XtSetArg(args[argcount], XmNbottomWidget, buttonbox_w); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; h_separator2_w = XmCreateSeparator(form_w, "h_separator2", args, argcount); XtManageChild(h_separator2_w); if (editable == YES) { button_w = XtVaCreateManagedWidget("Save", xmPushButtonWidgetClass, buttonbox_w, XmNfontList, fontlist, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 2, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 19, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 9, NULL); XtAddCallback(button_w, XmNactivateCallback, (XtCallbackProc)save_button, (XtPointer)0); button_w = XtVaCreateManagedWidget("Close", xmPushButtonWidgetClass, buttonbox_w, XmNfontList, fontlist, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 2, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 19, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 10, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 20, NULL); XtAddCallback(button_w, XmNactivateCallback, (XtCallbackProc)close_button, (XtPointer)0); } else { button_w = XtVaCreateManagedWidget("Close", xmPushButtonWidgetClass, buttonbox_w, XmNfontList, fontlist, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 2, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 19, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 20, NULL); XtAddCallback(button_w, XmNactivateCallback, (XtCallbackProc)close_button, (XtPointer)0); } XtManageChild(buttonbox_w); /* Create log_text as a ScrolledText window. */ argcount = 0; XtSetArg(args[argcount], XmNfontList, fontlist); argcount++; XtSetArg(args[argcount], XmNrows, 10); argcount++; XtSetArg(args[argcount], XmNcolumns, 80); argcount++; if (editable == YES) { XtSetArg(args[argcount], XmNeditable, True); argcount++; XtSetArg(args[argcount], XmNcursorPositionVisible, True); argcount++; XtSetArg(args[argcount], XmNautoShowCursorPosition, True); } else { XtSetArg(args[argcount], XmNeditable, False); argcount++; XtSetArg(args[argcount], XmNcursorPositionVisible, False); argcount++; XtSetArg(args[argcount], XmNautoShowCursorPosition, False); } argcount++; XtSetArg(args[argcount], XmNeditMode, XmMULTI_LINE_EDIT); argcount++; XtSetArg(args[argcount], XmNwordWrap, False); argcount++; XtSetArg(args[argcount], XmNscrollHorizontal, False); argcount++; XtSetArg(args[argcount], XmNcursorPositionVisible, False); argcount++; XtSetArg(args[argcount], XmNautoShowCursorPosition, False); argcount++; XtSetArg(args[argcount], XmNtopAttachment, XmATTACH_WIDGET); argcount++; XtSetArg(args[argcount], XmNtopWidget, h_separator1_w); argcount++; XtSetArg(args[argcount], XmNtopOffset, 3); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNleftOffset, 3); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightOffset, 3); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_WIDGET); argcount++; XtSetArg(args[argcount], XmNbottomWidget, h_separator2_w); argcount++; XtSetArg(args[argcount], XmNbottomOffset, 3); argcount++; info_w = XmCreateScrolledText(form_w, "host_info", args, argcount); XtManageChild(info_w); XtManageChild(form_w); /* Free font list. */ XmFontListFree(fontlist); #ifdef WITH_EDITRES XtAddEventHandler(appshell, (EventMask)0, True, _XEditResCheckMessages, NULL); #endif /* Realize all widgets. */ XtRealizeWidget(appshell); wait_visible(appshell); /* Read and display the information file. */ (void)check_info_file(afd_name, AFD_INFO_FILE, YES); XmTextSetString(info_w, NULL); /* Clears old entry. */ XmTextSetString(info_w, info_data); /* Call update_info() after UPDATE_INTERVAL ms. */ interval_id_host = XtAppAddTimeOut(app, UPDATE_INTERVAL, (XtTimerCallbackProc)update_info, form_w); /* We want the keyboard focus on the Done button. */ XmProcessTraversal(button_w, XmTRAVERSE_CURRENT); /* Write window ID, so mon_ctrl can set focus if it is called again. */ write_window_id(XtWindow(appshell), getpid(), MON_INFO); /* Start the main event-handling loop. */ XtAppMainLoop(app); exit(SUCCESS); }
/*############################ update_info() ############################*/ void update_info(Widget w) { static int interval = 0; int status; signed char flush = NO; char *ptr, str_line[MAX_INFO_STRING_LENGTH], tmp_str_line[MAX_INFO_STRING_LENGTH]; XmString text; /* Check if FSA changed. */ (void)check_fsa(YES, AFD_INFO); status = fsa[host_position].host_status & HOST_ERROR_OFFLINE_STATIC; if (prev.errors_offline != status) { if (status == HOST_ERROR_OFFLINE_STATIC) { XtSetSensitive(label_l_widget[4], False); XtSetSensitive(text_wl[4], False); } else { XtSetSensitive(label_l_widget[4], True); XtSetSensitive(text_wl[4], True); } prev.errors_offline = status; } if (prev.protocol != fsa[host_position].protocol) { size_t length; prev.protocol = fsa[host_position].protocol; length = sprintf(protocol_label_str, "Protocols : "); if (fsa[host_position].protocol & FTP_FLAG) { length += sprintf(&protocol_label_str[length], "FTP "); } if (fsa[host_position].protocol & SFTP_FLAG) { length += sprintf(&protocol_label_str[length], "SFTP "); } if (fsa[host_position].protocol & LOC_FLAG) { length += sprintf(&protocol_label_str[length], "LOC "); } if (fsa[host_position].protocol & EXEC_FLAG) { length += sprintf(&protocol_label_str[length], "EXEC "); } if (fsa[host_position].protocol & SMTP_FLAG) { length += sprintf(&protocol_label_str[length], "SMTP "); } #ifdef _WITH_DE_MAIL_SUPPORT if (fsa[host_position].protocol & DE_MAIL_FLAG) { length += sprintf(&protocol_label_str[length], "DEMAIL "); } #endif if (fsa[host_position].protocol & HTTP_FLAG) { length += sprintf(&protocol_label_str[length], "HTTP "); } #ifdef _WITH_SCP_SUPPORT if (fsa[host_position].protocol & SCP_FLAG) { length += sprintf(&protocol_label_str[length], "SCP "); } #endif #ifdef _WITH_WMO_SUPPORT if (fsa[host_position].protocol & WMO_FLAG) { length += sprintf(&protocol_label_str[length], "WMO "); } #endif #ifdef _WITH_MAP_SUPPORT if (fsa[host_position].protocol & MAP_FLAG) { length += sprintf(&protocol_label_str[length], "MAP "); } #endif #ifdef _WITH_DFAX_SUPPORT if (fsa[host_position].protocol & DFAX_FLAG) { length += sprintf(&protocol_label_str[length], "DFAX "); } #endif #ifdef WITH_SSL if (fsa[host_position].protocol & SSL_FLAG) { length += sprintf(&protocol_label_str[length], "SSL "); } #endif text = XmStringCreateLocalized(protocol_label_str); XtVaSetValues(protocol_label, XmNlabelString, text, NULL); XmStringFree(text); } if (fsa[host_position].real_hostname[0][0] != GROUP_IDENTIFIER) { if (my_strcmp(prev.real_hostname[0], fsa[host_position].real_hostname[0]) != 0) { (void)strcpy(prev.real_hostname[0], fsa[host_position].real_hostname[0]); (void)sprintf(str_line, "%*s", AFD_INFO_STR_LENGTH, prev.real_hostname[0]); XmTextSetString(text_wl[1], str_line); flush = YES; } if (my_strcmp(prev.real_hostname[1], fsa[host_position].real_hostname[1]) != 0) { (void)strcpy(prev.real_hostname[1], fsa[host_position].real_hostname[1]); (void)sprintf(str_line, "%*s", AFD_INFO_STR_LENGTH, prev.real_hostname[1]); XmTextSetString(text_wr[1], str_line); flush = YES; } } if (prev.retry_interval != fsa[host_position].retry_interval) { prev.retry_interval = fsa[host_position].retry_interval; (void)sprintf(str_line, "%*d", AFD_INFO_STR_LENGTH, prev.retry_interval / 60); XmTextSetString(text_wr[4], str_line); flush = YES; } if (prev.files_send != fsa[host_position].file_counter_done) { prev.files_send = fsa[host_position].file_counter_done; (void)sprintf(str_line, "%*u", AFD_INFO_STR_LENGTH, prev.files_send); XmTextSetString(text_wl[2], str_line); flush = YES; } if (prev.bytes_send != fsa[host_position].bytes_send) { prev.bytes_send = fsa[host_position].bytes_send; #if SIZEOF_OFF_T == 4 (void)sprintf(str_line, "%*lu", AFD_INFO_STR_LENGTH, prev.bytes_send); #else (void)sprintf(str_line, "%*llu", AFD_INFO_STR_LENGTH, prev.bytes_send); #endif XmTextSetString(text_wr[2], str_line); flush = YES; } if (prev.total_errors != fsa[host_position].total_errors) { prev.total_errors = fsa[host_position].total_errors; (void)sprintf(str_line, "%*u", AFD_INFO_STR_LENGTH, prev.total_errors); XmTextSetString(text_wl[4], str_line); flush = YES; } if (prev.no_of_connections != fsa[host_position].connections) { prev.no_of_connections = fsa[host_position].connections; (void)sprintf(str_line, "%*u", AFD_INFO_STR_LENGTH, prev.no_of_connections); XmTextSetString(text_wr[3], str_line); flush = YES; } if (prev.last_connection != fsa[host_position].last_connection) { prev.last_connection = fsa[host_position].last_connection; (void)strftime(tmp_str_line, MAX_INFO_STRING_LENGTH, "%d.%m.%Y %H:%M:%S", localtime(&prev.last_connection)); (void)sprintf(str_line, "%*s", AFD_INFO_STR_LENGTH, tmp_str_line); XmTextSetString(text_wl[3], str_line); flush = YES; } if ((fsa[host_position].real_hostname[0][0] != GROUP_IDENTIFIER) && (prev.toggle_pos != fsa[host_position].toggle_pos)) { prev.toggle_pos = fsa[host_position].toggle_pos; if (prev.toggle_pos == 0) { /* * There is NO secondary host */ /* Display the first host name. */ (void)strcpy(host_alias_1, host_name); if ((fsa[host_position].host_toggle_str[0] != '\0') && (active_pixmap != XmUNSPECIFIED_PIXMAP) && (passive_pixmap != XmUNSPECIFIED_PIXMAP)) { (void)sprintf(label_l[0], "%*c%-*s :", 3, ' ', (FSA_INFO_TEXT_WIDTH_L - 3), host_alias_1); XtVaSetValues(pll_widget, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 40, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNlabelType, XmPIXMAP, XmNlabelPixmap, active_pixmap, NULL); } else { (void)sprintf(label_l[0], "%-*s :", FSA_INFO_TEXT_WIDTH_L, host_alias_1); } text = XmStringCreateLocalized(label_l[0]); XtVaSetValues(label_l_widget[0], XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 40, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNlabelString, text, NULL); XmStringFree(text); /* Get IP for the first host. */ if ((fsa[host_position].protocol & FTP_FLAG) || (fsa[host_position].protocol & SFTP_FLAG) || #ifdef _WITH_SCP_SUPPORT (fsa[host_position].protocol & SCP_FLAG) || #endif #ifdef _WITH_WMO_SUPPORT (fsa[host_position].protocol & WMO_FLAG) || #endif #ifdef _WITH_MAP_SUPPORT (fsa[host_position].protocol & MAP_FLAG) || #endif (fsa[host_position].protocol & HTTP_FLAG) || #ifdef _WITH_DE_MAIL_SUPPORT (fsa[host_position].protocol & DE_MAIL_FLAG) || #endif (fsa[host_position].protocol & SMTP_FLAG)) { get_ip_no(fsa[host_position].real_hostname[0], tmp_str_line); } else { *tmp_str_line = '\0'; } (void)sprintf(str_line, "%*s", AFD_INFO_STR_LENGTH, tmp_str_line); XmTextSetString(text_wl[0], str_line); /* Display the second host name. */ (void)strcpy(host_alias_2, NO_SECODARY_HOST); (void)sprintf(label_r[0], "%-*s :", FSA_INFO_TEXT_WIDTH_R, host_alias_2); XmTextSetString(text_wr[0], NULL); } else { /* * There IS a secondary host */ /* Display the first host name. */ (void)strcpy(host_alias_1, host_name); ptr = host_alias_1 + strlen(host_alias_1); *ptr = fsa[host_position].host_toggle_str[1]; *(ptr + 1) = '\0'; if ((fsa[host_position].host_toggle_str[0] != '\0') && (active_pixmap != XmUNSPECIFIED_PIXMAP) && (passive_pixmap != XmUNSPECIFIED_PIXMAP)) { (void)sprintf(label_l[0], "%*c%-*s :", 3, ' ', (FSA_INFO_TEXT_WIDTH_L - 3), host_alias_1); if (fsa[host_position].host_toggle == HOST_ONE) { XtVaSetValues(pll_widget, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 40, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNlabelType, XmPIXMAP, XmNlabelPixmap, active_pixmap, NULL); } else { XtVaSetValues(pll_widget, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 40, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNlabelType, XmPIXMAP, XmNlabelPixmap, passive_pixmap, NULL); } } else { (void)sprintf(label_l[0], "%-*s :", FSA_INFO_TEXT_WIDTH_L, host_alias_1); } text = XmStringCreateLocalized(label_l[0]); XtVaSetValues(label_l_widget[0], XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 40, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNlabelString, text, NULL); XmStringFree(text); /* Get IP for the first host. */ if ((fsa[host_position].protocol & FTP_FLAG) || (fsa[host_position].protocol & SFTP_FLAG) || #ifdef _WITH_SCP_SUPPORT (fsa[host_position].protocol & SCP_FLAG) || #endif #ifdef _WITH_WMO_SUPPORT (fsa[host_position].protocol & WMO_FLAG) || #endif #ifdef _WITH_MAP_SUPPORT (fsa[host_position].protocol & MAP_FLAG) || #endif (fsa[host_position].protocol & HTTP_FLAG) || #ifdef _WITH_DE_MAIL_SUPPORT (fsa[host_position].protocol & DE_MAIL_FLAG) || #endif (fsa[host_position].protocol & SMTP_FLAG)) { get_ip_no(fsa[host_position].real_hostname[0], tmp_str_line); } else { *tmp_str_line = '\0'; } (void)sprintf(str_line, "%*s", AFD_INFO_STR_LENGTH, tmp_str_line); XmTextSetString(text_wl[0], str_line); /* Display the second host name. */ (void)strcpy(host_alias_2, host_name); ptr = host_alias_2 + strlen(host_alias_2); *ptr = fsa[host_position].host_toggle_str[2]; *(ptr + 1) = '\0'; if ((fsa[host_position].host_toggle_str[0] != '\0') && (active_pixmap != XmUNSPECIFIED_PIXMAP) && (passive_pixmap != XmUNSPECIFIED_PIXMAP)) { (void)sprintf(label_r[0], "%*c%-*s :", 3, ' ', (FSA_INFO_TEXT_WIDTH_R - 1), host_alias_2); if (fsa[host_position].host_toggle == HOST_ONE) { XtVaSetValues(plr_widget, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 40, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNlabelType, XmPIXMAP, XmNlabelPixmap, passive_pixmap, NULL); } else { XtVaSetValues(plr_widget, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 40, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNlabelType, XmPIXMAP, XmNlabelPixmap, active_pixmap, NULL); } } else { (void)sprintf(label_r[0], "%-*s :", FSA_INFO_TEXT_WIDTH_R, host_alias_2); } text = XmStringCreateLocalized(label_r[0]); XtVaSetValues(label_r_widget[0], XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 40, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNlabelString, text, NULL); XmStringFree(text); /* Get IP for the second host. */ if ((fsa[host_position].protocol & FTP_FLAG) || (fsa[host_position].protocol & SFTP_FLAG) || #ifdef _WITH_SCP_SUPPORT (fsa[host_position].protocol & SCP_FLAG) || #endif #ifdef _WITH_WMO_SUPPORT (fsa[host_position].protocol & WMO_FLAG) || #endif #ifdef _WITH_MAP_SUPPORT (fsa[host_position].protocol & MAP_FLAG) || #endif (fsa[host_position].protocol & HTTP_FLAG) || #ifdef _WITH_DE_MAIL_SUPPORT (fsa[host_position].protocol & DE_MAIL_FLAG) || #endif (fsa[host_position].protocol & SMTP_FLAG)) { get_ip_no(fsa[host_position].real_hostname[1], tmp_str_line); } else { *tmp_str_line = '\0'; } (void)sprintf(str_line, "%*s", AFD_INFO_STR_LENGTH, tmp_str_line); XmTextSetString(text_wr[0], str_line); } flush = YES; } /* Check if the host have been toggled. */ if ((fsa[host_position].host_toggle_str[0] != '\0') && (active_pixmap != XmUNSPECIFIED_PIXMAP) && (passive_pixmap != XmUNSPECIFIED_PIXMAP) && (prev.host_toggle != fsa[host_position].host_toggle)) { prev.host_toggle = fsa[host_position].host_toggle; if (fsa[host_position].host_toggle == HOST_ONE) { XtVaSetValues(pll_widget, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 40, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNlabelType, XmPIXMAP, XmNlabelPixmap, active_pixmap, NULL); XtVaSetValues(plr_widget, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 40, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNlabelType, XmPIXMAP, XmNlabelPixmap, passive_pixmap, NULL); } else { XtVaSetValues(pll_widget, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 40, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNlabelType, XmPIXMAP, XmNlabelPixmap, passive_pixmap, NULL); XtVaSetValues(plr_widget, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 40, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNlabelType, XmPIXMAP, XmNlabelPixmap, active_pixmap, NULL); } flush = YES; } if (interval++ == FILE_UPDATE_INTERVAL) { interval = 0; /* Check if the information file for this host has changed. */ if (check_info_file(host_name, HOST_INFO_FILE, YES) == YES) { flush = YES; XmTextSetString(info_w, NULL); /* Clears old entry. */ XmTextSetString(info_w, info_data); } } if (flush == YES) { XFlush(display); } /* Call update_info() after UPDATE_INTERVAL ms. */ interval_id_host = XtAppAddTimeOut(app, UPDATE_INTERVAL, (XtTimerCallbackProc)update_info, NULL); return; }