本文整理汇总了C++中set_err函数的典型用法代码示例。如果您正苦于以下问题:C++ set_err函数的具体用法?C++ set_err怎么用?C++ set_err使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_err函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: set_err
cap_cx *cap_new(char *err)
{
cap_cx *cx;
set_err("Out of memory");
if((cx = malloc(sizeof(cap_cx))))
{
memset(cx, 0, sizeof(cap_cx));
if((cx->hwnd = cap_create_hwnd(err)))
{
if(cap_assoc_set(cx->hwnd, cx))
{
if(cap_configure(cx, err))
{
set_err("");
return cx;
}
}
DestroyWindow(cx->hwnd);
}
free(cx);
}
return NULL;
}
开发者ID:ofilin,项目名称:remcam2,代码行数:26,代码来源:capture.c
示例2: memset
aud_out *aud_outopen(int device, int samplerate, int channels, char *err)
{
aud_out *cx;
wv_format fmt;
if((channels == 1) || (channels == 2))
{
if((cx = malloc(sizeof(aud_out))))
{
memset(cx, 0, sizeof(aud_out));
fmt.samplerate = samplerate;
fmt.samplebits = 16;
fmt.channels = channels;
if((cx->wvout = wv_outopen(device, &fmt)))
{
cx->samplerate = samplerate;
cx->channels = channels;
set_err("");
return cx;
}
free(cx);
}
}
set_err("Can't open audio output device");
return NULL;
}
开发者ID:ofilin,项目名称:remcam2,代码行数:27,代码来源:audstrm.c
示例3: create_mailbox
int
create_mailbox(char *box_name, int box_size,
int (* async_func) (int *box_id, char *box_name,
char *message_address, int message_length) )
{
/* int status;*/
int index;
int shmid;
/* Test function security */
if (async_func == NULL) {
set_err (EFAULT);
return (0); /* Verifies function exists */
}
if (box_size == 0){
set_err (EINVAL);
return (0);
}
if (box_name == NULL) {
set_err (EFAULT);
return (0);
}
index = alloc_entry(); /* Find an entry for id_table */
if (index == -1) {
set_err(EMFILE);
keep_clean();
return(0);
}
if (max_mail == 1 && index > 0) { /* If only one mail box authorized */
set_err (EMFILE);
return(0);
}
/* Create shared memory for the process */
shmid = create_sharedmemory ( &id_table[index].address, box_name, box_size);
if (shmid == 0) return (0);
put_pid (index); /* Put pid of server into shared memory */
id_table[index].channel = shmid; /* Keep id of shared memory */
id_table[index].size = box_size; /* Keep size of mail box */
strncpy(id_table[index].name,box_name,SIZEOFNAME); /* Keep name of mail box */
id_table[index].user_func = async_func; /* Keep user function */
/* Install asynchronous function : AST function */
signal (SIGUSR1, handler);
nb_mail++;
return (index);
}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:60,代码来源:OSD_Cmailbox.c
示例4: remove_mailbox
int
remove_mailbox(int *boxid, char *box_name)
{
if (boxid == 0){
set_err(EINVAL);
return (0);
}
if (box_name == NULL) {
set_err(EFAULT);
return (0);
}
/* (*boxid)--; JPT */
nb_mail--;
/* If last mail box removed, remove special shared memory */
if (nb_mail == 0) keep_clean();
remove_sharedmemory (&id_table[*boxid].channel, box_name ); /* Close shared memory */
id_table[*boxid].address = NULL;
return (1);
}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:27,代码来源:OSD_Cmailbox.c
示例5: kernel_call
Ref kernel_call(ref_list args){
if (args->length != 1){
set_err(ETYPE, "too many arguments");
return NULL;
}
if (arg_isMatrix(args->list[0]) == false) return NULL;
Matrix M = CAST_REF2MATRIX(args->list[0]);
if (M->nrows != M->ncols) {
set_err(ETYPE, "not a square Matrix");
return NULL;
}
Matrix K;
if ( noyau(M, &K) == 0 ) return NULL;
/* Print kernel */
unsigned int i,j;
printf("\n");
for(i = 0 ; i < K->nrows; i++)
{
printf("\t");
for (j = 0; j < K->ncols; j++){
printf("\t[%- 6.4g]",getElt(K,i,j));
}
printf("\n");
}
printf("\n\n");
return NO_REF;
}
开发者ID:werew,项目名称:minicas,代码行数:35,代码来源:mod_matrix.c
示例6: solve_call
/* Solve a system */
Ref solve_call(ref_list args){
if (args->length != 2){
set_err(ETYPE, "\"solve\" needs 2 arguments");
return NULL;
}
if (arg_isMatrix(args->list[0]) == false ||
arg_isMatrix(args->list[1]) == false ) return NULL;
Matrix m1 = CAST_REF2MATRIX(args->list[0]);
Matrix m2 = CAST_REF2MATRIX(args->list[1]);
if (m1->ncols != m2->nrows ||
m2->ncols > 1) {
set_err(EMXDIM, "not a valid system");
return NULL;
}
Matrix s = NULL;
if (solve(m1, m2, &s) == false) return NULL;
Ref r = new_vref(NULL, s, MATRIX);
if (r == NULL) dropMatrix(s);
return r;
}
开发者ID:werew,项目名称:minicas,代码行数:28,代码来源:mod_matrix.c
示例7: invert_call
/* Invert one matrix */
Ref invert_call(ref_list args){
if (args->length != 1){
set_err(ETYPE, "to many arguments");
return NULL;
}
if (arg_isMatrix(args->list[0]) == false) return NULL;
Matrix m = CAST_REF2MATRIX(args->list[0]);
if (m->nrows != m->ncols) {
set_err(ETYPE, "not a square Matrix");
return NULL;
}
Matrix inv = NULL;
if ( invert(m, &inv) == false) return NULL;
Ref r = new_vref(NULL, inv, MATRIX);
if (r == NULL) dropMatrix(inv);
return r;
}
开发者ID:werew,项目名称:minicas,代码行数:27,代码来源:mod_matrix.c
示例8: determinant_call
/* Determinant of one matrix */
Ref determinant_call(ref_list args){
if (args->length != 1){
set_err(ETYPE, "to many arguments");
return NULL;
}
if (arg_isMatrix(args->list[0]) == false) return NULL;
Matrix m = CAST_REF2MATRIX(args->list[0]);
if (m->nrows != m->ncols) {
set_err(ETYPE, "not a square Matrix");
return NULL;
}
float* d = malloc(sizeof (float));
if (d == NULL) return NULL;
if ( determinant(m, d) == false){
free(d);
return NULL;
}
Ref r = new_vref(NULL, d, FLOAT);
if (r == NULL) free(d);
return r;
}
开发者ID:werew,项目名称:minicas,代码行数:31,代码来源:mod_matrix.c
示例9: set_err
bool tunnelled_device_base::open()
{
if (!m_tunnel_base_dev)
return set_err(ENOSYS);
if (!m_tunnel_base_dev->open())
return set_err(m_tunnel_base_dev->get_err());
return true;
}
开发者ID:dllhlx,项目名称:smartmontools,代码行数:8,代码来源:dev_interface.cpp
示例10: clear_err
smart_device * smart_interface::get_smart_device(const char * name, const char * type)
{
clear_err();
// Call platform specific autodetection if no device type specified
smart_device * dev;
if (!type || !*type) {
dev = autodetect_smart_device(name);
if (!dev && !get_errno())
set_err(EINVAL, "Unable to detect device type");
return dev;
}
// First check for platform specific device types
dev = get_custom_smart_device(name, type);
if (dev || get_errno())
return dev;
if (!strcmp(type, "ata"))
dev = get_ata_device(name, type);
else if (!strcmp(type, "scsi"))
dev = get_scsi_device(name, type);
else if ( ((!strncmp(type, "sat", 3) && (!type[3] || strchr(",+", type[3])))
|| (!strncmp(type, "usb", 3)))) {
// Split "sat...+base..." -> ("sat...", "base...")
unsigned satlen = strcspn(type, "+");
std::string sattype(type, satlen);
const char * basetype = (type[satlen] ? type+satlen+1 : "");
// Recurse to allocate base device, default is standard SCSI
if (!*basetype)
basetype = "scsi";
smart_device_auto_ptr basedev( get_smart_device(name, basetype) );
if (!basedev) {
set_err(EINVAL, "Type '%s+...': %s", sattype.c_str(), get_errmsg());
return 0;
}
// Result must be SCSI
if (!basedev->is_scsi()) {
set_err(EINVAL, "Type '%s+...': Device type '%s' is not SCSI", sattype.c_str(), basetype);
return 0;
}
// Attach SAT tunnel
ata_device * satdev = get_sat_device(sattype.c_str(), basedev->to_scsi());
if (!satdev)
return 0;
basedev.release();
return satdev;
}
else {
set_err(EINVAL, "Unknown device type '%s'", type);
return 0;
}
if (!dev && !get_errno())
set_err(EINVAL, "Not a device of type '%s'", type);
return dev;
}
开发者ID:dllhlx,项目名称:smartmontools,代码行数:58,代码来源:dev_interface.cpp
示例11: StageIn_end
int gmShellPlink::StageIn(const gmdArrayString& locfiles, pCSTR remdir, unsigned flags){
gmdString tempdir, src, err;
gmdArrayString srclist;
if( StageIn_begin(NULL, remdir, flags) )
return StageIn_end(NULL, remdir, flags);
for(unsigned i=0; i<locfiles.GetCount(); i++) {
gmdString lfile = locfiles[i];
if( lfile.IsEmpty() ) continue;
lfile.Replace("/", "\\");
if( has_wildcards(lfile) ) {
// List all files explicitly if lfile contains wildcards
gmdArrayString filelist;
unsigned nfiles = files_by_mask(lfile, filelist, flags);
if(nfiles)
for(unsigned k=0; k<nfiles; k++) srclist.Add(filelist[k]);
else
set_err(NO_INPUT_FILE, fmt("%s: no such files", (pCSTR)lfile.c_str()));
}
else if( path_exists(lfile, flags) )
srclist.Add(lfile);
else
set_err(NO_INPUT_FILE, fmt("%s: no sich file or directory", (pCSTR)lfile.c_str()));
}
if( !srclist.IsEmpty() ) {
if(flags & TEXT) {
// Convert text files and store them in the temporary dir
assert_no_recursive(flags); // combination RECURSIVE & TEXT is not supported!
tempdir = GetTempDir();
//dos2unix(srclist, tempdir);
conv_files(srclist, tempdir, dos2unix);
src = tempdir + "\\*.*";
} else {
// prepare the space separated file list for PLINK
for(unsigned i=0; i<srclist.GetCount(); i++)
src += (i>0 ? "\" \"" : "") + srclist[i];
}
// Copy files
if(!error_code) {
gmdString args = (flags & RECURSIVE) ? "-r \"" : "\"";
args += src + "\" \"" + userhost + ':' + rem_path_subst(remdir) + "\"";
pscp_execute(args);
}
if( !tempdir.IsEmpty() ) remove_local(tempdir);
if(!error_code && (flags & MOVE)) // custom move (not using StageIn_end)
for(unsigned i=0; i<srclist.GetCount(); i++) RemoveLocal(srclist[i], flags);
}
return StageIn_end(NULL, remdir, flags);
}
开发者ID:ilya-valuev,项目名称:GridMD,代码行数:56,代码来源:plinkshell.cpp
示例12: LOGJOBERR
int gmShellPlink::pscp_execute(const gmdString& args){
int i, res;
gmdString errmsg;
if(!auth_defined)
LOGJOBERR("Authentification method are not defined, "
"check 'login', 'host' and 'plink_args' parameters!");
if(dump_commands)
LOGJOBMSG4( (pCSTR) ("------ pscp_execute ------\n"
" cmd=" + pscp_pre + args + "\n"
));
for(i=0; i<plink_att_num; i++){
if(i) { // Retrying on a network error
LOGJOBMSG( fmt("PLINK connection failed: %s\nRetrying %d more times",
(const gmdChar*)errmsg, plink_att_num - i) );
gmdMilliSleep(plink_retry_delay); // delay before a retry
}
gmdArrayString out, err;
//ttimer.Resume();
res = gmdExecute(pscp_pre + args, out, err);
//ttimer.Pause();
if(res == -1)
return( set_err(EXECUTE_ERROR, "Error executing PSCP!") );
if(dump_commands && res != 0)
LOGJOBMSG4( (pCSTR) ("------ pscp_execute (error)------\n"
" cout=" + ArrayToString(out)+"\n"
" cerr=" + ArrayToString(err)+"\n"
));
if(res == 0) break;
errmsg = ArrayToString(err);
if( !errmsg.StartsWith("Fatal: Network error:") ) break;
}
if(res) { // Replace 'res' by an internal error code
if(i >= plink_att_num) res = CONNECTION_ERROR;
else if( ( errmsg.Contains("no such file or directory") ||
errmsg.Contains("matched no files") ) &&
!errmsg.Contains("unable to open")
) res = NO_INPUT_FILE;
else res = COPY_ERROR;
set_err(res, errmsg);
}
return res;
}
开发者ID:ilya-valuev,项目名称:GridMD,代码行数:53,代码来源:plinkshell.cpp
示例13: open_mailbox
int
open_mailbox(char * box_name, int box_size)
{
int status;
int index; /* Index for mail box informations access */
/* Test function security */
if (box_size == 0){
set_err (EINVAL);
return (0);
}
if (box_name == NULL) {
set_err (EFAULT);
return (0);
}
index = alloc_entry(); /* Find an entry for id_table */
if (index == -1) {
set_err(EMFILE);
if (nb_mail == 0) keep_clean();
return(0);
}
id_table[index].size = box_size; /* Keep size of mail box */
strncpy(id_table[index].name,box_name,SIZEOFNAME); /* Keep name of mail box */
/* Attach shared memory to the process */
status = open_sharedmemory ( (int **)&id_table[index].address, box_name,
box_size);
if (status !=0)
if (get_pid (index) < 0){ /* Get pid from shared memory */
set_err(ESRCH);
return (0);
}
id_table[index].channel = status;
if (status != 0) {
return (index);
}
else { /* Error */
id_table[index].address = NULL; /* ensure pointer is empty */
keep_clean();
return(0);
}
}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:52,代码来源:OSD_Cmailbox.c
示例14: cap_setformat
int cap_setformat(cap_cx *cx, void *pfmt, size_t fmtlen, char *err)
{
if( (cx->opened) && (!cx->started) )
{
if(capSetVideoFormat(cx->hwnd, pfmt, fmtlen))
{
set_err("");
return 1;
}
}
set_err("Can't set video format");
return 0;
}
开发者ID:ofilin,项目名称:remcam2,代码行数:13,代码来源:capture.c
示例15: execute_begin
int gmShellPlink::execute(const gmdString& cmd, gmdArrayString& out, gmdArrayString& err){
// Execute Shell command
int i, res;
gmdString errmsg;
execute_begin(cmd, out, err);
if(!auth_defined)
return execute_error(
set_err(CONNECTION_ERROR,
"PLINK: Authentification method is not defined, "
"check 'login', 'host' and 'plink_args' parameters!" )
);
// Screed double quotes
gmdString cmd_scr(cmd);
cmd_scr.Replace("\"", "\\\"");
// Avoid empty command that switches plink into the interactive mode
if( cmd_scr.IsEmpty() ) cmd_scr = "#";
for(i=0; i<plink_att_num; i++){
if(i) { // Retrying on a network error
LOGJOBMSG( fmt("PLINK connection failed: %s\nRetrying %d more times",
(const gmdChar*)errmsg, plink_att_num - i) );
gmdMilliSleep(plink_retry_delay); // delay before a retry
}
if(dump_commands)
LOGJOBMSG4( (pCSTR)("------ execute (plink)------\n" + plink_pre + cmd_scr + '\"') );
res = gmdExecute(plink_pre + cmd_scr + '\"', out, err);
if(res == -1) {
execute_end(res, out, err);
return execute_error( set_err(EXECUTE_ERROR, "Error executing PLINK") );
}
else if(res == 0)
break;
errmsg = ArrayToString(err);
if( !errmsg.StartsWith("Unable to open connection") ) break;
}
if(i >= plink_att_num){
execute_end(-1, out, err); // pausing timer
return set_err(CONNECTION_ERROR, errmsg);
}
return execute_end(res, out, err);
}
开发者ID:imorozzov,项目名称:GridMD,代码行数:49,代码来源:plinkshell.cpp
示例16: cap_open
int cap_open(cap_cx *cx, int id, char *err)
{
if(!cx->opened)
{
if(capDriverConnect(cx->hwnd, id))
{
set_err("");
cx->opened = 1;
return 1;
}
}
set_err("Can't open specifed device");
return 0;
}
开发者ID:ofilin,项目名称:remcam2,代码行数:15,代码来源:capture.c
示例17: switch
bool ata_device::ata_cmd_is_supported(const ata_cmd_in & in,
unsigned flags, const char * type /* = 0 */)
{
// Check DATA IN/OUT
switch (in.direction) {
case ata_cmd_in::no_data: break;
case ata_cmd_in::data_in: break;
case ata_cmd_in::data_out: break;
default:
return set_err(EINVAL, "Invalid data direction %d", (int)in.direction);
}
// Check buffer size
if (in.direction == ata_cmd_in::no_data) {
if (in.size)
return set_err(EINVAL, "Buffer size %u > 0 for NO DATA command", in.size);
}
else {
if (!in.buffer)
return set_err(EINVAL, "Buffer not set for DATA IN/OUT command");
unsigned count = (in.in_regs.prev.sector_count<<16)|in.in_regs.sector_count;
// TODO: Add check for sector count == 0
if (count * 512 != in.size)
return set_err(EINVAL, "Sector count %u does not match buffer size %u", count, in.size);
}
// Check features
const char * errmsg = 0;
if (in.direction == ata_cmd_in::data_out && !(flags & supports_data_out))
errmsg = "DATA OUT ATA commands not implemented";
else if ( in.out_needed.is_set() && !(flags & supports_output_regs)
&& !( in.in_regs.command == ATA_SMART_CMD
&& in.in_regs.features == ATA_SMART_STATUS
&& (flags & supports_smart_status)))
errmsg = "Read of ATA output registers not implemented";
else if (!(in.size == 0 || in.size == 512) && !(flags & supports_multi_sector))
errmsg = "Multi-sector ATA commands not implemented";
else if (in.in_regs.is_48bit_cmd() && !(flags & (supports_48bit_hi_null|supports_48bit)))
errmsg = "48-bit ATA commands not implemented";
else if (in.in_regs.is_real_48bit_cmd() && !(flags & supports_48bit))
errmsg = "48-bit ATA commands not fully implemented";
if (errmsg)
return set_err(ENOSYS, "%s%s%s%s", errmsg,
(type ? " [" : ""), (type ? type : ""), (type ? "]" : ""));
return true;
}
开发者ID:dllhlx,项目名称:smartmontools,代码行数:48,代码来源:dev_interface.cpp
示例18: cap_ic_start
int cap_ic_start(cap_cx *cx, char *err)
{
char format[32];
char message[80];
if((cx->ic = ICDecompressOpen(
ICTYPE_VIDEO,
0,
&(cx->pfmt->bmiHeader),
NULL)))
{
cx->outfmtlen = ICDecompressGetFormatSize(cx->ic, cx->pfmt);
if((cx->poutfmt = malloc(cx->outfmtlen)))
{
if(ICDecompressGetFormat(cx->ic, cx->pfmt, cx->poutfmt) == ICERR_OK)
{
if(ICDecompressBegin(cx->ic, cx->pfmt, cx->poutfmt) == ICERR_OK)
{
cx->mode = CAP_USE_IC;
return 1;
}
}
free(cx->poutfmt);
}
ICClose(cx->ic);
}
sprintf(message, "Can't open decompressor for format \"%s\"",
reverse_fourcc(format, cx->pfmt->bmiHeader.biCompression));
set_err(message);
return 0;
}
开发者ID:ofilin,项目名称:remcam2,代码行数:33,代码来源:capture.c
示例19: expand_tilde
char*
expand_tilde(char *str, const char *home)
{
if (str == NULL || home == NULL)
return str;
int len = strlen(home);
static char dest[MAX_LEN];
char *from = str;
int i = 0;
for (int i = 0; str[i]; i++) {
if (i >= (MAX_LEN - 1)) {
set_err(ERR_DIRS_TOO_LONG);
strncpy(dest, str, MAX_LEN -1);
return dest;
}
if (str[i] == '~') {
strncat(dest, from, &str[i] - from);
strcat(dest, home);
from = str + i + 1;
}
}
strcat(dest, from);
return dest;
}
开发者ID:lchsk,项目名称:xstarter,代码行数:32,代码来源:utils_string.c
示例20: cap_configure
int cap_configure(cap_cx *cx, char *err)
{
CAPTUREPARMS params;
if(capCaptureGetSetup(cx->hwnd, ¶ms, sizeof(params)))
{
params.fYield = TRUE;
params.fCaptureAudio = FALSE;
params.wPercentDropForError = 100;
params.fMakeUserHitOKToCapture = FALSE;
params.fAbortLeftMouse = FALSE;
params.fAbortRightMouse = FALSE;
params.vKeyAbort = 0;
if(capCaptureSetSetup(cx->hwnd, ¶ms, sizeof(params)))
{
if(capSetCallbackOnVideoStream(cx->hwnd, cap_stream_cb))
{
return 1;
}
}
}
set_err("Can't set capture settings");
return 0;
}
开发者ID:ofilin,项目名称:remcam2,代码行数:27,代码来源:capture.c
注:本文中的set_err函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论