• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ perr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了perr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: pthreadCreate

void pthreadCreate(pthread_t *thread, const pthread_attr_t *attr,
	void *(*start_routine)(void *), void *arg)
/* Create a thread or squawk and die. */
{
int err = pthread_create(thread, attr, start_routine, arg);
perr("pthread_create", err);
}
开发者ID:blumroy,项目名称:kentUtils,代码行数:7,代码来源:pthreadWrap.c


示例2: pthreadCondSignal

void pthreadCondSignal(pthread_cond_t *cond)
/* Set conditional signal to wake up a sleeping thread, or
 * die trying. */
{
int err = pthread_cond_signal(cond);
perr("pthread_cond_signal", err);
}
开发者ID:blumroy,项目名称:kentUtils,代码行数:7,代码来源:pthreadWrap.c


示例3: init_ctl_channel

int init_ctl_channel(const char *name, int verb)
{
	char buf[PATH_MAX];
	struct statfs st;
	int old_transport = 0;

	if (statfs("/sys/kernel/debug", &st) == 0 && (int)st.f_type == (int)DEBUGFS_MAGIC) {
		if (sprintf_chk(buf, "/sys/kernel/debug/systemtap/%s/.cmd", name))
			return -1;
	} else {
		old_transport = 1;
		if (sprintf_chk(buf, "/proc/systemtap/%s/.cmd", name))
			return -2;
	}

	control_channel = open(buf, O_RDWR);
	dbug(2, "Opened %s (%d)\n", buf, control_channel);
	if (control_channel < 0) {
		if (verb) {
			if (attach_mod && errno == ENOENT)
				err("ERROR: Can not attach. Module %s not running.\n", name);
			else
				perr("Couldn't open control channel '%s'", buf);
		}
		return -3;
	}
	if (set_clexec(control_channel) < 0)
		return -4;

	return old_transport;
}
开发者ID:tsh185,项目名称:t80_platform_external,代码行数:31,代码来源:ctl.c


示例4: knox_print_event_log

void knox_print_event_log(int sg_fd)
{
#define EVENT_LOG_BUFFER_SIZE 8192
  unsigned char buf[EVENT_LOG_BUFFER_SIZE];
  unsigned char *buf_ptr;
  int64_t timestamp = 0;
  int i, j;
  char id_str[16];

  perr("NOTE: Event log in Knox is not complete at this time...\n");

  sg_ll_read_buffer(sg_fd, 2, 0xe5, 0, (void *) buf,
                    EVENT_LOG_BUFFER_SIZE, 1, 0);

  for (i = 0; i < EVENT_LOG_BUFFER_SIZE; i += 64) {
    buf_ptr = buf + i;
    timestamp = *((int64_t *)(buf_ptr));
    IF_PRINT_NONE_JSON
      printf("[%11ld][Event %d] %d %x %s\n", timestamp,
             buf_ptr[13] * 256 + buf_ptr[12],
             buf_ptr[15] * 256 + buf_ptr[14],
             *((int *)(buf_ptr + 16)),
             (char *)(buf_ptr + 24));

    PRINT_JSON_GROUP_SEPARATE;

    snprintf(id_str, 16, "%d", buf_ptr[13] * 256 + buf_ptr[12]);
    PRINT_JSON_GROUP_HEADER(id_str);
    PRINT_JSON_ITEM("timestamp", "%ld", timestamp);
    PRINT_JSON_ITEM("id", "%d", buf_ptr[13] * 256 + buf_ptr[12]);
    PRINT_JSON_LAST_ITEM("description", "%s", (char *)(buf_ptr + 24));
    PRINT_JSON_GROUP_ENDING;
  }
}
开发者ID:facebook,项目名称:ocpjbod,代码行数:34,代码来源:knox.c


示例5: perr

