This is util.c in view mode; [Download] [Up]
/* Utility Routines for scan300c Copyright (c) Terence P. Gliedt, 1992. This program may be freely redistributable in its original, unmodified form. The author grants you a nonexclusive, royalty-free license to use this software, and modify it as needed provided that this copyright notice remains, and any changes are clearly indicated as such. No part may be incorporated in products or packages sold for profit without express permission of the copyright holder. The author assumes no responsibility for the consequences of using this program and no warranty of any sort is expressed or implied. */ #include <sys/types.h> char _HexString[4096]; /* Hex builds into here */ /* Hex (String, Length) Function: Format String as a hexadecimal string for Length bytes Returns: char * to _HexString */ char *Hex(char *String, int Length) { const char HexChar[16] = "0123456789ABCDEF"; int I; char *P = &_HexString[0]; /* Return data goes here */ for (; Length; Length--) { I = (*String>>4) & 15; *P = HexChar[I]; P++; I = *String & 15; *P = HexChar[I]; P++; String++; } *P = '\0'; return(_HexString); } /* ByteCounter (ByteC) Function: Calculates the byte counter length Returns: int */ int ByteCounter(u_char *ByteC) { int Low, High; Low = (int) *ByteC; ByteC++; High = (int) *ByteC; return( (256*High) + Low); } /* MakeByteCounter (Value, ByteC) Function: Creates a two byte ByteC (lower byte followed by higher byte) from Value Returns: void */ void MakeByteCounter(int Value, u_char *ByteC) { *ByteC = (u_char) 255 & Value; Value = Value>>8; ByteC++; *ByteC = (u_char) 255 & Value; return; }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.