Back to index

tetex-bin  3.0
Functions | Variables
ascii85.c File Reference
#include <stdio.h>
#include <ctype.h>

Go to the source code of this file.

Functions

static int nextch (void)
static decode_block (void)
static output_block (int n)
 main (int argc, char *argv[])

Variables

unsigned long int ascii85
unsigned binary [4]

Function Documentation

static decode_block ( void  ) [static]

Definition at line 48 of file ascii85.c.

{
  int i;
  for (i=3; i>=0; i--){
    binary[i] = ascii85 % 256u;
    ascii85 /= 256u;
  }
}

Here is the caller graph for this function:

main ( int  argc,
char *  argv[] 
)

Definition at line 65 of file ascii85.c.

{
  int i, ch, eof = 0, nread;
  while (!eof) {
    ascii85 = 0;
    nread = 0;
    /* Look ahead for special zero key */
    if ((ch = nextch()) == 'z') {
      nread = 4;  /* Lie to it */
    } else{
      ungetc (ch, stdin);
      for (i=0; i<5; i++) {
       if ((ch=nextch()) < 0) {
         eof = 1;
         break;
       }
       ascii85 = ascii85 * 85 + (ch-'!');
       nread += 1;
      }
    }
    if (nread > 1) {
      decode_block();
      output_block(nread-1);
    }
  }
}

Here is the call graph for this function:

static int nextch ( void  ) [static]

Definition at line 29 of file ascii85.c.

{
  int ch;
  while ((ch = getchar()) >= 0) {
    if (ch >= '!' && ch <= 'u' || ch == 'z')
      return ch;
    if (ch == '~' && getchar() == '>') {
      return -1;
    }
  }
  if (ch < 0) {
    fprintf (stderr, "Premature end of file.\n");
    exit(1);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static output_block ( int  n) [static]

Definition at line 57 of file ascii85.c.

{
  int i;
  for (i=0; i<n; i++) {
    putchar (binary[i]);
  }
}

Here is the caller graph for this function:


Variable Documentation

unsigned long int ascii85

Definition at line 45 of file ascii85.c.

unsigned binary[4]

Definition at line 46 of file ascii85.c.