void
PingusSoundReal::real_play_sound(const std::string& name, float volume, float panning)
{
  if (!globals::sound_enabled)
    return;

  SoundHandle chunk;

  chunk = SoundResMgr::load(name);
  if (!chunk)
  {
    perr(PINGUS_DEBUG_SOUND) << "Can't open sound '" << name << "' -- skipping\n"
                             << "  Mix_Error: " << Mix_GetError() << std::endl;
    return;
  }

  int channel = Mix_PlayChannel(-1, chunk, 0);
  if (channel != -1)
  {
    Mix_Volume(channel, static_cast<int>(volume * MIX_MAX_VOLUME));
    if (panning != 0.0f)
    {
      Uint8 left  = static_cast<Uint8>((panning < 0.0f) ? 255 : static_cast<Uint8>((panning - 1.0f) * -255));
      Uint8 right = static_cast<Uint8>((panning > 0.0f) ? 255 : static_cast<Uint8>((panning + 1.0f) * 255));
      Mix_SetPanning(channel, left, right);
    }
  }
}
开发者ID:jcs12311,项目名称:pingus,代码行数:28,代码来源:sound_real.cpp


示例6: perr

int LshttpdMain::testRunningServer()
{
    int count = 0;
    int ret;
    do
    {
        ret = m_pidFile.lockPidFile(PID_FILE);
        if (ret)
        {
            if ((ret == -2) && (errno == EACCES || errno == EAGAIN))
            {
                ++count;
                if (count >= 10)
                {
                    perr("LiteSpeed Web Server is running!");
                    return 2;
                }
                ls_sleep(100);
            }
            else
            {
                fprintf(stderr, "[ERROR] Failed to write to pid file:%s!\n", PID_FILE);
                return ret;
            }
        }
        else
            break;
    }
    while (true);
    return ret;
}
开发者ID:kopytov,项目名称:openlitespeed,代码行数:31,代码来源:lshttpdmain.cpp


示例7: pout

void
PingusSoundReal::real_play_music (const std::string & arg_filename, float volume, bool loop)
{
  std::string filename;

  filename = arg_filename;

  if (!globals::music_enabled)
    return;

  pout(PINGUS_DEBUG_SOUND) << "PingusSoundReal: Playing music: " << filename << std::endl;

  real_stop_music();

  music_sample = Mix_LoadMUS(filename.c_str());
  if (!music_sample)
  {
    perr(PINGUS_DEBUG_SOUND) << "Can't load music: " << filename << "' -- skipping\n"
                             << "  Mix_Error: " << Mix_GetError() << std::endl;
    return;
  }

  Mix_VolumeMusic(static_cast<int>(volume * 0.5f * MIX_MAX_VOLUME)); // FIXME: music_volume
  Mix_PlayMusic(music_sample, loop ? -1 : 0);
}
开发者ID:jcs12311,项目名称:pingus,代码行数:25,代码来源:sound_real.cpp


示例8: prsnmpstr

void prsnmpstr(char *stroid) {
    struct snmp_pdu *pdu, *resp;
    oid tmp_oid[MAX_OID_LEN];
    size_t tmp_oid_len=MAX_OID_LEN;
    int stat;
    char *tmp;

    pdu=snmp_pdu_create(SNMP_MSG_GET);
    read_objid(stroid, tmp_oid, &tmp_oid_len);
    snmp_add_null_var(pdu, tmp_oid, tmp_oid_len);
    stat=snmp_synch_response(ses, pdu, &resp);

    if (stat != STAT_SUCCESS || resp->errstat != SNMP_ERR_NOERROR) 
        perr(resp);

    if(resp->variables->val_len && strlen((char *)resp->variables->val.string)) {
        tmp=malloc((resp->variables->val_len+1) * sizeof(char));
        memcpy(tmp, resp->variables->val.string, resp->variables->val_len);
        tmp[resp->variables->val_len]=0;
        printf("%s", tmp);
        free(tmp);
    }
    
    if(resp)
            snmp_free_pdu(resp);

}
开发者ID:xiongshaogang,项目名称:NetAndSysMonitor,代码行数:27,代码来源:ttg-snmp.cpp


