Example #1
0
void db_select1(int32_t* value) {
    if (debug) {
        fprintf(stderr, "db_select1()\n");
    }
    PGresult* res = PQexecPrepared(conn,
            STMT_ID_SELECT1,
            0,
            NULL,
            NULL,
            NULL,
            1);
    CHECK_RESULT(res);
    *value = -1;
    if (PQntuples(res) == 0) {
        fprintf(stderr, "db_select1() return no rows\n");
        if (exit_on_error) {
            exit(EXIT_FAILURE);
        }
        PQclear(res);
    } else {
        *value = ntohl(*(int32_t *) PQgetvalue(res, 0, 0));
        if (debug) {
            fprintf(stderr, "db_select1() return %d\n", *value);
        }
    }
    PQclear(res);
}
Example #2
0
/**
 * \brief Check for interrupt without wait
 * \param port a GPPort
 * \param data a pointer to an allocated buffer
 * \param size the number of bytes that should be read
 *
 * Reads a specified number of bytes from the inerrupt endpoint
 * into the supplied buffer.
 * Function waits 50 miliseconds for data on interrupt endpoint.
 *
 * \return a gphoto2 error code
 **/
int
gp_port_check_int_fast (GPPort *port, char *data, int size)
{
        int retval;

        gp_log (GP_LOG_DATA, __func__, "Reading %i = 0x%x bytes from interrupt endpoint...", size, size);

	C_PARAMS (port);
	CHECK_INIT (port);

	/* Check if we read as many bytes as expected */
	CHECK_SUPP (port, "check_int", port->pc->ops->check_int);
	retval = port->pc->ops->check_int (port, data, size, FAST_TIMEOUT);
	CHECK_RESULT (retval);

#ifdef IGNORE_EMPTY_INTR_READS
	/* For Canon cameras, we will make lots of
	   reads that will return zero length. Don't
	   bother to log them as errors. */
	if (retval != 0 )
#endif
		LOG_DATA (data, retval, size, "Read   ", "from interrupt endpoint (fast):");

	return (retval);
}
Example #3
0
void db_select(int32_t id, int32_t* value) {
    if (debug) {
        fprintf(stderr, "db_select(%d)\n", id);
    }
    int32_t _id = htonl(id);
    const char* paramValues[] = {
        (const char*) &_id,
    };
    PGresult* res = PQexecPrepared(conn,
            STMT_ID_SELECT,
            1,
            paramValues,
            paramLengths,
            paramFormats,
            1);
    CHECK_RESULT(res);
    *value = -1;
    if (PQntuples(res) == 0) {
        fprintf(stderr, "db_select(%d) return no rows\n", id);
        if (exit_on_error) {
            exit(EXIT_FAILURE);
        }
        PQclear(res);
    } else {
        *value = ntohl(*(int32_t *) PQgetvalue(res, 0, 0));
        if (debug) {
            fprintf(stderr, "db_select(%d) return %d\n", id, *value);
        }
    }
    PQclear(res);
}
Example #4
0
void Java_org_fmod_playsound_Example_cPlaySound(JNIEnv *env, jobject thiz, int id)
{
	FMOD_RESULT result = FMOD_OK;

	result = FMOD_System_PlaySound(gSystem, FMOD_CHANNEL_FREE, gSound[id], 0, &gChannel);
	CHECK_RESULT(result);
}
Example #5
0
GPResult gpiAuthBuddyRequest
( 
	GPConnection * connection,
	GPProfile profile
)
{
	GPIProfile * pProfile;
	GPIConnection * iconnection = (GPIConnection*)*connection;

	// Get the profile object.
	//////////////////////////
	if(!gpiGetProfile(connection, profile, &pProfile))
		Error(connection, GP_PARAMETER_ERROR, "Invalid profile.");

	// Check for a valid sig.
	/////////////////////////
	if(!pProfile->authSig)
		Error(connection, GP_PARAMETER_ERROR, "Invalid profile.");

	// Send the request.
	////////////////////
	CHECK_RESULT(gpiSendAuthBuddyRequest(connection, pProfile));

	// freeclear the sig if no more requests.
	////////////////////////////////////
	pProfile->requestCount--;
	if(!iconnection->infoCaching && (pProfile->requestCount <= 0))
	{
		freeclear(pProfile->authSig);
		if(gpiCanFreeProfile(pProfile))
			gpiRemoveProfile(connection, pProfile);
	}

	return GP_NO_ERROR;
}
Example #6
0
void Java_org_fmod_playsound_Example_cUpdate(JNIEnv *env, jobject thiz)
{
	FMOD_RESULT	result = FMOD_OK;

	result = FMOD_System_Update(gSystem);
	CHECK_RESULT(result);
}
Example #7
0
void Begin()
{
	FMOD_RESULT result = FMOD_OK;

	result = FMOD_System_Create(&gSystem);
	CHECK_RESULT(result);

	result = FMOD_System_Init(gSystem, 32, FMOD_INIT_NORMAL, 0);
	CHECK_RESULT(result);

	result = FMOD_System_CreateSound(gSystem, "/sdcard/fmod/wave.mp3", FMOD_DEFAULT | FMOD_LOOP_NORMAL, 0, &gSound);
	CHECK_RESULT(result);

	result = FMOD_System_PlaySound(gSystem, FMOD_CHANNEL_FREE, gSound, 0, &gChannel);
	CHECK_RESULT(result);
}
Example #8
0
/**
 * \brief Send a USB control message with input data
 *
 * \param port a GPPort
 * \param request control request code
 * \param value control value
 * \param index control index
 * \param bytes pointer to data
 * \param size size of the data
 *
 * Sends a specific USB interface control command and read associated data.
 *
 * \return a gphoto2 error code
 */
