示例#1
0
void TERMWINDOWMEMBER StartPrinting(const char *FileName)
    {
    if (OC.Printing)
        {
        fclose(OC.PrintFile);
        }

#ifdef WINCIT
	sprintf(OC.PrintfileName, "%s.%ld", FileName, GetCurrentThreadId());
#else
	CopyStringToBuffer(OC.PrintfileName, FileName);
#endif

    normalizeString(OC.PrintfileName);

    if (citOpen(OC.PrintfileName, CO_A, &OC.PrintFile))
        {
        if (cfg.VerboseConsole)
            {
            CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 37));
            }

        OC.Printing = TRUE;
        }
    else
        {
        if (cfg.VerboseConsole)
            {
            CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 38));
            }

        OC.Printing = FALSE;
        }
    }
示例#2
0
const char *TERMWINDOWMEMBER diffstamp(time_t oldtime)
	{
	static label THREAD diffstampstr;

	time_t diff;

	diff = time(NULL) - oldtime;

	// break it down
	long days;						// long in case it has been 90 years. :)
	int hours, minutes, seconds;

	seconds = (int) (diff % 60L);
	diff /= 60L;
	minutes = (int) (diff % 60L);
	diff /= 60L;
	hours = (int) (diff % 24L);
	days = diff / 24L;


	if (days)
		{
		sprintf(diffstampstr, getmsg(394), ltoac(days),
			(days == 1L) ? ns : justs, hours, minutes, seconds);
		}
	else
		{
		sprintf(diffstampstr, getmsg(420), hours, minutes, seconds);
		}

	return (diffstampstr);
	}
示例#3
0
void TERMWINDOWMEMBER showRoomDescription(void)
	{
	OC.SetOutFlag(OUTOK);

	label DescFile;
	CurrentRoom->GetDescFile(DescFile, sizeof(DescFile));

	if (CurrentUser->IsViewRoomDesc() && *DescFile && !Talley->Visited(thisRoom) && IsFilenameLegal(DescFile, NULL))
		{
		char pathToRoomDesc[128];
		sprintf(pathToRoomDesc, sbs, cfg.roompath, DescFile);

		if (filexists(pathToRoomDesc))
			{
			if (!CurrentUser->IsExpert())
				{
				CRmPrintfCR(getmsg(577));
				}

			dumpf(pathToRoomDesc, TRUE, 0);
			doCR();

			OC.SetOutFlag(OUTOK);
			}
		else
			{
			mPrintfCR(getmsg(427), cfg.Lroom_nym, DescFile);
			}

		doCR();
		}
	}
示例#4
0
void GetSysPWHandler(const char *PW)
    {
    if (LockMessages(MSG_CONSOLE))
        {
        if (SameString(PW, cfg.f6pass))
            {
            ConsoleLock.Unlock();
            ScreenSaver.Update();

            if (cfg.VerboseConsole)
                {
                CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 40));
                }
            }
        else
            {
            if (cfg.VerboseConsole)
                {
                CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 39));
                }
            }
        }
    else
        {
        cOutOfMemory(104);
        }
    }
