本文整理汇总了C++中putmsg函数的典型用法代码示例。如果您正苦于以下问题:C++ putmsg函数的具体用法?C++ putmsg怎么用?C++ putmsg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了putmsg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (void)
{
int fd;
struct strbuf control;
struct strbuf data;
struct log_ctl log;
char *message = "Danger Will Robinson!";
if ((fd = open ("/dev/log", O_WRONLY)) == -1)
err_msg ("Can't open /dev/log");
control.maxlen = sizeof (log);
control.len = sizeof (log);
control.buf = (caddr_t) &log;
data.maxlen = strlen (message);
data.len = strlen (message);
data.buf = message;
log.level = 42;
log.flags = SL_TRACE | SL_ERROR | SL_FATAL;
if (putmsg (fd, &control, &data, 0) == -1)
err_msg ("putmsg failed");
return (0);
}
示例2: tap_write
int tap_write(int fd, char *buf, int len)
{
struct strbuf sbuf;
sbuf.len = len;
sbuf.buf = buf;
return putmsg(fd, NULL, &sbuf, 0) >= 0 ? sbuf.len : -1;
}
示例3: DlipPromiscuous
// Set to promiscuous mode
bool DlipPromiscuous(int fd, UINT level)
{
dl_promiscon_req_t req;
struct strbuf ctl;
int flags;
// Validate arguments
if (fd == -1)
{
return false;
}
Zero(&req, sizeof(req));
req.dl_primitive = DL_PROMISCON_REQ;
req.dl_level = level;
Zero(&ctl, sizeof(ctl));
ctl.maxlen = 0;
ctl.len = sizeof(req);
ctl.buf = (char *)&req;
flags = 0;
if (putmsg(fd, &ctl, NULL, flags) < 0)
{
return false;
}
return true;
}
示例4: ctrlc_set
ctrlc_set(int4 dummy_param)
{
int4 status;
msgtype message;
error_def(ERR_LASTFILCMPLD);
if (!IS_MCODE_RUNNING)
{
message.arg_cnt = 4;
message.def_opts = message.new_opts = 0;
message.msg_number = ERR_LASTFILCMPLD;
message.fp_cnt = 2;
message.fp[0].n = strlen(source_file_name);
message.fp[1].cp = source_file_name;
sys$putmsg(&message, 0, 0, 0);
} else if (!outofband)
{
if (ctrlc_on)
{
status = sys$setef(efn_outofband);
assert(SS$_WASCLR == status);
if (status != SS$_WASCLR && status != SS$_WASSET)
GTMASSERT;
ctrap_action_is = 0;
outofband = ctrlc;
xfer_table[xf_linefetch] = op_fetchintrrpt;
xfer_table[xf_linestart] = op_startintrrpt;
xfer_table[xf_zbfetch] = op_fetchintrrpt;
xfer_table[xf_zbstart] = op_startintrrpt;
xfer_table[xf_forchk1] = op_startintrrpt;
xfer_table[xf_forloop] = op_forintrrpt;
sys$wake(0,0);
}
}
}
示例5: dlunitdatareq
void dlunitdatareq(int fd, u_char *addrp, int addrlen, u_long minpri, u_long maxpri, u_char *datap, int datalen)
{
long buf[MAXDLBUF];
union DL_primitives *dlp;
struct strbuf data, ctl;
dlp = (union DL_primitives*) buf;
dlp->unitdata_req.dl_primitive = DL_UNITDATA_REQ;
dlp->unitdata_req.dl_dest_addr_length = addrlen;
dlp->unitdata_req.dl_dest_addr_offset = sizeof (dl_unitdata_req_t);
dlp->unitdata_req.dl_priority.dl_min = minpri;
dlp->unitdata_req.dl_priority.dl_max = maxpri;
(void) memcpy(OFFADDR(dlp, sizeof (dl_unitdata_req_t)), addrp, addrlen);
ctl.maxlen = 0;
ctl.len = sizeof (dl_unitdata_req_t) + addrlen;
ctl.buf = (char *) buf;
data.maxlen = 0;
data.len = datalen;
data.buf = (char *) datap;
if (putmsg(fd, &ctl, &data, 0) < 0)
fatalSys("dlunitdatareq: putmsg");
}
示例6: dlpi_msg
static int
dlpi_msg(int fd, union DL_primitives *dlp, int rlen, int flags,
int ack, int alen, int size)
{
struct strbuf ctl;
ctl.maxlen = 0;
ctl.len = rlen;
ctl.buf = (caddr_t)dlp;
if (putmsg(fd, &ctl, NULL, flags) < 0)
return (-1);
ctl.maxlen = size;
ctl.len = 0;
flags = 0;
if (getmsg(fd, &ctl, NULL, &flags) < 0)
return (-1);
if (dlp->dl_primitive != ack || ctl.len < alen)
return (-1);
return (0);
}
示例7: dlrawdatareq
/*
* There's an ack *if* there's an error.
*/
static int
dlrawdatareq(int fd, const u_char *datap, int datalen)
{
struct strbuf ctl, data;
long buf[MAXDLBUF]; /* XXX - char? */
union DL_primitives *dlp;
int dlen;
dlp = MAKE_DL_PRIMITIVES(buf);
dlp->dl_primitive = DL_HP_RAWDATA_REQ;
dlen = DL_HP_RAWDATA_REQ_SIZE;
/*
* HP's documentation doesn't appear to show us supplying any
* address pointed to by the control part of the message.
* I think that's what raw mode means - you just send the raw
* packet, you don't specify where to send it to, as that's
* implied by the destination address.
*/
ctl.maxlen = 0;
ctl.len = dlen;
ctl.buf = (void *)buf;
data.maxlen = 0;
data.len = datalen;
data.buf = (void *)datap;
return (putmsg(fd, &ctl, &data, 0));
}
示例8: DlipAttatchRequest
// Attach to the device
bool DlipAttatchRequest(int fd, UINT devid)
{
dl_attach_req_t req;
struct strbuf ctl;
int flags;
// Validate arguments
if (fd == -1)
{
return false;
}
Zero(&req, sizeof(req));
req.dl_primitive = DL_ATTACH_REQ;
req.dl_ppa = devid;
Zero(&ctl, sizeof(ctl));
ctl.maxlen = 0;
ctl.len = sizeof(req);
ctl.buf = (char *)&req;
flags = 0;
if (putmsg(fd, &ctl, NULL, flags) < 0)
{
return false;
}
return true;
}
示例9: DlipBindRequest
// Bind to a SAP
bool DlipBindRequest(int fd)
{
dl_bind_req_t req;
struct strbuf ctl;
if (fd == -1)
{
return false;
}
Zero(&req, sizeof(req));
req.dl_primitive = DL_BIND_REQ;
req.dl_service_mode = DL_CLDLS;
req.dl_sap = 0;
Zero(&ctl, sizeof(ctl));
ctl.maxlen = 0;
ctl.len = sizeof(req);
ctl.buf = (char *)&req;
if (putmsg(fd, &ctl, NULL, 0) < 0)
{
return false;
}
return true;
}
示例10: fprintf
FILE *ed_open(char *fname, char *mode, char set_fattrs)
/* get file attributes ? 1=yes, 0=no */
{
register FILE *fp;
if(ed_fp) {
fprintf( stderr,"Panic...ed_fp left open\n");
exit( -1 );
}
unbreakable();
fp = fopen(fname, mode);
if(fp == 0) {
if(openerrflag)
putmsg("Unable to access file");
breakable();
return(0);
}
ed_fp = fp;
if (set_fattrs)
get_fattrs(ed_fp);
breakable();
return(fp);
}
示例11: Message_encode
/*
* call-seq:
* MessageClass.encode(msg) => bytes
*
* Encodes the given message object to its serialized form in protocol buffers
* wire format.
*/
VALUE Message_encode(VALUE klass, VALUE msg_rb) {
VALUE descriptor = rb_ivar_get(klass, descriptor_instancevar_interned);
Descriptor* desc = ruby_to_Descriptor(descriptor);
stringsink sink;
stringsink_init(&sink);
{
const upb_handlers* serialize_handlers =
msgdef_pb_serialize_handlers(desc);
stackenv se;
upb_pb_encoder* encoder;
VALUE ret;
stackenv_init(&se, "Error occurred during encoding: %s");
encoder = upb_pb_encoder_create(&se.env, serialize_handlers, &sink.sink);
putmsg(msg_rb, desc, upb_pb_encoder_input(encoder), 0);
ret = rb_str_new(sink.ptr, sink.len);
stackenv_uninit(&se);
stringsink_uninit(&sink);
return ret;
}
}
示例12: cannotopen
void
cannotopen(char *file)
{
char msg[MSGLEN + 1];
(void) sprintf(msg, "Cannot open file %s", file);
putmsg(msg);
}
示例13: show_msghdr
void sbbs_t::show_msg(smbmsg_t* msg, long mode)
{
char* text;
show_msghdr(msg);
if((text=smb_getmsgtxt(&smb,msg,/* body and hfields: */0))!=NULL) {
if(!(console&CON_RAW_IN))
mode|=P_WORDWRAP;
putmsg(text, mode);
smb_freemsgtxt(text);
}
if((text=smb_getmsgtxt(&smb,msg,GETMSGTXT_TAIL_ONLY))!=NULL) {
putmsg(text, mode&(~P_WORDWRAP));
smb_freemsgtxt(text);
}
}
示例14: myperror
void
myperror(char *text)
{
char msg[MSGLEN + 1]; /* message */
(void) sprintf(msg, "%s: %s", text, strerror(errno));
putmsg(msg);
}
示例15: move_player
void move_player(enum direction direction){
int x, y, ele;
int xx, yy;
struct square *from, *to;
struct tile *tilefrom, *tileto;
x = xx = player.x;
y = yy = player.y;
ele = player.ele;
switch(direction){
case(NW):
xx = x - 1;
case(N):
yy = y - 1;
break;
case(SW):
yy = y + 1;
case(W):
xx = x - 1;
break;
case(SE):
xx = x + 1;
case(S):
yy = y + 1;
break;
case(NE):
yy = y - 1;
case(E):
xx = x + 1;
break;
}
tilefrom = get_tile(pos_div(x, TILESIZE), pos_div(y, TILESIZE), 0);
if(pos_div(x, TILESIZE) == pos_div(xx, TILESIZE) && pos_div(y, TILESIZE) == pos_div(yy, TILESIZE))
tileto = tilefrom;
else
tileto = get_tile(pos_div(xx, TILESIZE), pos_div(yy, TILESIZE), 0);
from = tilefrom->type == Array? SQUARE(tilefrom->tile.sq, pos_mod(x, TILESIZE), pos_mod(y, TILESIZE)) : tilefrom->tile.fill;
to = tileto->type == Array? SQUARE(tileto->tile.sq, pos_mod(xx, TILESIZE), pos_mod(yy, TILESIZE)) : tileto->tile.fill;
// TODO handle elevation / going to adjacent layers
if(to->c){
// TODO FIGHT or do other things I guess
hit(to->c,&player);
}
else {
// try moving
switch(to->terrain){
case(TERRAIN_ROCK_WALL):
putmsg("You bump into a wall.");
break;
default:
from->c = 0;
player.x = xx;
player.y = yy;
to->c = &player;
draw_map(xx, yy, ele);
}
}
}