static int main_swapon(int argc, char *argv[]) { int status = 0; int c, i; while ((c = getopt_long(argc, argv, "ahdefp:svVL:U:", longswaponopts, NULL)) != -1) { switch (c) { case 'a': /* all */ ++all; break; case 'h': /* help */ swapon_usage(stdout, 0); break; case 'p': /* priority */ priority = atoi(optarg); break; case 'L': addl(optarg); break; case 'U': addu(optarg); break; case 'd': discard = 1; break; case 'e': /* ifexists */ ifexists = 1; break; case 'f': fixpgsz = 1; break; case 's': /* status report */ status = display_summary(); exit(status); case 'v': /* be chatty */ ++verbose; break; case 'V': /* version */ printf(_("%s (%s)\n"), progname, PACKAGE_STRING); exit(EXIT_SUCCESS); case 0: break; case '?': default: swapon_usage(stderr, 1); } } argv += optind; if (!all && !llct && !ulct && *argv == NULL) swapon_usage(stderr, 2); if (ifexists && (!all || strcmp(progname, "swapon"))) swapon_usage(stderr, 1); if (all) status |= swapon_all(); for (i = 0; i < llct; i++) status |= swapon_by_label(llist[i], priority, discard); for (i = 0; i < ulct; i++) status |= swapon_by_uuid(ulist[i], priority, discard); while (*argv != NULL) status |= do_swapon(*argv++, priority, discard, !CANONIC); return status; }
void main(unsigned int argc, char **argv) { Arg args[10]; int n; int i; XmString message; XmString cancel_label, ok_label, help_label; char message_begin[120]; n = 0; CommonTestInit(argc, argv); n = 0; XtSetArg(args[n], XmNwidth, 10); n++; XtSetArg(args[n], XmNheight, 10); n++; XtSetValues(Shell1, args, n); XtRealizeWidget(Shell1); CommonPause(); XSetErrorHandler(ErrorHandle); /* * Initialize the PIInfo data values */ for (i = 0; i < NUM_TESTS; i++) PIInfo[i].actual_return = False; /* * Create top level shell widget as parent for test_button widgets */ n = 0; XtSetArg(args[n], XtNallowShellResize, TRUE); n++; test_top = XtAppCreateShell("test_top", /* application name */ "Test_top", /* application class */ topLevelShellWidgetClass, /* widget class */ display, /* display */ args, n); /* arguments */ /* * Create button1 widget */ display = XtDisplay(test_top); screen = DefaultScreenOfDisplay(display); test1_btn1_icon = XCreatePixmapFromBitmapData(display, rootWindow, btn1_bits, btn1_width, btn1_height, CommonGetColor("red"), CommonGetColor("yellow"), DefaultDepth(display, DefaultScreen(display))); test2_btn1_icon = XCreatePixmapFromBitmapData(display, rootWindow, btn2_bits, btn2_width, btn2_height, CommonGetColor("yellow"), CommonGetColor("red"), DefaultDepth(display, DefaultScreen(display))); n = 0; XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++; XtSetArg(args[n], XmNlabelPixmap, test1_btn1_icon); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; test1_btn1 = XmCreatePushButton(test_top, "test1_btn1", args, n); XtManageChild(test1_btn1); XtRealizeWidget(test_top); /* * Create top level shell widget as parent for test_button2 widget */ n = 0; XtSetArg(args[n], XtNallowShellResize, TRUE); n++; test_top2 = XtAppCreateShell("test_top2", /* application name */ "Test_top2", /* application class */ topLevelShellWidgetClass, /* widget class */ display, /* display */ args, n); /* arguments */ /* * Create button2 widget */ n = 0; XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++; XtSetArg(args[n], XmNlabelPixmap, test2_btn1_icon); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; test2_btn1 = XmCreatePushButton(test_top2, "test2_btn1", args, n); XtManageChild(test2_btn1); XtRealizeWidget(test_top2); test_wdw = XtWindow(test_top); top_wdw = XtWindow(Shell1); test_wdw2 = XtWindow(test_top2); XtAddEventHandler(Shell1, NoEventMask, True, CMEventHandler, NULL); XtAddEventHandler(test_top, NoEventMask, True, CMEventHandler, NULL); XtAddEventHandler(test_top2, NoEventMask, True, CMEventHandler, NULL); /* * Move the test_top shell window and the Shell1 window */ XMoveWindow(display, test_wdw, 100, 100); XMoveWindow(display, test_wdw2, 100, 300); /* * set protocols - WM_DELETE_WINDOW */ proto_atom = XmInternAtom(display, "WM_PROTOCOLS", False); delwin_atom = XmInternAtom(display, "WM_DELETE_WINDOW", False); XmAddWMProtocols(test_top, &delwin_atom, 1); #ifdef DONT /* * set protocols - WM_SAVE_YOURSELF */ savylf_atom = XmInternAtom(display, "WM_SAVE_YOURSELF", False); XmAddWMProtocols(test_top2, &savylf_atom, 1); /* * set protocols - WM_TAKE_FOCUS */ takfoc_atom = XmInternAtom(display, "WM_TAKE_FOCUS", False); /* change it on test_wdw2 */ XChangeProperty(display, test_wdw2, proto_atom, proto_atom, 32, PropModeReplace, (unsigned char *)&takfoc_atom, 1); #endif /* DONT */ CommonPause(); iteration++; /* * Check if window is not deleted after f.kill WM_DELETE_WINDOW */ ret_stat = XGetWindowAttributes(display, test_wdw, &win_attrs); /* * Actual return is if the window is still mapped and * recognizable. */ PIInfo[PIInfo_DW2].actual_return = ret_stat; /* * set protocols - _MOTIF_WM_MESSAGES */ /* add to the menu with the _MOTIF_WM_MENU property */ strcpy(menu_item, send_msg1); menu_atom = XmInternAtom(display, "_MOTIF_WM_MENU", False); XChangeProperty(display, test_wdw2, menu_atom, menu_atom, 8, PropModeReplace, (unsigned char *)menu_item, strlen(menu_item) + 1); /* add a message acceptance to widget */ motif_msg_atom = XmInternAtom(display, "_MOTIF_WM_MESSAGES", False); XmAddWMProtocols(test_top2, &motif_msg_atom, 1); msg_num = MSG_NUMBER; XmAddProtocolCallback(test_top2, motif_msg_atom, (Atom)msg_num, HandleMsgCB, NULL); PIUnmapWindow(test_wdw2); wm_set_hints.flags = (StateHint); wm_set_hints.initial_state = NormalState; XSetWMHints(display, test_wdw2, &wm_set_hints); XMapWindow(display, test_wdw2); XMoveWindow(display, test_wdw2, 100, 300); #ifdef DONT /* * Iconify test_wdw2, see if save_yourself works */ /* * Unmap the window to change state */ PIUnmapWindow(test_wdw2); /* * Map the window into iconic state */ wm_set_hints.flags = (StateHint); wm_set_hints.initial_state = IconicState; XSetWMHints(display, test_wdw2, &wm_set_hints); XMapWindow(display, test_wdw2); #endif /* DONT */ CommonPause(); #ifdef SHOW_P899 iteration++; /* * set protocols - _MOTIF_WM_MENU */ /* add to the menu with the _MOTIF_WM_MENU property */ strcpy(menu_item2, send_msg2); XChangeProperty(display, test_wdw2, menu_atom, menu_atom, 8, PropModeAppend, (unsigned char *)menu_item2, strlen(menu_item2) + 1); /* * Turn on acceptance of send_message2 */ msg_num = MSG_NUMBER2; XmAddProtocolCallback(test_top2, motif_msg_atom, (Atom)msg_num, HandleMsg2CB, NULL); PIUnmapWindow(test_wdw2); wm_set_hints.flags = (StateHint); wm_set_hints.initial_state = NormalState; XSetWMHints(display, test_wdw2, &wm_set_hints); XMapWindow(display, test_wdw2); XMoveWindow(display, test_wdw2, 100, 300); CommonPause(); #endif /* P899 */ iteration++; /* * set protocols - _MOTIF_WM_MENU */ /* add to the menu with the _MOTIF_WM_MENU property */ strcpy(menu_item2, send_msg3); XChangeProperty(display, test_wdw2, menu_atom, menu_atom, 8, PropModeReplace, (unsigned char *)menu_item2, strlen(menu_item2) + 1); #ifndef P899 /* * Turn on acceptance of send_message2 */ msg_num = MSG_NUMBER2; XmAddProtocolCallback(test_top2, motif_msg_atom, (Atom)msg_num, HandleMsg2CB, NULL); #endif /* P899 */ PIUnmapWindow(test_wdw2); wm_set_hints.flags = (StateHint); wm_set_hints.initial_state = NormalState; XSetWMHints(display, test_wdw2, &wm_set_hints); XMapWindow(display, test_wdw2); XMoveWindow(display, test_wdw2, 100, 300); CommonPause(); iteration++; /* * Put up a message box with the results of the test. */ display_summary(NUM_TESTS, TEST_DESCRIP_LENGTH, PIInfo); CommonPause(); /* * Loop and process events. */ XtAppMainLoop(app_context); }
int cpp_main( int argc, char * argv[] ) { fs::initial_path(); if ( argc > 1 && (std::strcmp( argv[1], "-help" ) == 0 || std::strcmp( argv[1], "--help" ) == 0 ) ) { std::clog << "Usage: inspect [-cvs] [options...]\n" "options:\n" << options(); return 1; } bool license_ck = true; bool copyright_ck = true; bool crlf_ck = true; bool link_ck = true; bool long_name_ck = true; bool tab_ck = true; bool cvs = false; if ( argc > 1 && std::strcmp( argv[1], "-cvs" ) == 0 ) { cvs = true; --argc; ++argv; } if ( argc > 1 && *argv[1] == '-' ) { license_ck = false; copyright_ck = false; crlf_ck = false; link_ck = false; long_name_ck = false; tab_ck = false; } for(; argc > 1; --argc, ++argv ) { if ( std::strcmp( argv[1], "-license" ) == 0 ) license_ck = true; else if ( std::strcmp( argv[1], "-copyright" ) == 0 ) copyright_ck = true; else if ( std::strcmp( argv[1], "-crlf" ) == 0 ) crlf_ck = true; else if ( std::strcmp( argv[1], "-link" ) == 0 ) link_ck = true; else if ( std::strcmp( argv[1], "-long_name" ) == 0 ) long_name_ck = true; else if ( std::strcmp( argv[1], "-tab" ) == 0 ) tab_ck = true; else { std::cerr << "unknown option: " << argv[1] << "\nvalid options are:\n" << options(); return 1; } } inspector_list inspectors; if ( license_ck ) inspectors.push_back( inspector_element( new boost::inspect::license_check ) ); if ( copyright_ck ) inspectors.push_back( inspector_element( new boost::inspect::copyright_check ) ); if ( crlf_ck ) inspectors.push_back( inspector_element( new boost::inspect::crlf_check ) ); if ( link_ck ) inspectors.push_back( inspector_element( new boost::inspect::link_check ) ); if ( long_name_ck ) inspectors.push_back( inspector_element( new boost::inspect::long_name_check ) ); if ( tab_ck ) inspectors.push_back( inspector_element( new boost::inspect::tab_check ) ); // perform the actual inspection, using the requested type of iteration if ( cvs ) visit_all<hack::cvs_iterator>( "boost-root", fs::initial_path(), inspectors ); else visit_all<fs::directory_iterator>( "boost-root", fs::initial_path(), inspectors ); // close for ( inspector_list::iterator itr = inspectors.begin(); itr != inspectors.end(); ++itr ) { itr->inspector->close(); } char run_date[128]; std::time_t tod; std::time( &tod ); std::strftime( run_date, sizeof(run_date), "%X UTC, %A %d %B %Y", std::gmtime( &tod ) ); std::cout << "<html>\n" "<head>\n" "<title>Boost Inspection Report</title>\n" "</head>\n" "<body bgcolor=\"#ffffff\" text=\"#000000\">\n" "<table border=\"0\">\n" "<tr>\n" "<td><img border=\"0\" src=\"../boost.png\" width=\"277\" " "height=\"86\"></td>\n" "<td align=\"center\">\n" "<h1>Boost Inspection Report</h1>\n" "<b>Run Date:</b> " << run_date << "\n" "</td>\n" "</table>\n" "<p>An <a href=\"http://www.boost.org/tools/inspect/index.html\">inspection\n" "program</a> checks each file in the current Boost CVS for various problems,\n" "generating this web page as output. Problems detected include tabs in files,\n" "missing copyrights, broken URL's, and similar misdemeanors.</p>\n" ; std::cout << "<h2>Totals</h2>\n<pre>" << file_count << " files scanned\n" << directory_count << " directories scanned\n" << error_count << " problems reported\n"; std::cout << "\nproblem counts:\n"; for ( inspector_list::iterator itr = inspectors.begin(); itr != inspectors.end(); ++itr ) { itr->inspector.reset(); } std::sort( msgs.begin(), msgs.end() ); if ( !msgs.empty() ) { display_summary(); display_details(); } std::cout << "</body>\n" "</html>\n"; return 0; }
/* Event handler for tool 'error-support' */ ATerm error_support_handler(int conn, ATerm term) { ATerm in, out; /* We need some temporary variables during matching */ char *s0, *s1; ATerm t0; if(ATmatch(term, "rec-eval(make-error(<str>,<term>))", &s0, &t0)) { return make_error(conn, s0, t0); } if(ATmatch(term, "rec-eval(get-area-end-line(<term>))", &t0)) { return get_area_end_line(conn, t0); } if(ATmatch(term, "rec-eval(get-location-filename(<term>))", &t0)) { return get_location_filename(conn, t0); } if(ATmatch(term, "rec-eval(has-location-area(<term>))", &t0)) { return has_location_area(conn, t0); } if(ATmatch(term, "rec-eval(get-summary-id(<term>))", &t0)) { return get_summary_id(conn, t0); } if(ATmatch(term, "rec-eval(get-error-description(<term>))", &t0)) { return get_error_description(conn, t0); } if(ATmatch(term, "rec-do(display-summary(<term>))", &t0)) { display_summary(conn, t0); return NULL; } if(ATmatch(term, "rec-eval(lower-summary(<term>))", &t0)) { return lower_summary(conn, t0); } if(ATmatch(term, "rec-eval(make-localized-subject(<str>,<term>))", &s0, &t0)) { return make_localized_subject(conn, s0, t0); } if(ATmatch(term, "rec-eval(get-summary-producer(<term>))", &t0)) { return get_summary_producer(conn, t0); } if(ATmatch(term, "rec-eval(get-error-subjects(<term>))", &t0)) { return get_error_subjects(conn, t0); } if(ATmatch(term, "rec-eval(make-subject(<str>))", &s0)) { return make_subject(conn, s0); } if(ATmatch(term, "rec-eval(get-subject-location(<term>))", &t0)) { return get_subject_location(conn, t0); } if(ATmatch(term, "rec-eval(get-area-offset(<term>))", &t0)) { return get_area_offset(conn, t0); } if(ATmatch(term, "rec-eval(get-area-begin-line(<term>))", &t0)) { return get_area_begin_line(conn, t0); } if(ATmatch(term, "rec-eval(add-filename-in-error(<str>,<term>))", &s0, &t0)) { return add_filename_in_error(conn, s0, t0); } if(ATmatch(term, "rec-eval(get-location-area(<term>))", &t0)) { return get_location_area(conn, t0); } if(ATmatch(term, "rec-eval(set-summary-id(<term>,<str>))", &t0, &s0)) { return set_summary_id(conn, t0, s0); } if(ATmatch(term, "rec-eval(has-subject-location(<term>))", &t0)) { return has_subject_location(conn, t0); } if(ATmatch(term, "rec-eval(get-area-end-column(<term>))", &t0)) { return get_area_end_column(conn, t0); } if(ATmatch(term, "rec-eval(make-summary(<str>,<str>,<term>))", &s0, &s1, &t0)) { return make_summary(conn, s0, s1, t0); } if(ATmatch(term, "rec-eval(get-summary-errors(<term>))", &t0)) { return get_summary_errors(conn, t0); } if(ATmatch(term, "rec-eval(get-subject-description(<term>))", &t0)) { return get_subject_description(conn, t0); } if(ATmatch(term, "rec-eval(get-area-length(<term>))", &t0)) { return get_area_length(conn, t0); } if(ATmatch(term, "rec-terminate(<term>)", &t0)) { rec_terminate(conn, t0); return NULL; } if(ATmatch(term, "rec-eval(get-area-begin-column(<term>))", &t0)) { return get_area_begin_column(conn, t0); } if(ATmatch(term, "rec-do(signature(<term>,<term>))", &in, &out)) { ATerm result = error_support_checker(conn, in); if(!ATmatch(result, "[]")) ATfprintf(stderr, "warning: not in input signature:\n\t%\n\tl\n", result); return NULL; } ATerror("tool error-support cannot handle term %t", term); return NULL; /* Silence the compiler */ }
int cpp_main( int argc, char * argv[] ) { fs::initial_path(); if ( argc > 1 && (std::strcmp( argv[1], "-help" ) == 0 || std::strcmp( argv[1], "--help" ) == 0 ) ) { std::clog << "Usage: inspect [-cvs] [options...]\n" "options:\n" << options(); return 1; } bool license_ck = true; bool copyright_ck = true; bool crlf_ck = true; bool link_ck = true; bool long_name_ck = true; bool tab_ck = true; bool minmax_ck = true; bool cvs = false; if ( argc > 1 && std::strcmp( argv[1], "-cvs" ) == 0 ) { cvs = true; --argc; ++argv; } if ( argc > 1 && *argv[1] == '-' ) { license_ck = false; copyright_ck = false; crlf_ck = false; link_ck = false; long_name_ck = false; tab_ck = false; minmax_ck = false; } for (; argc > 1; --argc, ++argv ) { if ( std::strcmp( argv[1], "-license" ) == 0 ) license_ck = true; else if ( std::strcmp( argv[1], "-copyright" ) == 0 ) copyright_ck = true; else if ( std::strcmp( argv[1], "-crlf" ) == 0 ) crlf_ck = true; else if ( std::strcmp( argv[1], "-link" ) == 0 ) link_ck = true; else if ( std::strcmp( argv[1], "-long_name" ) == 0 ) long_name_ck = true; else if ( std::strcmp( argv[1], "-tab" ) == 0 ) tab_ck = true; else if ( std::strcmp( argv[1], "-minmax" ) == 0 ) minmax_ck = true; else { std::cerr << "unknown option: " << argv[1] << "\nvalid options are:\n" << options(); return 1; } } inspector_list inspectors; if ( license_ck ) inspectors.push_back( inspector_element( new boost::inspect::license_check ) ); if ( copyright_ck ) inspectors.push_back( inspector_element( new boost::inspect::copyright_check ) ); if ( crlf_ck ) inspectors.push_back( inspector_element( new boost::inspect::crlf_check ) ); //if ( link_ck ) //inspectors.push_back( inspector_element( new boost::inspect::link_check ) ); if ( long_name_ck ) inspectors.push_back( inspector_element( new boost::inspect::long_name_check ) ); if ( tab_ck ) inspectors.push_back( inspector_element( new boost::inspect::tab_check ) ); if ( minmax_ck ) inspectors.push_back( inspector_element( new boost::inspect::minmax_check ) ); // perform the actual inspection, using the requested type of iteration if ( cvs ) visit_all<hack::cvs_iterator>( "lifev-root", fs::initial_path(), inspectors ); else visit_all<fs::directory_iterator>( "lifev-root", fs::initial_path(), inspectors ); // close for ( inspector_list::iterator itr = inspectors.begin(); itr != inspectors.end(); ++itr ) { itr->inspector->close(); } char run_date[128]; std::time_t tod; std::time( &tod ); std::strftime( run_date, sizeof(run_date), "%X UTC, %A %d %B %Y", std::gmtime( &tod ) ); std::cout << "<html>\n" "<head>\n" "<title>LifeV Inspection Report</title>\n" "<style type=\"text/css\">\n" << css_style() << "</style>\n" "</head>\n" "<body bgcolor=\"#ffffff\" text=\"#000000\">\n" "<h1>LifeV Inspection Report(95% based on Boost Inspection tool)</h1>\n" "<p><b>Run Date:</b> " << run_date << "</p>\n" "<h2>Introduction</h2>\n" "<p>The <a href=\"http://www.boost.org/tools/inspect/index.html\">inspection\n" "program</a> checks each file in the current Life CVS for various problems,\n" "generating this web page as output. Problems detected include tabs in files,\n" "missing copyrights, broken URL's, and similar misdemeanors.</p>\n"; std::cout << "<p> Differences between <tt>LifeV::inspect</tt> and <tt>boost::inspect</tt>\n" "<ul>\n" "<li>LifeV::inspect is good looking thanks to proper css usage :)</li>\n" "<li>LifeV::inspect does not check in admin, Templates and autom4te.cache</li>\n" "<li>LifeV::inspect checks for GPL and LGPL presence in header and not Boost License</li>\n" "<li>LifeV::inspect does not check for links</li>\n" "</ul>\n"; std::cout << "<h2>Totals</h2>\n<pre>" << file_count << " files scanned\n" << directory_count << " directories scanned\n" << error_count << " problems reported\n"; std::cout << "\nproblem counts:\n"; for ( inspector_list::iterator itr = inspectors.begin(); itr != inspectors.end(); ++itr ) { itr->inspector.reset(); } std::sort( msgs.begin(), msgs.end() ); if ( !msgs.empty() ) { display_summary(); display_details(); } std::cout << "</body>\n" "</html>\n"; return 0; }