当前位置: 首页>>代码示例>>C++>>正文


C++ set_err函数代码示例

本文整理汇总了C++中set_err函数的典型用法代码示例。如果您正苦于以下问题:C++ set_err函数的具体用法?C++ set_err怎么用?C++ set_err使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了set_err函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的set_err函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。