示例#5
0
void	la_getdat(uint4 kid, int4 code, date *date_ptr, uint4 lo, uint4 hi)
/* kid - virt. keyb. ID		*/
/* code - promt msg code	*/
/* date_ptr - date/time returned	*/
/* lo - min value of date	*/
/* hi - max value of date	*/
{
	int		status;
	bool		valid;
	char		pro[64], res[64];
	unsigned short	length;			/* res. string length	*/
	int4		mlen = 32;		/* max length of result */
	int		smg$read_string(), sys$getmsg();
	int		sys$asctim();
	$DESCRIPTOR(dini, res);			/* initial string	*/
	$DESCRIPTOR(dres, res);			/* resuting string	*/
	$DESCRIPTOR(dprm, pro);			/* prompt string	*/
	error_def(LA_INVAL);

	dprm.dsc$w_length = 64;
	status = sys$getmsg(code, &length, &dprm, 1, 0);
	if (SS$_NORMAL != status)
		lib$signal(status);
	dprm.dsc$w_length = length;
	dres.dsc$w_length = 12;
	if (0 == (*date_ptr)[1])
	{	/* no initial date */
		res[0] = 0;
		length = 0;
	} else
	{
		status = sys$asctim(&length, &dres, date_ptr, 0);
		if (SS$_NORMAL != status)
			lib$signal(status);
	}
	dres.dsc$w_length = 64;
	valid = FALSE;
	while ((SS$_NORMAL != status) || !valid)
	{
		res[length] = ' ';
		dini.dsc$w_length = length;
		status = smg$read_string(&kid, &dres, &dprm, &mlen, 0, 0, 0, &length, 0, 0, &dini);
		if (SS$_NORMAL != status)
			lib$signal(status);
		else  if (0 == length)
		{	/* no datstatus/time */
			(*date_ptr)[0] = (*date_ptr)[1] = lo = 0;
			hi = 1;
		} else  if (0 != length)
		{	/* date/time entered */
			status = lib$convert_date_string(&dres, date_ptr);
			if (SS$_NORMAL != status)
				la_putmsgs(status);
		}
		valid = ((*date_ptr)[1] >= lo || (*date_ptr)[1] < hi);
		if (!valid)
			la_putmsgu(LA_INVAL, 0, 0);
	}
}
示例#6
0
Bool GroupBuffer::Load(const char *Name)
	{
	assert(this);
	Bool Good = TRUE;
	VerifyHeap();

	if (IsValid())
		{
		FILE *File;
		char FileName[256];

		sprintf(FileName, sbs, cfg.homepath, Name);

		if ((File = fopen(FileName, FO_RB)) != NULL)
			{
			fseek(File, sizeof(long), SEEK_SET);

			for (g_slot Index = 0; Index < NumGroups; Index++)
				{
				if (!Groups[Index].Load(File))
					{
#ifndef WINCIT
					mPrintf(getmsg(83), FileName);
#endif
					Good = FALSE;
					break;
					}

				Groups[Index].Verify();
				}

			fclose(File);
			}
		else
			{
#ifndef WINCIT
			mPrintf(getmsg(78), FileName);
#endif
			Good = FALSE;
			}
		}
	else
		{
		Good = FALSE;
		}

	VerifyHeap();
	return (Good);
	}
示例#7
0
void getdstamp(char *buffer, time_t stamp)
	{
	if (stamp == 0)
		{
		strcpy(buffer, getmsg(330));
		return;
		}

	struct tm *TM = localtime(&stamp);

	char month[4];
	CopyStringToBuffer(month, monthTab[TM->tm_mon]);

	sprintf(buffer, getmsg(329), TM->tm_year % 100, month, TM->tm_mday);
	}
示例#8
0
Bool GroupBuffer::Save(const char *Name) const
	{
	assert(this);
	Bool Good = TRUE;
	VerifyHeap();

	if (IsValid())
		{
		FILE *File;
		char FileName[256];

		sprintf(FileName, sbs, cfg.homepath, Name);

		if ((File = fopen(FileName, FO_WB)) != NULL)
			{
			long l = Groups[0].SizeOfDiskRecord();
			fwrite(&l, sizeof(long), 1, File);

			for (g_slot Index = 0; Index < NumGroups; Index++)
				{
				if (!Groups[Index].Save(File))
					{
#ifndef WINCIT
					mPrintf(getmsg(661), FileName);
#endif
					Good = FALSE;
					break;
					}
				}

			fclose(File);
			}
		else
			{
#ifndef WINCIT
			mPrintf(getmsg(78), FileName);
#endif
			Good = FALSE;
			}
		}
	else
		{
		Good = FALSE;
		}

	VerifyHeap();
	return (Good);
	}
