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


C++ perr函数代码示例

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


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


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