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

C++ oserror函数代码示例

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

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



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

示例1: so_listen

void
so_listen(int fd)
{
	int r;

	osenter();
	r = listen(fd, 256);
	osleave();
	if(r < 0)
		oserror();
}
开发者ID:8l,项目名称:inferno,代码行数:11,代码来源:ipif.c


示例2: audio_set_rate

static int audio_set_rate(struct audio_info_struct *ai, ALconfig config)
{
  int dev = alGetDevice(config);
  ALpv params[1];
  
  /* Make sure the device is OK */
  if (dev < 0)
    {
      fprintf(stderr,"audio_set_rate : %s\n",alGetErrorString(oserror()));
      return 1;      
    }

  params[0].param = AL_OUTPUT_RATE;
  params[0].value.ll = alDoubleToFixed(ai->rate);
  
  if (alSetParams(dev, params,1) < 0)
    fprintf(stderr,"audio_set_rate : %s\n",alGetErrorString(oserror()));
  
  return 0;
}
开发者ID:retsyx,项目名称:slapstick,代码行数:20,代码来源:audio_sgi.c


示例3: set_rate

static int set_rate(audio_output_t *ao, ALconfig config)
{
	int dev = alGetDevice(config);
	ALpv params[1];
	
	/* Make sure the device is OK */
	if (dev < 0)
	{
		error1("set_rate: %s",alGetErrorString(oserror()));
		return 1;      
	}
	
	params[0].param = AL_OUTPUT_RATE;
	params[0].value.ll = alDoubleToFixed(ao->rate);
	
	if (alSetParams(dev, params,1) < 0)
		error1("set_rate: %s",alGetErrorString(oserror()));
	
	return 0;
}
开发者ID:5py,项目名称:libmpg123,代码行数:20,代码来源:sgi.c


示例4: lfdread

static long
lfdread(Chan *c, void *buf, long n, vlong off)
{
	USED(off);	/* can't pread on pipes */
	n = read((int)(uintptr)c->aux, buf, n);
	if(n < 0){
		iprint("error %d\n", errno);
		oserror();
	}
	return n;
}
开发者ID:99years,项目名称:plan9,代码行数:11,代码来源:devlfd.c


示例5: clipwrite

int
clipwrite(char *buf)
{
	HANDLE h;
	char *p, *e;
	Rune16 *rp;
	int n = strlen(buf);

	if(!OpenClipboard(window)) {
		oserror();
		return -1;
	}

	if(!EmptyClipboard()) {
		oserror();
		CloseClipboard();
		return -1;
	}

	h = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE, (n+1)*sizeof(Rune));
	if(h == NULL)
		panic("out of memory");
	rp = GlobalLock(h);
	utftorunes16(rp, buf, n+1);
	GlobalUnlock(h);

	SetClipboardData(CF_UNICODETEXT, h);

	h = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE, n+1);
	if(h == NULL)
		panic("out of memory");
	p = GlobalLock(h);
	memcpy(p, buf, n);
	p[n] = 0;
	GlobalUnlock(h);
	
	SetClipboardData(CF_TEXT, h);

	CloseClipboard();
	return n;
}
开发者ID:JehanneOS,项目名称:devtools-drawterm,代码行数:41,代码来源:screen.c


示例6: osproc

void
osproc(Proc *p)
{
	DWORD tid;

	if(CreateThread(0, 0, tramp, p, 0, &tid) == 0) {
		oserror();
		panic("osproc: %r");
	}

	Sleep(0);
}
开发者ID:99years,项目名称:plan9,代码行数:12,代码来源:win32.c


示例7: osnewproc

void
osnewproc(Proc *p)
{
	Oproc *op;

	op = (Oproc*)p->oproc;
	op->sema = CreateSemaphore(0, 0, 1000, 0);
	if (op->sema == 0) {
		oserror();
		panic("could not create semaphore: %r");
	}
}
开发者ID:99years,项目名称:plan9,代码行数:12,代码来源:win32.c


示例8: fileread

int fileread(int fd,void *buf,ub4 len,const char *name)
{
  long n;

  if (len == 0) return error(0,"nil read from %s",name);

  n = osread(fd,buf,len);

  if (n == -1) return oserror(0,"cannot read from %s",name);
  else if (n  == 0) return error(0,"eof on reading \ah%u bytes from %s",len,name);
  else if (n != (long)len) return error(0,"partial read \ah%ld of \ah%u bytes from %s",n,len,name);
  else return 0;
}
开发者ID:dariaphoebe,项目名称:tripover,代码行数:13,代码来源:util.c