示例#9
0
void TERMWINDOWMEMBER dumpRoom(Bool infoLineAndAutoApp)
	{
	doCR();

	if (infoLineAndAutoApp)
		{
		char Buffer[80];
		if (*CurrentRoom->GetDescFile(Buffer, sizeof(Buffer)) &&  !Talley->Visited(thisRoom))
			{
			showRoomDescription();
			}
		else if (*CurrentRoom->GetInfoLine(Buffer, sizeof(Buffer)) && CurrentUser->IsViewRoomInfoLines())
			{
			mPrintfCR(getmsg(634), Buffer);
			}
		}

	// hmmm... where to put this?
	if (infoLineAndAutoApp && CurrentRoom->IsApplication() && CurrentRoom->IsAutoApp() && !Talley->Visited(thisRoom))
		{
		ExeAplic();
		}

	if (CurrentUser->IsAide())
		{
		mPrintf(getmsg(635), ltoac(Talley->TotalMessagesInRoom(thisRoom)));
		}

	const m_slot messages = Talley->MessagesInRoom(thisRoom);
	mPrintf(getmsg(636), ltoac(messages), (messages == 1) ? cfg.Lmsg_nym : cfg.Lmsgs_nym);

	const m_slot newMsgs = Talley->NewInRoom(thisRoom);
	if (newMsgs && loggedIn)
		{
		mPrintf(getmsg(637), ltoac(newMsgs));
		}

	mPrintfCR(getmsg(433));

	if (Talley->HasNewMail(thisRoom) && loggedIn)
		{
		mPrintfCR(getmsg(591));
		}

	if (Talley->HasOldMail(thisRoom) && loggedIn)
		{
		mPrintfCR(getmsg(599));
		}

	label NetID;
	RoomTab[thisRoom].GetNetID(NetID, sizeof(NetID));

	// maybe IsRoomShared check? definitely not!
	if (*NetID && CurrentUser->IsSysop() && IsNetIDCorrupted(NetID))
		{
		mPrintfCR(getmsg(464));
		}
	}
示例#10
0
const char *strip_punct(const char *str)
	{
	if (strlen(str) > MAXWORDLEN)
		{
#ifndef WINCIT
		cPrintf(getmsg(655));
		doccr();
#endif
		return (str);
		}

	const char *pc;
	for (pc = str; *pc && ispunct(*pc); pc++);

	strcpy(fmtBuf, pc);

	Bool done = FALSE;
	for (int i = strlen(fmtBuf); i && !done; i--)
		{
		if (ispunct(fmtBuf[i-1]))
			{
			fmtBuf[i-1] = 0;
			}
		else
			{
			done = TRUE;
			}
		}

	return (fmtBuf);
	}