int
gp_port_usb_msg_read (GPPort *port, int request, int value, int index,
	char *bytes, int size)
{
        int retval;

	gp_log (GP_LOG_DEBUG, "gphoto2-port", _("Reading message "
		"(request=0x%x value=0x%x index=0x%x size=%i=0x%x)..."),
		request, value, index, size, size);

	CHECK_NULL (port);
	CHECK_INIT (port);

	CHECK_SUPP (port, "msg_read", port->pc->ops->msg_read);
        retval = port->pc->ops->msg_read (port, request, value, index, bytes, size);
	CHECK_RESULT (retval);

	if (retval != size)
		gp_log (GP_LOG_DEBUG, "gphoto2-port", ngettext(
			"Could only read %i out of %i byte",
			"Could only read %i out of %i bytes",
			size
		), retval, size);

	gp_log_data ("gphoto2-port", bytes, retval);
        return (retval);
}
Example #9
0
static PyObject* wsql_result_fetch_row_async(wsql_result *self)
{
    PyObject *row = NULL, *result = NULL;
    MYSQL_ROW mysql_row;
    net_async_status status;

    CHECK_RESULT(self, NULL);

    status = mysql_fetch_row_nonblocking(self->result, &mysql_row);

    if (status == NET_ASYNC_NOT_READY)
    {
        row = Py_None;
        Py_INCREF(row);
    }
    else
    {
        row = wsql_result_convert_row(self, mysql_row);
    }

    if (row)
    {
        result = Py_BuildValue("(iO)", status, row);
        Py_DECREF(row);
        return result;
    }

    return NULL;
}
Example #10
0
int marshal_record(record *data, unsigned char **_out, size_t *_size) {
int _result;
_result = marshal_key(&(*data).k, _out, _size);
CHECK_RESULT();
_result = marshal_unsigned_int(&(*data).data.count, _out, _size);
CHECK_RESULT();
if ((*data).data.count > 1024) return -1;
{
size_t i;
for (i = 0; i < (*data).data.count; i++) {
_result = marshal_opaque(&(*data).data.data[i], _out, _size);
CHECK_RESULT();
}
}
return 0;
}
Example #11
0
void Java_org_fmod_programmerselected_Example_cEnd(JNIEnv *env, jobject thiz)
{
	FMOD_RESULT result = FMOD_OK;

	result = FMOD_EventSystem_Release(gEventSystem);
	CHECK_RESULT(result);
}
Example #12
0
int marshal_opaque_auth(opaque_auth *data, unsigned char **_out, size_t *_size) {
int _result;
_result = marshal_auth_flavor(&(*data).flavor, _out, _size);
CHECK_RESULT();
_result = marshal_unsigned_int(&(*data).body.count, _out, _size);
CHECK_RESULT();
if ((*data).body.count > 400) return -1;
{
size_t i;
for (i = 0; i < (*data).body.count; i++) {
_result = marshal_opaque(&(*data).body.data[i], _out, _size);
CHECK_RESULT();
}
}
return 0;
}
Example #13
0
/**
 * \brief Check for intterupt.
 *
 * \param port a GPPort
 * \param data a pointer to an allocated buffer
 * \param size the number of bytes that should be read
 *
 * Reads a specified number of bytes from the interrupt endpoint
 * into the supplied buffer.
 * Function waits port->timeout miliseconds for data on interrupt endpoint.
 *
 * \return a gphoto2 error code
 **/
