本文整理汇总了C++中check_error函数的典型用法代码示例。如果您正苦于以下问题:C++ check_error函数的具体用法?C++ check_error怎么用?C++ check_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: test
static enum piglit_result
test(void)
{
static const GLfloat dest_color[4] = { 0.75, 0.25, 0.25, 0.5 };
static const GLfloat test_color[4] = { 1.0, 0.25, 0.75, 0.25 };
static const GLfloat test_color1[4] = { 0.5, 0.5, 0.5, 0.5 };
GLfloat expected[4];
GLuint prog;
GLuint vs;
GLuint fs;
int i, j, k, o;
if (max_ds_buffers > 1) {
printf("Test only supports 1 dual source blending color buffer\n");
max_ds_buffers = 1;
}
prog = glCreateProgram();
vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text);
fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_text);
glAttachShader(prog, vs);
glAttachShader(prog, fs);
piglit_check_gl_error(GL_NO_ERROR);
glBindFragDataLocationIndexed(prog, 0, 0, "col0");
glBindFragDataLocationIndexed(prog, 0, 1, "col1");
create_fbo();
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
glLinkProgram(prog);
glUseProgram(prog);
uniform_src0 = glGetUniformLocation(prog, "src0");
uniform_src1 = glGetUniformLocation(prog, "src1");
/* Setup blend modes and compute expected result color.
* We only test two simple blending modes. A more elaborate
* test would exercise a much wider variety of modes.
*/
for (o = 0; o < ARRAY_SIZE(operators); o++) {
for (i = 0; i < ARRAY_SIZE(srcFactors); i++) {
for (j = 0; j < ARRAY_SIZE(dstFactors); j++) {
blend_expected(expected, test_color, test_color1,
dest_color, srcFactors[i],
dstFactors[j], operators[o]);
blend(test_color, test_color1, dest_color,
srcFactors[i], dstFactors[j],
operators[o]);
for (k = 0; k < max_ds_buffers; k++) {
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + k);
check_error(__LINE__);
if (!piglit_probe_pixel_rgba(5, 5, expected)) {
printf("For src/dst %d %d %d\n", i, j, o);
return PIGLIT_FAIL;
}
}
}
}
}
return PIGLIT_PASS;
}
开发者ID:blaztinn,项目名称:piglit,代码行数:67,代码来源:fbo-extended-blend.c
示例2: read_pipe_poll
/* Monitor a pipe for input */
void read_pipe_poll (HANDLE hStop, void *_data)
{
DWORD res;
DWORD event;
DWORD n;
LPSELECTQUERY iterQuery;
LPSELECTDATA lpSelectData;
DWORD i;
DWORD wait;
/* Poll pipe */
event = 0;
n = 0;
lpSelectData = (LPSELECTDATA)_data;
wait = 1;
DEBUG_PRINT("Checking data pipe");
while (lpSelectData->EState == SELECT_STATE_NONE)
{
for (i = 0; i < lpSelectData->nQueriesCount; i++)
{
iterQuery = &(lpSelectData->aQueries[i]);
res = PeekNamedPipe(
iterQuery->hFileDescr,
NULL,
0,
NULL,
&n,
NULL);
if (check_error(lpSelectData,
(res == 0) &&
(GetLastError() != ERROR_BROKEN_PIPE)))
{
break;
};
if ((n > 0) || (res == 0))
{
lpSelectData->EState = SELECT_STATE_SIGNALED;
select_data_result_add(lpSelectData, iterQuery->EMode, iterQuery->lpOrigIdx);
};
};
/* Alas, nothing except polling seems to work for pipes.
Check the state & stop_worker_event every 10 ms
*/
if (lpSelectData->EState == SELECT_STATE_NONE)
{
event = WaitForSingleObject(hStop, wait);
/* Fast start: begin to wait 1, 2, 4, 8 and then 10 ms.
* If we are working with the output of a program there is
* a chance that one of the 4 first calls succeed.
*/
wait = 2 * wait;
if (wait > 10)
{
wait = 10;
};
if (event == WAIT_OBJECT_0 || check_error(lpSelectData, event == WAIT_FAILED))
{
break;
}
}
}
DEBUG_PRINT("Finish checking data on pipe");
}
开发者ID:bmeurer,项目名称:ocaml-arm,代码行数:68,代码来源:select.c
示例3: glActiveTexture
void YCbCrInput::set_gl_state(GLuint glsl_program_num, const string& prefix, unsigned *sampler_num)
{
for (unsigned channel = 0; channel < num_channels; ++channel) {
glActiveTexture(GL_TEXTURE0 + *sampler_num + channel);
check_error();
if (texture_num[channel] == 0) {
GLenum format, internal_format;
if (channel == 1 && ycbcr_input_splitting == YCBCR_INPUT_SPLIT_Y_AND_CBCR) {
format = GL_RG;
internal_format = GL_RG8;
} else {
format = GL_RED;
internal_format = GL_R8;
}
// (Re-)upload the texture.
texture_num[channel] = resource_pool->create_2d_texture(internal_format, widths[channel], heights[channel]);
glBindTexture(GL_TEXTURE_2D, texture_num[channel]);
check_error();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
check_error();
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, pbos[channel]);
check_error();
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
check_error();
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch[channel]);
check_error();
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, widths[channel], heights[channel], format, GL_UNSIGNED_BYTE, pixel_data[channel]);
check_error();
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
check_error();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
check_error();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
check_error();
owns_texture[channel] = true;
} else {
glBindTexture(GL_TEXTURE_2D, texture_num[channel]);
check_error();
}
}
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
check_error();
// Bind samplers.
uniform_tex_y = *sampler_num + 0;
uniform_tex_cb = *sampler_num + 1;
if (ycbcr_input_splitting == YCBCR_INPUT_PLANAR) {
uniform_tex_cr = *sampler_num + 2;
}
*sampler_num += num_channels;
}
开发者ID:j-b-m,项目名称:movit,代码行数:55,代码来源:ycbcr_input.cpp
示例4: init_kwallet
// Initialize the connection to KWallet
static gboolean init_kwallet(backend_kwallet_context_t *context)
{
GError* error = NULL;
// Make a proxy to KWallet.
if(context->proxy)
g_object_unref(context->proxy);
context->proxy = g_dbus_proxy_new_sync(context->connection,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
kwallet_service_name,
kwallet_path,
kwallet_interface,
NULL,
&error);
if(check_error(error))
{
context->proxy = NULL;
return FALSE;
}
// Check KWallet is enabled.
GVariant *ret = g_dbus_proxy_call_sync(context->proxy,
"isEnabled",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
if(!ret)
return FALSE;
GVariant *child = g_variant_get_child_value(ret, 0);
gboolean is_enabled = g_variant_get_boolean(child);
g_variant_unref(child);
g_variant_unref(ret);
if(check_error(error) || !is_enabled)
return FALSE;
// Get the wallet name.
if(context->wallet_name)
g_free(context->wallet_name);
ret = g_dbus_proxy_call_sync(context->proxy,
"networkWallet",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
child = g_variant_get_child_value(ret, 0);
context->wallet_name = g_variant_dup_string(child, NULL);
g_variant_unref(child);
g_variant_unref(ret);
if(check_error(error) || !context->wallet_name)
{
context->wallet_name = NULL; // yes, it's stupid. go figure.
return FALSE;
}
return TRUE;
}
开发者ID:hauva69,项目名称:darktable,代码行数:68,代码来源:backend_kwallet.c
示例5: dt_pwstorage_kwallet_set
// Store (key,value) pairs from a GHashTable in the kwallet.
// Every 'slot' has to take care of it's own data.
gboolean dt_pwstorage_kwallet_set(const backend_kwallet_context_t *context, const gchar* slot, GHashTable* table)
{
printf("slot %s\n", slot);
GArray* byte_array = g_array_new(FALSE, FALSE, sizeof(gchar));
GHashTableIter iter;
g_hash_table_iter_init (&iter, table);
gpointer key, value;
guint size = g_hash_table_size(table);
size = GINT_TO_BE(size);
g_array_append_vals(byte_array, &size, sizeof(guint)/sizeof(gchar));
while (g_hash_table_iter_next (&iter, &key, &value))
{
dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_kwallet_set] storing (%s, %s)\n",(gchar*)key, (gchar*)value);
gsize length;
gchar* new_key = char2qstring(key, &length);
if(new_key == NULL)
{
g_free(g_array_free(byte_array, FALSE));
return FALSE;
}
g_array_append_vals(byte_array, new_key, length);
g_free(new_key);
gchar* new_value = char2qstring(value, &length);
if(new_value == NULL)
{
g_free(g_array_free(byte_array, FALSE));
return FALSE;
}
g_array_append_vals(byte_array, new_value, length);
g_free(new_value);
}
int wallet_handle = get_wallet_handle(context);
GError* error = NULL;
/* signature:
*
* in i handle,
* in s folder,
* in s key,
* in ay value,
* in s appid,
*
* out i arg_0
*/
GVariant *ret = g_dbus_proxy_call_sync(context->proxy,
"writeMap",
g_variant_new("([email protected])", wallet_handle, kwallet_folder, slot,
g_variant_new_from_data(G_VARIANT_TYPE_BYTESTRING,
byte_array->data,
byte_array->len,
TRUE,
g_free,
byte_array->data),
app_id),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
g_array_free(byte_array, FALSE);
if(check_error(error))
{
g_variant_unref(ret);
return FALSE;
}
GVariant *child = g_variant_get_child_value(ret, 0);
int return_code = g_variant_get_int32(child);
g_variant_unref(child);
g_variant_unref(ret);
if (return_code != 0)
dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_kwallet_set] Warning: bad return code %d from kwallet\n", return_code);
return return_code == 0;
}
开发者ID:hauva69,项目名称:darktable,代码行数:87,代码来源:backend_kwallet.c
示例6: cuda_free
void cuda_free(float *x_gpu)
{
cudaError_t status = cudaFree(x_gpu);
check_error(status);
}
开发者ID:KaiqiZhang,项目名称:darknet,代码行数:5,代码来源:cuda.c
示例7: cuda_pull_array
void cuda_pull_array(float *x_gpu, float *x, size_t n)
{
size_t size = sizeof(float)*n;
cudaError_t status = cudaMemcpy(x, x_gpu, size, cudaMemcpyDeviceToHost);
check_error(status);
}
开发者ID:KaiqiZhang,项目名称:darknet,代码行数:6,代码来源:cuda.c
示例8: jx_sqlFormatRow
/* ------------------------------------------------------------- */
PJXNODE jx_sqlFormatRow (PJXSQL pSQL)
{
int i;
PJXNODE pRow;
if ( pSQL->rc == SQL_SUCCESS) {
pRow = jx_NewObject(NULL);
for (i = 0; i < pSQL->nresultcols; i++) {
PJXCOL pCol = &pSQL->cols[i];
if (pCol->outlen != SQL_NULL_DATA) {
switch( pCol->coltype) {
case SQL_WCHAR:
case SQL_WVARCHAR:
case SQL_GRAPHIC:
case SQL_VARGRAPHIC: {
UCHAR temp [32768];
PUCHAR pInBuf = pCol->data;
size_t OutLen;
size_t inbytesleft;
for (inbytesleft = pCol->collen; inbytesleft > 0 ; inbytesleft -= 2) {
if ( * (PSHORT) (pInBuf + inbytesleft - 2) > 0x0020) break;
}
OutLen = XlateXdBuf (pConnection->pCd, temp , pInBuf, inbytesleft);
temp[OutLen] = '\0';
jx_NodeAdd (pRow , RL_LAST_CHILD, pCol->colname , temp, pCol->nodeType );
break;
}
case SQL_NUMERIC:
case SQL_DECIMAL:
case SQL_FLOAT:
case SQL_REAL:
case SQL_DOUBLE: {
PUCHAR p = pCol->data;
int len = strTrimLen(p);
p[len] = '\0';
// Have to fix .00 numeric as 0.00
if (*p == '.') {
memmove (p+1 , p, len+1);
*p = '0';
}
jx_NodeAdd (pRow , RL_LAST_CHILD, pCol->colname , p, pCol->nodeType );
break ;
}
default: {
PUCHAR p = pCol->data;
int len;
if (pCol->coltype != SQL_BLOB
&& pCol->coltype != SQL_CLOB) {
len = strTrimLen(p);
p[len] = '\0';
}
// trigger new parsing of JSON-objects in columns:
// Predicts json data i columns
if (pConnection->options.autoParseContent == ON) {
if (*p == BraBeg || *p == CurBeg) {
PJXNODE pNode = jx_ParseString(p, NULL);
if (pNode) {
jx_NodeRename(pNode, pCol->colname);
jx_NodeAddChildTail (pRow, pNode);
break;
}
}
}
jx_NodeAdd (pRow , RL_LAST_CHILD, pCol->colname , p, pCol->nodeType );
break;
}
}
}
}
return pRow; // Found
} else {
if (pSQL->rc != SQL_NO_DATA_FOUND ) {
check_error (pSQL);
}
}
return NULL; // not found
}
开发者ID:ataylorkt,项目名称:noxDB,代码行数:96,代码来源:JXM002_.C
示例9: jx_buildMetaFields
/* ------------------------------------------------------------- */
PJXNODE jx_buildMetaFields ( PJXSQL pSQL )
{
LONG attrParm;
PJXNODE pFields = jx_NewArray(NULL);
int i;
attrParm = SQL_TRUE;
pSQL->rc = SQLSetStmtAttr (pSQL->hstmt, SQL_ATTR_EXTENDED_COL_INFO , &attrParm , 0);
if (pSQL->rc != SQL_SUCCESS ) {
check_error (pSQL);
return NULL; // we have an error
}
for (i = 1; i <= pSQL->nresultcols; i++) {
PJXNODE pField = jx_NewObject (NULL);
PJXCOL pCol = &pSQL->cols[i-1];
PUCHAR type = "string";
UCHAR temp [256];
// Add name
jx_NodeAdd (pField , RL_LAST_CHILD, "name" , pCol->colname, VALUE );
// Add type
switch( pCol->coltype) {
case SQL_BLOB: type = "blob" ; break;
case SQL_CLOB: type = "clob" ; break;
case SQL_CHAR: type = "char" ; break;
case SQL_VARCHAR: type = "varchar" ; break;
case SQL_DATETIME: type = "datetime" ; break;
case SQL_DATE: type = "date" ; break;
case SQL_TIME: type = "time" ; break;
case SQL_TIMESTAMP: type = "timestamp" ; break;
case SQL_WCHAR: type = "wchar" ; break;
case SQL_WVARCHAR: type = "wvarchar" ; break;
case SQL_GRAPHIC: type = "graphic" ; break;
case SQL_VARGRAPHIC: type = "vargraphic" ; break;
default: {
if (pCol->coltype >= SQL_NUMERIC && pCol->coltype <= SQL_DOUBLE ) {
if (pCol->scale > 0) {
type = "dec" ;
} else {
type = "int" ;
}
} else {
sprintf(temp ,"unknown%d" , pCol->coltype);
type = temp;
}
}
}
jx_NodeAdd (pField , RL_LAST_CHILD, "datatype" , type, VALUE );
// Add size
sprintf(temp , "%d" , pCol->displaysize);
jx_NodeAdd (pField , RL_LAST_CHILD, "size" , temp, LITERAL );
// Add decimal precission
if (pCol->coltype >= SQL_NUMERIC && pCol->coltype <= SQL_DOUBLE
&& pCol->scale > 0) {
sprintf(temp , "%d" , pCol->scale);
jx_NodeAdd (pField , RL_LAST_CHILD, "prec" , temp, LITERAL );
}
// Push to array
jx_ArrayPush (pFields , pField, FALSE);
}
// jx_Debug ("Fields:", pFields);
return pFields;
}
开发者ID:ataylorkt,项目名称:noxDB,代码行数:73,代码来源:JXM002_.C
示例10: do_clean_ups
void do_clean_ups (MYSQL *mysql)
{
MYSQL_RES *res;
MYSQL_ROW row;
debug (1, "do_clean_ups");
/* auto logout */
/* alt where planet.mode & 0x0F = 2 */
res = do_query (mysql,"SELECT user.planet_id FROM user, planet " \
"WHERE planet.id=user.planet_id " \
"AND now() - INTERVAL 30 MINUTE > user.last "\
"AND (planet.mode = 0xF2 OR planet.mode = 2)");
if (res && mysql_num_rows(res)) {
while ((row = mysql_fetch_row (res))) {
vx_query(mysql, "UPDATE user SET uptime=" \
"SEC_TO_TIME(UNIX_TIMESTAMP(last) - UNIX_TIMESTAMP(login_date) + TIME_TO_SEC(uptime)) " \
"WHERE planet_id='%s'", row[0]);
vx_query (mysql,
"UPDATE planet SET mode=((mode & 0xF0) + 1) WHERE id=%s", row[0]);
do_log_id (mysql, atoi(row[0]), C_LOGOUT, T_AUTO, "");
}
}
check_error (mysql);
mysql_free_result(res);
/* protection */
/* alt where planet.mode & 0xF0 */
res = do_query (mysql,"SELECT user.planet_id FROM user,planet,general " \
"WHERE planet.id=user.planet_id " \
"AND planet.mode>127 " \
"AND general.tick>=user.first_tick+71");
if (res && mysql_num_rows(res)) {
while ((row = mysql_fetch_row (res))) {
vx_query (mysql, "UPDATE planet SET mode=(mode & 0xF) WHERE id=%s", row[0]);
}
}
check_error (mysql);
mysql_free_result(res);
/* sleeping */
/* alt where planet.mode & 0x0F = 3 */
res = do_query (mysql,"SELECT user.planet_id FROM user,planet " \
"WHERE planet.id=user.planet_id " \
"AND (planet.mode = 0xF3 OR planet.mode = 3) " \
"AND user.last_sleep < now() - INTERVAL 6 HOUR");
if (res && mysql_num_rows(res)) {
while ((row = mysql_fetch_row (res))) {
vx_query (mysql, "UPDATE planet SET mode=(mode & 0xF0)+1 WHERE id=%s", row[0]);
do_log_id (mysql, atoi(row[0]), C_FLOW, T_SLEEP, "");
}
}
check_error (mysql);
mysql_free_result(res);
/* clean politics */
res = do_query (mysql,"SELECT id FROM politics " \
"WHERE now() - INTERVAL 7 DAY > date");
if (res && mysql_num_rows(res)) {
while ((row = mysql_fetch_row (res))) {
vx_query (mysql, "DELETE FROM politics WHERE id = %s", row[0]);
vx_query (mysql, "DELETE FROM poltext WHERE thread_id = %s", row[0]);
}
}
check_error (mysql);
mysql_free_result(res);
/* delete idle/old/test accounts */
/* only if mytick > 24 hours = 120*24 = 1440 */
if (mytick > 2880) {
res = do_query (mysql, "SELECT planet.id FROM planet,user "\
"WHERE planet.id=user.planet_id "\
"AND planet.id>2 "\
"AND (metalroids+crystalroids+eoniumroids+uniniroids) < 4 " \
"AND (user.last < NOW() - INTERVAL 24 HOUR " \
"OR (user.last IS NULL "\
"AND user.signup < NOW() - INTERVAL 24 HOUR))");
if (res && mysql_num_rows(res)) {
while ((row = mysql_fetch_row (res)))
delete_user(mysql, atoi(row[0]));
}
}
/* delete deleted accounts */
res = do_query (mysql, "SELECT planet_id FROM user "\
"WHERE delete_date !=0 AND delete_date > last " \
"AND delete_date < NOW() - INTERVAL 12 HOUR");
if (res && mysql_num_rows(res)) {
while ((row = mysql_fetch_row (res)))
delete_user(mysql, atoi(row[0]));
//.........这里部分代码省略.........
开发者ID:jaypeeteeB,项目名称:MyPHPpa,代码行数:101,代码来源:cleanup.c
示例11: jx_sqlOpen
/* ------------------------------------------------------------- */
PJXSQL jx_sqlOpen(PUCHAR sqlstmt , PJXNODE pSqlParms)
{
PNPMPARMLISTADDRP pParms = _NPMPARMLISTADDR();
// LONG format = (pParms->OpDescList->NbrOfParms >= 3) ? formatP : 0; // Status & result object
LONG attrParm;
LONG i;
// PJXSQL pSQL = jx_sqlNewStatement (pParms->OpDescList->NbrOfParms >= 2 ? pSqlParms :NULL);
PJXSQL pSQL = jx_sqlNewStatement (NULL);
pSQL->rc = SQLAllocStmt(pConnection->hdbc, &pSQL->hstmt);
if (pSQL->rc != SQL_SUCCESS ) {
check_error (pSQL);
return NULL; // we have an error
}
attrParm = SQL_TRUE;
pSQL->rc = SQLSetStmtAttr (pSQL->hstmt, SQL_ATTR_CURSOR_SCROLLABLE , &attrParm , 0);
if (pSQL->rc != SQL_SUCCESS ) {
check_error (pSQL);
return NULL; // we have an error
}
/*
attrParm = SQL_TRUE;
pSQL->rc = SQLSetStmtAttr (pSQL->hstmt, SQL_ATTR_EXTENDED_COL_INFO , &attrParm , 0);
if (pSQL->rc != SQL_SUCCESS ) {
check_error (pSQL);
return NULL; // we have an error
}
*/
attrParm = SQL_CONCUR_READ_ONLY;
pSQL->rc = SQLSetStmtAttr (pSQL->hstmt, SQL_ATTR_CONCURRENCY , &attrParm , 0);
if (pSQL->rc != SQL_SUCCESS ) {
check_error (pSQL);
return NULL; // we have an error
}
// run the statement in "sqlstr"
if (pParms->OpDescList->NbrOfParms >= 2 && pSqlParms ) {
UCHAR sqlTempStmt[32766];
strFormat(sqlTempStmt , sqlstmt , pSqlParms);
pSQL->sqlstmt = strdup(sqlTempStmt);
} else {
pSQL->sqlstmt = strdup(sqlstmt);
}
pSQL->rc = SQLExecDirect (pSQL->hstmt, pSQL->sqlstmt, SQL_NTS);
if (pSQL->rc != SQL_SUCCESS && pSQL->rc != SQL_NO_DATA_FOUND) {
check_error (pSQL);
return NULL; // we have an error
}
// Number of rows? .. No does not work :(
/*
SQLGetDiagField(SQL_HANDLE_STMT,pSQL->hstmt, 0 ,SQL_DIAG_ROW_COUNT,&pSQL->rowcount,0, NULL);
*/
/*
// Row count is only affected row in a "delete" or "update" ..TODO find a solution for select
pSQL->rc = SQLRowCount (pSQL->hstmt, &pSQL->rowcount);
if (pSQL->rc != SQL_SUCCESS ) {
check_error (pSQL);
return; // we have an error
}
*/
pSQL->rc = SQLNumResultCols (pSQL->hstmt, &pSQL->nresultcols);
if (pSQL->rc != SQL_SUCCESS ) {
check_error (pSQL);
return NULL; // we have an error
}
for (i = 0; i < pSQL->nresultcols; i++) {
PJXCOL pCol = &pSQL->cols[i];
SQLDescribeCol (pSQL->hstmt, i+1, pCol->colname, sizeof (pCol->colname),
&pCol->colnamelen, &pCol->coltype, &pCol->collen, &pCol->scale, &pCol->nullable);
pCol->colname[pCol->colnamelen] = '\0';
if (OFF == jx_IsTrue (pConnection->pOptions ,"uppercasecolname")) {
str2lower (pCol->colname , pCol->colname);
}
// get display label for column
/****************
pSQL->rc = SQLColAttributes (hstmt, i+1, SQL_DESC_LABEL, Label , sizeof(Label) , &len , NULL);
if (pSQL->rc != SQL_SUCCESS ) {
check_error (pSQL);
return; // we have an error
}
***********/
//.........这里部分代码省略.........
开发者ID:ataylorkt,项目名称:noxDB,代码行数:101,代码来源:JXM002_.C
示例12: do_query
/*
res = do_query (mysql,"SELECT id, x, y, exile_id "\
"FROM galaxy WHERE exile_id>0 AND exile_date<now()");
*/
void check_exile (MYSQL *mysql, int gid, int x, int y, int pid)
{
static char c_fmt[] = "SELECT has_hostile, gal_hostile FROM planet WHERE id=%d";
static char q_fmt[] = "SELECT exile_vote FROM planet, user " \
"WHERE planet.x=%d AND planet.y=%d AND planet.id = user.planet_id " \
"AND user.last > now() - interval 36 HOUR AND mode not in (0, 4)";
MYSQL_RES *res;
MYSQL_ROW row;
int found=0, exile_cnt=0, active_cnt=0;
debug (3, "check_exile");
/* target still there ? */
res = vx_query (mysql, c_fmt, pid);
if (!res || mysql_num_rows(res)==0) {
fprintf (logfile, "[Exile]: cancelled - planet gone [%d]\n", pid);
fflush(logfile);
remove_vote (mysql, gid, x, y, pid, -1);
return;
}
row = mysql_fetch_row(res);
if (atoi(row[0])!=0 || atoi(row[1])!=0) {
/* under attack - wait a tick */
fprintf (logfile, "[Exile]: planet [%d] - gal under attack; delayed\n", pid);
mysql_free_result(res);
return;
}
check_error (mysql);
mysql_free_result(res);
/* vote succesfull ? */
res = vx_query (mysql, q_fmt, x, y);
if (!res || mysql_num_rows(res)<1)
return;
while ((row = mysql_fetch_row (res))) {
active_cnt++;
if (atoi(row[0]) == 1) {
exile_cnt++;
}
}
check_error (mysql);
mysql_free_result(res);
fprintf (logfile, "[Exile]: (%d:%d) [%d], %d / %d\n",
x, y, pid, exile_cnt, active_cnt);
/* exile or not */
if ((exile_cnt*1.5) > active_cnt) {
if (exile_planet (mysql, gid, pid)) {
return;
}
found = 1;
}
/* remove_vote */
remove_vote (mysql, gid, x, y, pid, found);
check_error (mysql);
}
开发者ID:jaypeeteeB,项目名称:MyPHPpa,代码行数:67,代码来源:cleanup.c
示例13: get_new_coords
int get_new_coords (MYSQL *mysql, int *x, int *y, int *z, int *gid)
{
MYSQL_RES *res;
MYSQL_ROW row;
int low=1, high=1, max_high=0;
int cnt=0, rval;
debug (4, "get_new_coords");
/* universe size */
res = do_query (mysql, "SELECT x FROM galaxy ORDER BY x DESC LIMIT 1");
row = mysql_fetch_row (res);
max_high = atoi(row[0]);
check_error (mysql);
mysql_free_result(res);
/* lowest cluster w free planets */
res = vx_query (mysql, "SELECT x FROM galaxy WHERE members<%d AND !(x=1 AND y=1) "\
"ORDER BY x ASC LIMIT 1", GALAXY_SIZE);
if (!res || mysql_num_rows(res)<1) {
return 1;
}
row = mysql_fetch_row (res);
low = atoi(row[0]);
check_error (mysql);
mysql_free_result(res);
/* highest cluster w members */
res = vx_query (mysql, "SELECT x FROM galaxy WHERE members>0 "\
"ORDER BY x DESC LIMIT 1");
row = mysql_fetch_row (res);
high = atoi(row[0]);
check_error (mysql);
mysql_free_result(res);
if (high < low)
high = low;
/* check Open clusters */
do {
res = vx_query (mysql, "SELECT x,y,id FROM galaxy WHERE x>=%d AND x<=%d "\
"AND members<%d AND !(x=1 and y=1) GROUP BY x, y",
low, high, GALAXY_SIZE);
if (!res) return 1;
cnt = mysql_num_rows(res);
if (cnt==0) {
/* next cluster */
low = high + 1;
if (low > max_high) return 1;
high = low;
}
} while (cnt==0);
if (cnt != 1) {
/* generate random value */
srand ((time(NULL) * (*gid + 1)));
rval = 1 + (int) (((float)cnt - 1.) * rand()/(RAND_MAX+1.0));
} else {
rval = 1;
}
/* fetch bis zum nten */
while (rval>1) {
row = mysql_fetch_row(res);
rval--;
}
row = mysql_fetch_row(res);
*x = atoi(row[0]);
*y = atoi(row[1]);
*gid = atoi(row[2]);
mysql_free_result(res);
res = vx_query (mysql, "SELECT z FROM planet WHERE x=%d AND y=%d "\
"ORDER BY z DESC LIMIT 1", *x, *y);
if (res && mysql_num_rows(res)) {
row = mysql_fetch_row(res);
*z = 1 + atoi(row[0]);
} else
*z = 1;
check_error (mysql);
mysql_free_result(res);
return 0;
}
开发者ID:jaypeeteeB,项目名称:MyPHPpa,代码行数:92,代码来源:cleanup.c
示例14: test_fbo
/** \return GL_TRUE for pass, GL_FALSE for fail */
static bool
test_fbo(const struct format_info *info)
{
const int comps = num_components(info->BaseFormat);
const GLenum type = get_datatype(info);
GLint f;
GLuint fbo, texObj;
GLenum status;
GLboolean intMode;
GLint buf;
bool pass = true;
if (0)
fprintf(stderr, "============ Testing format = %s ========\n", info->Name);
/* Create texture */
glGenTextures(1, &texObj);
glBindTexture(GL_TEXTURE_2D, texObj);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, info->IntFormat, TexWidth, TexHeight, 0,
info->BaseFormat, type, NULL);
if (check_error(__FILE__, __LINE__))
return GL_FALSE;
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &f);
assert(f == info->IntFormat);
/* Create FBO to render to texture */
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D, texObj, 0);
if (check_error(__FILE__, __LINE__))
return GL_FALSE;
status = glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
fprintf(stderr, "%s: failure: framebuffer incomplete.\n", TestName);
return GL_FALSE;
}
glGetBooleanv(GL_RGBA_INTEGER_MODE_EXT, &intMode);
if (check_error(__FILE__, __LINE__))
return GL_FALSE;
if (!intMode) {
fprintf(stderr, "%s: GL_RGBA_INTEGER_MODE_EXT return GL_FALSE\n",
TestName);
return GL_FALSE;
}
glGetIntegerv(GL_READ_BUFFER, &buf);
assert(buf == GL_COLOR_ATTACHMENT0_EXT);
glGetIntegerv(GL_DRAW_BUFFER, &buf);
assert(buf == GL_COLOR_ATTACHMENT0_EXT);
/* test clearing */
if (1) {
/* clear with an integer - exp unsigned int */
static const GLint clr_i[4] = { 300000005, -7, 6, 5 };
static const GLuint exp_ui[4] = { 300000005, 0, 6, 5 };
/* clear with an unsigned integer - exp int */
static const GLuint clr_ui[4] = { 300000005, 0x80000007, 6, 5 };
static const GLint exp_i[4] = { 300000005, 0x7fffffff, 6, 5 };
GLint pix[4], i;
GLuint pix_ui[4];
if (info->Signed)
glClearColorIiEXT(clr_i[0], clr_i[1], clr_i[2], clr_i[3]);
else
glClearColorIuiEXT(clr_ui[0], clr_ui[1], clr_ui[2], clr_ui[3]);
glClear(GL_COLOR_BUFFER_BIT);
if (info->Signed)
glReadPixels(5, 5, 1, 1, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_INT, pix_ui);
else
glReadPixels(5, 5, 1, 1, GL_RGBA_INTEGER_EXT, GL_INT, pix);
if (info->Signed) {
for (i = 0; i < comps; i++) {
if (pix_ui[i] != exp_ui[i]) {
fprintf(stderr, "%s: glClear failed\n", TestName);
fprintf(stderr, " Texture format = %s\n", info->Name);
fprintf(stderr, " Expected %u, %u, %u, %u\n",
exp_ui[0], exp_ui[1], exp_ui[2], exp_ui[3]);
fprintf(stderr, " Found %u, %u, %u, %u\n",
pix_ui[0], pix_ui[1], pix_ui[2], pix_ui[3]);
pass = false;
break;
}
}
} else {
for (i = 0; i < comps; i++) {
//.........这里部分代码省略.........
开发者ID:nobled,项目名称:piglit,代码行数:101,代码来源:fbo-integer-readpixels-sint-uint.c
示例15: piglit_display
enum piglit_result
piglit_display(void)
{
GLuint tex;
static const float red[] = { 1, 0, 0, 1 };
static const float green[] = { 0, 1, 0, 1 };
static const float blue[] = { 0, 0, 1, 1 };
static const float cyan[] = { 0, 1, 1, 1 };
pass = GL_TRUE;
extension_supported =
piglit_is_extension_supported("GL_EXT_unpack_subimage");
if (!piglit_automatic) {
if (extension_supported)
printf("GL_EXT_unpack_subimage is supported\n");
else
printf("GL_EXT_unpack_subimage is not supported\n");
}
piglit_reset_gl_error();
if (!piglit_automatic)
printf("Trying GL_UNPACK_ROW_LENGTH\n");
glPixelStorei(GL_UNPACK_ROW_LENGTH, 2);
check_error();
piglit_reset_gl_error();
if (!piglit_automatic)
printf("Trying GL_UNPACK_SKIP_PIXELS\n");
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 1);
check_error();
piglit_reset_gl_error();
if (!piglit_automatic)
printf("Trying GL_UNPACK_SKIP_ROWS\n");
glPixelStorei(GL_UNPACK_SKIP_ROWS, 4);
check_error();
glClear(GL_COLOR_BUFFER_BIT);
/* Try creating a texture with the unpacking parameters we've set */
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexImage2D(GL_TEXTURE_2D,
0, /* level */
GL_RGBA, /* internalFormat */
1, /* width */
2, /* height */
0, /* border */
GL_RGBA, /* format */
GL_UNSIGNED_BYTE, /* type */
tex_data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
make_program(vertex_shader, fragment_shader);
piglit_draw_rect_tex(-1, -1, 2, 2,
0, 0, 1, 1);
if (extension_supported) {
pass &= piglit_probe_pixel_rgba(piglit_width / 2,
piglit_height / 4,
blue);
pass &= piglit_probe_pixel_rgba(piglit_width / 2,
piglit_height * 3 / 4,
cyan);
} else {
pass &= piglit_probe_pixel_rgba(piglit_width / 2,
piglit_height / 4,
red);
pass &= piglit_probe_pixel_rgba(piglit_width / 2,
piglit_height * 3 / 4,
green);
}
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
开发者ID:dervishxgit,项目名称:piglit,代码行数:79,代码来源:ext_unpack_subimage.c
示例16: jx_sqlNewConnection
/* ------------------------------------------------------------- */
static PJXSQLCONNECT jx_sqlNewConnection(void )
{
// static SQLHSTMT hstmt = 0 ;
// SQLINTEGEREGER len;
// UCHAR Label [256];
// LGL err = ON;
// LONG rows =0;
PJXSQLCONNECT pConnection;
LONG attrParm;
PUCHAR server = "*LOCAL";
int rc;
PSQLOPTIONS po;
pConnection = memAlloc(sizeof(JXSQLCONNECT));
memset(pConnection , 0 , sizeof(JXSQLCONNECT));
pConnection->pCd = XlateXdOpen (13488, 0);
po = &pConnection->options;
po->upperCaseColName = OFF;
po->autoParseContent = ON;
po->DecimalPoint = '.';
po->hexSort = OFF;
po->sqlNaming = OFF;
po->DateSep = '-';
po->DateFmt = 'y';
po->TimeSep = ':';
po->TimeFmt = 'H';
// allocate an environment handle
rc = SQLAllocEnv (&pConnection->henv);
if (rc != SQL_SUCCESS ) {
check_error (NULL);
jx_sqlDisconnect (pConnection);
return NULL; // we have an error
}
// Note - this is invers: Default to IBMi naming
attrParm = pConnection->options.sqlNaming == ON ? SQL_FALSE : SQL_TRUE;
rc = SQLSetEnvAttr (pConnection->henv, SQL_ATTR_SYS_NAMING, &attrParm , 0);
if (rc != SQL_SUCCESS ) {
check_error (NULL);
jx_sqlDisconnect (pConnection);
return NULL; // we have an error
}
/*
attrParm = SQL_TRUE;
rc = SQLSetEnvAttr (pConnection->henv, SQL_ATTR_UTF8 , &attrParm , 0);
if (pSQL->rc != SQL_SUCCESS ) {
jx_sqlDisconnect (pConnection);
return NULL; // we have an error
}
*/
rc = SQLAllocConnect (pConnection->henv, &pConnection->hdbc); // allocate a connection handle
if (rc != SQL_SUCCESS ) {
check_error (NULL);
jx_sqlDisconnect (pConnection);
return NULL; // we have an error
}
attrParm = SQL_TXN_NO_COMMIT;
rc = SQLSetConnectAttr (pConnection->hdbc, SQL_ATTR_COMMIT , &attrParm , 0);
if (rc != SQL_SUCCESS ) {
check_error (NULL);
jx_sqlDisconnect (pConnection);
return NULL; // we have an error
}
rc = SQLConnect (pConnection->hdbc, server , SQL_NTS, NULL, SQL_NTS, NULL, SQL_NTS);
if (rc != SQL_SUCCESS ) {
check_error (NULL);
jx_sqlDisconnect (pConnection);
return NULL; // we have an error
}
return pConnection; // we are ok
}
开发者ID:ataylorkt,项目名称:noxDB,代码行数:81,代码来源:JXM002_.C
示例17: cuda_set_device
void cuda_set_device(int n)
{
gpu_index = n;
cudaError_t status = cudaSetDevice(n);
check_error(status);
}
开发者ID:KaiqiZhang,项目名称:darknet,代码行数:6,代码来源:cuda.c
示例18: jx_sqlUpsert
/* ------------------------------------------------------------- */
LGL jx_sqlUpsert (BOOL update, PUCHAR table , PJXNODE pSqlParms , PUCHAR where)
{
LONG attrParm;
LONG i;
UCHAR sqlTempStmt[32766];
PUCHAR stmt = sqlTempStmt;
PJXNODE pNode;
PUCHAR comma = "";
PUCHAR name, value;
SQLSMALLINT length;
SQLHDBC hdbctmp;
SQLHSTMT hstmttmp;
SQLRETURN rc;
PJXSQL pSQL = jx_sqlNewStatement (NULL);
SQLCHUNK sqlChunk[32];
SHORT sqlChunkIx =0;
PUCHAR sqlNullPtr = NULL;
// First get the columen types - by now we use a select to mimic that
// allocate a statement handle
pSQL->rc = SQLAllocHandle(SQL_HANDLE_STMT, pConnection->hdbc , &hstmttmp);
if (pSQL->rc != SQL_SUCCESS ) {
SQLError( pConnection->henv, pConnection->hdbc , hstmttmp, pConnection->sqlState ,
&pConnection->sqlCode, pConnection->sqlMsgDta ,
sizeof(pConnection->sqlMsgDta), &length);
substr ( jxMessage , pConnection->sqlMsgDta , length);
return ON; // we have an error
}
stmt = sqlTempStmt;
stmt += sprintf (stmt , "select ");
comma = "";
pNode = jx_GetNode(pSqlParms, "/");
while (pNode) {
name = jx_GetNodeNamePtr (pNode);
stmt += sprintf (stmt , "%s%s" , comma , name);
comma = ",";
pNode = jx_GetNodeNext(pNode);
}
stmt += sprintf (stmt , " from %s where 1=0" , table);
// prepare the statement */
pSQL->rc = SQLPrepare(hstmttmp , sqlTempStmt, SQL_NTS);
if (pSQL->rc != SQL_SUCCESS ) {
SQLError( pConnection->henv, pConnection->hdbc , hstmttmp, pConnection->sqlState ,
&pConnection->sqlCode, pConnection->sqlMsgDta ,
sizeof(pConnection->sqlMsgDta), &length);
substr ( jxMessage , pConnection->sqlMsgDta , length);
SQLFreeStmt(hstmttmp, SQL_CLOSE);
return ON; // we have an error
}
// Now we have the colume definitions - now build the update statement:
// allocate a statement handle
pSQL->rc = SQLAllocHandle(SQL_HANDLE_STMT, pConnection->hdbc , &pSQL->hstmt);
if (pSQL->rc != SQL_SUCCESS ) {
check_error (pSQL);
SQLFreeStmt(hstmttmp, SQL_CLOSE);
return ON; // we have an error
}
// This need to allow update
attrParm = SQL_INSENSITIVE;
pSQL->rc = SQLSetStmtAttr (pSQL->hstmt, SQL_ATTR_CURSOR_SENSITIVITY , &attrParm , 0);
if (pSQL->rc != SQL_SUCCESS ) {
check_error (pSQL);
return ON; // we have an error
}
if (update) {
buildUpdate (hstmttmp, sqlTempStmt , table, pSqlParms , where);
} else {
buildInsert (hstmttmp, sqlTempStmt , table, pSqlParms , where);
}
// prepare the statement that provides the coloumn types
pSQL
|
请发表评论