示例#11
0
static int
readstream(int fd, char *buf, int size)
{
	struct strbuf ctlbuf, datbuf;
	union T_primitives tpi;
	int	nbytes = 0;
	int	ret = 0;
	int	flags = 0;
	int	bufsize = size;
	int	nread;

	(void) memset(&ctlbuf, 0, sizeof (ctlbuf));
	(void) memset(&datbuf, 0, sizeof (datbuf));

	ctlbuf.buf = (char *)&tpi;
	ctlbuf.maxlen = sizeof (tpi);
	datbuf.buf = buf;
	datbuf.maxlen = size;

	for (;;) {
		if (ioctl(fd, I_NREAD, &nread) < 0) {
			syslog(LOG_ERR, "I_NREAD returned error %m");
			return (-1);
		}
		if (nread + nbytes > bufsize) {
			buf = (char *)realloc(buf, (unsigned)(bufsize + nread));
			if (buf == NULL) {
				syslog(LOG_WARNING,
				    "buffer allocation failed\n");
				return (-1);
			}
			bufsize += nread;
			rlbuf = buf;
			datbuf.buf = buf + nbytes;
		}
		datbuf.maxlen = bufsize - nbytes;
		ret = getmsg(fd, &ctlbuf, &datbuf, &flags);
		if (ret < 0) {
			syslog(LOG_ERR, "getmsg failed error %m");
			return (-1);
		}
		if ((ctlbuf.len == 0) && (datbuf.len == 0)) {
			/*
			 * getmsg() returned no data - this indicates
			 * that the connection is closing down.
			 */
			cleanup(0);
		}
		if (ctlbuf.len <= 0) {
			nbytes += datbuf.len;
			datbuf.buf += datbuf.len;
			continue;
		}
		if (tpi.type == T_DATA_REQ) {
			return (nbytes);
		}
		if ((tpi.type == T_ORDREL_IND) || (tpi.type == T_DISCON_IND))
			cleanup(0);
	}
}
示例#12
0
文件: rp.cpp 项目: biglad/WinUAE
static BOOL RPSendMessagex (UINT uMessage, WPARAM wParam, LPARAM lParam,
	LPCVOID pData, DWORD dwDataSize, const RPGUESTINFO *pInfo, LRESULT *plResult)
{
	BOOL v = FALSE;
	static int cnt;
	int ncnt;
	int dolog = log_rp;

	if (!pInfo) {
		write_log (_T("RPSEND: pInfo == NULL!\n"));
		return FALSE;
	}
	if (!pInfo->hHostMessageWindow) {
		write_log (_T("RPSEND: pInfo->hHostMessageWindow == NULL!\n"));
		return FALSE;
	}
	if (uMessage == RP_IPC_TO_HOST_DEVICESEEK)
		dolog = 0;
	recursive++;
	cnt++;
	ncnt = cnt;
	if (dolog & 1)
		write_log (_T("RPSEND_%d->\n"), ncnt);
	v = RPSendMessage (uMessage, wParam, lParam, pData, dwDataSize, pInfo, plResult);
	recursive--;
	if (dolog & 1) {
		write_log (_T("RPSEND_%d(%s [%d], %08x, %08x, %08x, %d)\n"), ncnt,
			getmsg (uMessage), uMessage - WM_APP, wParam, lParam, pData, dwDataSize);
		if (v == FALSE)
			write_log (_T("ERROR %d\n"), GetLastError ());
	}
	return v;
}
示例#13
0
文件: rp.cpp 项目: biglad/WinUAE
static BOOL RPPostMessagex(UINT uMessage, WPARAM wParam, LPARAM lParam, const RPGUESTINFO *pInfo)
{
	BOOL v = FALSE;
	static int cnt;
	int ncnt;
	int dolog = log_rp;

	if (!pInfo) {
		write_log (_T("RPPOST: pInfo == NULL!\n"));
		return FALSE;
	}
	if (uMessage == RP_IPC_TO_HOST_DEVICESEEK || uMessage == RP_IPC_TO_HOST_DEVICEACTIVITY)
		dolog = 0;
	recursive++;
	cnt++;
	ncnt = cnt;
	if (dolog)
		write_log (_T("RPPOST_%d->\n"), ncnt);
	v = RPPostMessage (uMessage, wParam, lParam, pInfo);
	recursive--;
	if (dolog) {
		write_log (_T("RPPOST_%d(%s [%d], %08x, %08x)\n"), ncnt,
			getmsg (uMessage), uMessage - WM_APP, wParam, lParam);
		if (v == FALSE)
			write_log (_T("ERROR %d\n"), GetLastError ());
	}
	return v;
}
示例#14
0
void prompt(void) {
char buf[IDLEN+1];
	// Run the script named "prompt" if there is one else print "> "
	strncpy_P(buf, getmsg(M_promptid), IDLEN);	// get the name "prompt" in our cmd buf
	if (findscript(buf)) doCommand(buf);
	else msgp(M_prompt);							// else print default prompt
}
示例#15
0
文件: scxdlpi.cpp 项目: Microsoft/pal
/**
    Get a message from a stream; return type of message

    \param      fd - file descriptor
    \returns    0 if OK, -1 otherwise
*/
int dlpi::getMessage(int fd)
{
    int flags = 0;
    int result;
    int status;
    controlInfo[0] = 0;
    dataInfo[0] = 0;
    status = 0;
    result = getmsg(fd, &control, &data, &flags);
    if (result < 0)
    {
        if (errno == EINTR)
        {
            return(INTERRUPT);
        } else
        {
            return(ERROR);
        }
    }
    if (control.len > 0)
    {
        status |= CONTROL;
    }
    if (data.len > 0)
    {
        status |= DATA;
    }
    return (status);
}
示例#16
0
int main(void)
{
	int n, flag;
	char ctlbuf[BUFFSIZE], datbuf[BUFFSIZE];
	struct strbuf ctl, dat;

	ctl.buf = ctlbuf;
	ctl.maxlen = BUFFSIZE;
	dat.buf = datbuf;
	dat.maxlen = BUFFSIZE;
	for ( ; ; ) {
		flag = 0;			/* return any message */
		if ((n = getmsg(STDIN_FILENO, &ctl, &dat, &flag)) < 0) {
			perror("getmsg error");
			exit(1);
		}
		fprintf(stderr, "flag = %d, ctl.len = %d, dat.len = %d\n",
				flag, ctl.len, dat.len);

		if (dat.len == 0)
			exit(0);
		else if (dat.len > 0)
			if (write(STDOUT_FILENO, dat.buf, dat.len) != dat.len) {
				perror("write error");
				exit(1);
			}
	}
}
示例#17
0
文件: eth_tap.cpp 项目: iver6/BA
void bx_tap_pktmover_c::rx_timer()
{
  int nbytes;
  Bit8u buf[BX_PACKET_BUFSIZE];
  Bit8u *rxbuf;
  if (fd<0) return;
#if defined(__sun__)
  struct strbuf sbuf;
  int f = 0;
  sbuf.maxlen = sizeof(buf);
  sbuf.buf = (char *)buf;
  nbytes = getmsg(fd, NULL, &sbuf, &f) >=0 ? sbuf.len : -1;
#else
  nbytes = read (fd, buf, sizeof(buf));
#endif

  // hack: discard first two bytes
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__sun__) // Should be fixed for other *BSD
  rxbuf = buf;