int
gp_port_check_int (GPPort *port, char *data, int size)
{
        int retval;

	gp_log (GP_LOG_DEBUG, "gphoto2-port",
		ngettext(
	"Reading %i=0x%x byte from interrupt endpoint...",
	"Reading %i=0x%x bytes from interrupt endpoint...",
	size), size, size);

	CHECK_NULL (port);
	CHECK_INIT (port);

	/* Check if we read as many bytes as expected */
	CHECK_SUPP (port, "check_int", port->pc->ops->check_int);
	retval = port->pc->ops->check_int (port, data, size, port->timeout);
	CHECK_RESULT (retval);
	if (retval != size)
		gp_log (GP_LOG_DEBUG, "gphoto2-port", _("Could only read %i "
			"out of %i byte(s)"), retval, size);

	gp_log_data ("gphoto2-port", data, retval);

	return (retval);
}
Example #14
0
GPResult
gpiCheckConnect(
  GPConnection * connection
)
{
	GPIConnection * iconnection = (GPIConnection*)*connection;
	int state;
	
	// Check if the connection is completed.
	////////////////////////////////////////
	CHECK_RESULT(gpiCheckSocketConnect(connection, iconnection->cmSocket, &state));
	
	// Check for a failed attempt.
	//////////////////////////////
	if(state == GPI_DISCONNECTED)
		CallbackFatalError(connection, GP_SERVER_ERROR, GP_LOGIN_CONNECTION_FAILED, "The server has refused the connection.");

	// Check if not finished connecting.
	////////////////////////////////////
	if(state == GPI_NOT_CONNECTED)
		return GP_NO_ERROR;
	
	// We're now negotiating the connection.
	////////////////////////////////////////
	assert(state == GPI_CONNECTED);
	iconnection->connectState = GPI_NEGOTIATING;

	return GP_NO_ERROR;
}
Example #15
0
int marshal_result(result *data, unsigned char **_out, size_t *_size) {
int _result;
_result = marshal_result_status(&(*data).status, _out, _size);
CHECK_RESULT();
_result = marshal_unsigned_int(&(*data).rec.count, _out, _size);
CHECK_RESULT();
if ((*data).rec.count > 1) return -1;
{
size_t i;
for (i = 0; i < (*data).rec.count; i++) {
_result = marshal_record(&(*data).rec.data[i], _out, _size);
CHECK_RESULT();
}
}
return 0;
}
Example #16
0
static int
SDSC_send (GPPort *port, unsigned char command)
{
	CHECK_RESULT (gp_port_write (port, (char *)&command, 1));

	return (GP_OK);
}
Example #17
0
//Destroyer
VulkanBase::~VulkanBase() {

    // Wait until all operations are complete to destroy stuff
    CHECK_RESULT(vkQueueWaitIdle(queue));

    swapchain.clean();

    //vkFreeCommandBuffers(device, commandPool, commandBuffersVector.size(), commandBuffersVector.data());

    vkDestroyCommandPool(device, commandPool, nullptr);

    // Destroy synchronization elements
    vkDestroySemaphore(device, imageAcquiredSemaphore, nullptr);
    vkDestroySemaphore(device, renderingCompletedSemaphore, nullptr);

    vkDestroyFence(device, presentFence, nullptr);

    // Destroy logical device
    vkDestroyDevice(device, nullptr);

#ifdef _DEBUG
    if (enableValidation) {
        vkDebug::freeDebugCallback(instance);
    }
#endif // _DEBUG

    vkDestroyInstance(instance,nullptr);
}
CAMLprim
value caml_gp_camera_new(value unit_val) {
  CAMLparam0();
  Camera *cam;
  int ret = gp_camera_new(&cam);
  CHECK_RESULT(ret);
  CAMLreturn(encapsulate_pointer(cam));
}
Example #19
0
int unmarshal_record(record *data, unsigned char **_in, size_t *_size) {
int _result;
_result = unmarshal_key(&(*data).k, _in, _size);
CHECK_RESULT();
_result = unmarshal_unsigned_int(&(*data).data.count, _in, _size);
CHECK_RESULT();
if ((*data).data.count > 1024) return -1;
_result = _checked_calloc((void **)&(*data).data.data, (*data).data.count, sizeof((*data).data.data[0]));
{
size_t i;
for (i = 0; i < (*data).data.count; i++) {
_result = unmarshal_opaque(&(*data).data.data[i], _in, _size);
CHECK_RESULT();
}
}
return 0;
}
Example #20
0
int unmarshal_result(result *data, unsigned char **_in, size_t *_size) {
int _result;
_result = unmarshal_result_status(&(*data).status, _in, _size);
CHECK_RESULT();
_result = unmarshal_unsigned_int(&(*data).rec.count, _in, _size);
CHECK_RESULT();
if ((*data).rec.count > 1) return -1;
_result = _checked_calloc((void **)&(*data).rec.data, (*data).rec.count, sizeof((*data).rec.data[0]));
{
size_t i;
for (i = 0; i < (*data).rec.count; i++) {
_result = unmarshal_record(&(*data).rec.data[i], _in, _size);
CHECK_RESULT();
}
}
return 0;
}
Example #21
0
void CD3DGraphics::SetDrawTexture(S_CTexture tex, unsigned int slot) {
	S_CD3DTexture d3dtex = std::static_pointer_cast<CD3DTexture>(tex);
	if (d3dtex == nullptr) {
		CHECK_RESULT(d3ddev->SetTexture(slot, NULL));
		return;
	}

	CHECK_RESULT(d3ddev->SetTexture(slot, d3dtex->GetD3DTexture()));

	D3DTEXTUREFILTERTYPE filterType = d3dtex->GetFilterType() == FilterType::LINEAR ? D3DTEXF_LINEAR : D3DTEXF_POINT;
	d3ddev->SetSamplerState(slot, D3DSAMP_MAGFILTER, filterType);
	d3ddev->SetSamplerState(slot, D3DSAMP_MINFILTER, filterType);

	D3DTEXTUREADDRESS address = d3dtex->GetOverflowHandling() == OverflowHandling::CLAMP_TO_EDGE ? D3DTADDRESS_CLAMP : D3DTADDRESS_WRAP;
	d3ddev->SetSamplerState(slot, D3DSAMP_ADDRESSU, address);
	d3ddev->SetSamplerState(slot, D3DSAMP_ADDRESSV, address);
}
Example #22
0
int unmarshal_opaque_auth(opaque_auth *data, unsigned char **_in, size_t *_size) {
int _result;
_result = unmarshal_auth_flavor(&(*data).flavor, _in, _size);
CHECK_RESULT();
_result = unmarshal_unsigned_int(&(*data).body.count, _in, _size);
CHECK_RESULT();
if ((*data).body.count > 400) return -1;
_result = _checked_calloc((void **)&(*data).body.data, (*data).body.count, sizeof((*data).body.data[0]));
{
size_t i;
for (i = 0; i < (*data).body.count; i++) {
_result = unmarshal_opaque(&(*data).body.data[i], _in, _size);
CHECK_RESULT();
}
}
return 0;
}
Example #23
0
Status LinuxThread::Destroy() {
    CHECK_ERROR(m_threadId);
    
    BEFORE_CHECK_RESULT();
    Terminate();
    delete m_threadId;
    m_threadId = NULL;

    m_bRun = false;
    m_bTerminate = false;

    CHECK_RESULT(_destroyMutex(m_terminateMutex));
    CHECK_RESULT(_destroyMutex(m_runMutex));
    CHECK_RESULT(_destroyCond(m_cond));

    AFTER_CHECK_RESULT();
}
Example #24
0
static int deletefile_logitech_pd(GPPort *port, const char *filename)
{
    unsigned char  command[0x10] = { 0x11, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    memcpy(command+3, filename, 11); /* the id of the image to delete */

    CHECK_RESULT(ultrapocket_command(port, 1, command, 0x10));
    return GP_OK;
}
Example #25
0
GPResult
gpiSendOrBufferStringLenToPeer(
	GPConnection * connection,
	GPIPeer_st peer,
	const char * string,
	int stringLen
)
{
	GPIConnection *iconnection;
	
	unsigned int sent;
	unsigned int total;
	unsigned int remaining;

	assert(peer->outputBuffer.buffer != NULL);
	
	sent = 0;
	iconnection = (GPIConnection *)*connection;
	remaining = (unsigned int)stringLen;
	total = 0;

	// Check for nothing to send.
	/////////////////////////////
	if(stringLen == 0)
		return GP_NO_ERROR;

	// Only try to send if the buffer is empty and there are no messages.
	/////////////////////////////////////////////////////////////////////
	if(!(peer->outputBuffer.len - peer->outputBuffer.pos) && !ArrayLength(peer->messages))
	{
		if ((int)remaining <= (gsUdpEngineGetPeerOutBufferFreeSpace(peer->ip, peer->port) - GS_UDP_RELIABLE_MSG_HEADER - GS_UDP_MSG_HEADER_LEN))
		{
			gsUdpEngineSendMessage(peer->ip, peer->port, iconnection->mHeader, (unsigned char *)string, remaining, gsi_true);
			total = remaining;
			remaining = 0;
		}
		else
		{
			unsigned int freeSpace = (unsigned int)gsUdpEngineGetPeerOutBufferFreeSpace(peer->ip, peer->port);
			if (freeSpace > (GS_UDP_MSG_HEADER_LEN + GS_UDP_RELIABLE_MSG_HEADER))
			{	
				sent = freeSpace - (GS_UDP_MSG_HEADER_LEN + GS_UDP_RELIABLE_MSG_HEADER);
				gsUdpEngineSendMessage(peer->ip, peer->port, iconnection->mHeader, (unsigned char *)string, 
					sent, gsi_true);
				total = sent;
				remaining -= sent;
			}
		}

	}

	// Buffer what wasn't sent.
	///////////////////////////
	if(remaining)
		CHECK_RESULT(gpiAppendStringToBufferLen(connection, &peer->outputBuffer, &string[total], (int)remaining));

	return GP_NO_ERROR;
}
Example #26
0
/*
 * Only need to reset the generic camera type, AFAICT -
 * the pocket digital never seems to need it.
 */
static int
ultrapocket_reset(Camera *camera)
{
   GPPortInfo oldpi;
   GPPort *port = camera->port;
   CameraAbilities cab;
   unsigned char cmdbuf[0x10];
   gp_camera_get_abilities(camera, &cab);
   GP_DEBUG ("First connect since camera was used - need to reset cam");

   /*
    * this resets the ultrapocket.  Messy, but it's what the windows
    * software does.   We only reset if it's been plugged in since
    * last reset.
    */
   memset(cmdbuf, 0, 16);
   cmdbuf[0] = 0x28;
   cmdbuf[1] = 0x01;
   CHECK_RESULT(ultrapocket_command(port, 1, cmdbuf, 0x10));
   /* -------------- */
   sleep(4); /* This should do - _might_ need increasing */
   CHECK_RESULT(gp_port_get_info(port, &oldpi));
   CHECK_RESULT(gp_port_free(port));
   CHECK_RESULT(gp_port_new(&port));
   CHECK_RESULT(gp_port_set_info(port, oldpi));
   CHECK_RESULT(gp_port_usb_find_device(port, 
      cab.usb_vendor, cab.usb_product));
   CHECK_RESULT(gp_port_open(port));
   camera->port = port;
   return GP_OK;
}
Example #27
0
void owl_register_signal_handlers(void) {
  struct sigaction sig_ignore = { .sa_handler = SIG_IGN };
  struct sigaction sig_default = { .sa_handler = SIG_DFL };
  sigset_t sigset;
  int ret, i;
  const int signals[] = { SIGABRT, SIGBUS, SIGCHLD, SIGFPE, SIGHUP, SIGILL,
                          SIGINT, SIGQUIT, SIGSEGV, SIGTERM, SIGWINCH };

  /* Sanitize our signals; the mask and dispositions from our parent
   * aren't really useful. Signal list taken from equivalent code in
   * Chromium. */
  CHECK_RESULT("sigemptyset", sigemptyset(&sigset));
  if ((ret = pthread_sigmask(SIG_SETMASK, &sigset, NULL)) != 0) {
    errno = ret;
    perror("pthread_sigmask");
  }
  for (i = 0; i < G_N_ELEMENTS(signals); i++) {
    CHECK_RESULT("sigaction", sigaction(signals[i], &sig_default, NULL));
  }

  /* Turn off SIGPIPE; we check the return value of write. */
  CHECK_RESULT("sigaction", sigaction(SIGPIPE, &sig_ignore, NULL));

  /* Register some signals with the signal thread. */
  CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGWINCH));
  CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGTERM));
  CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGHUP));
  CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGINT));
  owl_signal_init(&sigset, sig_handler, NULL);
}
static int mpu6050_set_delay(struct mpu6050_input_data *data)
{
	int result;
	int delay = 200;

	if (data->enabled_sensors & MPU6050_SENSOR_ACCEL)
		delay = MIN(delay, atomic_read(&data->accel_delay));

	if (data->enabled_sensors & MPU6050_SENSOR_GYRO)
		delay = MIN(delay, atomic_read(&data->gyro_delay));

	data->current_delay = delay;

	CHECK_RESULT(mpu6050_input_set_odr(data, data->current_delay));
	CHECK_RESULT(mpu6050_input_set_irq(data, BIT_RAW_RDY_EN));

	return result;
}
static int mpu6050_input_set_irq(struct mpu6050_input_data *data, int irq)
{
	int result;

	CHECK_RESULT(mpu6050_i2c_write_single_reg
		(data->client, MPUREG_INT_ENABLE, irq));

	return result;
}
Example #30
0
static pt_int32_t pt_ctcap_encode_result_comp(ctcap_comp_t *comp, void *buf, pt_int32_t pos)
{
    pt_int32_t tmp = pos;
    
    /*parameter*/
    pos = pt_asn1_encode_v(comp->para_len, comp->para, buf, pos);
    CHECK_RESULT(pos);

    /*comp id*/
    pos = pt_asn1_encode_tlv(0xcf, 1, &comp->comp_id, buf, pos);
    CHECK_RESULT(pos);

    /*result component len&tag*/
    pos = pt_asn1_encode_tl(0xea, (pt_uint16_t)(tmp - pos), buf, pos);
    CHECK_RESULT(pos);
    
    return pos;
}