本文整理汇总了C++中CHECK_INIT函数的典型用法代码示例。如果您正苦于以下问题:C++ CHECK_INIT函数的具体用法?C++ CHECK_INIT怎么用?C++ CHECK_INIT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CHECK_INIT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gp_camera_file_read
/**
* Reads a file partially from the #Camera.
*
* @param camera a #Camera
* @param folder a folder
* @param file the name of a file
* @param type the #CameraFileType
* @param offset the offset into the camera file
* @param data the buffer receiving the data
* @param size the size to be read and that was read
* @param context a #GPContext
* @return a gphoto2 error code
*
**/
int
gp_camera_file_read (Camera *camera, const char *folder, const char *file,
CameraFileType type,
uint64_t offset, char *buf, uint64_t *size,
GPContext *context)
{
GP_LOG_D ("Getting file '%s' in folder '%s'...", file, folder);
C_PARAMS (camera && folder && file && buf && size);
CHECK_INIT (camera, context);
/* Did we get reasonable foldername/filename? */
if (strlen (folder) == 0) {
CAMERA_UNUSED (camera, context);
return (GP_ERROR_DIRECTORY_NOT_FOUND);
}
if (strlen (file) == 0) {
CAMERA_UNUSED (camera, context);
return (GP_ERROR_FILE_NOT_FOUND);
}
CHECK_RESULT_OPEN_CLOSE (camera, gp_filesystem_read_file (camera->fs,
folder, file, type, offset, buf, size, context), context);
CAMERA_UNUSED (camera, context);
return (GP_OK);
}
示例2: gp_camera_capture_preview
/**
* Captures a preview that won't be stored on the camera but returned in
* supplied file.
*
* @param camera a #Camera
* @param file a #CameraFile
* @param context a #GPContext
* @return a gphoto2 error code
*
* For example, you could use gp_capture_preview() for taking some sample
* pictures before calling gp_capture().
*
**/
int
gp_camera_capture_preview (Camera *camera, CameraFile *file, GPContext *context)
{
char *xname;
C_PARAMS (camera && file);
CHECK_INIT (camera, context);
CR (camera, gp_file_clean (file), context);
if (!camera->functions->capture_preview) {
gp_context_error (context, _("This camera can "
"not capture previews."));
CAMERA_UNUSED (camera, context);
return (GP_ERROR_NOT_SUPPORTED);
}
CHECK_RESULT_OPEN_CLOSE (camera, camera->functions->capture_preview (
camera, file, context), context);
gp_file_get_name_by_type (file, "capture_preview", GP_FILE_TYPE_NORMAL, &xname);
/* FIXME: Marcus ... will go away, just keep compatible now. */
gp_file_set_name (file, xname);
free (xname);
CAMERA_UNUSED (camera, context);
return (GP_OK);
}
示例3: gp_port_check_int
/**
* \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);
}
示例4: html_valid_set_option
static html_valid_status_t
html_valid_set_option (html_valid_t * htv, SV * option, SV * value)
{
TidyOption to;
TidyOptionType tot;
TidyOptionId ti;
const char * coption;
STRLEN coption_length;
CHECK_INIT (htv);
coption = SvPV (option, coption_length);
to = tidyGetOptionByName(htv->tdoc, coption);
if (to == 0) {
warn ("unknown option %s", coption);
return html_valid_unknown_option;
}
ti = tidyOptGetId (to);
tot = tidyOptGetType (to);
switch (tot) {
case TidyString:
CALL (set_string_option (htv, coption, ti, value));
break;
case TidyInteger:
CALL (set_number_option (htv, coption, ti, value));
break;
case TidyBoolean:
tidyOptSetBool (htv->tdoc, ti, SvTRUE (value));
break;
default:
fprintf (stderr, "%s:%d: bad option type %d from tidy library.\n",
__FILE__, __LINE__, tot);
return html_valid_bad_option_type;
}
return html_valid_ok;
}
示例5: gp_port_check_int_fast
/**
* \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);
}
示例6: PrioQueueTop
int32_t PrioQueueTop(PrioQueue *self, Item *pItem)
{
CHECK_INIT(self);
BinHeap *pHeap = self->pData->pHeap_;
int32_t iRtnCode = pHeap->top(pHeap, pItem);
return iRtnCode;
}
示例7: _DEFUN_VOID
FILE *
_DEFUN_VOID (tmpfile)
{
int ret;
FILE* fp;
struct _reent *ptr = _REENT;
CHECK_INIT(ptr);
fp = __sfp(ptr);
if (!fp) {
return NULL;
}
ret = __send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_TMPFILE, &ret);
if (ret) {
fp->_fp = ret;
return fp;
}
else {
__sfp_free(fp);
return NULL;
}
}
示例8: VFSCANF
/**
* @brief Formats input of a stdarg argument list.
*
* @details The function is equivalent to fscanf() except that
* instead of being called with a variable number of arguments,
* is called with an argument list as defined in the <stdarg.h> header.
*
* @return Returns the same value of fscanf().
*/
int VFSCANF(register FILE *fp, const char *fmt, va_list ap)
{
struct _reent *reent = _REENT;
CHECK_INIT(reent, fp);
return __SVFSCANF_R (reent, fp, fmt, ap);
}
示例9: gp_camera_file_get
/**
* Retrieves a file from the #Camera.
*
* @param camera a #Camera
* @param folder a folder
* @param file the name of a file
* @param type the #CameraFileType
* @param camera_file a #CameraFile
* @param context a #GPContext
* @return a gphoto2 error code
*
**/
int
gp_camera_file_get (Camera *camera, const char *folder, const char *file,
CameraFileType type, CameraFile *camera_file,
GPContext *context)
{
gp_log (GP_LOG_DEBUG, "gphoto2-camera", "Getting file '%s' in "
"folder '%s'...", file, folder);
CHECK_NULL (camera && folder && file && camera_file);
CHECK_INIT (camera, context);
CR (camera, gp_file_clean (camera_file), context);
/* Did we get reasonable foldername/filename? */
if (strlen (folder) == 0) {
CAMERA_UNUSED (camera, context);
return (GP_ERROR_DIRECTORY_NOT_FOUND);
}
if (strlen (file) == 0) {
CAMERA_UNUSED (camera, context);
return (GP_ERROR_FILE_NOT_FOUND);
}
CHECK_RESULT_OPEN_CLOSE (camera, gp_filesystem_get_file (camera->fs,
folder, file, type, camera_file, context), context);
CAMERA_UNUSED (camera, context);
return (GP_OK);
}
示例10: PrioQueueSetCompare
int32_t PrioQueueSetCompare(PrioQueue *self, int32_t (*pFunc) (Item, Item))
{
CHECK_INIT(self);
BinHeap *pHeap = self->pData->pHeap_;
int32_t iRtnCode = pHeap->set_compare(pHeap, pFunc);
return iRtnCode;
}
示例11: CHECK_INIT
// Minimizes (but does not destroy) the window
void Window::Minimize()
{
CHECK_INIT();
if(!CloseWindow(hwnd()))
throw WIN32EXCEPTION_1("CloseWindow");
}
示例12: PrioQueueSetDestroy
int32_t PrioQueueSetDestroy(PrioQueue *self, void (*pFunc) (Item))
{
CHECK_INIT(self);
BinHeap *pHeap = self->pData->pHeap_;
int32_t iRtnCode = pHeap->set_destroy(pHeap, pFunc);
return iRtnCode;
}
示例13: gp_camera_file_get_info
/**
* Retrieves information about a file.
*
* @param camera a #Camera
* @param folder a folder
* @param file the name of the file
* @param info
* @param context a #GPContext
* @return a gphoto2 error code
*
**/
int
gp_camera_file_get_info (Camera *camera, const char *folder,
const char *file, CameraFileInfo *info,
GPContext *context)
{
int result = GP_OK;
const char *mime_type;
const char *data;
/* long int size; */
CameraFile *cfile;
gp_log (GP_LOG_DEBUG, "gphoto2-camera", "Getting file info for '%s' "
"in '%s'...", file, folder);
CHECK_NULL (camera && folder && file && info);
CHECK_INIT (camera, context);
memset (info, 0, sizeof (CameraFileInfo));
/* Check first if the camera driver supports the filesystem */
CHECK_OPEN (camera, context);
result = gp_filesystem_get_info (camera->fs, folder, file, info,
context);
CHECK_CLOSE (camera, context);
if (result != GP_ERROR_NOT_SUPPORTED) {
CAMERA_UNUSED (camera, context);
return (result);
}
/*
* The CameraFilesystem doesn't support file info. We simply get
* the preview and the file and look for ourselves...
*/
/* It takes too long to get the file */
info->file.fields = GP_FILE_INFO_NONE;
/* Get the preview */
info->preview.fields = GP_FILE_INFO_NONE;
CRS (camera, gp_file_new (&cfile), context);
if (gp_camera_file_get (camera, folder, file, GP_FILE_TYPE_PREVIEW,
cfile, context) == GP_OK) {
unsigned long size;
info->preview.fields |= GP_FILE_INFO_SIZE | GP_FILE_INFO_TYPE;
gp_file_get_data_and_size (cfile, &data, &size);
info->preview.size = size;
gp_file_get_mime_type (cfile, &mime_type);
strncpy (info->preview.type, mime_type,
sizeof (info->preview.type));
}
gp_file_unref (cfile);
/* We don't trust the camera libraries */
info->file.fields |= GP_FILE_INFO_NAME;
strncpy (info->file.name, file, sizeof (info->file.name));
info->preview.fields &= ~GP_FILE_INFO_NAME;
CAMERA_UNUSED (camera, context);
return (GP_OK);
}
示例14: gp_port_usb_msg_interface_read
/**
* \brief Send a USB interface 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 control command and read associated data.
*
* \return a gphoto2 error code
*/
int
gp_port_usb_msg_interface_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_interface_read);
retval = port->pc->ops->msg_interface_read (port, request,
value, index, bytes, size);
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", bytes, retval);
return (retval);
}
示例15: _perror_r
void
_perror_r (struct _reent *ptr,
const char *s)
{
char *error;
int dummy;
FILE *fp = _stderr_r (ptr);
CHECK_INIT (ptr, fp);
_newlib_flockfile_start(fp);
_fflush_r (ptr, fp);
if (s != NULL && *s != '\0')
{
WRITE_STR (s);
WRITE_STR (": ");
}
if ((error = _strerror_r (ptr, ptr->_errno, 1, &dummy)) != NULL)
WRITE_STR (error);
#ifdef __SCLE
WRITE_STR ((fp->_flags & __SCLE) ? "\r\n" : "\n");
#else
WRITE_STR ("\n");
#endif
fp->_flags &= ~__SOFF;
_newlib_flockfile_end(fp);
}