コード例 #1
0
int CWatchdogMngr::Add(CWatchdog* p_wdg, int p_type)
{
	if ( p_type >= __MAX_WATCHDOGS )
		return false ;

	m_wdg[p_type] = p_wdg ;
	m_nInsertPos = _max_(m_nInsertPos, p_type) ;
	m_lPingInterval = _max_(m_lPingInterval, p_wdg->GetPingInterval() );

	return true ;
}
コード例 #2
0
void solve()
{
    for(int j=0; j<=W; j++) {
        dp[0][j]=0;
    }
    for(int i=0; i<N; i++) {
        for(int j=0; j<=W; j++) {
            if(j<wi[i]) {
                dp[i+1][j]=dp[i][j];
            }
            else {
                dp[i+1][j]=_max_(dp[i][j],dp[i][j-wi[i]]+pi[i]);
            }
        }
    }
}
コード例 #3
0
void preprocess()
{
    la = strlen(a);
    lb = strlen(b);
    isNega = a[0] == '-' ? 1 : 0;
    isNegb = b[0] == '-' ? 1 : 0;
    la -= isNega;
    lb -= isNegb;
    max_l = _max_(la, lb);
    buf_l = max_l + 1;

    memset(buf_a, 0, sizeof(buf_a));
    memset(buf_b, 0, sizeof(buf_b));

    for(int i=0; i<la; i++){
        buf_a[buf_l - la + i] = a[i+isNega] - '0';
    }
    buf_a[buf_l] = '\0';

    for(int i=0; i<lb; i++){
        buf_b[buf_l - lb + i] = b[i+isNegb] - '0';
    }
    buf_b[buf_l] = '\0';
}
コード例 #4
0
void SimpleOptions::createLayout( )
{	QGridLayout* gridLayout  = new QGridLayout( this );

	byte row = 1;
	m_allPortsCheckBox       = new QCheckBox( i18n( "All ports (--allports)"              ), this, "all ports check"       );
	m_fastScanCheckBox       = new QCheckBox( i18n( "Fast Scan (-F)"                      ), this, "fast scan check"       );
	m_ipV6CheckBox           = new QCheckBox( i18n( "IPV6 support (-6)"                   ), this, "ipv6 check"            );
	m_privilegedCheckBox     = new QCheckBox( i18n( "Assume privileged (--privileged)"    ), this, "privileged check"      );
	m_noRandomPortsCheckBox  = new QCheckBox( i18n( "No Random Ports (-r)"                ), this, "no random ports check" );
	m_osDetectionCheckBox    = new QCheckBox( i18n( "OS Detection (-O)"                   ), this, "os detection check"    );
	m_osScanLimitCheckBox    = new QCheckBox( i18n( "OS scan limit (--osscan_limit)"      ), this, "os scan limit check"   );
	m_packetTraceCheckBox    = new QCheckBox( i18n( "Packet trace (--packet_trace)"       ), this, "packet trace check"    );
	m_prepackagedCheckBox    = new QCheckBox( i18n( "Prepackaged options (-A)"            ), this, "prepackaged check"    );
	m_randomizeHostsCheckBox = new QCheckBox( i18n( "Randomize hosts (--randomize_hosts)" ), this, "randomize check"       );
	m_sendEthCheckBox        = new QCheckBox( i18n( "Send raw eth. packets (--send_eth)"  ), this, "send eth check"        );
	m_sendIPCheckBox         = new QCheckBox( i18n( "Send raw IP packets (--send_ip)"     ), this, "send ip check"         );
	m_verboseCheckBox        = new QCheckBox( i18n( "Verbose (-v)"                        ), this, "verbose check"         );

	row = 1;
	gridLayout->addWidget( new QLabel( " ", this ),  row,   1 );
	gridLayout->addWidget( m_allPortsCheckBox,       row++, 3 );
	gridLayout->addWidget( new QLabel( " ", this ),  row,   1 );
	gridLayout->addWidget( m_privilegedCheckBox,     row++, 3 );
	gridLayout->addWidget( new QLabel( " ", this ),  row,   1 );
	gridLayout->addWidget( m_fastScanCheckBox,       row++, 3 );
	gridLayout->addWidget( new QLabel( " ", this ),  row,   1 );
	gridLayout->addWidget( m_ipV6CheckBox,           row++, 3 );
	gridLayout->addWidget( new QLabel( " ", this ),  row,   1 );
	gridLayout->addWidget( m_noRandomPortsCheckBox,  row++, 3 );
	byte rowBlock1 = row;

	row = 1;
	gridLayout->addWidget( new QLabel( "#", this ),  row,   5 );
	gridLayout->addWidget( m_osDetectionCheckBox,    row++, 7 );
	gridLayout->addWidget( new QLabel( " ", this ),  row,   5 );
	gridLayout->addWidget( m_osScanLimitCheckBox,    row++, 7 );
	gridLayout->addWidget( new QLabel( " ", this ),  row,   5 );
	gridLayout->addWidget( m_packetTraceCheckBox,    row++, 7 );
	gridLayout->addWidget( new QLabel( " ", this ),  row,   5 );
	gridLayout->addWidget( m_prepackagedCheckBox,    row++, 7 );
	byte rowBlock2 = row;

	row = 1;
	gridLayout->addWidget( new QLabel( " ", this ),  row,    9 );
	gridLayout->addWidget( m_randomizeHostsCheckBox, row++, 11 );
	gridLayout->addWidget( new QLabel( " ", this ),  row,    9 );
	gridLayout->addWidget( m_sendEthCheckBox,        row++, 11 );
	gridLayout->addWidget( new QLabel( " ", this ),  row,    9 );
	gridLayout->addWidget( m_sendIPCheckBox,         row++, 11 );
	gridLayout->addWidget( new QLabel( " ", this ),  row,    9 );
	gridLayout->addWidget( m_verboseCheckBox,        row++, 11 );
	byte rowBlock3 = row;

	gridLayout->setColStretch(  0, 8 );
	gridLayout->setColStretch(  2, 1 );
	gridLayout->setColStretch(  4, 8 );
	gridLayout->setColStretch(  6, 1 );
	gridLayout->setColStretch(  8, 8 );
	gridLayout->setColStretch( 10, 1 );
	gridLayout->setColStretch( 12, 8 );

	gridLayout->setRowStretch( 0, 10 );
	gridLayout->setRowStretch( _max_( rowBlock1, _max_( rowBlock2, rowBlock3 )) + 1, 10 );
}
コード例 #5
0
void LoggingOptions::createLayout( )
{	QGridLayout* gridLayout      = new QGridLayout( this );
	KIconLoader* iconLoader      = KGlobal::iconLoader( );
	QIconSet     fileOpenIconSet = iconLoader->loadIconSet( "fileopen",   KIcon::Small );

	m_baseFileNameButton   = new QPushButton( fileOpenIconSet, NULL, this, "base file name button" );
	m_grepableLogButton    = new QPushButton( fileOpenIconSet, NULL, this, "grepable log button"   );
	m_normalLogButton      = new QPushButton( fileOpenIconSet, NULL, this, "normal log button"     );
	m_resumeButton         = new QPushButton( fileOpenIconSet, NULL, this, "resume button"         );
	m_scriptKiddieButton   = new QPushButton( fileOpenIconSet, NULL, this, "script kiddie button"  );
	m_stylesheetButton     = new QPushButton( fileOpenIconSet, NULL, this, "stylesheet button"     );
	m_xmlLogButton         = new QPushButton( fileOpenIconSet, NULL, this, "xml log button"        );

	m_appendOutputCheckBox = new QCheckBox( i18n( "Append output (--append_output)"       ), this, "append output checkbox" );
	m_baseFileNameCheckBox = new QCheckBox( i18n( "Base file name (-oA <name>) "          ), this, "base name checkbox"     );
	m_grepableLogCheckBox  = new QCheckBox( i18n( "grep'able log file (-oG <file>) "      ), this, "grepable log checkbox"  );
	m_normalLogCheckBox    = new QCheckBox( i18n( "Normal log file (-oN <file>) "         ), this, "normal log checkbox"    );
	m_noStylesheetCheckBox = new QCheckBox( i18n( "No XSL stylesheet (--no_stylesheet)"   ), this, "no stylesheet checkbox" );
	m_resumeCheckBox       = new QCheckBox( i18n( "Resume file (--resume <file>) "        ), this, "resume checkbox"        );
	m_scriptKiddieCheckBox = new QCheckBox( i18n( "Script kiddie log file (-oS <file>) "  ), this, "script kiddie checkbox" );
	m_stylesheetCheckBox   = new QCheckBox( i18n( "XSL stylesheet (--stylesheet <file>) " ), this, "stylesheet checkbox"    );
	m_xmlLogCheckBox       = new QCheckBox( i18n( "XML log file (-oX <file>) "            ), this, "xml log checkbox"       );

	m_baseFileNameLineEdit = new QLineEdit( this, "base file name line edit" );
	m_grepableLogLineEdit  = new QLineEdit( this, "grepable log line edit"   );
	m_normalLogLineEdit    = new QLineEdit( this, "normal log line edit"     );
	m_resumeLineEdit       = new QLineEdit( this, "resume line edit"         );
	m_scriptKiddieLineEdit = new QLineEdit( this, "script kiddie line edit"  );
	m_stylesheetLineEdit   = new QLineEdit( this, "stylesheet line edit"     );
	m_xmlLogLineEdit       = new QLineEdit( this, "xml log line edit"        );

	byte row = 1;
	gridLayout->addWidget( m_appendOutputCheckBox, row++, 1 );
	gridLayout->addWidget( m_noStylesheetCheckBox, row++, 1 );
	byte rowBlock1 = row;

	row = 1;
	gridLayout->addWidget( m_baseFileNameCheckBox, row,   3 );
	gridLayout->addWidget( m_baseFileNameLineEdit, row,   4 );
	gridLayout->addWidget( m_baseFileNameButton,   row++, 5 );

	gridLayout->addWidget( m_grepableLogCheckBox,  row,   3 );
	gridLayout->addWidget( m_grepableLogLineEdit,  row,   4 );
	gridLayout->addWidget( m_grepableLogButton,    row++, 5 );

	gridLayout->addWidget( m_normalLogCheckBox,    row,   3 );
	gridLayout->addWidget( m_normalLogLineEdit,    row,   4 );
	gridLayout->addWidget( m_normalLogButton,      row++, 5 );

	gridLayout->addWidget( m_resumeCheckBox,       row,   3 );
	gridLayout->addWidget( m_resumeLineEdit,       row,   4 );
	gridLayout->addWidget( m_resumeButton,         row++, 5 );

	gridLayout->addWidget( m_scriptKiddieCheckBox, row,   3 );
	gridLayout->addWidget( m_scriptKiddieLineEdit, row,   4 );
	gridLayout->addWidget( m_scriptKiddieButton,   row++, 5 );

	gridLayout->addWidget( m_xmlLogCheckBox,       row,   3 );
	gridLayout->addWidget( m_xmlLogLineEdit,       row,   4 );
	gridLayout->addWidget( m_xmlLogButton,         row++, 5 );

	gridLayout->addWidget( m_stylesheetCheckBox,   row,   3 );
	gridLayout->addWidget( m_stylesheetLineEdit,   row,   4 );
	gridLayout->addWidget( m_stylesheetButton,     row++, 5 );
	byte rowBlock2 = row;

	gridLayout->setColStretch( 0,  5 );
	gridLayout->setColStretch( 2,  5 );
	gridLayout->setColStretch( 4, 10 );
	gridLayout->setColStretch( 6,  5 );

	gridLayout->setRowStretch( 0, 10 );
	gridLayout->setRowStretch( _max_( rowBlock1, rowBlock2 ), 10 );
}
コード例 #6
0
void HTMLWidget::zoomOut( )
{	m_zoomFactor = _max_( ZOOM_MIN_FACTOR, m_zoomFactor - m_zoomIncrement );
	m_htmlPart->setZoomFactor( int( m_zoomFactor ));
	emit( optionsDirty( ));
}
コード例 #7
0
void solve()
{
    maxn=0;
    for(int i=0;i<=n1;i++){
        for(int j=0;j<=n2;j++){
            if(i==0||j==0){
                dp[i][j]=0;

                //loc[i][j].prevx=0;
                //loc[i][j].prevy=0;

            }
            else if(s1[i-1]==s2[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
                if(dp[i][j]>maxn){
                    finalx=i;
                    finaly=j;
#if _DEBUG_
                    printf("finalx=%d,finaly=%d\n",finalx,finaly);
#endif
                }
                maxn=_max_(maxn,dp[i][j]);

                loc[i][j].ft=TGT;
            }
            else{
                dp[i][j]=_max_(dp[i-1][j],dp[i][j-1]);
                maxn=_max_(maxn,dp[i][j]);

                if(dp[i-1][j]>dp[i][j-1]){
                    loc[i][j].ft=LFT;
                }
                else {
                    loc[i][j].ft=TOP;
                }
            }
        }
    }

#if _DEBUG_
    for(int i=0;i<=n1;i++){
        for(int j=0;j<=n2;j++){
            printf("(%s,%s)%s",ftype[loc[i][j].ft],loc[i][j].ft==TGT?"Y":"N",j==n2?"\n":" ");
        }
    }
#endif

    int curx=finalx,cury=finaly;
#if _DEBUG_
    printf("finalx=%d,finaly=%d\n",finalx,finaly);
#endif
    int tgtn=0;
    char revs[1005];
    while(curx>=1&&cury>=1){
        if(loc[curx][cury].ft==TGT){
            revs[tgtn++]=s1[curx-1];
        }
#if _DEBUG_
        if(loc[curx][cury].ft==TGT){
            printf("curx=%d,cury=%d,%c\n",curx,cury,s1[curx-1]);
        }
        else{
            printf("curx=%d,cury=%d\n",curx,cury);
        }
#endif
        if(loc[curx][cury].ft==TGT){
            curx--;
            cury--;
        }
        else if(loc[curx][cury].ft==LFT){
            curx--;
        }
        else{
            cury--;
        }
    }
    for(int i=0;i<tgtn;i++){
        maxs[i]=revs[tgtn-1-i];
    }
    maxs[maxn]='\0';
}
コード例 #8
0
ファイル: ddvgraph.c プロジェクト: hsptools/hsp-wrap
/*******************************************************************************

  Function : DDV_GetRulerForEditor()
  
  Purpose : create the ruler for the editor. This new descriptor is created
      using the descriptor of the viewer.

  Return value : an allocated data block ready for use by the editor. Null if
  failure

*******************************************************************************/
NLM_EXTERN ValNodePtr DDV_GetRulerForEditor(ValNodePtr descr_head,Int4 from_disp,
		Int4 to_disp)
{
DDVRulerDescrPtr drdp,prev_drdp,new_drdp;
ValNodePtr  vnp2,vnp3,vnpDesc;
Int4     cumulDecr,drdp_size,beginCopy,endCopy,drdp_start_ali;
Boolean  bPop;

	cumulDecr=0;
	vnpDesc=NULL;
	prev_drdp=NULL;
	
	for(vnp2=descr_head;vnp2!=NULL;vnp2=vnp2->next){
		drdp=(DDVRulerDescrPtr)vnp2->data.ptrvalue;
		drdp_size=drdp->disp_stop-drdp->disp_start+1;

		/*not yet in the region of interest ?*/
		if (drdp->disp_stop<from_disp) {
			cumulDecr+=drdp_size;
			continue;
		}
		
		beginCopy=_max_(from_disp,drdp->disp_start);
		endCopy=_min_(drdp->disp_stop,to_disp);

		if (drdp->bUnAligned==FALSE)
			drdp_start_ali=drdp->align_start+(beginCopy-drdp->disp_start);
		else
			drdp_start_ali=(Int4)-1;
		/*in order to merge nodes of same type, i keep track of
		the previous populated drdp node. Same style==yes, then
		just extend to the right the previous node*/
		if (prev_drdp){
			if (prev_drdp->bUnAligned==drdp->bUnAligned){
				prev_drdp->disp_stop=endCopy;
				bPop=TRUE;
			}
			else{
				bPop=FALSE;
			}
		}
		else{
			bPop=FALSE;
		}
		if (!bPop){
			new_drdp=(DDVRulerDescrPtr)MemNew(sizeof(DDVRulerDescr));
			if (!new_drdp) goto erreur;
			
			new_drdp->disp_start=beginCopy;
			new_drdp->disp_stop=endCopy;
			new_drdp->align_start=drdp_start_ali;
			new_drdp->bUnAligned=drdp->bUnAligned;
			if (!vnpDesc){
				vnp3=ValNodeAddPointer(&vnpDesc,0,(Pointer)new_drdp);
			}
			else{
				vnp3=ValNodeAddPointer(&vnp3,0,(Pointer)new_drdp);
			}
			prev_drdp=new_drdp;
		}
		if (drdp->disp_stop>=to_disp) break;
		cumulDecr+=drdp_size;
	}

	return(vnpDesc);
erreur:
	if (vnpDesc)
		ValNodeFreeData(vnpDesc);
	return(NULL);
}