Beispiel #1
0
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);
}
Beispiel #2
0
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;
}
// 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;
}
Beispiel #4
0
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);
		}
	}
}
Beispiel #5
0
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");
}
Beispiel #6
0
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);
}
Beispiel #7
0
/*
 * 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));
}
// 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;
}
// 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;
}
Beispiel #10
0
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);
	}
Beispiel #11
0
/*
 * 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;
  }
}
Beispiel #12
0
void
cannotopen(char *file)
{
	char	msg[MSGLEN + 1];

	(void) sprintf(msg, "Cannot open file %s", file);
	putmsg(msg);
}
Beispiel #13
0
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);
	}
}
Beispiel #14
0
void
myperror(char *text)
{
	char	msg[MSGLEN + 1];	/* message */

	(void) sprintf(msg, "%s: %s", text, strerror(errno));
	putmsg(msg);
}
Beispiel #15
0
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);
        }
    }
}
Beispiel #16
0
ssize_t
tun_send(tun_t *tun, const void *buf, size_t size)
{
	struct strbuf sbuf;

	sbuf.buf = buf;
	sbuf.len = size;
	return (putmsg(tun->fd, NULL, &sbuf, 0) >= 0 ? sbuf.len : -1);
}
Beispiel #17
0
void sbbs_t::fileinfo(file_t* f)
{
	char	ext[513];
	char 	tmp[512];
	char	path[MAX_PATH+1];
	char	fpath[MAX_PATH+1];
	uint	i,j;

	for(i=0;i<usrlibs;i++)
		if(usrlib[i]==cfg.dir[f->dir]->lib)
			break;
	for(j=0;j<usrdirs[i];j++)
		if(usrdir[i][j]==f->dir)
			break;

	getfilepath(&cfg,f,path);
	bprintf(text[FiLib],i+1,cfg.lib[cfg.dir[f->dir]->lib]->lname);
	bprintf(text[FiDir],j+1,cfg.dir[f->dir]->lname);
	bprintf(text[FiFilename],getfname(path));
	SAFECOPY(fpath,path);
	fexistcase(fpath);
	if(strcmp(path,fpath) && strcmp(f->desc,getfname(fpath)))	/* Different "actual" filename */
		bprintf(text[FiFilename],getfname(fpath));

	if(f->size!=-1L)
		bprintf(text[FiFileSize],ultoac(f->size,tmp));
	bprintf(text[FiCredits]
		,(cfg.dir[f->dir]->misc&DIR_FREE || !f->cdt) ? "FREE" : ultoac(f->cdt,tmp));
	bprintf(text[FiDescription],f->desc);
	bprintf(text[FiUploadedBy],f->misc&FM_ANON ? text[UNKNOWN_USER] : f->uler);
	if(f->date)
		bprintf(text[FiFileDate],timestr(&f->date));
	bprintf(text[FiDateUled],timestr(&f->dateuled));
	bprintf(text[FiDateDled],f->datedled ? timestr(&f->datedled) : "Never");
	bprintf(text[FiTimesDled],f->timesdled);
	if(f->size!=-1L)
		bprintf(text[FiTransferTime],sectostr(f->timetodl,tmp));
	if(f->altpath) {
		if(f->altpath<=cfg.altpaths) {
			if(SYSOP)
				bprintf(text[FiAlternatePath],cfg.altpath[f->altpath-1]); 
		}
		else
			bprintf(text[InvalidAlternatePathN],f->altpath); 
	}
	CRLF;
	if(f->misc&FM_EXTDESC) {
		getextdesc(&cfg,f->dir,f->datoffset,ext);
		CRLF;
		putmsg(ext,P_NOATCODES);
		CRLF; }
	if(f->size==-1L)
		bprintf(text[FileIsNotOnline],f->name);
	if(f->opencount)
		bprintf(text[FileIsOpen],f->opencount,f->opencount>1 ? "s" : nulstr);

}
Beispiel #18
0
static int dlpi_req (struct dlpi_driver_data *dlpi, void *req, int reqlen,
		     int ackprim, void **ack, int *acklen) {
  struct strbuf ctlptr;
  int len, ret, flags;
  dl_error_ack_t *err_ack;
  
  ctlptr.maxlen = 0;
  ctlptr.len = reqlen;
  ctlptr.buf = req;
  
  if (putmsg(dlpi->fd, &ctlptr, NULL, 0) < 0) {
    ifstat_perror("putmsg");
    return 0;
  }
  
  ctlptr.maxlen = dlpi->maxlen;
  ctlptr.buf = (char *) dlpi->buf;
  ctlptr.len = 0;
  
  len = 0;
  flags = 0;
  while ((ret = getmsg(dlpi->fd, &ctlptr, NULL, &flags)) == MORECTL) {
    /* duplicate size of buf */
    dlpi->maxlen *= 2;
    if ((dlpi->buf = realloc(dlpi->buf, dlpi->maxlen)) == NULL) {
      ifstat_perror("malloc");
      return 0;
    }
    len += ctlptr.len;
    ctlptr.buf = (char *) dlpi->buf + len;
    ctlptr.maxlen = dlpi->maxlen - len;
    ctlptr.len = 0;
  }
  if (ret < 0) {
    ifstat_perror("getmsg");
    return 0;
  }
  len += ctlptr.len;
  
  err_ack = (dl_error_ack_t *) dlpi->buf;
  if (err_ack->dl_primitive != ackprim) {
    if (err_ack->dl_primitive == DL_ERROR_ACK) {
      errno = err_ack->dl_errno;
      ifstat_perror("dlpi");
    } else {
      ifstat_error("dlpi: unexpected ack type returned");
    }
    return 0;
  }

  if (ack != NULL)
    *ack = dlpi->buf;
  if (acklen != NULL)
    *acklen = len;
	
  return 1;
}
Beispiel #19
0
/**
    Put a control message on a stream

    \param      fd - DLPI device file descriptor
    \param      len - length of control message
    \param      pri - message type
    \returns    0 if OK, -1 otherwise
*/
int dlpi::putControlMessage(int fd, int len, int pri)
{
    control.len = len;
    if (putmsg(fd, &control, 0, pri) < 0)
    {
        return ERROR;
    }
    return  0;
}
Beispiel #20
0
void pick_up(void){
    struct itemlist* i = get_square(player.x, player.y, player.ele)->i;
    if(!i){
        putmsg("There is nothing to pick up here.");
    }
    else {
        // TODO what would you like to pick up? blabla
    }
}
Beispiel #21
0
/* put a control message on a stream */
static int put_ctrl(int fd, int len, int pri){

	ctl.len = len;
	if(putmsg(fd, &ctl, 0, pri) < 0){
		printf(_("Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n"), strerror(errno));
		exit(STATE_UNKNOWN);
		}

	return  0;
	}