示例9: ErrorPrintf

/*-----------------------------------------------------
        Parameters:

        Returns value:

        Description
------------------------------------------------------*/
int
ErrorPrintf(int ecode, const char *fmt, ...)
{
  va_list  args ;
  FILE     *fp ;

  Gerror = ecode ;
  va_start(args, fmt) ;
  (*error_vfprintf)(stderr, fmt, args) ;
  fprintf(stderr, "\n") ;
  fflush(stderr);
  fflush(stdout);
  va_end(args);
  if (errno)
    perror(NULL) ;
#if 0
  if (hipserrno)
    perr(ecode, "Hips error:") ;
#endif

  va_start(args, fmt) ;
  fp = fopen(ERROR_FNAME, "a") ;
  if (fp)
  {
    (*error_vfprintf)(fp, fmt, args) ;
    fprintf(fp, "\n") ;
    fclose(fp) ;     /* close file to flush changes */
  }
  va_end(args);
  return(ecode) ;
}
开发者ID:ewong718,项目名称:freesurfer,代码行数:38,代码来源:error.c


示例10: corrupted_dcache

/**
 * corrupted_dcache
 * @brief "corrupted D-cache" error injection handler
 *
 * This will inject a corrupted D-cache error onto the system
 *
 * @param ei_func errinjct functionality
 * @return 0 on success, !0 otherwise
 */
int corrupted_dcache(ei_function *ei_func)
{
	int rc;

	if (ext_help || check_cpu_arg() || check_token_arg()) {
		corrupted_dcache_usage(ei_func);
		return 1;
	}

	if ((action < 0) || (action > MAX_DCACHE_ACTION_CODE)) {
		perr(0, "Invalid action code (%d)", action);
		corrupted_dcache_usage(ei_func);
		return 1;
	}

	if (!be_quiet) {
		printf("Injecting a %s error\n", ei_func->name);
		printf("Action: %d - %s\n", action, action_codes[action]);
	}

	if (dryrun)
		return 0;

	err_buf[0] = action;

	rc = do_rtas_errinjct(ei_func);

	return rc;
}
开发者ID:vaibhav92,项目名称:powerpc-utils,代码行数:38,代码来源:dcache.c


示例11: prifalias

void prifalias(oid inst) {
    struct snmp_pdu *pdu, *resp;
    oid tmp_oid[] = { 1,3,6,1,2,1,31,1,1,1,18,0 };
    int stat;
    char *tmp;

    if(!extended) {
        fprintf(stderr, "ifalias is only available in eXtended mode\n");
        snmp_close(ses);
        SOCK_CLEANUP;
        exit(1);
    }
    
    tmp_oid[11]=inst;
    pdu=snmp_pdu_create(SNMP_MSG_GET);
    snmp_add_null_var(pdu, tmp_oid, sizeof(tmp_oid)/sizeof(oid));
    stat=snmp_synch_response(ses, pdu, &resp);

    if (stat != STAT_SUCCESS || resp->errstat != SNMP_ERR_NOERROR) 
        perr(resp);

    if(resp->variables->val_len && strlen((char *)resp->variables->val.string)) {
        tmp=malloc((resp->variables->val_len+1) * sizeof(char));
        memcpy(tmp, resp->variables->val.string, resp->variables->val_len);
        tmp[resp->variables->val_len]=0;
        printf("  \"%s\"", tmp);
        free(tmp);
    }

    if(resp)
            snmp_free_pdu(resp);

}
开发者ID:xiongshaogang,项目名称:NetAndSysMonitor,代码行数:33,代码来源:ttg-snmp.cpp


示例12: getcntr32

