change function definitions

Buffers are no longer wired into any input or translation functions.
They are supplied as arguments through main.
This commit is contained in:
Eric 2025-05-26 12:23:54 +02:00
parent 9b1fe95a8e
commit 848c3749d2
5 changed files with 53 additions and 60 deletions

34
input.c
View file

@ -1,37 +1,29 @@
#include "input.h"
#define OBUFSIZE 4
#define SBUFSIZE 5
#define PADDING '='
unsigned char o[OBUFSIZE];
unsigned char s[SBUFSIZE];
unsigned char *
getocts(FILE *fp, int *np)
int
getocts(FILE *fp, unsigned char *o, int olen)
{
int n, c;
int c, n;
n = 0;
while (n < OBUFSIZE-1 && (c = fgetc(fp)) != EOF)
while (n < olen-1 && (c = fgetc(fp)) != EOF)
o[n++] = c;
*np = n;
return (*np) ? o : NULL;
return n;
}
unsigned char *
getsxts(FILE *fp, int *np)
int
getsxts(FILE *fp, unsigned char *s, int slen)
{
int n, p, c;
int c, n, pad;
n = p = 0;
while (n < SBUFSIZE-1 && (c = fgetc(fp)) != EOF && c != PADDING)
n = pad = 0;
while (n < slen-1 && (c = fgetc(fp)) != EOF && c != PADDING)
s[n++] = c;
while (n+p < SBUFSIZE-1)
s[n+p++] = PADDING;
*np = n;
while (n+pad < slen-1)
s[n+pad++] = PADDING;
return (n) ? s : NULL;
return n;
}