ftp.nice.ch/pub/next/developer/resources/libraries/Puppeteer.1.1.s.tar.gz#/Puppeteer1.1.src/util.c

This is util.c in view mode; [Download] [Up]

/*
 * Puppeteer 1.1
 *
 * Copyright (c) 1994 Primitive Software Ltd.  All rights reserved.
 *
 * Author: Dave Griffiths <dave@prim.demon.co.uk>
 */

#include <streams/streams.h>
#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>

char chtbl[256];

void
uuinit()
{
	int i, j;
	
	for (i = 0; i < ' '; i++)
		chtbl[i] = 0;
	for (i = ' ', j = 0; i < ' ' + 64; i++, j++)
		chtbl[i] = j;
	for (i = ' ' + 64; i < 128; i++)
		chtbl[i] = 0;
	chtbl['`'] = chtbl[' '];
	chtbl['~'] = chtbl['^'];
}
	
void
uudecode(NXStream *in, NXStream *out)
{
	int count, b0, b1, b2, b3;
	
	while (count = chtbl[NXGetc(in)]) {
		while (count > 0) {
			b0 = NXGetc(in);
			b1 = NXGetc(in);
			b2 = NXGetc(in);
			b3 = NXGetc(in);
			NXPutc(out, (chtbl[b0] << 2 | chtbl[b1] >> 4));
			count--;
			if (count > 0) {
				NXPutc(out, (chtbl[b1] << 4 | chtbl[b2] >> 2));
				count--;
			}
			if (count > 0) {
				NXPutc(out, (chtbl[b2] << 6 | chtbl[b3]));
				count--;
			}
		}
		NXGetc(in);
	}
	
	NXFlush(out);
}

void
printTime(char *msg)
{
     struct timeval tp;
     struct timezone tzp;
     
     gettimeofday(&tp, &tzp);
     
     printf("%s, SECS = %d, MSECS = %d\n", msg, tp.tv_sec, tp.tv_usec/1000);
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.