#else
  rxbuf = buf+2;
  nbytes-=2;
#endif

#if defined(__linux__)
  // hack: TAP device likes to create an ethernet header which has
  // the same source and destination address FE:FD:00:00:00:00.
  // Change the dest address to FE:FD:00:00:00:01.
  if (!memcmp(&rxbuf[0], &rxbuf[6], 6)) {
    rxbuf[5] = guest_macaddr[5];
  }
#endif

  if (nbytes>0)
    BX_DEBUG(("tap read returned %d bytes", nbytes));
  if (nbytes<0) {
    if (errno != EAGAIN)
      BX_ERROR(("tap read error: %s", strerror(errno)));
    return;
  }
#if BX_ETH_TAP_LOGGING
  if (nbytes > 0) {
    BX_DEBUG(("receive packet length %u", nbytes));
    // dump raw bytes to a file, eventually dump in pcap format so that
    // tcpdump -r FILE can interpret them for us.
    int n = fwrite(rxbuf, nbytes, 1, rxlog);
    if (n != 1) BX_ERROR(("fwrite to rxlog failed, nbytes = %d", nbytes));
    // dump packet in hex into an ascii log file
    write_pktlog_txt(rxlog_txt, rxbuf, nbytes, 1);
    // flush log so that we see the packets as they arrive w/o buffering
    fflush(rxlog);
  }
