Example #1
0
void sysimport (char *befbuf)
//*************************************************************************
//
//*************************************************************************
{
  lastfunc("sysimport");

  if (! *befbuf)
    putf("Syntax: IMPORT <filename>\n");
  else
    if (t->input != io_file && t->output != io_file)
    {
      b->inputfile = s_fopen(defext(befbuf, "imp"), "lrb");
      if (b->inputfile)
      {
        b->oldinput = t->input;
        t->input = io_file;
      }
      else
        putf(ms(m_filenotfound), befbuf);
    }
    else
    {
      char *im = stristr(befbuf, ".imp");
      if (im) *im = 0;
      runbatch(befbuf);
    }
}
Example #2
0
int grep (char *name, char *pattern, bitfeld options)
//*************************************************************************
//
//
//
//*************************************************************************
{
  FILE *f;
  CRegEx cr;
  int matches = 0;
  cr.m_options = options;

  if (name[0])
  {
    if (cr.regex_compile(pattern))
    {
      f = s_fopen(name, "srt");
      if (f)
      {
        setvbuf(f, NULL, _IOFBF, 4096);
        matches = cr.grepfile(f);
        s_fclose(f);
      }
      else
        putf(ms(m_filenotopen), name);
    }
    else
      putf(ms(m_badregex));
  }
  return matches;
}
Example #3
0
void WriteJAFont( char *filename, jafont_t font[256] )
{
	FILE *fp;
	char magic[4];
	magic[0] = 0;
	magic[1] = 0;
	magic[2] = 0;
	magic[3] = 0;
	int i;
	int def = 0;
	fp = fopen(filename, "wb");
	fseek( fp, 0, SEEK_SET );
	i = 0;
	while( i < 256 )
	{
		puts( font[i].phWidth, fp );
		puts( font[i].phHeight, fp );
		puts( font[i].hAdv, fp );
		puts( font[i].hOfs, fp );
		putw( font[i].baseline, fp );
		putf( font[i].st1[0], fp );
		putf( font[i].st1[1], fp );
		putf( font[i].st2[0], fp );
		putf( font[i].st2[1], fp );
		i++;
	}
	puts( 16, fp );
	puts( 18, fp );
	puts( 16, fp );
	puts( 12, fp );
	puts( 0, fp );
	puts( 0, fp );
	fclose( fp );
}
Example #4
0
int CRegEx::grepfile (FILE * fp)
//*************************************************************************
//
//  Scan the file for the pattern in pbuf[]
//
//*************************************************************************
{
  unsigned int lno = 0, count = 0, n;
  char obuf[LMAX];

  while (fgets(obuf, LMAX - 2, fp))
  {
    ++lno;
    n = regex_match(obuf);
    if ((n && ! (m_options & o_v)) || (! n && (m_options & o_v)))
    {
      ++count;
      if (! (m_options & o_c))
      {
        if (m_options & o_n)
          putf("%d:", lno);
        putf("%s", obuf);
      }
    }
    if ((lno % 50) == 0)
    {
      waitfor(e_ticsfull);
      if (testabbruch()) break;
    }
  }
  if ((m_options & o_c) && ! (m_options & o_x))
    putf(ms(m_matchinglines), count);
  return count;
}
Example #5
0
int main(int argc, char *argv[])
{
  time_t t;
  struct tm tmarg, tmp;
  signed_time_t y;
  char *str;

  if (argc <= 1) {
    fprintf(stderr, "usage: mktime year [mon [day [hour [min [sec [isdst]]]]]]\n");
    exit(1);
  }

  tmarg.tm_year = atoi(argv[1]) - 1900;
  tmarg.tm_mon = 2 < argc ? atoi(argv[2]) - 1 : 0;
  tmarg.tm_mday = 3 < argc ? atoi(argv[3]) : 1;
  tmarg.tm_hour = 4 < argc ? atoi(argv[4]) : 0;
  tmarg.tm_min = 5 < argc ? atoi(argv[5]) : 0;
  tmarg.tm_sec = 6 < argc ? atoi(argv[6]) : 0;
  tmarg.tm_isdst = 7 < argc ? atoi(argv[7]) : -1;

  tmp = tmarg;

  t = mktime(&tmp);
  if (t == (time_t)-1) { fprintf(stderr, "mktime returns -1 (error)\n"); exit(1); }

  y = 1900 + (signed_time_t)tmarg.tm_year;
  printf("%"PRIdSTIME"-%02d-%02d %02d:%02d:%02d",
    y, tmarg.tm_mon + 1, tmarg.tm_mday,
    tmarg.tm_hour, tmarg.tm_min, tmarg.tm_sec);

  printf(" %s", CHOOSE_ISDST(tmarg.tm_isdst, "std", "dst", "std/dst"));

  printf(" ->");

  printf(" %"PRIdTIME, t);

  y = 1900 + (signed_time_t)tmp.tm_year;
  printf(" %"PRIdSTIME"-%02d-%02d %02d:%02d:%02d",
    y, tmp.tm_mon + 1, tmp.tm_mday,
    tmp.tm_hour, tmp.tm_min, tmp.tm_sec);

  (void)((WITH_TM_GMTOFF(1) || WITH_TIMEZONE_ALTZONE(0 <= tmp.tm_isdst)) && putchar(' '));
  (void)(WITH_TM_GMTOFF(print_gmtoff(tmp.tm_gmtoff, 0)) ||
      WITH_TIMEZONE_ALTZONE(0 <= tmp.tm_isdst && print_gmtoff(tmp.tm_isdst ? altzone : timezone, 1)));

  printf(" %s", CHOOSE_ISDST(tmp.tm_isdst, "std", "dst", "std/dst"));

  (void)(WITH_TM_ZONE(putf(" %s", tmp.tm_zone)) ||
      WITH_TZNAME(0 <= tmp.tm_isdst && putf(" %s", tzname[tmp.tm_isdst ? 1 : 0])));

  printf(" tm_yday=%d", tmp.tm_yday);

  (str = weekday_str(tmp.tm_wday)) ? printf(" (%s)", str) :
                                     printf(" tm_wday=%d", tmp.tm_wday);
  
  printf("\n");

  return 0;
}
Example #6
0
static bool textprinter_endstr(void *closure, const void *handler_data) {
  upb_textprinter *p = closure;
  UPB_UNUSED(handler_data);
  putf(p, "\"");
  endfield(p);
  return true;
}
Example #7
0
void putversion_tnc (void)
//**************************************************************************
//
//
//**************************************************************************
{
  if (l2vorhanden)
  {
    if (highestport > 0) putf("OpenBCM-L2 %d ports"
#ifdef _AX25K
            ", Linux Kernel AX25"
#endif
            "\n", highestport - 1);
  }
  else putf("-\n");
}
Example #8
0
static void
prompt(void)
{
	putf(LM);
	if (CO)
		putchr('\n');
}
Example #9
0
void control_tnc (char *befehl)
//**************************************************************************
//
//
//**************************************************************************
{                              // *** dummy!
  putf("L2: %s\n", befehl);
}
Example #10
0
static void *textprinter_startstr(void *closure, const void *handler_data,
                      size_t size_hint) {
  upb_textprinter *p = closure;
  const upb_fielddef *f = handler_data;
  UPB_UNUSED(size_hint);
  indent(p);
  putf(p, "%s: \"", upb_fielddef_name(f));
  return p;
}
Example #11
0
static void *textprinter_startsubmsg(void *closure, const void *handler_data) {
  upb_textprinter *p = closure;
  const char *name = handler_data;
  CHECK(indent(p));
  putf(p, "%s {%c", name, p->single_line_ ? ' ' : '\n');
  p->indent_depth_++;
  return p;
err:
  return UPB_BREAK;
}
Example #12
0
void testdfull (void)
//*************************************************************************
//
//*************************************************************************
{
  if (   (dfree(".", 0) < HOMEDISKFULL)
      || (dfree(m.userpath, 0) < USERDISKFULL)
      || (dfree(m.infopath, 0) < INFODISKFULL))
    putf("***************** HDD is full ******************\n");
}
Example #13
0
int autofwd (char *call, int ausgabe)
//*************************************************************************
//
//*************************************************************************
{
  lastfunc("autofwd");
  int ret = unbekannt;
  bitfeld options;

  if (! afp || ! aboxdest) return unbekannt;
  if (ausgabe)
  {
    scanoptions(call);
    options = b->optplus;
  }
  else
    options = 0;
  strupr(call);
  ret = autofile(call, ausgabe);
  call += blkill(call);
  if ((options & o_a) && ret == auto_bekannt)
    putf("Autopath: Found %s in "AFWDLISTNAME", using autofwd to %s.\n",
                                                call, b->destboxlist);
  else
  {
    if (ret == unbekannt)
    {
      if (*call && ! (strcmp(call,m.boxname)))
        ret = unbekannt; // eigenes Boxcall ausschliessen
      else
        ret = autohadr(call, ausgabe); //only really new adresses may not be found
    }
    if (ausgabe)
    {
      if (ret == auto_bekannt)
        putf("Autopath: forward %s to %s seems to be possible for autorouter.\n",
             call, b->destboxlist);
      else
        putf("Autopath: Autorouter found no path for %s\n", call);
    }
  }
  return ret;
}
Example #14
0
int executeServerCommand(int msfd, struct url *url, struct config *cfg) {
	/* In base al comando inserito, viene chiamata la rispettiva funzione. */

	// Si controlla l'esistenza dell'identificativo e si cambia directory.
	int returnCode = checkIdentifier(url->identifier, cfg->rootdir);

	if (returnCode != BAD_IDENTIFIER) {
		char* identifierPath = createFullPath(cfg->rootdir, url->identifier);
		char* command = url->command;

		if (strcmp(command, "mkdir") == 0) {
			returnCode = makeDir(identifierPath, url->argument);
		} else if (strcmp(command, "put") == 0) {
			returnCode = putf(msfd, identifierPath, url->argument, url->optionalArgument, "wb");
		} else if (strcmp(command, "puta") == 0) {
			returnCode = putf(msfd, identifierPath, url->argument, url->optionalArgument, "ab");
		} else if (strcmp(command, "move") == 0) {
			returnCode = movefd(identifierPath, url->argument, url->optionalArgument);
		} else if (strcmp(command, "dele") == 0) {
			returnCode = deletefd(identifierPath, url->argument);
		} else if (strcmp(command, "get") == 0) {
			returnCode = getf(msfd, identifierPath, url->argument);
		} else {
			log_err("Unknown_command");
			returnCode = MALFORMED_COMMAND;
		}

		free(identifierPath);
	} else {
		if (strcmp(url->command, "get") == 0) {
			/* Se l'identificativo non è valido, bisogna comunque
			avvertire il client che non sta per ricevere alcun file. */
			sendEntireFile(msfd, NULL);
		} else if (strcmp(url->command, "put") == 0 || strcmp(url->command, "puta") == 0) {
			/* E allo stesso modo devo avvertire il client, nel caso in cui
			lui voglia effettuare un put ma l'identificativo è errato. */
			sendReturnCode(msfd, returnCode);
		}
	}

	log_info("Return code: %d", returnCode);
	return returnCode;
}
Example #15
0
static bool textprinter_putbool(void *closure, const void *handler_data,
                                bool val) {
  upb_textprinter *p = closure;
  const upb_fielddef *f = handler_data;
  CHECK(indent(p));
  putf(p, "%s: %s", upb_fielddef_name(f), val ? "true" : "false");
  CHECK(endfield(p));
  return true;
err:
  return false;
}
Example #16
0
int main(int argc, char* argv[])
{
    int n, nx, nz;
    float dx, dz;
    float ** t0, **tinit, **t;
    sf_file so1, so2, so3;
    char * fname = 0;

    sf_init(argc,argv);

    so1 = sf_output("out");
    so2 = sf_output("init");
    so3 = sf_output("final");

    if (!sf_getint("N",&n)) sf_error("No N= ");
    nx = nz = n;

    dx = dz = 1.f / (n - 1);

    putf(so1, nx, nz, dx, dz);
    putf(so2, nx, nz, dx, dz);
    putf(so3, nx, nz, dx, dz);


    fname = sf_getstring ("sample");

    t0    = sf_floatalloc2(nz,nx);
    tinit = sf_floatalloc2(nz,nx);
    t     = sf_floatalloc2(nz,nx);

    // sprintf(fname,"sample%-3d",S.nx);
    read4file(fname, t0, tinit, t, nx, nz);

    sf_floatwrite(t0[0],    nx*nz, so1);
    sf_floatwrite(tinit[0], nx*nz, so2);
    sf_floatwrite(t[0],     nx*nz, so3);

    sf_close();

    exit(0);
}
Example #17
0
File: main.c Project: gepp88/Meiji
O#include "beagleboneblack.h"