Beispiel #22
0
/**
    Put a control + data message on a stream

    \param      fd - DLPI device file descriptor
    \param      controlLen - length of control message
    \param      dataLen - length of data message
    \param      pri - message type
    \returns    0 if OK, -1 otherwise
*/
int dlpi::putControlAndData(int fd, int controlLen, int dataLen, int pri)
{
    control.len = controlLen;
    data.len = dataLen;
    if (putmsg(fd, &control, &data, pri) < 0)
    {
        return ERROR;
    }
    return  0;
}
Beispiel #23
0
void
putmsg2(char *msg)
{
	if (incurses == NO) {
		putmsg(msg);
	} else {
		clearmsg2();
		(void) addstr(msg);
		(void) refresh();
	}
}
Beispiel #24
0
/* put a control + data message on a stream */
static int put_both(int fd, int clen, int dlen, int pri){

	ctl.len = clen;
	dat.len = dlen;
	if(putmsg(fd, &ctl, &dat, pri) < 0){
		printf(_("Error: DLPI stream API failed to get MAC in put_both/putmsg().\n"), strerror(errno));
		exit(STATE_UNKNOWN);
		}

	return  0;
	}
Beispiel #25
0
void
os_error(int t_num, const char *str, va_dcl)
#endif
{
#ifdef VA_START
    va_list args;
#endif
#ifdef VMS
    static status[2] = { 1, 0 };		/* 1 is count of error msgs */
#endif /* VMS */

    /* reprint line if screen has been written to */

    if (t_num == DATAFILE) {
        df_showdata();
    } else if (t_num != NO_CARET) {	/* put caret under error */
        if (!screen_ok)
            PRINT_MESSAGE_TO_STDERR;

        PRINT_SPACES_UNDER_PROMPT;
        PRINT_SPACES_UPTO_TOKEN;
        PRINT_CARET;
    }
    PRINT_SPACES_UNDER_PROMPT;

#ifdef VA_START
    VA_START(args, str);
# if defined(HAVE_VFPRINTF) || _LIBC
    vfprintf(stderr, str, args);
# else
    _doprnt(str, args, stderr);
# endif
    va_end(args);
#else
    fprintf(stderr, str, a1, a2, a3, a4, a5, a6, a7, a8);
#endif
    putc('\n', stderr);

    PRINT_SPACES_UNDER_PROMPT;
    PRINT_FILE_AND_LINE;

#ifdef VMS
    status[1] = vaxc$errno;
    sys$putmsg(status);
    (void) putc('\n', stderr);
#else /* VMS */
    perror("util.c");
    putc('\n', stderr);
#endif /* VMS */

    scanning_range_in_progress = FALSE;

    bail_to_command_line();
}
Beispiel #26
0
static void putsubmsg(VALUE submsg, const upb_fielddef *f, upb_sink *sink,
                      int depth) {
  if (submsg == Qnil) return;

  upb_sink subsink;
  VALUE descriptor = rb_ivar_get(submsg, descriptor_instancevar_interned);
  Descriptor* subdesc = ruby_to_Descriptor(descriptor);

  upb_sink_startsubmsg(sink, getsel(f, UPB_HANDLER_STARTSUBMSG), &subsink);
  putmsg(submsg, subdesc, &subsink, depth + 1);
  upb_sink_endsubmsg(sink, getsel(f, UPB_HANDLER_ENDSUBMSG));
}
Beispiel #27
0
void
os_error(int t_num, const char *str, va_dcl)
#endif
{
#ifdef VA_START
    va_list args;
#endif
#ifdef VMS
    static status[2] = { 1, 0 };		/* 1 is count of error msgs */
#endif /* VMS */

    /* reprint line if screen has been written to */

    if (t_num == DATAFILE) {
	df_showdata();
    } else if (t_num != NO_CARET) {	/* put caret under error */
	if (!screen_ok)
	    PRINT_MESSAGE_TO_STDERR;

	PRINT_SPACES_UNDER_PROMPT;
	PRINT_SPACES_UPTO_TOKEN;
	PRINT_CARET;
    }
    PRINT_SPACES_UNDER_PROMPT;

#ifdef VA_START
    VA_START(args, str);
# if defined(HAVE_VFPRINTF) || _LIBC
    vfprintf(stderr, str, args);
# else
    _doprnt(str, args, stderr);
# endif
    va_end(args);
#else
    fprintf(stderr, str, a1, a2, a3, a4, a5, a6, a7, a8);
#endif
    putc('\n', stderr);

    PRINT_SPACES_UNDER_PROMPT;
    PRINT_FILE_AND_LINE;

#ifdef VMS
    status[1] = vaxc$errno;
    sys$putmsg(status);
#else /* VMS */
    perror("system error");
#endif /* VMS */

    putc('\n', stderr);
    fill_gpval_string("GPVAL_ERRMSG", strerror(errno));
    common_error_exit();
}
Beispiel #28
0
ssize_t
eth_send(eth_t *e, const void *buf, size_t len)
{
#if defined(DLIOCRAW)
	return (write(e->fd, buf, len));
#else
	union DL_primitives *dlp;
	struct strbuf ctl, data;
	struct eth_hdr *eth;
	uint32_t ctlbuf[8192];
	u_char sap[4] = { 0, 0, 0, 0 };
	int dlen;

	dlp = (union DL_primitives *)ctlbuf;
#ifdef DL_HP_RAWDATA_REQ
	dlp->dl_primitive = DL_HP_RAWDATA_REQ;
	dlen = DL_HP_RAWDATA_REQ_SIZE;
#else
	dlp->unitdata_req.dl_primitive = DL_UNITDATA_REQ;
	dlp->unitdata_req.dl_dest_addr_length = ETH_ADDR_LEN;
	dlp->unitdata_req.dl_dest_addr_offset = DL_UNITDATA_REQ_SIZE;
	dlp->unitdata_req.dl_priority.dl_min =
	    dlp->unitdata_req.dl_priority.dl_max = 0;
	dlen = DL_UNITDATA_REQ_SIZE;
#endif
	eth = (struct eth_hdr *)buf;
	*(uint16_t *)sap = ntohs(eth->eth_type);
	
	/* XXX - DLSAP setup logic from ISC DHCP */
	ctl.maxlen = 0;
	ctl.len = dlen + ETH_ADDR_LEN + abs(e->sap_len);
	ctl.buf = (char *)ctlbuf;
	
	if (e->sap_len >= 0) {
		memcpy(ctlbuf + dlen, sap, e->sap_len);
		memcpy(ctlbuf + dlen + e->sap_len,
		    eth->eth_dst.data, ETH_ADDR_LEN);
	} else {
		memcpy(ctlbuf + dlen, eth->eth_dst.data, ETH_ADDR_LEN);
		memcpy(ctlbuf + dlen + ETH_ADDR_LEN, sap, abs(e->sap_len));
	}
	data.maxlen = 0;
	data.len = len;
	data.buf = (char *)buf;

	if (putmsg(e->fd, &ctl, &data, 0) < 0)
		return (-1);

	return (len);
#endif
}
Beispiel #29
0
/*****************************************************************************
 * dlbindreq()
 *
 * DLPI のルーチン。 putmsg(9F) を使って DL_BIND_REQ をドライバに送る
 * 
 *****************************************************************************/