#endif
  BX_DEBUG(("eth_tap: got packet: %d bytes, dst=%x:%x:%x:%x:%x:%x, src=%x:%x:%x:%x:%x:%x\n", nbytes, rxbuf[0], rxbuf[1], rxbuf[2], rxbuf[3], rxbuf[4], rxbuf[5], rxbuf[6], rxbuf[7], rxbuf[8], rxbuf[9], rxbuf[10], rxbuf[11]));
  if (nbytes < 60) {
    BX_INFO(("packet too short (%d), padding to 60", nbytes));
    nbytes = 60;
  }
  (*rxh)(netdev, rxbuf, nbytes);
}
示例#18
0
void
looposd ()
{
  int flag = 0, brightness = 0, sound = 0;

  /* Load user def */
  loadUserConfig();

  /* Fork OSD to loop on cmd msg */
  if (fork()==0) {
    loopcmd();
    exit(0);
  }

  osd_load ();

  if (loadqueue ()!=-1) {
    while (1 == 1) {
		  
      if (getmsg (&flag, &brightness, &sound)==-1) {
	break; // exit the loop if problems
      }

      if (flag & MOD_BRIGHTNESS) {
	osd_brightness (brightness);
      }
          
      if (flag & MOD_SOUND) {
	osd_volume (sound);
      }
    }// while 1
  }

  osd_unload ();
}
示例#19
0
int
dev_config(void)
{
    int sfd;
    struct termios tios;
    struct portconfig *pcp = &Pty.comport->portconfig;
    int modes = Pty.portmodes;
    struct strbuf *ctlmsg = &Message.ctlbuf;
    struct strbuf *datamsg = &Message.databuf;
    int flags = 0;

    sysmessage(MSG_NOTICE, "Opening %s pseudo-tty\n", P_sname);
    if ((sfd = open(P_sname, O_RDWR | O_NOCTTY)) == -1) {
	sysmessage(MSG_ERR, "Can't open slave device : %s\n",
		   strerror(errno));
	return (E_FILEIO);
    }

    memset((void *) &tios, 0, sizeof(struct termios));

    portconfig_to_termios(pcp, &tios);

    tios.c_cflag |= CREAD;
    tios.c_lflag |= NOFLSH;

/* PTY modes */
    if (modes & PORT_HUPCL) {
	tios.c_cflag |= HUPCL;
    }

    if (modes & PORT_CLOCAL) {
	tios.c_cflag |= CLOCAL;
    }

    if (modes & PORT_IGNBRK) {
	tios.c_iflag |= IGNBRK;
    }

    if (modes & PORT_IGNPAR) {
	tios.c_iflag |= IGNPAR;
    }

    if (tcsetattr(sfd, TCSANOW, &tios) == -1) {
	sysmessage(MSG_ERR, "Can't set termios : %s\n", strerror(errno));
	(void) close(sfd);
	return (E_FILEIO);
    }

    P_sfd = sfd;

    ctlmsg->buf = Ctlbuf;
    ctlmsg->maxlen = 1;

    datamsg->buf = Databuf;
    datamsg->maxlen = Pty.iosize;

    (void) getmsg(P_mfd, ctlmsg, datamsg, &flags);

    return (E_NORMAL);
}
示例#20
0
void initBitlash(unsigned long baud) {

#if defined(TINY_BUILD)
	beginSerial(9600);
#else
	beginSerial(baud);
#endif

#if defined(ARM_BUILD)
	eeinit();
#endif

	initTaskList();
	vinit();
	displayBanner();

#if !defined(TINY_BUILD)
	// Run the script named "startup" if there is one
	strncpy_P(lbuf, getmsg(M_startup), STRVALLEN);	// get the name "startup" in our cmd buf
	//if (findKey(lbuf) >= 0) doCommand(lbuf);		// look it up.  exists?  call it.
	if (findscript(lbuf)) doCommand(lbuf);			// look it up.  exists?  call it.
#endif

	initlbuf();
}
示例#21
0
static int
dlpi_msg(int fd, union DL_primitives *dlp, int rlen, int flags, unsigned 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;
}
示例#22
0
static gssize
log_transport_streams_read(LogTransport *self, void *buf, gsize buflen, GSockAddr **sa)
{
  struct strbuf ctl, data;
  struct log_ctl lc;
  gint flags;
  gint res;
  gchar tmpbuf[buflen];
  gint len;

  ctl.maxlen = ctl.len = sizeof(lc);
  ctl.buf = (char *) &lc;
  data.maxlen = buflen;
  data.len = 0;
  data.buf = tmpbuf;
  flags = 0;

  res = getmsg(self->fd, &ctl, &data, &flags);
  if (res == -1)
    return -1;
  else if ((res & (MORECTL+MOREDATA)) == 0)
    {
      len = g_snprintf(buf, buflen, "<%d>%.*s", lc.pri, data.len, data.buf);
      return MIN(len, buflen);
    }
  else
    {
      msg_error("Insufficient buffer space for retrieving STREAMS log message",
                evt_tag_printf("res", "%x", res));
    }
  return 0;
}
示例#23
0
/* get a message from a stream; return type of message */
static int get_msg(int fd){
	int flags = 0;
	int res, ret;
	ctl_area[0] = 0;
	dat_area[0] = 0;
	ret = 0;
	res = getmsg(fd, &ctl, &dat, &flags);

	if(res < 0){
		if(errno == EINTR){
			return(GOT_INTR);
			}
		else{
			printf("%s\n", "get_msg FAILED.");
			return(GOT_ERR);
			}
		}
	if(ctl.len > 0){
		ret |= GOT_CTRL;
		}
	if(dat.len > 0){
		ret |= GOT_DATA;
		}

	return(ret);
	}