示例9: cmdread

static long
cmdread(Chan *ch, void *a, long n, vlong offset)
{
	Conv *c;
	char *p, *cmds;
	int fd;

	USED(offset);

	p = a;
	switch(TYPE(ch->qid)) {
	default:
		error(Eperm);
	case Qcmd:
	case Qtopdir:
	case Qconvdir:
		return devdirread(ch, a, n, 0, 0, cmdgen);
	case Qctl:
		sprint(up->genbuf, "%ld", CONV(ch->qid));
		return readstr(offset, p, n, up->genbuf);
	case Qstatus:
		c = cmd.conv[CONV(ch->qid)];
		cmds = "";
		if(c->cmd != nil)
			cmds = c->cmd->f[1];
		snprint(up->genbuf, sizeof(up->genbuf), "cmd/%d %d %s %q %q\n",
			c->x, c->inuse, c->state, c->dir, cmds);
		return readstr(offset, p, n, up->genbuf);
	case Qdata:
	case Qstderr:
		fd = 1;
		if(TYPE(ch->qid) == Qstderr)
			fd = 2;
		c = cmd.conv[CONV(ch->qid)];
		qlock(&c->l);
		if(c->fd[fd] == -1){
			qunlock(&c->l);
			return 0;
		}
		qunlock(&c->l);
		osenter();
		n = read(c->fd[fd], a, n);
		osleave();
		if(n < 0)
			oserror();
		return n;
	case Qwait:
		c = cmd.conv[CONV(ch->qid)];
		return qread(c->waitq, a, n);
	}
}
开发者ID:8l,项目名称:inferno,代码行数:51,代码来源:devcmd.c


示例10: mounts_grab_config_info

/*
 * This routine opens the config file and stores the information in the
 * mounts structure.  The mounts structure must be reallocated as
 * necessary, and also the num_procs structure needs to be reallocated
 * as we define new mounts.  When all of that is done, we fill in the
 * values in the indomtab structure, those being the number of instances
 * and the pointer to the mounts structure.
 */
static void
mounts_grab_config_info(void)
{
    FILE *fp;
    char mount_name[MAXPATHLEN];
    char *q;
    size_t size;
    int mount_number = 0;
    int sep = __pmPathSeparator();

    snprintf(mypath, sizeof(mypath), "%s%c" "mounts" "%c" "mounts.conf",
             pmGetConfig("PCP_PMDAS_DIR"), sep, sep);
    if ((fp = fopen(mypath, "r")) == NULL) {
        __pmNotifyErr(LOG_ERR, "fopen on %s failed: %s\n",
                      mypath, pmErrStr(-oserror()));
        if (mounts) {
            free(mounts);
            mounts = NULL;
            mount_number = 0;
        }
        goto done;
    }

    while (fgets(mount_name, sizeof(mount_name), fp) != NULL) {
        if (mount_name[0] == '#')
            continue;
        /* Remove the newline */
        if ((q = strchr(mount_name, '\n')) != NULL) {
            *q = '\0';
        } else {
            /* This means the line was too long */
            __pmNotifyErr(LOG_WARNING, "line %d in the config file too long\n",
                          mount_number+1);
        }
        size = (mount_number + 1) * sizeof(pmdaInstid);
        if ((mounts = realloc(mounts, size)) == NULL)
            __pmNoMem("process", size, PM_FATAL_ERR);
        mounts[mount_number].i_name = malloc(strlen(mount_name) + 1);
        strcpy(mounts[mount_number].i_name, mount_name);
        mounts[mount_number].i_inst = mount_number;
        mount_number++;
    }
    fclose(fp);

done:
    if (mounts == NULL)
        __pmNotifyErr(LOG_WARNING, "\"mounts\" instance domain is empty");
    indomtab[MOUNTS_INDOM].it_set = mounts;
    indomtab[MOUNTS_INDOM].it_numinst = mount_number;
    mount_list = realloc(mount_list, (mount_number)*sizeof(mountinfo));
}
开发者ID:felipebetancur,项目名称:pcp,代码行数:59,代码来源:mounts.c


示例11: copy_fd

