Back to index

glibc  2.9
Defines | Functions | Variables
iopadn.c File Reference
#include "libioP.h"

Go to the source code of this file.

Defines

#define PADSIZE   16

Functions

_IO_ssize_t _IO_padn (_IO_FILE *fp, int pad, _IO_ssize_t count)

Variables

static char const blanks [PADSIZE]
static char const zeroes [PADSIZE]

Define Documentation

#define PADSIZE   16

Definition at line 30 of file iopadn.c.


Function Documentation

_IO_ssize_t _IO_padn ( _IO_FILE fp,
int  pad,
_IO_ssize_t  count 
)

Definition at line 37 of file iopadn.c.

{
  char padbuf[PADSIZE];
  const char *padptr;
  int i;
  _IO_size_t written = 0;
  _IO_size_t w;

  if (pad == ' ')
    padptr = blanks;
  else if (pad == '0')
    padptr = zeroes;
  else
    {
      for (i = PADSIZE; --i >= 0; )
       padbuf[i] = pad;
      padptr = padbuf;
    }
  for (i = count; i >= PADSIZE; i -= PADSIZE)
    {
      w = _IO_sputn (fp, padptr, PADSIZE);
      written += w;
      if (w != PADSIZE)
       return written;
    }

  if (i > 0)
    {
      w = _IO_sputn (fp, padptr, i);
      written += w;
    }
  return written;
}

Variable Documentation

char const blanks[PADSIZE] [static]
Initial value:
{' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}

Definition at line 31 of file iopadn.c.

char const zeroes[PADSIZE] [static]
Initial value:
{'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}

Definition at line 33 of file iopadn.c.