Ejemplo n.º 1
0
ptinit(){
	register i, j;
	register char **p;
	char *q;
	int x[8];
	extern char *setbrk();

	if(((i=open(termtab,0)) < 0) && (i=open(_PATH_TERM,0)) < 0){
		prstr("Cannot open ");
		prstr(termtab);
		prstr("\n");
		exit(-1);
	}
	read(i,(char *)x,8*sizeof(int));
	/* Calc size of table, not counting zzz */
	j = ((int) &t.zzz - (int) &t.bset);
	read(i, (char *)&t.bset, j);
	x[2] -= j;
	q = setbrk(x[2]);
	lseek(i,(long)t.twinit+8*sizeof(int),0);
	i = read(i,q,x[2]);
	j = q - t.twinit;
	for(p = &t.twinit; p < &t.zzz; p++){
		if(*p)*p += j;else *p = "";
	}
	sps = EM;
	ics = EM*2;
	dtab = 8 * t.Em;
	for(i=0; i<16; i++)tabtab[i] = dtab * (i+1);
	if(eqflg)t.Adj = t.Hor;
}
Ejemplo n.º 2
0
/* Print a text variable */
static void
prvar(
    const char *var,
    const char *val)
{
    size_t new_len;

    new_len = strlen(var)
	      + sizeof("=\\\"")
	      + strlen(val)
	      + sizeof("\\\"")
	      + 1;
    if(new_len > buf_len) {
	free(buf);
	buf_len = new_len;
	buf = malloc(new_len);
	if (!buf) {
	    g_fprintf(stderr, _("genversion: Not enough memory"));
	    abort();
	    /*NOTREACHED*/
	}
    }
    g_snprintf(buf, buf_len, "%s=\\\"%s\\\"", var, val);	/* safe */
    prstr(buf);
}
Ejemplo n.º 3
0
/* Print a numeric variable */
static void
prnum(
    const char *var,
    long	val)
{
    static char number[NUM_STR_SIZE];
    size_t new_len;

    g_snprintf(number, sizeof(number), "%ld", val);
    new_len = strlen(var)
	      + sizeof("=")
	      + strlen(number)
	      + 1;
    if(new_len > buf_len) {
	free(buf);
	buf_len = new_len;
	buf = malloc(new_len);		/* let it die if malloc() fails */
	if (!buf) {
	    g_fprintf(stderr, _("genversion: Not enough memory"));
	    abort();
	    /*NOTREACHED*/
	}
    }
    g_snprintf(buf, buf_len, "%s=%s", var, number);		/* safe */
    prstr(buf);
}
Ejemplo n.º 4
0
/* Print a undef variable */
static void
prundefvar(
    const char *var)
{
    size_t new_len;

    new_len = strlen(var)
	      + sizeof("=UNDEF")
	      + 1;
    if(new_len > buf_len) {
	free(buf);
	buf_len = new_len;
	buf = malloc(new_len);		/* let it die if malloc() fails */
	if (!buf) {
	    g_fprintf(stderr, _("genversion: Not enough memory"));
	    abort();
	    /*NOTREACHED*/
	}
    }
    g_snprintf(buf, buf_len, "%s=UNDEF", var);	/* safe */
    prstr(buf);
}
Ejemplo n.º 5
0
static void
hprf(const char *fmt, int mesg, FILE *f, int threaded, const char *attrlist)
{
	struct message	*mp = &message[mesg-1];
	char	*headline = NULL, *subjline, *name, *cp, *pbuf = NULL;
	struct headline	hl;
	size_t	headsize = 0;
	const char	*fp;
	int	B, c, i, n, s;
	int	headlen = 0;
	struct str	in, out;
	int	subjlen = scrnwidth, fromlen, isto = 0, isaddr = 0;
	FILE	*ibuf;

	if ((mp->m_flag & MNOFROM) == 0) {
		if ((ibuf = setinput(&mb, mp, NEED_HEADER)) == NULL)
			return;
		if ((headlen = readline(ibuf, &headline, &headsize)) < 0)
			return;
	}
	if ((subjline = hfield("subject", mp)) == NULL)
		subjline = hfield("subj", mp);
	if (subjline == NULL) {
		out.s = NULL;
		out.l = 0;
	} else {
		in.s = subjline;
		in.l = strlen(subjline);
		mime_fromhdr(&in, &out, TD_ICONV | TD_ISPR);
		subjline = out.s;
	}
	if ((mp->m_flag & MNOFROM) == 0) {
		pbuf = ac_alloc(headlen + 1);
		parse(headline, headlen, &hl, pbuf);
	} else {
		hl.l_from = /*fakefrom(mp);*/NULL;
		hl.l_tty = NULL;
		hl.l_date = fakedate(mp->m_time);
	}
	if (value("datefield") && (cp = hfield("date", mp)) != NULL)
		hl.l_date = fakedate(rfctime(cp));
	if (Iflag) {
		if ((name = hfield("newsgroups", mp)) == NULL)
			if ((name = hfield("article-id", mp)) == NULL)
				name = "<>";
		name = prstr(name);
	} else if (value("show-rcpt") == NULL) {
		name = name1(mp, 0);
		isaddr = 1;
		if (value("showto") && name && is_myname(skin(name))) {
			if ((cp = hfield("to", mp)) != NULL) {
				name = cp;
				isto = 1;
			}
		}
	} else {
		isaddr = 1;
		if ((name = hfield("to", mp)) != NULL)
			isto = 1;
	}
	if (name == NULL) {
		name = "";
		isaddr = 0;
	}
	if (isaddr) {
		if (value("showname"))
			name = realname(name);
		else {
			name = prstr(skin(name));
		}
	}
	for (fp = fmt; *fp; fp++) {
		if (*fp == '%') {
			if (*++fp == '-') {
				fp++;
			} else if (*fp == '+')
				fp++;
			while (digitchar(*fp&0377))
				fp++;
			if (*fp == '\0')
				break;
		} else {
#if defined (HAVE_MBTOWC) && defined (HAVE_WCWIDTH)
			if (mb_cur_max > 1) {
				wchar_t	wc;
				if ((s = mbtowc(&wc, fp, mb_cur_max)) < 0)
					n = s = 1;
				else {
					if ((n = wcwidth(wc)) < 0)
						n = 1;
				}
			} else
#endif  /* HAVE_MBTOWC && HAVE_WCWIDTH */
			{
				n = s = 1;
			}
			subjlen -= n;
			while (--s > 0)
				fp++;
		}
	}
	for (fp = fmt; *fp; fp++) {
		if (*fp == '%') {
			B = 0;
			n = 0;
			s = 1;
			if (*++fp == '-') {
				s = -1;
				fp++;
			} else if (*fp == '+')
				fp++;
			if (digitchar(*fp&0377)) {
				do
					n = 10*n + *fp - '0';
				while (fp++, digitchar(*fp&0377));
			}
			if (*fp == '\0')
				break;
			n *= s;
			switch (*fp) {
			case '%':
				putc('%', f);
				subjlen--;
				break;
			case '>':
			case '<':
				c = dot == mp ? *fp&0377 : ' ';
				putc(c, f);
				subjlen--;
				break;
			case 'a':
				c = dispc(mp, attrlist);
				putc(c, f);
				subjlen--;
				break;
			case 'm':
				if (n == 0) {
					n = 3;
					if (threaded)
						for (i=msgCount; i>999; i/=10)
							n++;
				}
				subjlen -= fprintf(f, "%*d", n, mesg);
				break;
			case 'f':
				if (n <= 0)
					n = 18;
				fromlen = n;
				if (isto)
					fromlen -= 3;
				fprintf(f, "%s%s", isto ? "To " : "",
						colalign(name, fromlen, 1));
				subjlen -= n;
				break;
			case 'd':
				if (n <= 0)
					n = 16;
				subjlen -= fprintf(f, "%*.*s", n, n, hl.l_date);
				break;
			case 'l':
				if (n == 0)
					n = 4;
				if (mp->m_xlines)
					subjlen -= fprintf(f, "%*ld", n,
							mp->m_xlines);
				else {
					subjlen -= n;
					while (n--)
						putc(' ', f);
				}
				break;
			case 'o':
				if (n == 0)
					n = -5;
				subjlen -= fprintf(f, "%*lu", n,
						(long)mp->m_xsize);
				break;
			case 'i':
				if (threaded)
					subjlen -= putindent(f, mp,
							scrnwidth - 60);
				break;
			case 'S':
				B = 1;
				/*FALLTHRU*/
			case 's':
				n = n>0 ? n : subjlen - 2;
				if (B)
					n -= 2;
				if (subjline != NULL && n >= 0) {
					/* pretty pathetic */
					fprintf(f, B ? "\"%s\"" : "%s",
						colalign(subjline, n, 0));
				}
				break;
			case 'U':
				if (n == 0)
					n = 9;
				subjlen -= fprintf(f, "%*lu", n, mp->m_uid);
				break;
			case 'e':
				if (n == 0)
					n = 2;
				subjlen -= fprintf(f, "%*u", n, threaded == 1 ?
						mp->m_level : 0);
				break;
			case 't':
				if (n == 0) {
					n = 3;
					if (threaded)
						for (i=msgCount; i>999; i/=10)
							n++;
				}
				fprintf(f, "%*ld", n, threaded ?
						mp->m_threadpos : mesg);
				subjlen -= n;
				break;
			case 'c':
				if (n == 0)
					n = 6;
				subjlen -= fprintf(f, "%*g", n, mp->m_score);
				break;
			}
		} else
			putc(*fp&0377, f);
	}
	putc('\n', f);
	if (out.s)
		free(out.s);
	if (headline)
		free(headline);
	if (pbuf)
		ac_free(pbuf);
}
Ejemplo n.º 6
0
int
main(
    int		argc,
    char **	argv)
{
    const char *v;
    char *verstr;
    size_t v_len;

    (void)argc;	/* Quiet unused parameter warning */
    (void)argv;	/* Quiet unused parameter warning */

    /*
     * Configure program for internationalization:
     *   1) Only set the message locale for now.
     *   2) Set textdomain for all amanda related programs to "amanda"
     *      We don't want to be forced to support dozens of message catalogs.
     */  
    setlocale(LC_MESSAGES, "C");
    textdomain("amanda"); 

    g_printf(_("/* version.c - generated by genversion.c - DO NOT EDIT! */\n"));
    g_printf("const char * const version_info[] = {\n");

    startline("build:");
    v = VERSION;
    v_len = sizeof("Amanda-") + strlen(v) + 1;
    verstr = malloc(v_len);
    if (!verstr) {
	g_fprintf(stderr, _("genversion: Not enough memory"));
	abort();
	/*NOTREACHED*/
    }
    g_snprintf(verstr, v_len, "Amanda-%s", v);		/* safe */
    prvar("VERSION", verstr);
    free(verstr);

#ifdef BUILT_DATE
    prvar("BUILT_DATE", BUILT_DATE);
#else
    prundefvar("BUILT_DATE");
#endif

#ifdef BUILT_MACH
    prvar("BUILT_MACH", BUILT_MACH);
#else
    prundefvar("BUILT_MACH");
#endif

#ifdef BUILT_REV
    prvar("BUILT_REV", BUILT_REV);
#else
    prundefvar("BUILT_REV");
#endif

#ifdef BUILT_BRANCH
    prvar("BUILT_BRANCH", BUILT_BRANCH);
#else
    prundefvar("BUILT_BRANCH");
#endif

#ifdef CC
    prvar("CC", CC);
#else
    prundefvar("CC");
#endif

    endline();

    startline("paths:");

    prvar("bindir", bindir);
    prvar("sbindir", sbindir);
    prvar("libexecdir", libexecdir);
    prvar("amlibexecdir", amlibexecdir);
    prvar("mandir", mandir);
    prvar("AMANDA_TMPDIR", AMANDA_TMPDIR);
#ifdef AMANDA_DBGDIR
    prvar("AMANDA_DBGDIR", AMANDA_DBGDIR);
#else
    prundefvar("AMANDA_DBGDIR");
#endif
    prvar("CONFIG_DIR", CONFIG_DIR);

#ifdef DEV_PREFIX
    prvar("DEV_PREFIX", DEV_PREFIX);
#else
    prundefvar("DEV_PREFIX");
#endif

#ifdef RDEV_PREFIX
    prvar("RDEV_PREFIX", RDEV_PREFIX);
#else
    prundefvar("RDEV_PREFIX");
#endif

#ifdef DUMP
    prvar("DUMP", DUMP);
    prvar("RESTORE", RESTORE);
#else
    prundefvar("DUMP");
    prundefvar("RESTORE");
#endif

#ifdef VDUMP
    prvar("VDUMP", VDUMP);
    prvar("VRESTORE", VRESTORE);
#else
    prundefvar("VDUMP");
    prundefvar("VRESTORE");
#endif

#ifdef XFSDUMP
    prvar("XFSDUMP", XFSDUMP);
    prvar("XFSRESTORE", XFSRESTORE);
#else
    prundefvar("XFSDUMP");
    prundefvar("XFSRESTORE");
#endif

#ifdef VXDUMP
    prvar("VXDUMP", VXDUMP);
    prvar("VXRESTORE", VXRESTORE);
#else
    prundefvar("VXDUMP");
    prundefvar("VXRESTORE");
#endif

#ifdef SAMBA_CLIENT
    prvar("SAMBA_CLIENT", SAMBA_CLIENT);
#else
    prundefvar("SAMBA_CLIENT");
#endif

#ifdef GNUTAR
    prvar("GNUTAR", GNUTAR);
#else
    prundefvar("GNUTAR");
#endif

#ifdef COMPRESS_PATH
    prvar("COMPRESS_PATH", COMPRESS_PATH);
#else
    prundefvar("COMPRESS_PATH");
#endif

#ifdef UNCOMPRESS_PATH
    prvar("UNCOMPRESS_PATH", UNCOMPRESS_PATH);
#else
    prundefvar("UNCOMPRESS_PATH");
#endif

#ifdef LPRCMD
    prvar("LPRCMD", LPRCMD);
#else
    prundefvar(" LPRCMD");
#endif

#ifdef MAILER
    prvar("MAILER", MAILER);
#else
    prundefvar(" MAILER");
#endif

#ifdef GNUTAR_LISTED_INCREMENTAL_DIR
    prvar("listed_incr_dir", GNUTAR_LISTED_INCREMENTAL_DIR);
#else
    prundefvar("GNUTAR_LISTED_INCREMENTAL_DIR");
#endif
    endline();

    startline("defs:");

    prvar("DEFAULT_SERVER", DEFAULT_SERVER);
    prvar("DEFAULT_CONFIG", DEFAULT_CONFIG);
    prvar("DEFAULT_TAPE_SERVER", DEFAULT_TAPE_SERVER);

#ifdef DEFAULT_TAPE_DEVICE
    prvar("DEFAULT_TAPE_DEVICE", DEFAULT_TAPE_DEVICE);
#endif

#ifdef AIX_BACKUP
    prstr("AIX_BACKUP");
#endif

#ifdef BROKEN_VOID
    prstr("BROKEN_VOID");
#endif

#ifdef DUMP_RETURNS_1
    prstr("DUMP_RETURNS_1");
#endif

#ifdef HAVE_MMAP
    prstr("HAVE_MMAP");
#endif

#ifndef HAVE_STRERROR
    prstr("NEED_STRERROR");
#endif

#ifndef HAVE_STRSTR
    prstr("NEED_STRSTR");
#endif

#ifdef HAVE_SYSVSHM
    prstr("HAVE_SYSVSHM");
#endif

#ifdef WANT_AMFLOCK_POSIX
    prstr("AMFLOCK_POSIX");
#endif
#ifdef WANT_AMFLOCK_FLOCK
    prstr("AMFLOCK_FLOCK");
#endif
#ifdef WANT_AMFLOCK_LOCKF
    prstr("AMFLOCK_LOCKF");
#endif
#ifdef WANT_AMFLOCK_LNLOCK
    prstr("AMFLOCK_LNLOCK");
#endif

#ifdef STATFS_BSD
    prstr("STATFS_BSD");
#endif

#ifdef STATFS_OSF1
    prstr("STATFS_OSF1");
#endif

#ifdef STATFS_ULTRIX
    prstr("STATFS_ULTRIX");
#endif

#ifdef SETPGRP_VOID
    prstr("SETPGRP_VOID");
#endif

#ifdef ASSERTIONS
    prstr("ASSERTIONS");
#endif

#ifdef AMANDA_DEBUG_DAYS
    prnum("AMANDA_DEBUG_DAYS", AMANDA_DEBUG_DAYS);
#endif

#ifdef BSD_SECURITY
    prstr("BSD_SECURITY");
#endif

#ifdef KRB5_SECURITY
    prstr("KRB5_SECURITY");
#endif

#ifdef RSH_SECURITY
    prstr("RSH_SECURITY");
#endif

#ifdef USE_AMANDAHOSTS
    prstr("USE_AMANDAHOSTS");
#endif

#ifdef USE_RUNDUMP
    prstr("USE_RUNDUMP");
#endif

    prvar("CLIENT_LOGIN", CLIENT_LOGIN);

#ifdef CHECK_USERID
    prstr("CHECK_USERID");
#endif

#ifdef HAVE_GZIP
    prstr("HAVE_GZIP");
#endif

#ifdef COMPRESS_SUFFIX
    prvar("COMPRESS_SUFFIX", COMPRESS_SUFFIX);
#endif

#ifdef COMPRESS_FAST_OPT
    prvar("COMPRESS_FAST_OPT", COMPRESS_FAST_OPT);
#endif

#ifdef COMPRESS_BEST_OPT
    prvar("COMPRESS_BEST_OPT", COMPRESS_BEST_OPT);
#endif

#ifdef UNCOMPRESS_OPT
    prvar("UNCOMPRESS_OPT", UNCOMPRESS_OPT);
#endif

    endline();

    g_printf("  0\n};\n");

    return (0); /* exit */
}