コード例 #1
0
int main()
{
int a,b,c;
double x1,x2;	
printf("请输入整数a,b,c,中间用逗号隔开");
scanf("%d,%d,%d",&a,&b,&c);
if (b*b-4*a*c>0){
	x1=x11(a,b,c);
	x2=x22(a,b,c);
	printf("x1=%d,x2=%d",x1,x2);
}
else if(b*b-4*a*c==0)
{
	x1=x1x2(a,b,c);
    printf("x1=x2=%d",x1);
}
else
print();

	 
return 0;
}
コード例 #2
0
ファイル: rsa.cpp プロジェクト: Mellnik/hash-plugin
void RSA_TestInstantiations()
{
	RSASS<PKCS1v15, SHA1>::Verifier x1(1, 1);
	RSASS<PKCS1v15, SHA1>::Signer x2(NullRNG(), 1);
	RSASS<PKCS1v15, SHA1>::Verifier x3(x2);
	RSASS<PKCS1v15, SHA1>::Verifier x4(x2.GetKey());
	RSASS<PSS, SHA1>::Verifier x5(x3);
#ifndef __MWERKS__
	RSASS<PSSR, SHA1>::Signer x6 = x2;
	x3 = x2;
	x6 = x2;
#endif
	RSAES<PKCS1v15>::Encryptor x7(x2);
#ifndef __GNUC__
	RSAES<PKCS1v15>::Encryptor x8(x3);
#endif
	RSAES<OAEP<SHA1> >::Encryptor x9(x2);
	x4 = x2.GetKey();

	RSASS<PKCS1v15, SHA3_256>::Verifier x10(1, 1);
	RSASS<PKCS1v15, SHA3_256>::Signer x11(NullRNG(), 1);
	RSASS<PKCS1v15, SHA3_256>::Verifier x12(x11);
	RSASS<PKCS1v15, SHA3_256>::Verifier x13(x11.GetKey());
}
コード例 #3
0
ファイル: scope02.C プロジェクト: 0day-ci/gcc
int main(void)
{
  // 3.4.5 Class member access
  // p 2
  // if the id-expression in a class member access is an
  // unqualified-id, and the type of the object expression is of class
  // type C (or pointer to class type C), the unqualified-id is looked
  // up in the scope of class C. If the type of the object-expression
  // is of pointer to scalar type, the unqualified-id is looked up in
  // the context of the complete postfix-expression.

  // p 3
  // if the unqualitified id is ~type-name, and the type of the object
  // expression is of a class type C (or pointer to class type C), the
  // type-name is looked up in the context of the entire
  // postfix-expression and in the scope of class C. The type-name
  // shall refer to a class-name. If type-name is found in both
  // contexts, the name shall refer to the same class type. If the
  // type of the object expression is of scalar type, the type-name is
  // looked up in the complete postfix-expression.
  
  typedef X localtype;

  //
  // 1 non-templatized, pointer, unqualified
  //
  X x01 ;
  X *px = &x01;
  px->~X(); 

  X x02 (66);
  px = &x02;
  px->~localtype();

  X x03 (68);
  px = &x03;
  px->~classtype(); //-g++  //p3: unqual-id lookup in object and postfix-expr

  X x04 (70);
  px = &x04;
  px->~globaltype();


  // p 1
  // . . . the id-expression is first looked up in the class of the
  // object-expression. If the identifier is not found, itis then
  // looked up in the context of the entier postfix-expression and
  // shall name a class or function template. If the lookup in the
  // class of the object-expression finds a template, the name is also
  // looked up in teh context of the entier postfix-expression and
  // 1 if the name is not found, use the name from the object-expr
  // 2 if the name found in postfix-expr != class template, use object-expr
  // 3 if name found is class template, name must match object-expr or error

  // p 4 

  // if the id-expr in a class member acess is a qualified-id, the
  // id-expression is looked up in both the context of the entire
  // postfix-expr and in the scope of the class of the object-expr. If
  // the name is found in both contexts, the id-expr shall refer to
  // the same entity.


  //
  // 2 non-templatized, pointer, qualified
  //
  X x05 ;
  px = &x05;
  px->X::~X(); 

  X x06 (66);
  px = &x06;
  px->X::~localtype();

  X x07 (68);
  px = &x07;
  px->X::~classtype(); // -edg

  X x08 (70);
  px = &x08;
  px->X::~globaltype();

  X x09 (66);
  px = &x09;
  px->localtype::~localtype();

  X x10 (68);
  px = &x10;
  px->classtype::~classtype();

  X x11 (70);
  px = &x11;
  px->globaltype::~globaltype();

  X x12 (66);
  px = &x12;
  px->classtype::~localtype();

  X x13 (68);
  px = &x13;
  px->globaltype::~localtype();

  X x14 (70);
  px = &x14;
  px->localtype::~globaltype();

  X x15 (70);
  px = &x15;
  px->classtype::~globaltype();

  X x16 (70);
  px = &x16;
  px->localtype::~classtype(); //-edg

  X x17 (70);
  px = &x17;
  px->globaltype::~classtype(); //-edg

#if 0
  //
  // non-templatized, non-pointer
  //
  X xo5 ;
  xo5.~X(); //unqualified

  localtype xo6 (66);
  xo6.~localtype();

  X xo7 (68);
  xo7.~classtype();

  X xo8 (70);
  xo8.~globaltype();


  //
  // templatized, pointer
  //
  X_tem<int> xto1 ;
  X_tem<int> *pxt = &xto1;
  pxt->~X_tem(); //unqualified

  typedef X_tem<int> localtype_tem;
  localtype_tem xto2 (66);
  pxt = &xto2;
  pxt->~localtype_tem();

  //paragraph 2:  unqualitifed id looked up in scope of post-fix expr if object
  X_tem<int> xto3 (68);
  pxt = &xto3;
  pxt->~classtype_tem();

  X_tem<int> xto4 (70);
  pxt = &xto4;
  pxt->~globaltype_tem();

  //
  // templatized, non-pointer
  //
  X_tem<int> xto5 ;
  xto5.~X_tem(); //unqualified

  localtype_tem xto6 (66);
  xto6.~localtype_tem();

  X_tem<int> xto7 (68);
  xto7.~classtype_tem();

  X_tem<int> xto8 (70);
  xto8.~globaltype_tem();
#endif
  return 0;
}
コード例 #4
0
ファイル: firemon.c プロジェクト: Acidburn0zzz/firejail
int main(int argc, char **argv) {
	unsigned pid = 0;
	int i;

	// handle CTRL-C
	signal (SIGINT, my_handler);
	signal (SIGTERM, my_handler);

	for (i = 1; i < argc; i++) {
		// default options
		if (strcmp(argv[i], "--help") == 0 ||
		    strcmp(argv[i], "-?") == 0) {
			usage();
			return 0;
		}
		else if (strcmp(argv[i], "--version") == 0) {
			printf("firemon version %s\n\n", VERSION);
			return 0;
		}
		
		// options without a pid argument
		else if (strcmp(argv[i], "--top") == 0) {
			top(); // never to return
		}
		else if (strcmp(argv[i], "--list") == 0) {
			list();
			return 0;
		}
		else if (strcmp(argv[i], "--netstats") == 0) {
			struct stat s;
			if (getuid() != 0 && stat("/proc/sys/kernel/grsecurity", &s) == 0) {
				fprintf(stderr, "Error: this feature is not available on Grsecurity systems\n");
				exit(1);
			}	

			netstats();
			return 0;
		}


		// cumulative options with or without a pid argument
		else if (strcmp(argv[i], "--x11") == 0) {
			arg_x11 = 1;
		}
		else if (strcmp(argv[i], "--cgroup") == 0) {
			arg_cgroup = 1;
		}
		else if (strcmp(argv[i], "--cpu") == 0) {
			arg_cpu = 1;
		}
		else if (strcmp(argv[i], "--seccomp") == 0) {
			arg_seccomp = 1;
		}
		else if (strcmp(argv[i], "--caps") == 0) {
			arg_caps = 1;
		}
		else if (strcmp(argv[i], "--tree") == 0) {
			arg_tree = 1;
		}
		else if (strcmp(argv[i], "--interface") == 0) {
			arg_interface = 1;
		}
		else if (strcmp(argv[i], "--route") == 0) {
			arg_route = 1;
		}
		else if (strcmp(argv[i], "--arp") == 0) {
			arg_arp = 1;
		}

		else if (strncmp(argv[i], "--name=", 7) == 0) {
			char *name = argv[i] + 7;
			if (name2pid(name, (pid_t *) &pid)) {
				fprintf(stderr, "Error: cannot find sandbox %s\n", name);
				return 1;
			}
		}
		
		// etc
		else if (strcmp(argv[i], "--nowrap") == 0)
			arg_nowrap = 1;
		
		// invalid option
		else if (*argv[i] == '-') {
			fprintf(stderr, "Error: invalid option\n");		
			return 1;
		}
		
		// PID argument
		else {
			// this should be a pid number
			char *ptr = argv[i];
			while (*ptr != '\0') {
				if (!isdigit(*ptr)) {
					fprintf(stderr, "Error: not a valid PID number\n");
					exit(1);
				}
				ptr++;
			}

			sscanf(argv[i], "%u", &pid);
			break;
		}
	}

	if (arg_tree)
		tree((pid_t) pid);
	if (arg_interface)
		interface((pid_t) pid);
	if (arg_route)
		route((pid_t) pid);
	if (arg_arp)
		arp((pid_t) pid);
	if (arg_seccomp)
		seccomp((pid_t) pid);
	if (arg_caps)
		caps((pid_t) pid);
	if (arg_cpu)
		cpu((pid_t) pid);
	if (arg_cgroup)
		cgroup((pid_t) pid);
	if (arg_x11)
		x11((pid_t) pid);
	
	if (!arg_route && !arg_arp && !arg_interface && !arg_tree && !arg_caps && !arg_seccomp && !arg_x11)
		procevent((pid_t) pid); // never to return
		
	return 0;
}
コード例 #5
0
ファイル: projects.cpp プロジェクト: gam3/trasker
ProjectsTree::ProjectsTree(TTCP *ttcp, QWidget *parent)
    : QMainWindow(parent)
{
    setupUi(this);
    setWindowFlags( windowFlags() & ~Qt::WindowMinimizeButtonHint );

    recentMenuClean = true;

    readSettings();

    recentMenu = new QMenu(this);
    alignmentGroup = new QActionGroup(this);

    recentMenu->setTitle(tr("projects"));
    recentMenu->setObjectName("project menu");
    recentMenu->setTearOffEnabled(true);

    TreeModel *model = new TreeModel(this);

    createActions();
    createViewActions();

    this->ttcp = ttcp;

#if defined TRAYPROJECT
    trayIcon = new QSystemTrayIcon();
    trayIconMenu = new QMenu();
    QIcon icon = QIcon(":/pics/active-icon-0.xpm");

    trayIconMenu->addAction(selectCurrentAction);
    trayIconMenu->addAction(timeEditAction);
    trayIconMenu->addAction(minimizeAction);
    trayIconMenu->addAction(maximizeAction);
    trayIconMenu->addAction(restoreAction);
    trayIconMenu->addAction(quitAction);

    trayIcon->setIcon(icon);
    trayIcon->setContextMenu(trayIconMenu);

    trayIcon->show();
#endif

    QStringList headers;
    headers << tr("Title") << tr("Description");

    view->setModel(model);
    view->resizeColumnToContents(0);
    QHeaderView *header = view->header();
    header->moveSection(0, 1);
    view->setColumnWidth(1, 100);
    view->hideColumn(2);
    header->setMovable(false);

    /*! \sa
     * MyTreeView::popMenu()
     * ProjectsTree::itemMenu()
     */
    connect(ttcp, SIGNAL(error(const QString &)), this, SLOT(p_error(const QString &)));
    connect(ttcp, SIGNAL(recentprojects(QList<int>&)), this, SLOT(updateRecentMenu(QList<int>&)));

    connect(view, SIGNAL(popMenu()), this, SLOT(itemMenu()));
    connect(view, SIGNAL(projPopMenu(int)), this, SLOT(projItemMenu(int)));

    connect(model, SIGNAL(get_time(int)), ttcp, SLOT(gettime(int)));
    connect(this, SIGNAL(changeProjectTo(int)), ttcp, SLOT(setProject(int)));

    connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));

    connect(view, SIGNAL(expanded(QModelIndex)),
            model, SLOT(expanded(QModelIndex)));

    connect(view, SIGNAL(collapsed(QModelIndex)),
            model, SLOT(collapsed(QModelIndex)));

    connect(ttcp, SIGNAL(disconnected()),
            view, SLOT(disable()));
    connect(ttcp, SIGNAL(connected()),
            view, SLOT(enable()));

    connect(ttcp, SIGNAL(add_entry(QString,int,int,QTime,QTime)),
            model, SLOT(add_entry(QString,int,int,QTime,QTime)));

    connect(ttcp, SIGNAL(current(int)),
            this, SLOT(setCurrent(int)));

    //! Unselect the view
    connect(ttcp, SIGNAL(current(int)),
            view, SLOT(clearSelection()));

    connect(ttcp, SIGNAL(current(int)),
            model, SLOT(set_current(int)));

    connect(ttcp, SIGNAL(settime(int, QTime, QTime)),
            model, SLOT(update_time(int, QTime, QTime)));

    connect(view->selectionModel(),
            SIGNAL(selectionChanged(const QItemSelection &,
                                    const QItemSelection &)),
            this, SLOT(updateActions()));

#if defined TRAYPROJECT
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
	    this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
#endif

#if defined (Q_WS_X11)
    x11();
#endif

    updateActions();

    addNoteW = new Notes(ttcp, this);
    connect(ttcp, SIGNAL(accept_note(const QString &)), addNoteW, SLOT(notesDone(const QString &)));
    addTaskW = new AddProject(ttcp, this);
    connect(ttcp, SIGNAL(accept_project(const QString &)), addTaskW, SLOT(done(const QString &)));
    addAutoSelW = new AddAuto(ttcp, this);
    connect(ttcp, SIGNAL(accept_select(const QString &)), addAutoSelW, SLOT(autoDone(const QString &)));
    errorWin = new ErrorWindow(this);
    timeEditWin = new TimeEdit(ttcp, this);
    
    connect(timeEditAction, SIGNAL(triggered()), timeEditWin, SLOT(myShow()));
//    timeEditWin->myShow();
}