uint32_t getcntr32(int dir, oid inst) {
    struct snmp_pdu *pdu, *resp;
    oid iftable_oid[]  = { 1,3,6,1,2,1,2,2,1,0,0 };    // dir=9 ; inst=10
    int stat;
    uint32_t tmp;

    pdu=snmp_pdu_create(SNMP_MSG_GET);
    iftable_oid[9]=dir;
    iftable_oid[10]=inst;
    snmp_add_null_var(pdu, iftable_oid, sizeof(iftable_oid)/sizeof(oid));
    
    stat=snmp_synch_response(ses, pdu, &resp);
    if (stat != STAT_SUCCESS || resp->errstat != SNMP_ERR_NOERROR) 
        perr(resp);

    if(resp->variables->type != ASN_COUNTER) {
        fprintf(stderr, "\nError: unsupported data type (only 32bit counter is supported in normal mode)\n");
        snmp_close(ses);
        SOCK_CLEANUP;
        exit(1);
    }

    tmp=resp->variables->val.counter64->high;

    if(resp)
        snmp_free_pdu(resp);

    return tmp;
}
开发者ID:xiongshaogang,项目名称:NetAndSysMonitor,代码行数:29,代码来源:ttg-snmp.cpp


示例13: fi_output

/**
 * IOチャネル出力時の処理 
 */
static void fi_output(ioent_t *io, event_t *evt, int exec) {
    DWORD error;

//    printf("fi_output: enter(exec=%d,trans=%d)\n", exec, evt->trans);
//    fflush(stdout);

    if (evt->trans == 0) {
        int len = STRLEN(evt->val);
        if (len == 0) {
            io_write_complete(io, 0);
            close_file(io);
            return;
        }
        io->offset = 0;
        write_exec(io, evt);
        return;
    }

    if (!SetEvent(io->ctlblk.hEvent)) {
        error = GetLastError();
        perr(PERR_SYSTEM, "SetEvent", error, __FILE__, __LINE__);
        return;
    }
    TAILQ_INSERT_TAIL(&__prc__mioq, io, mlink);
}
开发者ID:khattori,项目名称:preccs,代码行数:28,代码来源:file.c


示例14: cmpdirRename

btbool	cmpdirRename(cmpdir_t *dir, char *newPath, int WinVolume)
{
int ii;
	
	if(trace)
		printf("renaming directory %s to %s\n", dir->name, newPath);
	if(rename(dir->name, newPath) < 0) {
		/* 
		 * Remember that Windows will not let you rename a directory, if
		 * there is an open file in the directory. So if we get an EACCES
		 * error, and there are any open files in the directory just ignore
		 * the error.
		 */
		if (WinVolume && (errno == EACCES)) {
			for (ii = 0; ii < CMPDIR_MAX_FILES; ii++)
				if (dir->files[ii].fd)
					return 1;
		}
		perr(errno, "error renaming dir %s to %s", dir->name, newPath);
		return 0;
	}
	free(dir->name);
	dir->name = malloc(strlen(newPath) + 1);
	strcpy(dir->name, newPath);
	return 1;
}
开发者ID:Liryna,项目名称:fstools,代码行数:26,代码来源:cmpdir.c


示例15: main

int main(int argc, char **argv)
{
	int pid_fd = -1, r = 0;
	pid_t old_pid;
	struct pfiled pfiled;

	init_perr("pfiled");
	parse_cmdline(argc, argv);

	perr(PI, 0, "p = %ld, nr_ops = %lu\n", cmdline_portno, cmdline_nr_ops);
	
	if (cmdline_pidfile){
		pid_fd = pidfile_open(cmdline_pidfile, &old_pid);
		if (pid_fd < 0) {
			if (old_pid) {
				perr(PFE, 0, "Daemon already running, pid: %d.", old_pid);
			} else {
				perr(PFE, 0, "Cannot open or create pidfile");
			}
			return -1;
		}
	}

	if (cmdline_daemon){
		if (daemon(0, 1) < 0){
			perr(PFE, 0, "Cannot daemonize");
			r = -1;
			goto out;
		}
	}
	setup_signals();
	if (pid_fd > 0)
		pidfile_write(pid_fd);


	if (pfiled_init(&pfiled) < 0){
		r = -1;
		goto out;
	}

	r = pfiled_loop(&pfiled);
out:
	if (pid_fd > 0)
		pidfile_remove(cmdline_pidfile, pid_fd);
	return r;

}
开发者ID:cnanakos,项目名称:archipelago,代码行数:47,代码来源:pfiled.c