示例#24
0
// Verify the ACK message
bool DlipReceiveAck(int fd)
{
	union DL_primitives *dlp;
	struct strbuf ctl;
	int flags = 0;
	char *buf;
	// Validate arguments
	if (fd == -1)
	{
		return false;
	}

	buf = MallocFast(SOLARIS_MAXDLBUF);

	Zero(&ctl, sizeof(ctl));
	ctl.maxlen = SOLARIS_MAXDLBUF;
	ctl.len = 0;
	ctl.buf = buf;

	if (getmsg(fd, &ctl, NULL, &flags) < 0)
	{
		return false;
	}

	dlp = (union DL_primitives *)ctl.buf;
	if (dlp->dl_primitive != (UINT)DL_OK_ACK && dlp->dl_primitive != (UINT)DL_BIND_ACK)
	{
		Free(buf);
		return false;
	}

	Free(buf);

	return true;
}
示例#25
0
short	la_getstr(uint4 kid, int4 code, char *res, int lo, int hi)
/* kid - virt. keyb. ID		*/
/* code - prompt message code	*/
/* res - result returned	*/
/* lo - min length of result	*/
/* hi - max length of result	*/
{
	boolean_t	valid;
	char		buf[4 * ADDR], pro[80];
	char		*ini = NULL;
	unsigned short  w_short;		/* res. string length   */
	int 		cnt;
	int4		status;
	int4		smg$read_string(), sys$getmsg();
	$DESCRIPTOR	(dini, ini);		/* initial string 	*/
	$DESCRIPTOR	(dbuf, buf);		/* resuting string 	*/
	$DESCRIPTOR	(dpro, pro);		/* prompt string	*/
	error_def	(LA_INVAL);

	dpro.dsc$w_length = 80;
	status = sys$getmsg(code, &w_short, &dpro, 1, 0);
	if (SS$_NORMAL != status)
		lib$signal(status);
	dpro.dsc$w_length = w_short;
	for (w_short = 0;  !w_short || ((0 != res[w_short]) && (hi > w_short));  w_short++)
		buf[w_short] = res[w_short];
	dini.dsc$a_pointer = buf;
	dbuf.dsc$w_length = hi;
	valid = FALSE;
	while ((SS$_NORMAL != status) || !valid)
	{
		buf[w_short] = ' ';
		dini.dsc$w_length = w_short;
		status = smg$read_string(&kid, &dbuf, &dpro, &hi, 0, 0, 0, &w_short, 0, 0, &dini);
		if (SS$_NORMAL != status)
			lib$stop(status);
		valid = ((w_short >= lo) && (w_short < hi)) || ((1 == w_short) && (1 == hi));
		if (!valid)
		{
			w_short = MIN(w_short, hi - 1);
 			la_putmsgu(LA_INVAL, 0, 0);
		}
	}
	for (cnt = 0;  cnt < hi;  cnt++)
		res[cnt] = (cnt < w_short) ? buf[cnt] : 0;
	return w_short;
}
示例#26
0
void prompt(void) {
char buf[IDLEN+1];
	// Run the script named "prompt" if there is one else print "> "
	strncpy_P(buf, getmsg(M_promptid), IDLEN);	// get the name "prompt" in our cmd buf
	int entry = findKey(buf);
	if (entry >= 0) doCommand(kludge(findend(entry)));
	else msgp(M_prompt);							// else print default prompt
}
示例#27
0
// print the nth string from the message table, e.g., msgp(M_missing);
void msgp(byte id) {
	const prog_char *msg = getmsg(id);
	for (;;) {
		char c = pgm_read_byte(msg++);
		if (!c) break;
		spb(c);
	}
}
示例#28
0
const char *special_deansi(const char *str, const char *strip)
	{
	int i = 0;
	const char *pc;
	int len = strlen(strip);

	if (strlen(str) > ((LABELSIZE * 4) + 1))
		{
#ifndef WINCIT
		cPrintf(getmsg(651));
		doccr();
#endif
		return (str);
		}

	pc = str;

	while (*pc)
		{
		if (*pc == CTRL_A && ((toupper(*(pc + 1)) == 'X' &&
				strnicmp(pc + 2, strip, len)) ||
				(*(pc + 1) == strip[0] && len == 1)))
			{
			if (*(pc + 1))
				{
				pc += 2;

				if (toupper(*(pc - 1)) == 'X')
					{
					while (*pc > CTRL_B && !isspace(*pc) &&
							toupper(*pc) != 'X' && *pc != '\r' && *pc != '\n')
						{
						pc++;
						}

					if (toupper(*pc) == 'X')
						{
						pc++;
						}
					}
				}
			else
				{
				pc++;
				}
			}
		else
			{
			fmtBuf[i] = *pc;
			i++;
			pc++;
			}
		}

	fmtBuf[i] = 0;

	return (fmtBuf);
	}