static void banner(void)
{
	putcn('=', 65);
	putnl();
	puts("SERT: System Environment for Real-Time, version ");
	putf(2015.11, 2);	/* just for trying the floating-point unit */
	puts("\nMarco Cesati, SPRG, DICII, University of Rome Tor Vergata\n");
	putcn('=', 65);
	putnl();
}
Example #18
0
/* Output a symbolic value from the enum if found, else just print as int32. */
static bool textprinter_putenum(void *closure, const void *handler_data,
                                int32_t val) {
  upb_textprinter *p = closure;
  const upb_fielddef *f = handler_data;
  const upb_enumdef *enum_def = upb_downcast_enumdef(upb_fielddef_subdef(f));
  const char *label = upb_enumdef_iton(enum_def, val);
  if (label) {
    indent(p);
    putf(p, "%s: %s", upb_fielddef_name(f), label);
    endfield(p);
  } else {
    if (!textprinter_putint32(closure, handler_data, val))
      return false;
  }
  return true;
}
Example #19
0
static unsigned putchw(FILE *putp, struct param *p)
{
    unsigned written = 0;
    char ch;
    int n = p->width;
    char *bf = p->bf;

    /* Number of filling characters */
    while (*bf++ && n > 0)
        n--;
    if (p->sign)
        n--;
    if (p->alt && p->base == 16)
        n -= 2;
    else if (p->alt && p->base == 8)
        n--;

    /* Fill with space, before alternate or sign */
    if (!p->lz) {
        while (n-- > 0)
            written += putf(putp, ' ');
    }

    /* print sign */
    if (p->sign)
        written += putf(putp, '-');

    /* Alternate */
    if (p->alt && p->base == 16) {
        written += putf(putp, '0');
        written += putf(putp, (p->uc ? 'X' : 'x'));
    } else if (p->alt && p->base == 8) {
        written += putf(putp, '0');
    }

    /* Fill with zeros, after alternate or sign */
    if (p->lz) {
        while (n-- > 0)
            written += putf(putp, '0');
    }

    /* Put actual buffer */
    bf = p->bf;
    while ((ch = *bf++))
        written += putf(putp, ch);
    
    return written;
}
Example #20
0
static int
getname(void)
{
	int c;
	char *np;
	unsigned char cs;
	int ppp_state = 0;
	int ppp_connection = 0;

	/*
	 * Interrupt may happen if we use CBREAK mode
	 */
	if (setjmp(intrupt)) {
		signal(SIGINT, SIG_IGN);
		return (0);
	}
	signal(SIGINT, interrupt);
	set_flags(1);
	prompt();
	oflush();
	if (PF > 0) {
		sleep(PF);
		PF = 0;
	}
	if (tcsetattr(STDIN_FILENO, TCSANOW, &tmode) < 0) {
		syslog(LOG_ERR, "%s: %m", ttyn);
		exit(1);
	}
	crmod = digit = lower = upper = 0;
	np = name;
	for (;;) {
		oflush();
		if (read(STDIN_FILENO, &cs, 1) <= 0)
			exit(0);
		if ((c = cs&0177) == 0)
			return (0);

		/* PPP detection state machine..
		   Look for sequences:
		   PPP_FRAME, PPP_STATION, PPP_ESCAPE, PPP_CONTROL_ESCAPED or
		   PPP_FRAME, PPP_STATION, PPP_CONTROL (deviant from RFC)
		   See RFC1662.
		   Derived from code from Michael Hancock, <*****@*****.**>
		   and Erik 'PPP' Olson, <*****@*****.**>
		 */

		if (PP && (cs == PPP_FRAME)) {
			ppp_state = 1;
		} else if (ppp_state == 1 && cs == PPP_STATION) {
			ppp_state = 2;
		} else if (ppp_state == 2 && cs == PPP_ESCAPE) {
			ppp_state = 3;
		} else if ((ppp_state == 2 && cs == PPP_CONTROL)
			|| (ppp_state == 3 && cs == PPP_CONTROL_ESCAPED)) {
			ppp_state = 4;
		} else if (ppp_state == 4 && cs == PPP_LCP_HI) {
			ppp_state = 5;
		} else if (ppp_state == 5 && cs == PPP_LCP_LOW) {
			ppp_connection = 1;
			break;
		} else {
			ppp_state = 0;
		}

		if (c == EOT || c == CTRL('d'))
			exit(0);
		if (c == '\r' || c == '\n' || np >= &name[sizeof name-1]) {
			putf("\r\n");
			break;
		}
		if (islower(c))
			lower = 1;
		else if (isupper(c))
			upper = 1;
		else if (c == ERASE || c == '\b' || c == 0177) {
			if (np > name) {
				np--;
				if (cfgetospeed(&tmode) >= 1200)
					puts("\b \b");
				else
					putchr(cs);
			}
			continue;
		} else if (c == KILL || c == CTRL('u')) {
			putchr('\r');
			if (cfgetospeed(&tmode) < 1200)
				putchr('\n');
			/* this is the way they do it down under ... */
			else if (np > name)
				puts("                                     \r");
			prompt();
			digit = lower = upper = 0;
			np = name;
			continue;
		} else if (isdigit(c))
			digit = 1;
		if (IG && (c <= ' ' || c > 0176))
			continue;
		*np++ = c;
		putchr(cs);
	}
	signal(SIGINT, SIG_IGN);
	*np = 0;
	if (c == '\r')
		crmod = 1;
	if ((upper && !lower && !LC) || UC)
		for (np = name; *np; np++)
			if (isupper(*np))
				*np = tolower(*np);
	return (1 + ppp_connection);
}
Example #21
0
int
main(int argc, char *argv[])
{
	extern	char **environ;
	int first_sleep = 1, first_time = 1;
	struct rlimit limit;
	int rval;

	signal(SIGINT, SIG_IGN);
	signal(SIGQUIT, SIG_IGN);

	openlog("getty", LOG_ODELAY|LOG_CONS|LOG_PID, LOG_AUTH);
	gethostname(hostname, sizeof(hostname) - 1);
	hostname[sizeof(hostname) - 1] = '\0';
	if (hostname[0] == '\0')
		strcpy(hostname, "Amnesiac");

	/*
	 * Limit running time to deal with broken or dead lines.
	 */
	(void)signal(SIGXCPU, timeoverrun);
	limit.rlim_max = RLIM_INFINITY;
	limit.rlim_cur = GETTY_TIMEOUT;
	(void)setrlimit(RLIMIT_CPU, &limit);

	gettable("default", defent);
	gendefaults();
	tname = "default";
	if (argc > 1)
		tname = argv[1];

	/*
	 * The following is a work around for vhangup interactions
	 * which cause great problems getting window systems started.
	 * If the tty line is "-", we do the old style getty presuming
	 * that the file descriptors are already set up for us.
	 * J. Gettys - MIT Project Athena.
	 */
	if (argc <= 2 || strcmp(argv[2], "-") == 0)
	    strcpy(ttyn, ttyname(STDIN_FILENO));
	else {
	    strcpy(ttyn, dev);
	    strncat(ttyn, argv[2], sizeof(ttyn)-sizeof(dev));
	    if (strcmp(argv[0], "+") != 0) {
		chown(ttyn, 0, 0);
		chmod(ttyn, 0600);
		revoke(ttyn);

		/*
		 * Do the first scan through gettytab.
		 * Terminal mode parameters will be wrong until
		 * defttymode() called, but they're irrelevant for
		 * the initial setup of the terminal device.
		 */
		dogettytab();

		/*
		 * Init or answer modem sequence has been specified.
		 */
		if (IC || AC) {
			if (!opentty(ttyn, O_RDWR|O_NONBLOCK))
				exit(1);
			defttymode();
			setttymode(1);
		}

		if (IC) {
			if (getty_chat(IC, CT, DC) > 0) {
				syslog(LOG_ERR, "modem init problem on %s", ttyn);
				(void)tcsetattr(STDIN_FILENO, TCSANOW, &tmode);
				exit(1);
			}
		}

		if (AC) {
			int i, rfds;
			struct timeval to;

        		rfds = 1 << 0;	/* FD_SET */
        		to.tv_sec = RT;
        		to.tv_usec = 0;
        		i = select(32, (fd_set*)&rfds, (fd_set*)NULL,
        			       (fd_set*)NULL, RT ? &to : NULL);
        		if (i < 0) {
				syslog(LOG_ERR, "select %s: %m", ttyn);
			} else if (i == 0) {
				syslog(LOG_NOTICE, "recycle tty %s", ttyn);
				(void)tcsetattr(STDIN_FILENO, TCSANOW, &tmode);
				exit(0);  /* recycle for init */
			}
			i = getty_chat(AC, CT, DC);
			if (i > 0) {
				syslog(LOG_ERR, "modem answer problem on %s", ttyn);
				(void)tcsetattr(STDIN_FILENO, TCSANOW, &tmode);
				exit(1);
			}
		} else { /* maybe blocking open */
			if (!opentty(ttyn, O_RDWR | (NC ? O_NONBLOCK : 0 )))
				exit(1);
		}
	    }
	}

	defttymode();
	for (;;) {

		/*
		 * if a delay was specified then sleep for that 
		 * number of seconds before writing the initial prompt
		 */
		if (first_sleep && DE) {
		    sleep(DE);
		    /* remove any noise */
		    (void)tcflush(STDIN_FILENO, TCIOFLUSH);
		}
		first_sleep = 0;

		setttymode(0);
		if (AB) {
			tname = autobaud();
			dogettytab();
			continue;
		}
		if (PS) {
			tname = portselector();
			dogettytab();
			continue;
		}
		if (CL && *CL)
			putpad(CL);
		edithost(HE);

		/* if this is the first time through this, and an
		   issue file has been given, then send it */
		if (first_time && IF) {
			int fd;

			if ((fd = open(IF, O_RDONLY)) != -1) {
				char * cp;

				while ((cp = getline(fd)) != NULL) {
					  putf(cp);
				}
				close(fd);
			}
		}
		first_time = 0;

		if (IM && *IM && !(PL && PP))
			putf(IM);
		if (setjmp(timeout)) {
			cfsetispeed(&tmode, B0);
			cfsetospeed(&tmode, B0);
			(void)tcsetattr(STDIN_FILENO, TCSANOW, &tmode);
			exit(1);
		}
		if (TO) {
			signal(SIGALRM, dingdong);
			alarm(TO);
		}

		rval = 0;
		if (AL) {
			const char *p = AL;
			char *q = name;

			while (*p && q < &name[sizeof name - 1]) {
				if (isupper(*p))
					upper = 1;
				else if (islower(*p))
					lower = 1;
				else if (isdigit(*p))
					digit = 1;
				*q++ = *p++;
			}
		} else if (!(PL && PP))
			rval = getname();
		if (rval == 2 || (PL && PP)) {
			oflush();
			alarm(0);
			limit.rlim_max = RLIM_INFINITY;
			limit.rlim_cur = RLIM_INFINITY;
			(void)setrlimit(RLIMIT_CPU, &limit);
			execle(PP, "ppplogin", ttyn, (char *) 0, env);
			syslog(LOG_ERR, "%s: %m", PP);
			exit(1);
		} else if (rval || AL) {
			int i;

			oflush();
			alarm(0);
			signal(SIGALRM, SIG_DFL);
			if (name[0] == '\0')
				continue;
			if (name[0] == '-') {
				puts("user names may not start with '-'.");
				continue;
			}
			if (!(upper || lower || digit)) {
				if (AL) {
					syslog(LOG_ERR,
					    "invalid auto-login name: %s", AL);
					exit(1);
				} else
					continue;
			}
			set_flags(2);
			if (crmod) {
				tmode.c_iflag |= ICRNL;
				tmode.c_oflag |= ONLCR;
			}
#if REALLY_OLD_TTYS
			if (upper || UC)
				tmode.sg_flags |= LCASE;
			if (lower || LC)
				tmode.sg_flags &= ~LCASE;
#endif
			if (tcsetattr(STDIN_FILENO, TCSANOW, &tmode) < 0) {
				syslog(LOG_ERR, "tcsetattr %s: %m", ttyn);
				exit(1);
			}
			signal(SIGINT, SIG_DFL);
			for (i = 0; environ[i] != (char *)0; i++)
				env[i] = environ[i];
			makeenv(&env[i]);

			limit.rlim_max = RLIM_INFINITY;
			limit.rlim_cur = RLIM_INFINITY;
			(void)setrlimit(RLIMIT_CPU, &limit);
			execle(LO, "login", AL ? "-fp" : "-p", name,
			    (char *) 0, env);
			syslog(LOG_ERR, "%s: %m", LO);
			exit(1);
		}
		alarm(0);
		signal(SIGALRM, SIG_DFL);
		signal(SIGINT, SIG_IGN);
		if (NX && *NX) {
			tname = NX;
			dogettytab();
		}
	}
}
Example #22
0
void wx::show_wx (wxdata_t *wx, int detail)
//*************************************************************************
// Userinterface for wx-data
//  detail:  0..raw format (debugging-output)
//           1..short format
//           2..long (detailed) format
//           3..dl3baa-format
//*************************************************************************
{
  static char *beaunam[] = {
   "Windstille", "leiser Zug", "leichte Briese", "maessige Briese",
   "frische Briese", "starker Wind", "steifer Wind", "stuermischer Wind",
   "Sturm", "schwerer Sturm", "orkanartiger Sturm", "Orkan"};
  if (! wx->data_valid)
  {
    putf("Sorry, no data available.\n");
    return;
  }
  putf("WX-Station %s\n", m.wxstnname);
  switch (detail)
  {
   case 1: //short format
     putf("Aussentemperatur.....%6.1f C\n", wx->outdoort);
     putf("Raumtemperatur.......%6.1f C\n", wx->indoort);
     putf("Luftdruck QNH........%6.1f hPa\n", wx->air_pres_qnh);
     putf("Rel.Luftfeuchte......%6.1f %%\n", wx->humidity);
     putf("Windgeschwindigkeit..%6.1f km/h\n", wx->windspeed*3.6);
     if (wx->windspeed > 0.1) // wind_direction only valid if there is wind
       putf("Windrichtung........%6s\n", wx->winddir_str);
     putf("Messzeit............%s\n", datestr(wx->t,12));
     putf("\nMehr Infos sind mit WX INFO abrufbar!\n");
   break;

   case 2: //detailed format
      putf("Aussentemperatur.......%6.1f C\n", wx->outdoort);
      putf("Windchill-Temp.........%6.1f C\n", wx->wind_chill);
      putf("Taupunkt...............%6.1f C\n", wx->dew_point);
      putf("Schneefallgrenze.......%6.0f m\n", wx->snowfall_limit);
      putf("Raumtemperatur.........%6.1f C\n", wx->indoort);
      putf("Luftdruck QNH..........%6.1f hPa\n", wx->air_pres_qnh);
      putf("Luftdruck lokal QFE....%6.1f hPa\n", wx->air_pres_qfe);
      putf("Saettigungsdampfdruck..%6.1f hPa\n", wx->sat_sp);
      putf("Dampfdruck.............%6.1f hPa\n", wx->steam_pressure);
      putf("Rel.Luftfeuchte........%6.1f %%\n", wx->humidity);
      if (wx->humidity < 100.0)
        //only defined when < 100%
        putf("Absolute Feuchte.......%6.1f g/m3\n", wx->abs_humidity);
      putf("Windgeschwindigkeit....%6.1f m/s = %4.1f km/h (%ld Bf %s)\n",
            wx->windspeed, wx->windspeed*3.6, wx->wind_beaufort,
            beaunam[wx->wind_beaufort]);
      if (wx->windspeed > 0.1)     /*wind-direction only when there is wind*/
        putf("Windrichtung...........%6.1f Grad (%s)\n",
              wx->wind_direction, wx->winddir_str);
      putf("Messzeit...............%s\n", datestr(wx->t, 12));
   break;

   case 3: //special format
/* Format compatible with DC4FS:
============================================================================
Temperatur           :  -9.0 C      15.8 F      konstant
Luftdruck QNH        :   997 hPa    748 mmHg    steigend
relative Feuchte     :    88 %                  konstant
Sonnenscheindauer    :   2.5 h
Niederschlagsmenge   :   0.0 mm     0.0 l/m2
Windgeschwindigkeit  :   0.8 m/s    2.9 km/h    konstant
Windrichtung         :   100 Grad     O         konstant
============================================================================
*/
    putf("Gekuerzte Ausgabe kompatibel zu DC4FS's WX-Software\n");
    putf("Temperatur        :%6.1f C\n", wx->outdoort);
    putf("Luftdruck QNH  :%6.0f hPa\n", wx->air_pres_qnh);
    putf("relative Feuchte      :%6.0f %%\n", wx->humidity);
    putf("Windgeschwindigkeit   :%6.1f m/s\n", wx->windspeed);
    if (wx->windspeed > 0.1) // wind-direction only when there is wind...
      putf("Windrichtung   :%6.0f Grad\n", wx->wind_direction);
   break;
  }
}
Example #23
0
int mbtransfer (char *ziel)
//*************************************************************************
//
//  TRANSFER-Prozedur
//  (wird fuer jedes transferierte File einzeln aufgerufen)
//
//*************************************************************************
{
  char name[20];
  strcpy(name, "mbtransfer");
  lastfunc(name);
  char *line = b->line;
  int findex;
  FILE *oldf, *newf;
  char usermail = 0;
  int retwert = NO;
  int nocp; //no-copy flag
  char oldsubject[101];
  unsigned long int oldfpos;
  char oldmsgty;
  char oldmailfname[10];
  time_t oldmsgtime;
  char old_ziel[DIRLEN+1];
  int old_usermail;
  char oldboardname[10];
  char oldmailpath[FNAMELEN+1];
  char zielcall[CALLEN+1];
  char newcall[CALLEN+1];
  int gleichesboard = NO;
  unsigned long nummer;
#ifdef USERLT
  short int old_lt;
#endif

#ifdef DEBUG_FWD
  trace(report, "mbtransfer", "ziel: %s", ziel);
#endif
  strupr(ziel);

  nexttoken(ziel, zielcall, CALLEN);
  strcpy(oldmailpath, b->mailpath);
  if (sema_test("sendlock") || m.disable)
  {
    putf(ms(m_sendnotpossible));
    return NO;
  }
  if (mbcallok(zielcall))
  { // Use newcall
    if (get_newcall(zielcall, newcall))
    {
      strcpy(zielcall, newcall);
      putf(ms(m_usingnewcall), newcall);
    }
  }
  char *bbuf = (char *) t_malloc(sizeof(tvar_t) - sizeof(task_t), "tran");
  char *oldfname;
  oldfname = (char *) t_malloc(sizeof(char) * (FNAMELEN+1), "tra2");
  if (! bbuf || ! oldfname)
    return NO;
  memcpy(bbuf, (char *) b + sizeof(task_t), sizeof(tvar_t) - sizeof(task_t));
  strlwr(b->mailpath);
  strcpy(oldfname, b->mailpath);
  strcpy(oldmailfname, b->mailfname);
  oldmsgtime = filename2time(b->mailfname);
  if ((oldf = s_fopen(oldfname, "srt")) != NULL)
  {
    fgets(b->line, BUFLEN - 1, oldf);    // Befehlszeile einlesen
    mbsend_parse(line, 0);
    if (b->mailtype == 'A'
        || (b->mailtype == 'B' && b->eraseinfo == 'T'))
    {
      retwert = NIL;
      s_fclose(oldf);
      goto error_exit;
    }
    oldmsgty = b->conttype;              // save mailflags ...(conttype)
    fgets(b->line, BUFLEN - 1, oldf);    // Forwardzeile vernichten
    fgets(b->line, BUFLEN - 1, oldf);    // Read-Zeile
    fgets(oldsubject, BETREFFLEN, oldf); // Betreff
    cut_blank(oldsubject);               // Newline entfernen
    if (mbcallok(zielcall)) *b->at = 0;  // Verteiler loeschen -> Neubestimmen
    strcpy(old_ziel, b->ziel);
#ifdef USERLT
    old_lt = b->lifetime;
    b->lifetime = 0;
#endif
    old_usermail = b->usermail;
    mbsend_parse(ziel, 2);
    if (! stricmp(b->ziel, b->mailpath+strlen(b->mailpath)-strlen(b->ziel)-8))
    {
      retwert = NIL;
      s_fclose(oldf);
      goto error_exit;
    }
    b->conttype = oldmsgty;              // set mailflags again.. (conttype)
    if (b->mailtype == 'B' && ! old_usermail)
      strcpy(b->ziel, old_ziel);
    weiterleiten(1, b->zielboard);
    waitfor(e_ticsfull);
    findex = finddir(b->zielboard, b->sysop);
    if (findex && !(strlen(b->zielboard)==1 && !b->sysop))
    {
      if (xmkdir(b->boardpath))
      {
        trace(serious, name, "mkdir %s error", b->boardpath);
        s_fclose(oldf);
        goto error_exit;
      }
      nocp = ! strcmp(b->herkunft, b->logincall) || b->sysop;
             //kein "CP " wenn Sysop!
      if (nocp || b->mailtype == 'B')
        strcpy(b->betreff, oldsubject);
      else
        sprintf(b->betreff, "CP %s: %.67s", b->logincall, oldsubject);
      //Bei Nicht-Bulletin BID neu generieren bzw. wenn BID fehlt
      if (b->mailtype != 'B'|| ! *b->bid) strcpy(b->bid, newbid());
      make_mask(b->mailpath, b->boardfullname);
      strcpy(b->mask, b->mailpath);
      // Ursprungsboardnamen aus b->mailpath holen und mit ziel vergleichen
      strcpy(oldboardname, b->boardname);
      oldmailpath[strlen(oldmailpath)-8] = 0;
      if (finddir(oldmailpath,0) > 0)
      {
        if (! strcmp(ziel, b->boardname))
          gleichesboard = YES;
      }
      else
        gleichesboard = NO;
      strcpy(b->boardname,oldboardname); // b->boardname wieder herstellen
      // bei Usermail oder gleichem Board zum Sortieren
      // Filezeit/-namen neu setzen
      if (mbcallok(zielcall) || gleichesboard)
      {
        strcpy(b->mailfname, time2filename(0));
      }
      else
        strcpy(b->mailfname, oldmailfname);
      if (! strstr(b->mailpath, "*.*"))
        trace(fatal, name, "mask %s", b->mailpath);
      strcpy(strstr(b->mailpath, "*.*"), b->mailfname);
      strlwr(b->mailpath);
      if ((newf = s_fopen(b->mailpath, "sw+t")) != NULL)
      {
        s_fsetopt(newf, 1);
#ifdef USERLT
        set_boardlife_max(old_lt);
        b->lifetime = old_lt;
#endif
        writeheader(newf, 1);
        if (b->mailtype != 'B')
        {
          if (fgets(b->line, BUFLEN - 1, oldf))
          {
            do
            { // fputs(line,f); skip old R-lines
              waitfor(e_ticsfull);
              fgets(b->line, BUFLEN - 1, oldf);
            }
            while (! feof(oldf) && *line == 'R' && line[1] == ':');
          }
          fprintf(newf, "%s\n", makeheader(1));
          fprintf(newf, "X-Transfer: %s by %s @ %s\n",
                  datestr(ad_time(), 12), b->logincall, m.boxadress);
          fprintf(newf, "X-Original-Date: %s\n", datestr(oldmsgtime, 10));
          do
          {
            if((   ! strncasecmp(line, "from", 4)
                || ! strncmp(line, "de: ", 4)
                || ! strncmp(line, "de ", 3)
                || ! strncmp(line, "fm ", 3)) && ! nocp)
              fprintf(newf, "X-Originally %s", line);
            else if ((   ! strncasecmp(line, "to: ", 4)
                      || ! strncasecmp(line, "to ", 3)) && ! nocp)
              fprintf(newf, "X-Originally %s", line);
            else if (! strncmp(line, "X-MID: ", 7))
              fprintf(newf, "X-Old-MID: %s", line + 7);
            else if (! strncmp(line, "X-BID: ", 7))
              fprintf(newf, "X-Old-BID: %s", line + 7);
            else fputs(line, newf);
            waitfor(e_ticsfull);
            fgets(b->line, BUFLEN - 1, oldf);
          }
          while (! feof(oldf) && *line != LF);
          fputc(LF, newf);
        }
        //Files binaer behandeln
        oldfpos = ftell(oldf);
        s_fclose(oldf);
        s_fclose(newf);
        writemailflags();
        if ((oldf = s_fopen(oldfname, "srb")) != NULL)
        {
          if ((newf = s_fopen(b->mailpath, "sab")) != NULL) //append to file
          {
            fseek(oldf, oldfpos, SEEK_SET);
            do
            { //oe3dzw: Transferroutine transparent
              int len;
              len = fread(line, 1, 255, oldf);
              if (len) fwrite(line, 1, len, newf);
              waitfor(e_ticsfull);
            }
            while (! feof(oldf));
            if (b->binstart)  //bei binaeren Mails offset neu berechnen
            {
              b->binstart += ftell(newf) - ftell(oldf);
              if (b->binstart < 0)
                trace(serious, name, "offset %ld in %s", b->binstart, b->mailpath);
            }
            s_fclose(newf);
            if (b->binstart) writelines(); //Neuen Binstart speichern
            if (b->bytes)
            {
              if (old_usermail || gleichesboard)
                nummer = appenddirlist(1);
              else
                nummer = appenddirlist(0); //change old CHECKLINE
              if (b->usermail)
              {
                add_fwdfile("", get_fdelay(b->herkunft), 0);
                sprintf(b->line, "%s %lu", b->herkunft, nummer);
                mbtalk("\001", b->zielboard, b->line);
                trigger_ufwd(b->zielboard);
              }
              else
              {
                handle fh;
                char found;
                if (old_usermail)
                  add_fwdfile("", get_fdelay(b->herkunft), 0);
                else
                  add_fwdfile("", get_fdelay(b->herkunft), 1);
                if (findex > 0)
                  tree[findex - 1].newestmail = oldmsgtime;
                if ((fh = s_open(CHECKNAME, "sr+b")) != EOF)
                {
                  seek_fname(fh, b->mailfname, &found, 1);
                  long pos = ltell(fh);
                  if (found)
                  {
                    _read(fh, b->line, BLEN);
                    sprintf(b->line + 15, "%-8s", b->boardname);
                    b->line[23] = '~';
#ifdef USERLT
                    char nlt[4];
                    sprintf(nlt, "%3.3d", b->boardlife_max);
                    memcpy(b->line + 51, nlt, 3);
#endif
                    lseek(fh, -(LBLEN), SEEK_CUR);
                    _write(fh, b->line, BLEN);
                  }
                  s_close(fh);
                  if (found && (fh = s_open(CHECKNUMNAME, "sr+b")) != EOF)
                  {
                    lseek(fh, 2*(pos >> 6), SEEK_SET); //2* da 32bit!
                    _write(fh, &nummer, 4); // 4Byte=32 bit
                    s_close(fh);
                  }
                }
                else
                  trace(serious, name, "check");
              }
              inc_mailgot(b->boardname);
              writemailflags();
              retwert = OK;
Example #24
0
static void
FFN(Fdefun)(object args)
{

	object name,oname;
	object body, form;

	if (endp(args) || endp(MMcdr(args)))
		FEtoo_few_argumentsF(args);
	if (MMcadr(args) != Cnil && !consp(MMcadr(args)))
		FEerror("~S is an illegal lambda-list.", 1, MMcadr(args));
	oname=name = MMcar(args);
	
	if (type_of(name) != t_symbol)
	  name=ifuncall1(sSfunid_to_sym,name);

	if (name->s.s_sfdef != NOT_SPECIAL) {
	  if (name->s.s_mflag) {
	    if (symbol_value(sSAinhibit_macro_specialA) != Cnil)
	      name->s.s_sfdef = NOT_SPECIAL;
	  } else if (symbol_value(sSAinhibit_macro_specialA) != Cnil)
	    FEerror("~S, a special form, cannot be redefined.", 1, name);
	}
	if (name->s.s_hpack == lisp_package &&
	    name->s.s_gfdef != OBJNULL && !raw_image && sLwarn->s.s_gfdef) {
	  vs_push(make_simple_string("~S is being redefined."));
	  ifuncall2(sLwarn, vs_head, name);
	  vs_popp;
	}
	vs_base = vs_top;
	if (lex_env[0] == Cnil && lex_env[1] == Cnil && lex_env[2] == Cnil) {
	  vs_push(MMcons(sLlambda_block, args));
	} else {
	  vs_push(MMcons(lex_env[2], args));
	  vs_base[0] = MMcons(lex_env[1], vs_base[0]);
	  vs_base[0] = MMcons(lex_env[0], vs_base[0]);
	  vs_base[0] = MMcons(sLlambda_block_closure, vs_base[0]);
	}
	{/* object fname; */
	  vs_base[0]=fSfset_in(name,vs_base[0]);
	/* object x=alloc_object(t_ifun); */
	/* x->ifn.ifn_self=vs_base[0]; */
	/* x->ifn.ifn_name=name; */
	/* x->ifn.ifn_call=Cnil; */
	/* vs_base[0]=x; */
	/* fname =  clear_compiler_properties(name,vs_base[0]); */
	/* fname->s.s_gfdef = vs_base[0]; */
	/* fname->s.s_mflag = FALSE; */
	}
	vs_base[0] = oname;
	for (body = MMcddr(args);  !endp(body);  body = body->c.c_cdr) {
	  form = macro_expand(body->c.c_car);
	  if (type_of(form) == t_string) {
	    if (endp(body->c.c_cdr))
	      break;
	    vs_push(form);
	    name->s.s_plist =
	      putf(name->s.s_plist,
		   form,
		   sSfunction_documentation);
	    vs_popp;
	    break;
	  }
	  if (!consp(form) || form->c.c_car != sLdeclare)
	    break;
	}
}
Example #25
0
void wx::show_diags (int what, time_t t_n)
//*************************************************************************
//
//*************************************************************************
{
  //show diagram
  int i;
  wxdata_t wxt;
  char oneline[80];
  double temp[48];
  time_t next_t;

  for (i = 0; i < 48; i++)
  {
    next_t = t_n-DAY-400+1800*(i+1);
    if (! read_wx_data(oneline, next_t))
    {
      putf("No data for %s available.\n", datestr(next_t, 12));
      return;
    }
    //printf("oneline %s\n", oneline);
    if (orgdata(&wxt, oneline))
    switch (what)
    {
      case 3:
        temp[i] = wxt.humidity;
        break;

      case 2:
        temp[i] = wxt.air_pres_qnh;
        break;

      case 1:
        temp[i] = wxt.windspeed;
        break;

      default:
        temp[i] = wxt.outdoort;
        break;
    }
    else
    {
      putf("Data invalid.\n");
      return;
    }
  }
  switch (what)
  {
    case 1:
      diag_24h("Windstaerke der letzten 24h",
          "m/s", temp);
      break;

    case 2:
      diag_24h("Luftdruck QNH der letzten 24h",
          "hPa", temp);

      break;

    case 3:
      diag_24h("Luftfeuchtigkeit der letzten 24h",
          "%", temp);

      break;

    default:
      diag_24h("Temperatur der letzten 24h",
           "Grad C",
           temp);
      break;
  }
}
Example #26
0
void wx::mbwxcmd (char *befbuf)
//*************************************************************************
// WX command interpreter
//*************************************************************************
{
 static char *beftab[] = {"ALL", "TEMPERATURE", "DRUCK", "PRESSURE",
                          "WINDSPEED", "FEUCHTIGKEIT", "HUMIDITY",
                          "DC4FS", "INFO", "LOOP", NULL};
 enum befnum {unsinn, _all, temperatur, luftdruck, luftdruck_,
                     wind, humidity, humidity_, dc4fs, info,
             _loop
             } cmd = unsinn;
 befbuf += blkill(befbuf);
 cmd = (befnum) readcmd(beftab, &befbuf, 0);
 switch(cmd)
 {
  case unsinn:
    show_wx(&m.wx, 1);
  break;
  case _all:
    if (befbuf[0])
    {
      char oneline[80];
       wxdata_t wxt;
       time_t t1 = atol(befbuf); //simple but works for _any_ date
      if (t1 && read_wx_data(oneline, t1)
             && orgdata(&wxt, oneline))
        show_wx(&wxt, 2);
      else
        putf("No data available.\n");
    }
    else
      show_wx(&m.wx, 2);
  break;
  case _loop:
    while (1)
    {
      show_wx(&m.wx, 1);
      putflush();
      wdelay(2000);
    }
  case temperatur:
    show_diags(0, ad_time());
    break;
  case wind:
    show_diags(1, ad_time());
    break;
  case luftdruck:
  case luftdruck_:
    show_diags(2, ad_time());
    break;
  case humidity:
  case humidity_:
    show_diags(3, ad_time());
    break;
  case dc4fs:
    show_wx(&m.wx, 3);
  break;
  case info:
    readtext("wxinfo");
  break;
 }
}
Example #27
0
int sysbef (char *befbuf)
//*************************************************************************
//
//*************************************************************************
{
  static char shutdown_reason[23];
  char xbuf[20];
  static char *beftab[] =
    {
      "CONNECT", "LOGIN", "CALL", "OSHELL",
#ifdef __DOS16__
#ifdef _TNC
      "TNC",
#endif
      "W2", "UWIN", "TWIN",
#ifdef _AUTOTRCWIN
      "TRWIN",
#endif
#endif
      "RTEXT", "CAT", "RPRG", "WTEXT", "WPRG", "RBIN", "WBIN",
      "SLR", "CLOG", "REORG",
      "LIFETIME", "MKBOARD", "RMBOARD", "MVBOARD", "SHUTDOWN", "NEW",
      "KILL", "TEST", "IMPORT", "DISABLE", "ENABLE",
#ifdef DIEBOX_UIMPORT
      "UIMPORT",
#endif
#ifdef OLDMAILIMPORT
      "OLDMAILIMPORT",
#endif
      "SETUSER", "BEACON", "GREP", "TGREP", "TAIL", "BEGIN", "BATCH",
      "EXPORT", "PWGEN", "POSTFWD", "MONITOR", "NOTE", "MACRO", "CFGFLEX",
      "ORM", "OMV", "OCP", "OMD", "APPEND",
#ifdef DF3VI_EXTRACT
      "EXTRACT",
#endif
      "HOLD", "SETPW",
#ifdef FEATURE_YAPP
      "WYAPP", "RYAPP",
#endif
#ifdef FEATURE_DIDADIT
      "WDIDADIT", "RDIDADIT",
#endif
#if defined FEATURE_SERIAL || defined _TELEPHONE
      "TTYINIT",
#endif
#ifdef _TELEPHONE // JJ
      "TTYCMD", "TTYDIAL", "TTYHANGUP", "TTYSTATUS", "TTYWIN",
      "TTYCOUNTERRESET",
#endif
#ifdef _AUTOFWD
      "AFWDLIST",
#endif
#ifdef FEATURE_MDPW
      "MD2SUM", "MD5SUM",
#endif
#ifdef FEATURE_EDITOR
      "EDIT", "FEDIT", "REDIT",
#else
 #ifdef DF3VI_FWD_EDIT
      "FEDIT", "FWDEDIT",
 #endif
 #ifdef DF3VI_REJ_EDIT
      "REDIT", "REJECTEDIT",
 #endif
 #ifdef DF3VI_CONV_EDIT
      "CEDIT", "CONVEDIT",
 #endif
#endif
#ifdef _FILEFWD
      "FWDIMPORT", "FWDEXPORT",
#endif
      "YMBTEST",
      "SCMDLIST", // Dies ist immer das letzte Kommando!
      NULL
    };

  enum befnum
    { unsinn, connect_, login, call_, oshell_,
#ifdef __DOS16__
#ifdef _TNC
      tnc,
#endif
      w2, uwin, twin,
#ifdef _AUTOTRCWIN
      trwin,
#endif
#endif
      rtext, rtext_, rprg, wtext, wprg, rbin, wbin,
      slr, clog, reorg,
      life_, mkb, rmb, mvb, shutdown_, new_,
      kill_, test, import, disable_, enable_,
#ifdef DIEBOX_UIMPORT
      uimport_,
#endif
#ifdef OLDMAILIMPORT
      oldmailimport_,
#endif
      setuser, beacon, grep_, tgrep, tail, begin, batch,
      export_, pwgen, postfwd_, monitor_, note, macro, cfgflex_,
      orm, omv, ocp, omd, _append,
#ifdef DF3VI_EXTRACT
      extract_,
#endif
      hold, setpw,
#ifdef FEATURE_YAPP
      wyapp, ryapp,
#endif
#ifdef FEATURE_DIDADIT
      wdidadit, rdidadit,
#endif
#if defined FEATURE_SERIAL || defined _TELEPHONE
      ttyinit,
#endif
#ifdef _TELEPHONE // JJ
      ttycmd, ttydial, ttyhangup, ttystatus, ttywin_,
      ttycounterreset,
#endif
#ifdef _AUTOFWD
      afwdlist_,
#endif
#ifdef FEATURE_MDPW
      md2sum, md5sum,
#endif
#ifdef FEATURE_EDITOR
      edit, fedit, redit,
#else
 #ifdef DF3VI_FWD_EDIT
      fedit, fwdedit,
 #endif
 #ifdef DF3VI_REJ_EDIT
      redit, rejectedit,
 #endif
 #ifdef DF3VI_CONV_EDIT
      cedit, convedit_,
 #endif
#endif
#ifdef _FILEFWD
      fwdimport, fwdexport,
#endif
      ymbtest,
      scmdlist // Dies ist immer das letzte Kommando!
    } cmd = unsinn;
  befbuf += blkill(befbuf);
  cmd = (befnum) readcmd(beftab, &befbuf, 0);
  switch (cmd)
  {
#ifdef FEATURE_YAPP
    case ryapp:
#endif
#ifdef FEATURE_DIDADIT
    case rdidadit:
#endif
#if defined(FEATURE_YAPP) || defined(FEATURE_DIDADIT)
      break;
#endif
    default:
      if (u->lf != 6)
        putv(LF);
      leerzeile(); // Sends the number of CRs stored in "ALTER LF"
  }

  switch (cmd)
  {
    case unsinn:
      if (   mbinitbef(befbuf, 0)
      #ifdef _TELEPHONE // JJ
          || ttyinitbef(befbuf, 0)
      #endif
         )
      {
        strcpy(xbuf, "^");
        mbparsave();
#ifdef _TELEPHONE // JJ
        ttyparsave();
#endif
        strncpy(xbuf + 1, befbuf, 18);
        xbuf[19] = 0;
        subst1(xbuf, ' ', 0);
        subst1(xbuf, '=', 0);
        grep(MBINITNAME, xbuf, o_i);
#ifdef _TELEPHONE // JJ
        grep(INITTTYNAME, xbuf, o_i);
#endif
        return OK;
      }
      else return NO;
    case note: trace(replog, "note", "%s", befbuf); break;
#ifdef DF3VI_EXTRACT
    case extract_: mbchange(befbuf, w_extract, 1); break;
#endif
    case hold: mbchange(befbuf, w_hold, 1); break;
    case omv:
    {
      char f1[50], f2[50];
      befbuf = nexttoken(befbuf, f1, 49);
      befbuf = nexttoken(befbuf, f2, 49);
      if (! *f1 || ! *f2 || xrename(f1, f2))
        putf(ms(m_error));
      else
      {
        putf(ms(m_moving));
        putf(ms(m_nach), f1, f2);
      }
      break;
    }
    case ocp:
    {
      char f1[50], f2[50];
      befbuf = nexttoken(befbuf, f1, 49);
      befbuf = nexttoken(befbuf, f2, 49);
      if (! *f1 || ! *f2 || filecopy(f1, f2))
        putf(ms(m_error));
      else
      {
        putf(ms(m_copying));
        putf(ms(m_nach), f1, f2);
      }
      break;
    }
    case orm:
    {
      char f1[50];
      befbuf = nexttoken(befbuf, f1, 49);
      if (! *f1 || xunlink(f1))
        putf(ms(m_filecantdeleted), f1);
      else
        putf(ms(m_filedeleted), f1);
      break;
    }
    case omd:
    {
      char f1[50];
      befbuf = nexttoken(befbuf, f1, 49);
      killbackslash(f1);
      if (! *f1 || xmkdir(f1))
        putf(ms(m_directorycantcreated), f1);
      else
        putf(ms(m_directorycreated), f1);
      break;
    }
    case _append:
    {
      char textline[LINELEN+1];
      befbuf = nexttoken(befbuf, textline, LINELEN);
      if (! *befbuf)
      {
        putf("Syntax: APPEND <textline> <filename>\n");
        break;
      }
      FILE *f = s_fopen(befbuf, "sat");
      if (f)
      {
        fprintf(f, "%s\n", textline);
        s_fclose(f);
      }
      else putf(ms(m_filenotfound), befbuf);
    } break;
    case macro:
    {
      mk_start(befbuf);
    } break;
    case setuser:
    {
      char call[CALLEN+1];
      befbuf = nexttoken(befbuf, call, CALLEN+1);
      strupr(call);
      if (mbcallok(call) && *befbuf)
      {
        trace(report, "setuser", "%s", befbuf);
        {
          if (! mbalter(NULL, befbuf, call))
            putf(ms(m_isunknown), call);
          b->msg_loadnum = 0; //reload msg
          loaduser(b->logincall, u, 1);
        }
      }
      else
        putf("Syntax: SETUSER <call> <option> <value>\n");
    } break;
    case setpw: //automatisierte Passwort-Vergabe
    {
      char call[CALLEN+1];
      char passwd[40];
      int i, pwline = 0;
      FILE *upwf;
      befbuf = nexttoken(befbuf, call, CALLEN+1);
      strupr(call);
      pwline = atoi(befbuf);
      if (! mbcallok(call) || ! pwline)
      {
        putf("Syntax: SETPW <call> <number>\n");
        break;
      }
      if (! loaduser(call, u, 0))
      {
        putf(ms(m_isunknown), call);
        break;
      }
      upwf = s_fopen("userpw.bcm", "sr");
      if (! upwf)
      {
        putf(ms(m_filenotfound), "userpw.bcm");
        break;
      }
      for (i = 0; i < pwline && ! feof(upwf); i++)
        fgets(passwd, sizeof(passwd) - 1, upwf);
      s_fclose(upwf);
      if (i < pwline)
      {
        putf(ms(m_userpwlines), i - 1);
        break;
      }
      strcpy(u->password, passwd);
      saveuser(u);
      pwline = strlen(u->password);
      putf(ms(m_loginpw), pwtypestr(u->loginpwtype), pwtypestr(u->sfpwtype));
      putf(" ");
      putf(ms(m_pwdlength), pwline);
      sprintf(passwd, "pw set to %i char", pwline);
      pwlog(call, b->logincall, passwd);
      b->msg_loadnum = 0; //reload msg
      loaduser(b->logincall, u, 1);
    } break;
#ifdef DIEBOX_UIMPORT
    case uimport_:
    {
      putf(ms(m_dieboximport));
      uimport();
    } break;
#endif
#ifdef OLDMAILIMPORT
    case oldmailimport_:
    {
      scanoptions(befbuf);
      formoptions();
      befbuf += blkill(befbuf);
      if (isdir(befbuf))
      {
        putf(ms(m_omi_started), befbuf);
        putflush();
        oldmailimport(befbuf);
      }
      else
        putf(ms(m_dirunknown), befbuf);
    } break;
#endif
    case disable_:
    {
      putf(ms(m_boxdisabled));
      m.disable = 1;
      mbparsave();
    } break;
    case enable_:
    {
      putf(ms(m_boxenabled));
      m.disable = 0;
      mbparsave();
    } break;
    case test:
    {
      if (*befbuf == 'W') { while (1); } // for testing watchdog
      else if (*befbuf == 'S') { trace(fatal, "test", "abort"); }
      else if (*befbuf == 'V') { *(char *)0 = 1; }
      else mk_start(befbuf);
    } break;
    case batch:
    {
      runbatch(befbuf);
    } break;
    case rtext:
    case rtext_:
    {
      fileio_text fio;
      fio.usefile(befbuf);
      fio.tx();
      putf("\032\n"); // CTRL-Z
    } break;
    case wtext:
    {
      fileio_text fio;
      fio.usefile(befbuf);
      fio.rx();
    } break;
    case rbin:
    case rprg:
    {
      fileio_abin fio;
      fio.usefile(befbuf);
      fio.tx();
    } break;
    case wbin:
    case wprg:
    {
      fileio_abin fio;
      fio.usefile(befbuf);
      fio.rx();
    } break;
#ifdef FEATURE_YAPP
    case ryapp:
    {
      fileio_yapp fio;
      fio.usefile(befbuf);
      fio.tx();
    } break;
    case wyapp:
    {
      fileio_yapp fio;
      fio.usefile(befbuf);
      fio.rx();
    } break;
#endif // FEATURE_YAPP
#ifdef FEATURE_DIDADIT
    case rdidadit:
    {
      fileio_dida fio;
      fio.usefile(befbuf);
      fio.tx();
    } break;
    case wdidadit:
    {
      fileio_dida fio;
      if (! *befbuf) fio.usefile("dummy");
      else
      {
        if (befbuf[strlen(befbuf) - 1] != '/') strcat(befbuf, "/");
        strcat(befbuf, "dummy");
        fio.usefile(befbuf);
      }
      fio.rx();
    } break;
#endif // FEATURE_DIDADIT
    case slr:
    {
      scanoptions(befbuf);
      putlog(TRACEPATH "/" SYSLOGRNAME, befbuf);
    } break;
    case clog:
    {
      scanoptions(befbuf);
      putlog(TRACEPATH "/" CMDLOGNAME, befbuf);
    } break;
    case tail:
    {
      scanoptions(befbuf);
      befbuf += blkill(befbuf);
      if (b->optplus&o_f && *befbuf)
      {
        int a;
        FILE *f = s_fopen(befbuf, "lrt");
        if (f)
        {
          fseek(f, 0, SEEK_END);
          do
          {
            while ((a = fgetc(f)) != EOF) putv(a);
            wdelay(349);
          }
          while (! testabbruch());
          s_fclose(f);
        }
      }
      else
      {
        fileio_text fio;
        fio.usefile(befbuf);
        fio.settail(-2000);
        fio.tx();
      }
    } break;
    case begin:
    {
      fileio_text fio;
      fio.usefile(befbuf);
      fio.settail(2000);
      fio.tx();
    } break;
    case monitor_:
    {
      if (*befbuf)
      {
        scanoptions(befbuf);
        b->continous = 1;
        monitor(atoi(befbuf), b->optplus);
      }
      else
        putf("Syntax: MONITOR [-iords] <task-id>\n");
    } break;
    case tgrep:
    {
      char string[61];
      char name[40];
      scanoptions(befbuf);
      if (b->optminus & o_i) b->optplus |= o_i;
      //wenn nicht explizit "-i-", ist "-i" default
      b->usermail = 0;
      if (! *befbuf)
      {
        putf("Syntax: TGREP [pattern] <fwd-bbs>\n");
        break;
      }
      befbuf = nexttoken(befbuf, string, 60);
      if (*befbuf)
      {
        sprintf(name, TRACEPATH "/t_%s.bcm", befbuf);
        grep(name, string, b->optplus);
      }
      else
      {
        sprintf(name, TRACEPATH "/t_%s.bcm", string);
        putlog(name, "");
      }
    } break;
    case grep_:
    {
      char string[61];
      scanoptions(befbuf);
      if (b->optminus & o_i) b->optplus |= o_i;
      //wenn nicht explizit "-i-", ist "-i" default
      b->usermail = 0;
      befbuf = nexttoken(befbuf, string, 60);
      grep(befbuf, string, b->optplus);
    } break;
#ifdef _AUTOFWD
    case afwdlist_:
    {
      afwdlist(befbuf);
    } break;
#endif
    case life_:
    {
      if (*befbuf)
      {
        strupr(befbuf);
        char *life = skip(befbuf);
        int board = finddir(befbuf, b->sysop);
        if (board > 0)
        {
          board -= 1;
          if (life && *life)
          {
            tree[board].lifetime_max = atoi(life);
            tree[board].lifetime_min = 1;
            if (tree[board].lifetime_max > 999)
              tree[board].lifetime_max = 999;
            if (tree[board].lifetime_max < 1)
              tree[board].lifetime_max = 1;
            char *life_min = skip(life);
            if (life_min && *life_min)
            {
              tree[board].lifetime_min = atoi(life_min);
              if (tree[board].lifetime_min > 999)
                tree[board].lifetime_min = 999;
              if (tree[board].lifetime_min < 1)
                tree[board].lifetime_min = 1;
            }
            mbtreesave();
          }
          putf(ms(m_lifetimestat), b->boardfullname, tree[board].lifetime_max,
                                                     tree[board].lifetime_min);
        }
        else
          putf(ms(m_notfound), befbuf);
      }
      else
        putf("Syntax: LIFETIME <board> <days_maximum> [<days_minimum>]\n"
             "            (with 1 <= days_maximum/days_minimum <= 999)\n\n");
    } break;
#ifdef _TNC
    case tnc:
    {
      control_tnc(befbuf);
    } break;
#endif
    case connect_:
    {
      termqso(befbuf);
    } break;
    case login:
    {
      if (mbcallok(befbuf))
      {
        mblogin(befbuf, login_standard, b->uplink);
        cmdlog("login changed");
        putf(ms(m_loginchanged));
      }
      else
        putf("Syntax: LOGIN <new logincall>\n");
    } break;
    case call_:
    {
      if (mbcallok(befbuf))
      {
        mblogin(befbuf, login_silent, b->uplink);
        b->msg_loadnum--; //Sonst wird falsche Sprache benutzt
        cmdlog("call changed");
      }
      else
        putf("Syntax: CALL <new logincall>\n");
    } break;
    case oshell_:
    {
      if (t->input == io_file || t->output == io_file)
        oshell(befbuf, sh_noinput);
      else oshell(befbuf, m.dosinput ? sh_forceinput : sh_ifmultitask);
    } break;
    case reorg:
    {
      if (sema_test("purgereorg") == 1)
        putf(ms(m_purgeallstarted));
      else
      {
        putf(ms(m_reorginvoked));
        fork(P_BACK | P_MAIL, 0, mbreorg, befbuf);
      }
    } break;
    case postfwd_:
    {
      putf(ms(m_postfwdinvoked));
      fork(P_BACK | P_MAIL, 0, postfwd, "Postfwd");
    } break;
#ifdef FEATURE_EDITOR
    case edit:
    {
      fork(P_WIND | P_KEYB, 0, editfile, befbuf);
    } break;
    case fedit:
    {
      fork(P_WIND | P_KEYB, 0, editfile, FWDLISTNAME);
    } break;
    case redit:
    {
      fork(P_WIND | P_KEYB, 0, editfile, REJECTNAME);
    } break;
#else
 #ifdef DF3VI_FWD_EDIT
    case fedit: //wenn kein editor vorhanden remote-editor aufrufen
    case fwdedit:
    {
      fwdlistedit(befbuf);
    } break;
 #endif
 #ifdef DF3VI_REJ_EDIT
    case redit:
    case rejectedit:
    {
      rejectlistedit(befbuf);
    } break;
 #endif
 #ifdef DF3VI_CONV_EDIT
    case cedit:
    case convedit_:
    {
      convedit(befbuf);
    } break;
 #endif
#endif
    case new_:
    {
      scanoptions(befbuf);
      mbinit();
      initfwdlist();
#ifdef _AUTOFWD
      initafwdlist();
#endif
      if (! (b->optplus & o_q)) // skip statistics on "new -q"
      {
        b->optplus = o_s | o_f | o_c;
        putf(ms(m_hadrstat));
        browse_hadr("");
      }
      mbcvtload();
#ifdef RUNUTILS
      read_runfile();
#endif
      msg_dealloc(1);
      mk_read_jobs();
    } break;
    case kill_:
    {
      if (atoi(befbuf))
      {
        while (atoi(befbuf))
        {
          if (! killtask(nextdez(&befbuf), 1))
            putf(ms(m_cantkilltask));
        }
      }
      else
        putf("Syntax: KILL <task-id>\n");
    } break;
#ifdef __DOS16__
    case w2:
    {
      fork(P_WIND | P_KEYB|P_MAIL, 0, mbwin2, m.sysopcall);
    } break;
    case uwin:
    {
      fork(P_WIND | P_KEYB|P_MAIL, 0, userwin, "Users");
    } break;
    case twin:
    {
      fork(P_WIND | P_MAIL, 0, taskwin, befbuf);
    } break;
#ifdef _AUTOTRCWIN
    case trwin:
    {
      if (*befbuf) fork(P_WIND | P_MAIL, 0, trcwin, befbuf);
      else putf("Syntax: TRWIN [-iords] <task-id>\n");
    } break;
#endif
#endif //__DOS16__
    case mkb:
    {
      char mainboard[30];
      char newboard[20];
      char *slash;
      befbuf = nexttoken(befbuf, mainboard, 29);
      befbuf = nexttoken(befbuf, newboard, 19);
      slash = strchr(mainboard + 1, '/');
      if (slash && (! *newboard))
      {
        *slash = 0;
        strcpy(newboard, slash + 1);
      }
      if (! *newboard && *mainboard == '/')
      {
        strcpy(newboard, mainboard + 1);
        mainboard[1] = 0;
      }
      if (*mainboard && *newboard)
      {
        switch (mkboard(mainboard, newboard, 0))
        {
          case 0: putf(ms(m_boardcreated)); break;
          case 1: putf(ms(m_mainboardnotfound)); break;
          case 2: putf(ms(m_toomanyboards)); break;
          case 3: putf(ms(m_boardnameexist)); break;
          case 4: putf(ms(m_invalidboardname)); break;
        }
      }
      else
        putf("Syntax: MKBOARD <mainboard> <subboard>\n");
    } break;
    case rmb:
    {
      if (*befbuf)
      {
        subst1(befbuf, ' ', '/');
        if (*befbuf == '/' && befbuf[1] == '/') befbuf++;
        switch (rmboard(befbuf))
        {
          case 0: putf(ms(m_boardremoved)); break;
          case 1: putf(ms(m_boardnotfound)); break;
          case 2: putf(ms(m_boardnotempty)); break;
        }
      }
      else
        putf("Syntax: RMBOARD <mainboard> <subboard>\n");
    } break;
    case mvb:
    {
      char oldboard[20];
      char subboard[20];
      char neuboard[20];
      befbuf = nexttoken(befbuf, oldboard, 19);
      befbuf = nexttoken(befbuf, subboard, 19);
      befbuf = nexttoken(befbuf, neuboard, 19);
      if (*oldboard && *subboard && *neuboard)
      {
        switch (mvboard(oldboard, subboard, neuboard))
        {
          case 0: putf(ms(m_boardmoved)); break;
          case 1: putf(ms(m_newboardnotfound)); break;
          case 2: putf(ms(m_toomanyboards)); break;
          case 4: putf(ms(m_oldboardnotfound)); break;
        }
      }
      else
        putf("Syntax: MVBOARD <oldboard> <subboard> <newboard>\n");
    } break;
    case shutdown_:
    {
      scanoptions(befbuf);
#ifdef __DOS16__
      if (b->optplus & o_r) atexit((void(*)()) MK_FP(0xffff, 0x0000));
#endif
      runterfahren = 1;
      sprintf(shutdown_reason, "shutdown by %s", b->logincall);
      stopreason = shutdown_reason;
    } break;
    case cfgflex_:
    {
      if (*befbuf && file_isreg("cfgflex.bcm"))
      {
        putf(ms(m_flexstarted));
        fork(P_BACK | P_MAIL, 0, cfgflex, befbuf);
      }
      else
        putf("Syntax: CFGFLEX <flexcall> (cfgflex.bcm must exist)\n");
    } break;
    case import:
    {
      sysimport(befbuf);
    } break;
    case export_:
    {
      if (*befbuf)
      {
        if ((t->input != io_file || t->output == io_dummy)
            && t->output != io_file)
        {
          char fname[51];
          scanoptions(befbuf);
          befbuf = nexttoken(befbuf, fname, 50);
          if (b->optplus & o_a) // neue Option -b fuer binaer
          {
            if (b->optplus & o_b) b->outputfile = s_fopen(fname, "sab");
            else b->outputfile = s_fopen(fname, "sat");
          }
          else
          {
            if (b->optplus & o_b) b->outputfile = s_fopen(fname, "swb");
            else b->outputfile = s_fopen(fname, "swt");
          }
          if (b->outputfile)
          {
            s_fsetopt(b->outputfile, 1);
            b->oldinput = t->input;
            b->oldoutput = t->output;
            t->input = io_dummy;
            t->output = io_file;
            b->continous = 1;
            if (b->optplus & o_u) b->sysop = 0;
            if (*befbuf) mailbef(befbuf, 0);
            b->sysop = 1;
          }
          else
            putf(ms(m_filenotopen), fname);
        }
      }
      else
        putf("Syntax: EXPORT <filename> <box-command>\n");
    } break;
    case beacon:
    {
      if (*befbuf)
      {
        FILE *f = s_fopen(BEACONNAME, "srt");
        unsigned int i = 0;
        char s[LINELEN+1];
        if (f)
        {
          while (fgets(s, LINELEN, f))
          {
            if (*s)
            {
              s[strlen(s) - 1] = 0;
              putbeacon_tnc(s, befbuf);
              i++;
            }
          }
          s_fclose(f);
        }
        putf(ms(m_beaconframes), i);
      }
      else
      {
        fork(P_BACK | P_MAIL, 0, sendmailbake, "Beacon");
        putf(ms(m_beaconstarted));
      }
    } break;
    case pwgen:
    {
      FILE *f;
      if (*befbuf && (f = s_fopen(befbuf, "swt")) != 0)
      {
        unsigned int i;
        int upw;
        upw = ! stricmp(befbuf, "userpw.bcm"); // file fuer setpw
        for (i = 0; i < 1620; i++)
        {
          char c = 0;
          while (! isalnum(c)) c = random_max('z');
          fputc(c, f);
          //pw-file fuer setpw erzeugen (81 Zeilen mit je 20 Zeichen)
          if (upw && (i % 20) == 19) fputc(LF, f);
        }
        trace(report, "pwgen", "%s created", befbuf);
        s_fclose(f);
      }
      else //ohne Parameter immer userpw.bcm erzeugen
      if (! *befbuf && (f = s_fopen("userpw.bcm", "swt")) != 0)
      {
        unsigned int i;
        for (i = 0; i < 1620; i++)
        {
          char c = 0;
          while (! isalnum(c)) c = random_max('z');
          fputc(c, f);
          //pw-file fuer setpw erzeugen (81 Zeilen mit je 20 Zeichen)
          if ((i % 20) == 19) fputc(LF, f);
        }
        trace(report, "pwgen", "userpw.bcm created");
        s_fclose(f);
      }
    } break;
    case scmdlist: // DH3MB
    {
      unsigned int i = 0;
      while (beftab[i]) putf("(%02d) %s\n", ++i, beftab[i]);
    } break;
#ifdef FEATURE_MDPW
    case md2sum:
    {
      if (! *befbuf)
      {
        putf("Syntax: MD2SUM <filename>\n");
        break;
      }
      if (! file_isreg(befbuf))
        putf(ms(m_filenotfound), befbuf);
      else
      {
        MD2 md2;
        md2.readfile(befbuf, 0L);
        md2.gethexdigest(b->line);
        putf("%s  %s\n", b->line, befbuf);
      }
    } break;
    case md5sum:
    {
      if (! *befbuf)
      {
        putf("Syntax: MD5SUM <filename>\n");
        break;
      }
      if (! file_isreg(befbuf))
        putf(ms(m_filenotfound), befbuf);
      else
      {
        MD5 md5;
        md5.readfile(befbuf, 0L);
        md5.gethexdigest(b->line);
        putf("%s  %s\n", b->line, befbuf);
      }
    } break;
#endif
#if defined FEATURE_SERIAL || defined _TELEPHONE
    case ttyinit:
    {
      if (eingelogt("getty", 0, 0))
        putf(ms(m_ttyactive));
      else
        init_tty();
    } break;
#endif
#ifdef _TELEPHONE // JJ
    case ttycmd:
    {
      if (*befbuf)
      {
        if (m.ttydevice > 1)
          putf_tty("%s\r", befbuf);
        else
          putf(ms(m_nomodem));
      }
      else
        putf("Syntax: TTYCMD <command>\n");
    } break;
    case ttydial:
    {
      strupr(befbuf);
      char *nummer;
      char call[8];
      nummer = nexttoken(befbuf, call, 8);
      if (*befbuf && mbcallok(call))
      {
        if (m.ttydevice
            && (get_ufwd(call)[0] || isforwardpartner(call) >= 0))
        {
          putf(ms(m_startphonefwd), call, nummer);
          sprintf(befbuf, "%s TTY %s", call, nummer);
          fork(P_BACK | P_MAIL, 0, fwdsend, befbuf);
        }
        else
          putf(ms(m_nottyactive));
      }
      else
        putf("Syntax: TTYDIAL <call> <number>\n");
    } break;
    case ttyhangup:
    {
      tty_hangup();
      putf(ms(m_hangupmodem));
    } break;
    case ttystatus:
    {
      tty_statustext();
      putv(LF);
    } break;
    case ttywin_:
    {
      fork(P_WIND | P_MAIL, 0, tty_win, befbuf);
    } break;
    case ttycounterreset:
    {
      tty_counterreset();
      putv(LF);
    } break;
#endif
#ifdef _FILEFWD
    case fwdimport:
    {
      if (*befbuf) fwd_import(befbuf);
    } break;
    case fwdexport:
    {
      if (*befbuf) fwd_export(befbuf);
    } break;
#endif

    case ymbtest:
    {
#ifdef _USERCOMP
      if (u->comp == 1)
      {
/*
    char output[256] = { 0 };
    char output2[256] = { 0 };
    int i, il = 0;
*/
        putf("//COMP 1\n\n");
        putflush();

/*
    il = comp_sp_stat_huff(befbuf, strlen(befbuf), output);
//    printf("il: %d strlen: %d\n",il,strlen(befbuf));
//    printf("befbuf:\n-%s-\nOut:\n-%s-\n",befbuf,output);
    //putflush();
    for (i = 1; i < il ; i++)
      bputv(output[i]);

    putv(LF);
    putflush();
    output[0] = '\0';
    strcpy(befbuf, "dies ist noch ein laengerer text 2");
    il = comp_sp_stat_huff(befbuf, strlen(befbuf), output);
    for (i = 1; i < il ; i++)
      bputv(output[i]);

    putv(LF);
    putflush();
    output[0] = '\0';
    strcpy(befbuf, "dies ist ein noch laengerer text 3");
    il = comp_sp_stat_huff(befbuf, strlen(befbuf), output);
    for (i = 1; i < il ; i++)
      bputv(output[i]);


    putv(LF);
    putflush();
    putf("\n");
    il = decomp_sp_stat_huff(output, strlen(output), output2);
    printf("il: %d strlen: %d\n",il,strlen(output));
    printf("Out2:\n-%s-\n",output2);
*/

/*
#include "ahuf.h"
   // TOP-Huffman
class AHUF;
   AHUF *ahuf;
   ahuf = new AHUF();

    il = ahuf->Komprimieren(true, befbuf, output, strlen(befbuf) );
    printf("il: %d strlen: %d\n",il,strlen(befbuf));
    printf("befbuf:\n-%s-\nOut:\n-%s-\n",befbuf,output);
    putflush();
    putf("%s",output);
    putflush();
    putf("\n");
*/
      }
#endif
    } break;
  }
  return OK;
Example #28
0
void wx::diag_24h (char *title, char *yunit, double f[48])
//*************************************************************************
//
//*************************************************************************
{
  double min = f[0];
  double max = f[0];
  long imin, step;
  int hour, line;
  int i;

  for (i=1; i<48; i++)
  {
    if (f[i] < min)
      min = (long int) f[i];
    if (f[i] > max)
      max = (long int) f[i];
  }
  if (max - min < 10)
  {
    imin = (long int) (max+min)/2-5;
    step = 1;
  }
  else
  {
    imin = (long int) min-1;
    step = (long int) (max-min+1)/9 +1;
  }
  putf(" %s\n ",title);
  for (i = 0 ; title[i] ; i++) // line of dashes as long as title
    putf("-");
  putf("\n");
  putf("     %s\n",yunit);
  for (line = 0 ; line <= 10 ; line++)
  {
    long int nom = imin+step*(10-line);
    putf("   %5d |", nom);
    for (hour = 0; hour<48; hour++)
    {
      if (f[hour] >= nom && f[hour] < (nom+step))
        putf("-");
      else
        putf(" ");
    }
      putf("\n");
  }
  putf(
  "       ------------------------------------------------>\n");
  putf(
  "              2                 1                 Stunden\n");
  putf(
  " gestern   3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 heute\n");
  putf("\n");
}
Example #29
0
void mbhelp_t::dohelp (char *subject)
//*************************************************************************
//
//*************************************************************************
{
  unsigned int i = 0;
  long seekpos = 0;
  int helpall = ! stricmp(subject, "ALL");
  int found = 0;
  char idx[20];
  char *subsubject = strchr(subject, ' ');
  char *mlink = NULL;
  char *sublink = NULL;
  char linkstr[40];
  char sublinkstr[40];
  int linkcnt = 0;
  char oldsubject[60];

  strcpy(linkstr, "");
  strcpy(sublinkstr, "");
  strcpy(oldsubject, "");
  strcpy(idx, "INDEX");
  helpf = NULL;
  idxf = NULL;
  if (! subsubject) subsubject = strchr(subject, '.');
  if (subsubject) *subsubject++ = 0;
  if (! *subject) subject = "HELP";
  if (! helpopen(ms(m_helpext)))
  {
    if (! helpopen("GB"))
    {
      if (! helpopen("DL"))
      {
        putf(ms(m_nohelp));
        trace(serious, "dohelp", ms(m_nohelp));
        return;
      }
    }
  }
  if (strstr(idx, subject) == idx)
  {
    putf(ms(m_helpkeywords));
    while (fscanf(idxf, "%s %ld", inbuf, &seekpos) == 2)
    {
      subst1(inbuf, '=', 0);
      if (! subsubject || strstr(inbuf, subsubject) == inbuf)
      {
#ifdef __FLAT__
        if (! strcmp(b->uplink, "HTTP"))
          html_putf("<a href=\"/cmd?cmd=h+%s\">%-19s</a>", inbuf, inbuf);
        else
#endif
          putf("%-19s", inbuf);
        i++;
        if (! (i % 4)) putv(LF);
        else putv(' ');
      }
    }
    putv(LF);
  }
  else
  {
    while (fscanf(idxf, "%s %ld\n", inbuf, &seekpos) == 2)
    {
      if (strstr(inbuf, subject) == inbuf || helpall)
      {
        if (subsubject && ! helpall)
        {
          char *dot = strchr(inbuf, '.');
          if (dot)
          {
            dot++;
            if (strstr(dot, subsubject) != dot) continue;
          }
          else continue;
        }
        mlink = strchr(inbuf, '=');
        if (mlink)
        {
          if (helpall) continue;
          *mlink = 0;
          mlink++;
          strcpy(linkstr, mlink);
          sublink = strchr(linkstr, '.');
          sprintf(oldsubject, "%s -> ", inbuf);
          if (sublink)
          {
            *sublink = 0;
            strcpy(sublinkstr, sublink + 1);
            subsubject = sublinkstr;
          }
          else
            subsubject = NULL;
          subject = linkstr;
          rewind(idxf);
          fgets(inbuf, LINELEN, idxf); // skip first line containing filetime
          if (++linkcnt > 10)
          {
            trace(serious, "help", "cyclic link %s.%s", subject, subsubject);
            break;
          }
          continue;
        }
        found++;
        subst1(inbuf, '.', ' ');
        subst1(oldsubject, '.', ' ');
        putv(LF);
        charstr(strlen(inbuf) + 6 + strlen(oldsubject), ':');
        putf(":: %s%s ::", oldsubject, inbuf);
        putv(LF);
        charstr(strlen(inbuf) + 6 + strlen(oldsubject), ':');
        fseek(helpf, seekpos, SEEK_SET);
        while (fgets(inbuf, LINELEN, helpf))
        {
          if (*inbuf == '\\' && inbuf[1] == '\\') break;
          putf("%s", inbuf);
          if (b->abbruch) break;
        }
        if (! helpall) break;
      }
      if (b->abbruch) break;
    }
    //testabbruch();
    if (! found)
      putf(ms(m_helpnotfound), subject, subsubject ? subsubject : "*");
  }
}
Example #30
0
void putl2info (void)
//**************************************************************************
//
// Gibt eine Info zu verbundenen Layer2-Port aus
//
//**************************************************************************
{
  port_t *pp;
#ifdef _AX25K
//  sock_t *ss;
#endif
  task_t *tt;
  int pnummer;
  int i, found;
  lastfunc("putl2info");
  if (l2vorhanden)
  {
    putf("OpenBCM-L2 %d ports\n\n", highestport-1);
    putf("Layer2 parameter of connected ports:\n");
    for (pnummer = 0; pnummer <= (highestport-1); pnummer++)
      if ((pp = pfeld[pnummer]) != NULL && ! pp->lstate == disconnected)
      {
        putf("Port %-3d: ", pnummer);
        found = false;
        for (i = 0; i < TASKS; i++)
        {
          tt = tfeld[i];
          if (tt)
          {
            tvar_t *bb = (tvar_t *) tt->b;
            if (bb)
              if (tt->port == pnummer)
              {
                found = true;
                putf("%-9.9s via %-9.9s\n", tt->name, bb->uplink);
              }
          }
        }
        if (! found) putf("\n");
        putf("          Frack  %-4d ", pp->frack);
        putf("Paclen %-4d ", pp->paclen);
        putf("Timer1 %-4d ", pp->timer1);
        putf("Timer2 %-4d ", pp->timer2);
        putf("Timer3 %-4d\n", pp->timer3);
        putf("          ITimer %-4d ", pp->itimer);
        putf("QTimer %-4d ", pp->qtimer);
        putf("Retries %-3d ", pp->retries);
        putf("Roundtrip %d ", pp->roundtrip);
        putf("DiscTimer %d\n", pp->disctimer);
      }
    putf("\n");
  }
#ifdef _AX25K
/*  if (ax25k_ok)
  {
    putf("OpenBCM Linux Kernel AX25\n\n");
    putf("Kernel AX25 parameter of connected ports:\n");
    for (pnummer = 0; pnummer <= (highestport-1); pnummer++)
      if ((ss = so[pnummer]))
      {
            putf("Port %-3d: ",pnummer);
        found = false;
        for (i = 0; i < TASKS; i++)
        { tt = tfeld[i];
          if (tt)
          { tvar_t *bb = (tvar_t *) tt->b;
            if (bb)
              if (tt->port == pnummer)
              {
                found = true;
                putf("%-9.9s via %-9.9s\n", tt->name, bb->uplink);
              }
          }
        }
        if (! found) putf("\n");
      }
  }
*/
#endif
}