示例16: get_mass_storage_status

static int get_mass_storage_status(libusb_device_handle *handle, uint8_t endpoint, uint32_t expected_tag)
{
	int i, r, size;
	struct command_status_wrapper csw;

	// The device is allowed to STALL this transfer. If it does, you have to
	// clear the stall and try again.
	i = 0;
	do {
		r = libusb_bulk_transfer(handle, endpoint, (unsigned char*)&csw, 13, &size, 1000);
		if (r == LIBUSB_ERROR_PIPE) {
			libusb_clear_halt(handle, endpoint);
		}
		i++;
	} while ((r == LIBUSB_ERROR_PIPE) && (i<RETRY_MAX));
	if (r != LIBUSB_SUCCESS) {
		perr("   get_mass_storage_status: %s\n", libusb_strerror((enum libusb_error)r));
		return -1;
	}
	if (size != 13) {
		perr("   get_mass_storage_status: received %d bytes (expected 13)\n", size);
		return -1;
	}
	if (csw.dCSWTag != expected_tag) {
		perr("   get_mass_storage_status: mismatched tags (expected %08X, received %08X)\n",
			expected_tag, csw.dCSWTag);
		return -1;
	}
	// For this test, we ignore the dCSWSignature check for validity...
	printf("   Mass Storage Status: %02X (%s)\n", csw.bCSWStatus, csw.bCSWStatus?"FAILED":"Success");
	if (csw.dCSWTag != expected_tag)
		return -1;
	if (csw.bCSWStatus) {
		// REQUEST SENSE is appropriate only if bCSWStatus is 1, meaning that the
		// command failed somehow.  Larger values (2 in particular) mean that
		// the command couldn't be understood.
		if (csw.bCSWStatus == 1)
			return -2;	// request Get Sense
		else
			return -1;
	}

	// In theory we also should check dCSWDataResidue.  But lots of devices
	// set it wrongly.
	return 0;
}
开发者ID:BurhanEyuboglu,项目名称:libusb,代码行数:46,代码来源:xusb.c


示例17: intarg

static int intarg (char * op) {
  const char * tok;
  if (!(tok = strtok (0, " ")) || !isnumstr (tok) || strtok (0, " ")) {
    perr ("expected integer argument for '%s'", op);
    exit (1);
  }
  return atoi (tok);
}
开发者ID:subodhvsharma,项目名称:mopper-spo,代码行数:8,代码来源:lgluntrace.c


示例18: main