示例#29
0
void TERMWINDOWMEMBER shownode(const NodesCitC *nd, ModemConsoleE W)
    {
    assert (nd);

    if (!read_node_ddata())
        {
        wPrintf(W, getmsg(59));
        return;
        }

    const char **nettypes = (const char **) nddd->next->aux;
    const char **nodemsgs = (const char **) nddd->next->next->aux;

    wPrintf(W, getnodemsg(14), nd->GetName());                  wDoCR(W);
    wPrintf(W, getnodemsg(15), nd->GetOldRegion());             wDoCR(W);
    wPrintf(W, getnodemsg(16), nd->GetAlias(), nd->GetLocID()); wDoCR(W);
#ifdef WINCIT
    wPrintf(W, "IpAddress:   %s", nd->GetIpAddress());          wDoCR(W);
    wPrintf(W, "IpPort:      %d", nd->GetIpPort());             wDoCR(W);
#endif
    wPrintf(W, getnodemsg(17), nd->GetPreDial());               wDoCR(W);
    wPrintf(W, getnodemsg(18), nd->GetDialOut());               wDoCR(W);
    wPrintf(W, getnodemsg(19), bauds[nd->GetBaud()]);           wDoCR(W);
    wPrintf(W, getnodemsg(20), nd->GetLoginMacro());            wDoCR(W);
    wPrintf(W, getnodemsg(21), nd->GetDialTimeout());           wDoCR(W);
    wPrintf(W, getnodemsg(22), nd->GetProtocol());              wDoCR(W);
    wPrintf(W, getnodemsg(23), nd->GetWaitTimeout());           wDoCR(W);
    wPrintf(W, getnodemsg(24), nd->GetMailFileName());          wDoCR(W);

    label Buffer;
    wPrintf(W, getnodemsg(25), nd->GetAutoHall() > 0 ?
            HallData[nd->GetAutoHall()].GetName(Buffer, sizeof(Buffer)) : getnodemsg(28));
    wDoCR(W);

    wPrintf(W, getnodemsg(26), nd->GetAutoGroup() > 0 ?
            GroupData[nd->GetAutoGroup()].GetName(Buffer, sizeof(Buffer)) : getnodemsg(28));
    wDoCR(W);

    wPrintf(W, getnodemsg(27), GroupData[nd->GetMapUnknownGroup()].GetName(Buffer, sizeof(Buffer)));
    wDoCR(W);

    wPrintf(W, getnodemsg(29), nettypes[nd->GetNetworkType()],
            nd->GetNetworkRevisionNumber() ? nd->GetNetworkRevisionNumber() + '@' : ' ');
    wDoCR(W);

    wPrintf(W, getnodemsg(30), nd->GetCreatePacket());          wDoCR(W);
    wPrintf(W, getnodemsg(31), nd->GetExtractPacket());         wDoCR(W);
    wPrintf(W, getnodemsg(32), nd->IsAutoRoom());               wDoCR(W);
    wPrintf(W, getnodemsg(33), nd->GetRequest());               wDoCR(W);
    wPrintf(W, getnodemsg(34), nd->IsGateway());                wDoCR(W);
    wPrintf(W, getnodemsg(35), nd->GetFetch());                 wDoCR(W);
    wPrintf(W, getnodemsg(36), nd->GetNetFail());               wDoCR(W);
    wPrintf(W, getnodemsg(37), nd->GetRedial());                wDoCR(W);
    wPrintf(W, getnodemsg(38), nd->GetOutputPace());            wDoCR(W);

    dump_node_ddata();
    }
示例#30
0
int tun_read(int fd, char *buf, int len)
{
	struct strbuf sbuf;
	int f = 0;

	sbuf.maxlen = len;
	sbuf.buf = buf;
	return getmsg(fd, NULL, &sbuf, &f) >= 0 ? sbuf.len : -1;
}