예제 #1
0
int yprefs::PutParam(const char *param, bool value)
{
	if(value==true)
		return PutParam(param,"1");
	else
		return PutParam(param,"0");
}
예제 #2
0
파일: fcgiapp.c 프로젝트: oripka/bagunceiro
/*
 *----------------------------------------------------------------------
 *
 * ReadParams --
 *
 *      Reads FastCGI name-value pairs from stream until EOF.  Converts
 *      each pair to name=value format and adds it to Params structure.
 *
 *----------------------------------------------------------------------
 */
static int ReadParams(Params * paramsPtr, FCGX_Stream * stream)
{
	int nameLen, valueLen;
	unsigned char lenBuff[3];
	char *nameValue;

	while ((nameLen = FCGX_GetChar(stream)) != EOF) {
		/*
		 * Read name length (one or four bytes) and value length
		 * (one or four bytes) from stream.
		 */
		if ((nameLen & 0x80) != 0) {
			if (FCGX_GetStr((char *)&lenBuff[0], 3, stream) != 3) {
				SetError(stream, FCGX_PARAMS_ERROR);
				return -1;
			}
			nameLen = ((nameLen & 0x7f) << 24) + (lenBuff[0] << 16)
				+ (lenBuff[1] << 8) + lenBuff[2];
		}
		if ((valueLen = FCGX_GetChar(stream)) == EOF) {
			SetError(stream, FCGX_PARAMS_ERROR);
			return -1;
		}
		if ((valueLen & 0x80) != 0) {
			if (FCGX_GetStr((char *)&lenBuff[0], 3, stream) != 3) {
				SetError(stream, FCGX_PARAMS_ERROR);
				return -1;
			}
			valueLen =
				((valueLen & 0x7f) << 24) + (lenBuff[0] << 16)
				+ (lenBuff[1] << 8) + lenBuff[2];
		}
		/*
		 * nameLen and valueLen are now valid; read the name and value
		 * from stream and construct a standard environment entry.
		 */
		nameValue = (char *)Malloc(nameLen + valueLen + 2);
		if (FCGX_GetStr(nameValue, nameLen, stream) != nameLen) {
			SetError(stream, FCGX_PARAMS_ERROR);
			free(nameValue);
			return -1;
		}
		*(nameValue + nameLen) = '=';
		if (FCGX_GetStr(nameValue + nameLen + 1, valueLen, stream)
			!= valueLen) {
			SetError(stream, FCGX_PARAMS_ERROR);
			free(nameValue);
			return -1;
		}
		*(nameValue + nameLen + valueLen + 1) = '\0';
		PutParam(paramsPtr, nameValue);
	}
	return 0;
}
예제 #3
0
int KSGTaskParams::Parse(const std::string& str)
{
	TiXmlDocument doc;
	doc.Parse(str.c_str());
	TiXmlNode* root = doc.FirstChild("taskdef");
	if(!root)
		return -1;
	TiXmlNode* elem = root->FirstChild();
	while(elem!=NULL)
	{
		//elem->f
		TiXmlNode* t = elem->FirstChild();
		if(t)
			PutParam(elem->Value(),t->Value());
		else
			PutParam(elem->Value(),"");
		elem = elem->NextSibling();
	}
	return 0;

}
예제 #4
0
파일: fcgiapp.c 프로젝트: oripka/bagunceiro
/*
 *----------------------------------------------------------------------
 *
 * FCGX_Accept_r --
 *
 *      Accepts a new request from the HTTP server.
 *
 * Results:
 *	0 for successful call, -1 for error.
 *
 * Side effects:
 *
 *      Finishes the request accepted by (and frees any
 *      storage allocated by) the previous call to FCGX_Accept.
 *      Creates input, output, and error streams and
 *      assigns them to *in, *out, and *err respectively.
 *      Creates a parameters data structure to be accessed
 *      via getenv(3) (if assigned to environ) or by FCGX_GetParam
 *      and assigns it to *envp.
 *
 *      DO NOT retain pointers to the envp array or any strings
 *      contained in it (e.g. to the result of calling FCGX_GetParam),
 *      since these will be freed by the next call to FCGX_Finish
 *      or FCGX_Accept.
 *
 *----------------------------------------------------------------------
 */