int main( int argc, char *argv[] ) {
  word_count *casted_c;
  GHashTableIter iter_c;
  //int *id_t, *id_c; 
  gpointer key_c, value_t_c, value_t, key_t;  
  if( argc != 2 ) { usage(); }
  perr( "Reading input file into hashmap...\n" );
  read_input_file( argv[1] ); 

  // File header
  perr( "Calculating association scores...\n" );
  printf( "target\tid_target\tcontext\tid_context\tf_tc\tf_t\tf_c\t" );
  printf( "cond_prob\tpmi\tnpmi\tlmi\ttscore\tzscore\tdice\tchisquare\t" );
  printf( "loglike\taffinity\tentropy_target\tentropy_context\n" );
  // First calculate all entropies for contexts
  g_hash_table_iter_init( &iter_c, c_dict );
  while( g_hash_table_iter_next( &iter_c, &key_c, &value_t_c ) ){
    casted_c = g_hash_table_lookup( c_dict, key_c );
    casted_c->entropy = calculate_entropy(casted_c->count, casted_c->links);      
  }
  g_hash_table_iter_init( &iter_t, t_dict );
  nb_targets = g_hash_table_size( t_dict );
  if( nb_threads > 1 ) {
    run_multi_threaded( &calculate_ams_all, nb_threads );
  }
  else {
    while( g_hash_table_iter_next( &iter_t, &key_t, &value_t ) ){
      calculate_ams_all_serial( (word_count *)value_t, key_t );
      update_count();
    }
  }
  // Clean and free to avoid memory leaks
  perr( "Finished, cleaning up...\n" );
  g_hash_table_destroy( t_dict );
  g_hash_table_destroy( c_dict );
  // MUST be last to be destroyed, otherwise will destroy keys in previous dicts 
  // and memory will leak from unreachable values
  g_hash_table_destroy( symbols_dict );   
  g_hash_table_destroy( inv_symbols_dict ); // no effect  
  
  perra( "Number of targets: %d\n", idc_t );
  perra( "Number of contexts: %d\n", idc_c );
  perr( "You can now calculate similarities with command below\n");
  perr( "  ./calculate_similarity [OPTIONS] <out-file>\n\n" );
  return 0;
}
开发者ID:ceramisch,项目名称:minimantics,代码行数:46,代码来源:build_profiles.c


示例19: read_ms_winsub_feature_descriptors

// Read the MS WinUSB Feature Descriptors, that are used on Windows 8 for automated driver installation
static void read_ms_winsub_feature_descriptors(libusb_device_handle *handle, uint8_t bRequest, int iface_number)
{
#define MAX_OS_FD_LENGTH 256
	int i, r;
	uint8_t os_desc[MAX_OS_FD_LENGTH];
	uint32_t length;
	void* le_type_punning_IS_fine;
	struct {
		const char* desc;
		uint8_t recipient;
		uint16_t index;
		uint16_t header_size;
	} os_fd[2] = {
		{"Extended Compat ID", LIBUSB_RECIPIENT_DEVICE, 0x0004, 0x10},
		{"Extended Properties", LIBUSB_RECIPIENT_INTERFACE, 0x0005, 0x0A}
	};

	if (iface_number < 0) return;

	for (i=0; i<2; i++) {
		printf("\nReading %s OS Feature Descriptor (wIndex = 0x%04d):\n", os_fd[i].desc, os_fd[i].index);

		// Read the header part
		r = libusb_control_transfer(handle, (uint8_t)(LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_VENDOR|os_fd[i].recipient),
			bRequest, (uint16_t)(((iface_number)<< 8)|0x00), os_fd[i].index, os_desc, os_fd[i].header_size, 1000);
		if (r < os_fd[i].header_size) {
			perr("   Failed: %s", (r<0)?libusb_error_name((enum libusb_error)r):"header size is too small");
			return;
		}
		le_type_punning_IS_fine = (void*)os_desc;
		length = *((uint32_t*)le_type_punning_IS_fine);
		if (length > MAX_OS_FD_LENGTH) {
			length = MAX_OS_FD_LENGTH;
		}

		// Read the full feature descriptor
		r = libusb_control_transfer(handle, (uint8_t)(LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_VENDOR|os_fd[i].recipient),
			bRequest, (uint16_t)(((iface_number)<< 8)|0x00), os_fd[i].index, os_desc, (uint16_t)length, 1000);
		if (r < 0) {
			perr("   Failed: %s", libusb_error_name((enum libusb_error)r));
			return;
		} else {
			display_buffer_hex(os_desc, r);
		}
	}
}
开发者ID:DmitrySni,项目名称:libusbx,代码行数:47,代码来源:xusb.c


示例20: usage

static void
usage(void)
{
    extern char *__progname;

    perr("usage: %s dev0 dev1\n", __progname);
    exit(EXIT_FAILURE);
}
开发者ID:javarange,项目名称:libpeak,代码行数:8,代码来源:fuse.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ perror函数代码示例发布时间:2022-05-30
下一篇:
C++ perp函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap