Category : C Source Code
Archive   : SDB.ZIP
Filename : SDBTBL.C

 
Output of file : SDBTBL.C contained in archive : SDB.ZIP
/* SDB - table output routines */

#include "sdbio.h"

static char buffer[TABLEMAX+1];
int bndx;

/* db_thead - print a table header */
db_thead(fp,slptr)
FILE *fp; struct sel *slptr;
{
struct sattr *saptr;
int twidth,fwidth,i;
char *aname;

/* compute the table width */
twidth = 1;
for (saptr = slptr->sl_attrs; saptr != NULL; saptr = saptr->sa_next)
twidth += saptr->sa_attr->at_size + 3;

/* print the top line of the table */
bstart();
for (i = 0; i < twidth; i++)
binsert('-');
bprint(fp);

/* print the label line of the table */
bstart();
for (saptr = slptr->sl_attrs; saptr != NULL; saptr = saptr->sa_next) {
fwidth = saptr->sa_attr->at_size;
binsert('|'); binsert(' ');
if ((aname = saptr->sa_name) == NULL)
aname = saptr->sa_aname;
for (i = 0; i < fwidth; i++)
if (*aname != 0)
binsert(*aname++);
else
binsert(' ');
binsert(' ');
}
binsert('|');
bprint(fp);

/* print the line under the labels */
bstart();
for (i = 0; i < twidth; i++)
binsert('-');
bprint(fp);
}

/* db_tfoot - print a table foot */
db_tfoot(fp,slptr)
FILE *fp; struct sel *slptr;
{
struct sattr *saptr;
int twidth,i;

/* compute the table width */
twidth = 1;
for (saptr = slptr->sl_attrs; saptr != NULL; saptr = saptr->sa_next)
twidth += saptr->sa_attr->at_size + 3;

/* print the line at the foot of the table */
bstart();
for (i = 0; i < twidth; i++)
binsert('-');
bprint(fp);
}

/* db_tentry - print a table entry */
db_tentry(fp,slptr)
FILE *fp; struct sel *slptr;
{
struct sattr *saptr;
int fwidth,i;

/* print a table entry */
bstart();
for (saptr = slptr->sl_attrs; saptr != NULL; saptr = saptr->sa_next) {
fwidth = saptr->sa_attr->at_size;
binsert('|'); binsert(' ');
for (i = 0; i < fwidth; i++)
if (saptr->sa_aptr[i] != 0)
binsert(saptr->sa_aptr[i]);
else
binsert(' ');
binsert(' ');
}
binsert('|');
bprint(fp);
}

/* bstart - start building a line */
static bstart()
{
bndx = 0;
}

/* binsert - insert a character into the buffer */
static binsert(ch)
int ch;
{
if (bndx < TABLEMAX)
buffer[bndx++] = ch;
}

/* bprint - print the current line */
static bprint(fp)
FILE *fp;
{
buffer[bndx] = EOS;
fprintf(fp,"%s\n",buffer);
}



  3 Responses to “Category : C Source Code
Archive   : SDB.ZIP
Filename : SDBTBL.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/