int
dlbindreq(
    int fd,
    t_uscalar_t sap,
    t_uscalar_t max_conind,
    uint16_t    service_mode,
    uint16_t    conn_mgmt,
    t_uscalar_t xidtest_flg,
    caddr_t     buf
    )
{
    union DL_primitives	 *primitive;        
    dl_bind_req_t         bindreq;
    struct strbuf	  ctlbuf;
    int	                  flags = 0;
    int                   ret;    

    bindreq.dl_primitive    = DL_BIND_REQ;
    bindreq.dl_sap          = sap;
    bindreq.dl_max_conind   = max_conind;
    bindreq.dl_service_mode = service_mode;
    bindreq.dl_conn_mgmt    = conn_mgmt;
    bindreq.dl_xidtest_flg  = xidtest_flg;

    ctlbuf.maxlen = 0;
    ctlbuf.len    = sizeof(bindreq);
    ctlbuf.buf    = (caddr_t)&bindreq;

    if (putmsg(fd, &ctlbuf, (struct strbuf*) NULL, flags) < 0){
        dlprint_err(LOG_ERR, "dlbindreq: putmsg: %s", strerror(errno));
        return(-1);
    }

    ctlbuf.maxlen = MAXDLBUFSIZE;
    ctlbuf.len    = 0;
    ctlbuf.buf    = (caddr_t)buf;

    if ((ret = getmsg(fd, &ctlbuf, (struct strbuf *)NULL, &flags)) < 0) {
        dlprint_err(LOG_ERR, "dlbindreq: getmsg: %s\n", strerror(errno));
        return(-1);
    }

    primitive = (union DL_primitives *) ctlbuf.buf;
    if ( primitive->dl_primitive != DL_BIND_ACK){
        dlprint_err(LOG_ERR, "dlbindreq: not DL_BIND_ACK\n");
        return(-1);
    }
    
    return(0);
}
Beispiel #30
0
BOOL
writerefsfound(void)
{
	if (refsfound == NULL) {
		if ((refsfound = fopen(temp1, "w")) == NULL) {
			cannotopen(temp1);
			return (NO);
		}
	} else if (freopen(temp1, "w", refsfound) == NULL) {
		putmsg("Cannot reopen temporary file");
		return (NO);
	}
	return (YES);
}