Difference between revisions of "OpenDBX/C API/odbx escape"

From Linuxnetworks
< OpenDBX‎ | C API
Jump to: navigation, search
(Changed last parameter to pointer)
 
(40 intermediate revisions by 7 users not shown)
Line 1: Line 1:
[http://washingtonmutuag.fiberia.com | Washington Mutual Mortgage]
+
__NOTOC__
[http://secondomemort.fiberia.com | Second Home Mortgage]
+
'''Prepare strings for inclusion in statements'''
[http://secondmortgaget.fiberia.com | Second Mortgage And Home Equity Loan]
+
 
[http://secondmortgages.fiberia.com | Second Mortgage]
+
#include <opendbx/api.h>
[http://secondmortgager.fiberia.com | Second Mortgage Bad Credit]
+
 
[http://secondmortgaged.fiberia.com | Second Mortgage Lender]
+
int '''odbx_escape'''(
[http://refinancemortgaw.fiberia.com | Refinance Mortgage Loan]
+
    odbx_t* '''''handle''''',
[http://refinancemortga7.fiberia.com | Refinance Mortgage Rate]
+
    const char* '''''from''''',
[http://refinancemortga2.fiberia.com | Refinance Mortgage Interest Rate]
+
    unsigned long '''''fromlen''''',
[http://refinancehomemtg.fiberia.com | Refinance Home Mortgage Interest Rate]
+
    char* '''''to''''',
[http://refinancehomem.fiberia.com | Refinance Home Mortgage Rate]
+
    unsigned long* '''''tolen''''' )
[http://refinance2ndmo.fiberia.com | Refinance 2nd Mortgage]
+
 
[http://onlinemortgageyt.fiberia.com | Online Mortgage Advice]
+
== Description ==
[http://onlinemortgage1.fiberia.com | Online Mortgage Application]
+
 
[http://ohiomortgage.fiberia.com | Ohio Mortgage]
+
[[OpenDBX/API/odbx_escape|odbx_escape]]() neutralizes potentially dangerous characters of the string so it can be used as part of a statement. For security reasons every user input has to be passed to [[OpenDBX/API/odbx_escape|odbx_escape]]() to avoid SQL injection attacks which can have fatal consequences! It's also a good idea to escape strings returned from database fields again if you want to use them in a query because they don't stay escaped once they are returned as part of a record.
[http://newjerseymortg.fiberia.com | New Jersey Mortgage Loan]
+
 
[http://ndmortgageref21.fiberia.com | 2nd Mortgage Refinance]
+
Most backends require the buffer to be more than twice as long as the input string. To be precise, the output buffer must be 2 * size of input + 1 bytes long. After successfully escaping the characters in '''''from''''', they are written into the memory provided via '''''to''''' and the value/result parameter '''''tolen''''' is updated to the new length of '''''to''''' in the end.
[http://ndmortgageratge.fiberia.com | 2nd Mortgage Rate]
+
 
[http://ndmortgageloan2.fiberia.com | 2nd Mortgage Loan]
+
The first parameter '''''handle''''' is the connection object created and returned by [[OpenDBX/API/odbx_init|odbx_init]]() which becomes invalid as soon as it was supplied to [[OpenDBX/API/odbx_finish|odbx_finish]]().
[http://ndmortgage2.fiberia.com | 2nd Mortgage]
+
 
[http://ndloanmortgag2.fiberia.com | 2nd Loan Mortgage]
+
'''''from''''' has to point to a character string containing the string which should be used as part of a statement. It doesn't have to be zero-terminated because the length of it is also given via '''''fromlen'''''. The backends may support variable width character sets like UTF-8 but this function doesn't support the wide char type (wchar_t) where each character has a fixed size of two or four bytes.
[http://ndhomemortg2ag.fiberia.com | 2nd Home Mortgage]
+
 
[http://nationalcitymota.fiberia.com | National City Mortgage]
+
The value of the parameter '''''fromlen''''' must be the length in bytes of the string which '''''from''''' is pointing to. This is also true for variable width character sets like UTF-8 but the wide char type (wchar_t) is not supported. The terminating \0 character shouldn't be part of '''''fromlen'''''.
[http://mortgagesecond6.fiberia.com | Mortgage Second]
+
 
[http://mortgagesanjosqs.fiberia.com | Mortgage San Jose California]
+
The calling function provides a buffer for storing the escaped string via '''''to'''''. In general, the length of the buffer should be more than twice as long as the string passed via '''''from''''' to be able to store the escaped string even if every character has to be escaped.
[http://mortgageresident.fiberia.com | Mortgage Residential]
+
 
[http://mortgagerefinanw.fiberia.com | Mortgage Refinance Second]
+
'''''tolen''''' is a value-result parameter which points to an integer variable in the calling function. It must contain the original length of the buffer given via '''''to''''' and if escaping the string in '''''from''''' suceeded, [[OpenDBX/API/odbx_escape|odbx_escape]]() will store the new length of the escaped string in this variable.
[http://mortgagerefinanq.fiberia.com | Mortgage Refinance California]
+
 
[http://mortgagerefinan7.fiberia.com | Mortgage Refinancing Company]
+
== Return value ==
[http://mortgagerateregs.fiberia.com | Mortgage Rate Refinance]
+
 
[http://mortgagepennsyl.fiberia.com | Mortgage Pennsylvania Refinance]
+
[[OpenDBX/API/odbx_escape|odbx_escape]]() returns ODBX_ERR_SUCCESS, or an error code whose value is less than zero if one of the operations couldn't be completed successfully. Possible error codes are listed in the error section and they can be feed to [[OpenDBX/API/odbx_error|odbx_error]]() and [[OpenDBX/API/odbx_error_type|odbx_error_type]]() to get further details.
[http://mortgageohio.fiberia.com | Mortgage Ohio]
+
 
[http://mortgageloanrate.fiberia.com | Mortgage Loan Rate]
+
== Errors ==
[http://mortgageloanpra.fiberia.com | Mortgage Loan Processor]
+
 
[http://mortgageloane3.fiberia.com | Mortgage Loan Refinance And Debt Consolidation]
+
; -ODBX_ERR_BACKEND : The native database library returned an error because it wasn't able to escape the given string to be suitable for a statement
[http://mortgageloan.fiberia.com | Mortgage Loan]
+
; -ODBX_ERR_PARAM : One of the supplied parameters is invalid or is NULL and this isn't allowed in the used backend module or in the native database client library
[http://mortgagelifein12.fiberia.com | Mortgage Life Insurance]
+
; -ODBX_ERR_SIZE : The length of the escaped string exceeds or is likely to exeed the available buffer (before 1.1.4 the name of the label was ODBX_ERR_TOOLONG but the value is still the same)
[http://mortgageinsurani.fiberia.com | Mortgage Insurance Quote]
+
 
[http://mortgagebrokerr.fiberia.com | Mortgage Broker In California]
+
== See also ==
[http://mortgageapplicat.fiberia.com | Mortgage Application]
+
 
[http://lowmortgagerate.fiberia.com | Low Mortgage Rate Refinance]
+
* [[OpenDBX/API/odbx_error|odbx_error]]()
[http://loanmortgagereg.fiberia.com | Loan Mortgage Refinance]
+
* [[OpenDBX/API/odbx_error_type|odbx_error_type]]()
[http://loanmortgage.fiberia.com | Loan Mortgage]
+
* [[OpenDBX/API/odbx_query|odbx_query]]()
[http://interestmortgagt.fiberia.com | Interest Mortgage Rate Refinance]
+
[http://interestmortgag3.fiberia.com | Interest Mortgage Rate]
+
[http://interestmortgag.fiberia.com | Interest Mortgage]
+
[http://insurancemortga.fiberia.com | Insurance Mortgage]
+
[http://insurancelifem32.fiberia.com | Insurance Life Mortgage]
+
[http://insurance2mortga.fiberia.com | Insurance Mortgage Quote]
+
[http://illinoismortgagt.fiberia.com | Illinois Mortgage Rate]
+
[http://hommortgagera1.fiberia.com | Home Mortgage Rate Refinance]
+
[http://homemortgagera.fiberia.com | Home Mortgage Rate]
+
[http://homemortgagelo.fiberia.com | Home Mortgage Loan Rate]
+
[http://homemortgagein2.fiberia.com | Home Mortgage Insurance]
+
[http://homeloanmortgag.fiberia.com | Home Loan Mortgage Refinance]
+
[http://homeloanmortga1.fiberia.com | Home Loan Mortgage Rate]
+
[http://homeloanmortga.fiberia.com | Home Loan Mortgage Second]
+
[http://homeinterest1mo.fiberia.com | Home Interest Mortgage Rate Refinance]
+
[http://homeinsurancemo.fiberia.com | Home Insurance Mortgage]
+
[http://homeequitymort1.fiberia.com | Home Equity Mortgage]
+
[http://homeequitymort.fiberia.com | Home Equity Mortgage Loan]
+
[http://gmacmortgage.fiberia.com | Gmac Mortgage]
+
[http://floridarefinanc4.fiberia.com | Florida Refinance Mortgage]
+
[http://floridamortgagew.fiberia.com | Florida Mortgage Company]
+
[http://floridamortgagea.fiberia.com | Florida Mortgage Refinance]
+
[http://floridamortgage7.fiberia.com | Florida Mortgage Lender]
+
[http://floridamortgage4.fiberia.com | Florida Mortgage]
+
[http://floridainmortgee.fiberia.com | Florida In Mortgage Refinance]
+
[http://fixedratemortg12.fiberia.com | Fixed Rate Mortgage]
+
[http://fixedmortgagerat.fiberia.com | Fixed Mortgage Rate]
+
[http://fixedmortgag30.fiberia.com | 30 Fixed Mortgage Rate Year]
+
[http://fhamortgage.fiberia.com | Fha Mortgage]
+
[http://ditechmortgage32.fiberia.com | Ditech Mortgage Loan]
+
[http://ditechloanmort.fiberia.com | Ditech Loan Mortgage]
+
[http://debtconsolidati1.fiberia.com | Debt Consolidation Mortgage Loan]
+
[http://dailymortgagerq.fiberia.com | Daily Mortgage Rate]
+
[http://currentmortgage3.fiberia.com | Current Mortgage Rate]
+
[http://currentinterestq.fiberia.com | Current Interest Mortgage Rate]
+
[http://currenmortgaget.fiberia.com | Current Mortgage Interest Rate]
+
[http://countrywidemorta.fiberia.com | Countrywide Mortgage]
+
[http://consolidationdet.fiberia.com | Consolidation Debt Loan Mortgage]
+
[http://consolidationde.fiberia.com | Consolidation Debt Loan Mortgage Refinance]
+
[http://connecticutmortg.fiberia.com | Connecticut Mortgage Refinance]
+
[http://companymortgage1.fiberia.com | Company Mortgage Refinance]
+
[http://companyflorida4.fiberia.com | Company Florida Mortgage]
+
[http://coloradomortgag5.fiberia.com | Colorado Mortgage Loan]
+
[http://coloradocompany.fiberia.com | Colorado Company Home Loan Mortgage]
+
[http://citymortgagenas.fiberia.com | City Mortgage National]
+
[http://chasemanhattan3.fiberia.com | Chase Manhattan Mortgage]
+
[http://californiamortgf.fiberia.com | California Mortgage Refinance]
+
[http://californiamortge.fiberia.com | California Mortgage]
+
[http://californiamortg3.fiberia.com | California Mortgage Broker]
+
[http://californiamortg.fiberia.com | California Mortgage Rate]
+
[http://californialoanca.fiberia.com | California Loan Mortgage]
+
[http://calculatormortge.fiberia.com | Calculator Mortgage]
+
[http://broker1californi.fiberia.com | Broker California Mortgage]
+
[http://bestrefinanceqh.fiberia.com | Equity Home Loan Mortgage Second]
+
[http://bestrefinanceqh.fiberia.com | Best Refinance Home Mortgage Loan Rate]
+
[http://bestrefinancem12.fiberia.com | Best Refinance Mortgage Rate]
+
[http://bestmortgagerate.fiberia.com | Best Mortgage Rate]
+
[http://bestmortgagerat.fiberia.com | Best Mortgage Rate Refinance]
+
[http://bestmortgagelows.fiberia.com | Best Mortgage Loan]
+
[http://bestloanmortga.fiberia.com | Best Loan Mortgage]
+
[http://besthome2loanm.fiberia.com | Best Home Loan Mortgage Rate Refinance]
+
[http://badcreditmortggt.fiberia.com | Bad Credit Mortgage Second]
+
[http://badcreditmortge.fiberia.com | Bad Credit Mortgage Lender]
+
[http://badcreditloaba.fiberia.com | Bad Credit Loan Mortgage]
+
[http://badcredithomeqw.fiberia.com | Bad Credit Home Loan Mortgage]
+
[http://badcredithomegt.fiberia.com | Bad Credit Home Mortgage Loan]
+
[http://badcredithomeg1.fiberia.com | Bad Credit Home Mortgage]
+
[http://badcredit1mortg.fiberia.com | Bad Credit Mortgage Memphis]
+
[http://arizonamortgageq.fiberia.com | Arizona Mortgage Rate]
+
[http://arizonamortgage1.fiberia.com | Arizona Mortgage Lender]
+
[http://arizonamortgage.fiberia.com | Arizona Mortgage Loan]
+
[http://arizonaloanmorw.fiberia.com | Arizona Loan Mortgage]
+
[http://applicationmorte.fiberia.com | Application Mortgage]
+
[http://applicationmort1.fiberia.com | Application Mortgage Online]
+
[http://advicemortgagew.fiberia.com | Advice Mortgage Online]
+
[http://adjustablerateqw.fiberia.com | Adjustable Rate Mortgage]
+
[http://adjustablemortga.fiberia.com | Adjustable Mortgage Rate]
+

Latest revision as of 19:42, 17 July 2010

Prepare strings for inclusion in statements

#include <opendbx/api.h>
int odbx_escape(
    odbx_t* handle,
    const char* from,
    unsigned long fromlen,
    char* to,
    unsigned long* tolen )

Description

odbx_escape() neutralizes potentially dangerous characters of the string so it can be used as part of a statement. For security reasons every user input has to be passed to odbx_escape() to avoid SQL injection attacks which can have fatal consequences! It's also a good idea to escape strings returned from database fields again if you want to use them in a query because they don't stay escaped once they are returned as part of a record.

Most backends require the buffer to be more than twice as long as the input string. To be precise, the output buffer must be 2 * size of input + 1 bytes long. After successfully escaping the characters in from, they are written into the memory provided via to and the value/result parameter tolen is updated to the new length of to in the end.

The first parameter handle is the connection object created and returned by odbx_init() which becomes invalid as soon as it was supplied to odbx_finish().

from has to point to a character string containing the string which should be used as part of a statement. It doesn't have to be zero-terminated because the length of it is also given via fromlen. The backends may support variable width character sets like UTF-8 but this function doesn't support the wide char type (wchar_t) where each character has a fixed size of two or four bytes.

The value of the parameter fromlen must be the length in bytes of the string which from is pointing to. This is also true for variable width character sets like UTF-8 but the wide char type (wchar_t) is not supported. The terminating \0 character shouldn't be part of fromlen.

The calling function provides a buffer for storing the escaped string via to. In general, the length of the buffer should be more than twice as long as the string passed via from to be able to store the escaped string even if every character has to be escaped.

tolen is a value-result parameter which points to an integer variable in the calling function. It must contain the original length of the buffer given via to and if escaping the string in from suceeded, odbx_escape() will store the new length of the escaped string in this variable.

Return value

odbx_escape() returns ODBX_ERR_SUCCESS, or an error code whose value is less than zero if one of the operations couldn't be completed successfully. Possible error codes are listed in the error section and they can be feed to odbx_error() and odbx_error_type() to get further details.

Errors

-ODBX_ERR_BACKEND 
The native database library returned an error because it wasn't able to escape the given string to be suitable for a statement
-ODBX_ERR_PARAM 
One of the supplied parameters is invalid or is NULL and this isn't allowed in the used backend module or in the native database client library
-ODBX_ERR_SIZE 
The length of the escaped string exceeds or is likely to exeed the available buffer (before 1.1.4 the name of the label was ODBX_ERR_TOOLONG but the value is still the same)

See also