SQL_QuoteString can now be used without a DB handle (bug 3427, r=sawce).

This commit is contained in:
David Anderson
2009-01-08 20:02:09 +00:00
parent d97ab913cf
commit 0b4f28fecf
8 changed files with 127 additions and 46 deletions

View File

@ -77,3 +77,4 @@ int SqliteDatabase::QuoteString(const char *str, char buffer[], size_t maxlen, s
return 0;
}

View File

@ -63,3 +63,15 @@ IDatabase *SqliteDriver::Connect(DatabaseInfo *info, int *errcode, char *error,
}
}
int SqliteDriver::QuoteString(const char *str, char buffer[], size_t maxlen, size_t *newsize)
{
char *res = sqlite3_snprintf(static_cast<int>(maxlen), buffer, "%q", str);
if (res != NULL && newsize != NULL)
{
*newsize = strlen(buffer);
}
return 0;
}

View File

@ -12,6 +12,7 @@ namespace SourceMod
IDatabase *Connect2(DatabaseInfo *info, int *errcode, char *error, size_t maxlength);
const char *NameString();
bool IsCompatDriver(const char *namestr);
int QuoteString(const char *str, char buffer[], size_t maxlen, size_t *newsize);
};
};