int FCGX_Accept_r(FCGX_Request * reqDataPtr)
{
	if (!libInitialized) {
		return -9998;
	}

	/* Finish the current request, if any. */
	FCGX_Finish_r(reqDataPtr);

	for (;;) {
		/*
		 * If a connection isn't open, accept a new connection (blocking).
		 * If an OS error occurs in accepting the connection,
		 * return -1 to the caller, who should exit.
		 */
		if (reqDataPtr->ipcFd < 0) {
			int fail_on_intr =
				reqDataPtr->flags & FCGI_FAIL_ACCEPT_ON_INTR;

			reqDataPtr->ipcFd =
				OS_Accept(reqDataPtr->listen_sock, fail_on_intr,
				webServerAddressList);
			if (reqDataPtr->ipcFd < 0) {
				return (errno > 0) ? (0 - errno) : -9999;
			}
		}
		/*
		 * A connection is open.  Read from the connection in order to
		 * get the request's role and environment.  If protocol or other
		 * errors occur, close the connection and try again.
		 */
		reqDataPtr->isBeginProcessed = FALSE;
		reqDataPtr->in = NewReader(reqDataPtr, 8192, 0);
		FillBuffProc(reqDataPtr->in);
		if (!reqDataPtr->isBeginProcessed) {
			goto TryAgain;
		}
		{
			char *roleStr;
			switch (reqDataPtr->role) {
			case FCGI_RESPONDER:
				roleStr = "FCGI_ROLE=RESPONDER";
				break;
			case FCGI_AUTHORIZER:
				roleStr = "FCGI_ROLE=AUTHORIZER";
				break;
			case FCGI_FILTER:
				roleStr = "FCGI_ROLE=FILTER";
				break;
			default:
				goto TryAgain;
			}
			reqDataPtr->paramsPtr = NewParams(30);
			PutParam(reqDataPtr->paramsPtr, StringCopy(roleStr));
		}
		SetReaderType(reqDataPtr->in, FCGI_PARAMS);
		if (ReadParams(reqDataPtr->paramsPtr, reqDataPtr->in) >= 0) {
			/*
			 * Finished reading the environment.  No errors occurred, so
			 * leave the connection-retry loop.
			 */
			break;
		}

		/*
		 * Close the connection and try again.
		 */
TryAgain:
		FCGX_Free(reqDataPtr, 1);

	}			/* for (;;) */
	/*
	 * Build the remaining data structures representing the new
	 * request and return successfully to the caller.
	 */
	SetReaderType(reqDataPtr->in, FCGI_STDIN);
	reqDataPtr->out = NewWriter(reqDataPtr, 8192, FCGI_STDOUT);
	reqDataPtr->err = NewWriter(reqDataPtr, 512, FCGI_STDERR);
	reqDataPtr->nWriters = 2;
	reqDataPtr->envp = reqDataPtr->paramsPtr->vec;
	return 0;
}
예제 #5
0
int yprefs::PutParam(const char *param, int value)
{	char string[255];
	sprintf(string,"%d",value);
	return PutParam(param,string);
}
예제 #6
0
//----------------------------------------------------------------------------
//!	\brief	handle OK key press function for any GUI's, 
//----------------------------------------------------------------------------
void CReturnDlg::OnOK()
{
	Beep1();
	CString str;
	switch(m_iLevel)
	{
	case PASSWORD_INPUT: //Password Input
		if (m_strPassword.GetLength() == 0)
		{
			Beep();
			return;
		}
		if (!CheckPassword())
		{
			m_IncorrectTimes++;
			if (m_IncorrectTimes >= 5)
			{
				CDataFile::Save(L"CLERK PW", L"On");
				CDialog::OnCancel();
			}
			else
			{
				Beep();
				m_strPassword = L"";
				m_strMsg2.SetCaption(L"");
			}
		    return;
		}
		break;
	case AMOUNT_INPUT:
		str = m_strMsg2.m_szCaption;
		str.Remove('$');
		str.Remove(' ');
		str.Remove('.');
		str.Remove(', ');
		str.TrimLeft('0');
		if (str.GetLength() == 0)
		{
			Beep();
			return;
		}
		PutParam(m_TRREC.Amount, str);
		m_strAmount = m_strMsg2.m_szCaption;
		break;
	case CLERK_INPUT:
		str = m_strMsg2.m_szCaption;
		PutParam(m_TRREC.ClerkID, str);
		break;
	case RECEIP_TINPUT:
		str = m_strMsg2.m_szCaption;
		PutParam(m_TRREC.ReceiptNo, str);
		break;
	case ENTERCARD_INPUT:
		if (!m_KeyEntry)
		{
			Beep();
			return;
		}
		KillTimer(1);
		str = m_strMsg2.m_szCaption;
		if (str.GetLength() < 10 || str.GetLength() > 19)
		{
			Beep();
			return;
		}
		PutParam(m_TRREC.Account, str);
		ProcessManualCard(m_TRREC.Account);
		m_iLevel = MANUALENTRYY-1;
		break;
	case DEBITCARDENTRY:
		KillTimer(1);
		break;
	case DEBITCASHBACK: //CASHBACK
		m_strCashback = m_strMsg2.m_szCaption;
		break;
	case DEBITSURCHARGEFEE: //surcharge fee
		break;
	case DEBITTIPSELECT: //TipSelect
		break;
	case DEBITTOTALCOMFIRM: // TotalComfirm
		break;
//	case DEBITSELECTACCOUNT: // SelectAccount
//		break;
	case DEBITONLINEPIN: //OnlinePin
		break;
	case DEBITMERCHANTCOPY: // for merchant copy of the receipt
		return;
	case DEBITCUSTOMERCOPY: // for Customer copy of the receipt
		KillTimer(1);
		Print(2);
		break;
	case DEBITWAITCOPYEND: // waiting for Customer copy of the receipt ending...
//		KillTimer(1);
		return;
// == == == == == == == == == == == == == = EMV Chip Card Debit Sale :C chip page 122 == == == == == == == == == == == == == = 
	case CHIPENTRYY:
		KillTimer(1);
		break;
	case SELECT_LANGUAGE: //select language
	case SELECT_APPLICATIION: //select application
	case APPLICATION_CONFIRM: //select comfirm
		Beep();
		return;
/*	case CHIP_DEBITCASHBACK: //CASHBACK
		m_strCashback = m_strMsg2.m_szCaption;
		break;
	case CHIP_DEBITSURCHARGEFEE: //surcharge fee
		break;
	case CHIP_DEBITTIPSELECT: //TipSelect
		break;
	case CHIP_DEBITTOTALCOMFIRM: // TotalComfirm
		break;
//	case CHIP_DEBITSELECTACCOUNT: // SelectAccount
//		break;
*/	case CHIP_DEBITENTERPIN: //EnterPin
		break;
	case CHIP_PASSTOCLERK: //pass to clerk
		KillTimer(1);
		GoToLevel(DOTRANSACTION);
		return;
	case CHIP_DEBITMERCHANTCOPY: // for merchant copy of the receipt
		return;
	case CHIP_DEBITCUSTOMERCOPY: // for Customer copy of the receipt
		KillTimer(1);
		Print(2);
		break;
	case CHIP_DEBITWAITCOPYEND: // waiting for Customer copy of the receipt ending...
//		KillTimer(1);
		return;
// == == == == == == == == == == == == == = Credit Card Sale :C Swiped page 75 == == == == == == == == == == == == == == == == == = 
	case CREDITSWIPEENTRYY: //Fraud Check
		str = m_strMsg2.m_szCaption;
		GoToLevel(DOTRANSACTION);
		return;
//		PutParam(m_TRREC.FraudNo, str);  //Fix me later
//		break;
	case CREDITSWIPETOCUSTOMER:
		KillTimer(1);
		break;
	case CREDITSWIPETIPSELECT: //TipSelect
		break;
	case CREDITSWIPETOTALCOMFIRM: // TotalComfirm
		break;
	case CREDITSWIPETOCLERK:   //Pass to clerk
		KillTimer(1);
		GoToLevel(DOTRANSACTION);
		return;
	case CREDITMERCHANTCOPY: // for merchant copy of the receipt
		return;
	case CREDITCUSTOMERCOPY: // for Customer copy of the receipt
		KillTimer(1);
		Print(2);
		break;
	case CREDITWAITCOPYEND: // waiting for Customer copy of the receipt ending...
//		KillTimer(1);
		return;
// == == == == == == == == == == == = /Manual Entry == == == == == == == == == == == == == == == == == == == == == == = 
	case MANUALENTRYY: //Fraud Check
		str = m_strMsg2.m_szCaption;
		if (str.GetLength() != SZ_EXPIRY_DATE)
		{
			Beep();
			return;
		}
		str = m_strMsg2.m_szCaption.Mid(2,2) + m_strMsg2.m_szCaption.Mid(0,2) ;
		PutParam(m_TRREC.ExpDate, str);
		break;
	case MANUAL_IMPRINT_CARD:
		break;
	case MANUAL_SWIPETOCUSTOMER:
		KillTimer(1);
		break;
	case MANUAL_SWIPETIPSELECT: //TipSelect
		break;
	case MANUAL_SWIPETOTALCOMFIRM: // TotalComfirm
		break;
	case MANUAL_SWIPETOCLERK:   //Pass to clerk
		KillTimer(1);
		GoToLevel(DOTRANSACTION);
		return;

// == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == = 
	case CANCELENTRY: 
		KillTimer(1);
		break;
	case CANCELTOCLERK:
		KillTimer(1);
		CDialog::OnCancel();
		return;
	case ERRORENTRY:
		KillTimer(1);
		if ( m_TRREC.bEmvTransaction)
		{
			GoToLevel(EMV_REMOVE_CARD);
		}
		else
			CDialog::OnCancel();
		return;
	case ERRORENTRY1:
		KillTimer(1);
		GoToLevel(m_iNextLevel);
		return;

// == == == == == == == Display Window == == == == == 
	case DISPLAY_WINDOW:
		if (CDisplay::GetMask() & MASK_OK)
			CDisplay::SetKeyReturn(KEY_ENTER);
		return;
	case EMV_SELECT_LANGUAGE: //EMV Select language
	case EMV_CONFIRM_AMOUNT: //EMV confirm amount
	case EMV_SELECT_ACCOUNT: //EMV select account
		m_strMsg2.m_nFormat = DT_LEFT;
		ShowText(L"Please Wait...", L"Do not remove", L"Card!");
		m_iLevel = EMV_WAIT;
		SetKeyReturn(KEY_ENTER);
		return;
	case EMV_PASS_COUSTOMER: //pass to customer
		SetKeyReturn(KEY_ENTER);
		return;
	case CHIP_DEBITCASHBACK: //CASHBACK
		m_strCashback = m_strMsg2.m_szCaption;
		break;
	case CHIP_DEBITSURCHARGEFEE: //surcharge fee
	case CHIP_DEBITTIPSELECT: //TipSelect
	case CHIP_DEBITTOTALCOMFIRM: // TotalComfirm
		break;
	case CHIP_DEBITSELECTACCOUNT: // SelectAccount
		Beep();
		return;
	default:
//		CDialog::OnOK();
		return;
	}
	GoNext();
	SetFocus();
}