static void
copy_fd(int i, int o)
{ char buf[CPBUFSIZE];
  ssize_t n;

  while( (n=read(i, buf, sizeof(buf))) > 0 )
  { while( n > 0 )
    { ssize_t n2;

      if ( (n2 = write(o, buf, n)) > 0 )
      { n -= n2;
      } else
      { fprintf(stderr, "%s: write failed: %s\n", plld, oserror());
	error(1);
      }
    }
  }

  if ( n < 0 )
  { fprintf(stderr, "%s: read failed: %s\n", plld, oserror());
    error(1);
  }
}
开发者ID:ddgold,项目名称:design_patterns,代码行数:23,代码来源:swipl-ld.c


示例12: clipread

char*
clipread(void)
{
	HANDLE h;
	uchar *p;

	if(!OpenClipboard(window)) {
		oserror();
		return strdup("");
	}

	if((h = GetClipboardData(CF_UNICODETEXT)))
		p = clipreadunicode(h);
	else if((h = GetClipboardData(CF_TEXT)))
		p = clipreadutf(h);
	else {
		oserror();
		p = strdup("");
	}
	
	CloseClipboard();
	return p;
}
开发者ID:JehanneOS,项目名称:devtools-drawterm,代码行数:23,代码来源:screen.c


示例13: set_channels

static int set_channels(audio_output_t *ao, ALconfig config)
{
	int ret;
	
	if(ao->channels == 2)
		ret = alSetChannels(config, AL_STEREO);
	else
		ret = alSetChannels(config, AL_MONO);
	
	if (ret < 0)
		error1("set_channels : %s",alGetErrorString(oserror()));
	
	return 0;
}
开发者ID:5py,项目名称:libmpg123,代码行数:14,代码来源:sgi.c


示例14: stringErrorReport

