Пример #1
0
/*
 * Output a number in a given base.
 */
static void printu(unsigned long n, unsigned long b, Bool upperCase) {
  unsigned long a;

  a = n / b;
  if (a != 0) {
    printu(a, b, upperCase);
  }
  if (upperCase) {
    charOut("0123456789ABCDEF"[n % b]);
  } else {
    charOut("0123456789abcdef"[n % b]);
  }
}
Пример #2
0
/*
 * Output a number in base 10.
 */
static void printn(long n) {
  long a;

  if (n < 0) {
    charOut('-');
    n = -n;
  }
  a = n / 10;
  if (a != 0) {
    printn(a);
  }
  charOut(n % 10 + '0');
}
int addFa(FILE *f, char *ctgFaName)
/* Append contents of FA file. Return the number of bases written. */
{
struct lineFile *lf = lineFileOpen(ctgFaName, TRUE);
int lineSize;
char *line, c;
int recordCount = 0;
int baseCount = 0;
int i;

while (lineFileNext(lf, &line, &lineSize))
    {
    if (line[0] == '>')
        {
	++recordCount;
	if (recordCount > 1)
	   warn("More than one record in %s\n", ctgFaName);
	}
    else
        {
	for (i=0; i<lineSize; ++i)
	    {
	    c = line[i];
	    if (isalpha(c))
		{
	        charOut(f, c);
		baseCount++;
		}
	    }
	}
    }
lineFileClose(&lf);
return(baseCount);
}
void addN(FILE *f, int count)
/* Write count N's to fa file. */
{
int i;
for (i=0; i<count; ++i)
    charOut(f, 'N');
}
Пример #5
0
/*
 * Formatted output with a variable argument list.
 */
static void vprintf(char *fmt, va_list ap) {
  char c;
  int n;
  long ln;
  unsigned int u;
  unsigned long lu;
  char *s;
  Bool negFlag;
  char filler;
  int width, count;

  while (1) {
    while ((c = *fmt++) != '%') {
      if (c == '\0') {
        return;
      }
      charOut(c);
    }
    c = *fmt++;
    if (c == '-') {
      negFlag = TRUE;
      c = *fmt++;
    } else {
      negFlag = FALSE;
    }
    if (c == '0') {
      filler = '0';
      c = *fmt++;
    } else {
      filler = ' ';
    }
    width = 0;
    while (c >= '0' && c <= '9') {
      width *= 10;
      width += c - '0';
      c = *fmt++;
    }
    if (c == 'd') {
      n = va_arg(ap, int);
      count = countPrintn(n);
      if (width > 0 && !negFlag) {
        fill(width - count, filler);
      }
      printn(n);
      if (width > 0 && negFlag) {
        fill(width - count, filler);
      }
    } else
    if (c == 'u' || c == 'o' || c == 'x' || c == 'X') {
Пример #6
0
/*
 * Output a number of filler characters.
 */
static void fill(int numFillers, char filler) {
  while (numFillers-- > 0) {
    charOut(filler);
  }
}