static const char *
stringErrorReport(void)
{
#if ( defined(sgi) )
	return strerror(oserror());
#elif ( defined(_AIX) )
	return strerror(errno);
#else
	if ( errno > 0 && errno < sys_nerr )
		return sys_errlist[errno];
	else
		return "Unknown error.\n";
#endif
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:14,代码来源:page.c


示例15: __pmtracexmitPDU

int
__pmtracexmitPDU(int fd, __pmTracePDU *pdubuf)
{
    int			n, len;
    __pmTracePDUHdr	*php = (__pmTracePDUHdr *)pdubuf;

#if defined(HAVE_SIGPIPE)
    SIG_PF		user_onpipe;
    user_onpipe = signal(SIGPIPE, SIG_IGN);
    if (user_onpipe != SIG_DFL)	/* put user handler back */
	signal(SIGPIPE, user_onpipe);
#endif

    php->from = (__int32_t)getpid();
#ifdef PMTRACE_DEBUG
    if (__pmstate & PMTRACE_STATE_PDU) {
	int	j;
	int	jend = (php->len+(int)sizeof(__pmTracePDU)-1)/(int)sizeof(__pmTracePDU);
	char	*p;

	/* for Purify ... */
	p = (char *)pdubuf + php->len;
	while (p < (char *)pdubuf + jend*sizeof(__pmTracePDU))
	    *p++ = '~';	/* buffer end */

	fprintf(stderr, "[%d]__pmtracexmitPDU: %s fd=%d len=%d",
		php->from, pdutypestr(php->type), fd, php->len);
	for (j = 0; j < jend; j++) {
	    if ((j % 8) == 0)
		fprintf(stderr, "\n%03d: ", j);
	    fprintf(stderr, "%8x ", pdubuf[j]);
	}
	putc('\n', stderr);
    }
#endif
    len = php->len;

    php->len = htonl(php->len);
    php->from = htonl(php->from);
    php->type = htonl(php->type);
    n = (int)__pmWrite(fd, pdubuf, len);
    php->len = ntohl(php->len);
    php->from = ntohl(php->from);
    php->type = ntohl(php->type);

    if (n != len)
	return -oserror();

    return n;
}
开发者ID:goodwinos,项目名称:pcp,代码行数:50,代码来源:pdu.c


示例16: __pmAFregister

int
__pmAFregister(const struct timeval *delta, void *data, void (*func)(int, void *))
{
    qelt		*qp;
    struct timeval	now;
    struct timeval	interval;

    if (PM_MULTIPLE_THREADS(PM_SCOPE_AF))
	return PM_ERR_THREAD;

    if (!block)
	AFhold();
    if (afid == 0x8000 && !block)	/* first time */
	AFrearm();
    if ((qp = (qelt *)malloc(sizeof(qelt))) == NULL) {
	return -oserror();
    }
    qp->q_afid = ++afid;
    qp->q_data = data;
    qp->q_delta = *delta;
    qp->q_func = func;
    __pmtimevalNow(&qp->q_when);
    tadd(&qp->q_when, &qp->q_delta);

    enqueue(qp);
    if (root == qp) {
	/* we ended up at the head of the list, set itimer */
	interval = qp->q_when;
	__pmtimevalNow(&now);
	tsub(&interval, &now);

	if (interval.tv_sec == 0 && interval.tv_usec < MIN_ITIMER_USEC)
	    /* use minimal delay (platform dependent) */
	    interval.tv_usec = MIN_ITIMER_USEC;

#ifdef PCP_DEBUG
	if (pmDebug & DBG_TRACE_AF) {
	    __pmPrintStamp(stderr, &now);
	    fprintf(stderr, " AFsetitimer for delta ");
	    printdelta(stderr, &interval);
	    fputc('\n', stderr);
	}
#endif
	AFsetitimer(&interval);
    }

    if (!block)
	AFrelse();
    return qp->q_afid;
}
开发者ID:tongfw,项目名称:pcp,代码行数:50,代码来源:AF.c


示例17: audio_set_channels

static int audio_set_channels(struct audio_info_struct *ai, ALconfig config)
{
  int ret;
  
  if(ai->channels == 2)
    ret = alSetChannels(config, AL_STEREO);
  else
    ret = alSetChannels(config, AL_MONO);

  if (ret < 0)
    fprintf(stderr,"audio_set_channels : %s\n",alGetErrorString(oserror()));
  
  return 0;
}
开发者ID:retsyx,项目名称:slapstick,代码行数:14,代码来源:audio_sgi.c


示例18: so_bind

void
so_bind(int fd, int su, uchar *addr, ushort port)
{
	int i, one;
	struct sockaddr_storage sa;
	struct sockaddr_in6 *sin6;

	sin6 = (struct sockaddr_in6*)&sa;

	one = 1;
	if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&one, sizeof(one)) < 0) {
		oserrstr(up->genbuf, sizeof(up->genbuf));
		print("setsockopt: %s", up->genbuf);
	}

	if(su) {
		for(i = 600; i < 1024; i++) {
			memset(&sa, 0, sizeof(sa));
			sin6->sin6_family = AF_INET6;
			memmove(&sin6->sin6_addr, addr, IPaddrlen);
			hnputs(&sin6->sin6_port, i);

			if(bind(fd, (struct sockaddr*)sin6, sizeof(*sin6)) >= 0)	
				return;
		}
		oserror();
	}

	memset(&sa, 0, sizeof(sa));
	sin6->sin6_family = AF_INET6;
	memmove(&sin6->sin6_addr, addr, IPaddrlen);
	hnputs(&sin6->sin6_port, port);

	if(bind(fd, (struct sockaddr*)sin6, sizeof(*sin6)) < 0)
		oserror();
}
开发者ID:AndreasBriese,项目名称:node9,代码行数:36,代码来源:ipif6-posix.c


示例19: filegetprefsspec

static boolean filegetprefsspec (bigstring fname, tybrowserspec *fsprefs) {
	
	short vnum;
	long dirid;
	OSErr ec;
	
	ec = FindFolder (kOnSystemDisk, kPreferencesFolderType, kCreateFolder, &vnum, &dirid);
	
	if (oserror (ec)) 
		return (false);
	
	claymakespec (vnum, dirid, fname, fsprefs);
	
	return (true);
	} /*filegetprefsspec*/
开发者ID:pombredanne,项目名称:Frontier,代码行数:15,代码来源:claycallbacks.c


示例20: setrate

/*
	Set the sample rate of an audio port.
*/
void setrate (ALport port, double rate)
{
	int		rv;
	ALpv	params;

	rv = alGetResource(port);

	params.param = AL_RATE;
	params.value.ll = alDoubleToFixed(rate);

	if (alSetParams(rv, &params, 1) < 0)
	{
		printf("alSetParams failed: %s\n", alGetErrorString(oserror()));
	}
}
开发者ID:OS2World,项目名称:LIB-MM-audiofile,代码行数:18,代码来源:sgi.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ osgExit函数代码示例发布时间:2022-05-30
下一篇:
C++ osd_ticks函数代码示例发布时间: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