-

LIBRARIES PUBLIC DOCUMENT SUPLIB

From HI-TECH C for CP/M Fan WIKI(EN)
Jump to: navigation, search

Supplement Library for HI-TECH C V3.09 manual By Tatsuhiko Syoji(Tatsu) 1995-2000

Contents of this package

CTYPE .H 
Header file which defines character processing functions.
STDLIB .H 
Header file which defines a sort of functions.
STRING .H 
Header file which defines strings processing functions.
LIBT .LIB 
Library file of this library package.
LIBT .L 
Source file of a sort of functions.
SUPLIB .TXT 
The file you read now.
AREL .BAT 
Bat file for ELIBR I made.
CREL .BAT 
Bat file for ELIBR I made.

Target of this library

HI-TECH C V3.09 for CP/M

What is this library?

Port of functions which HI-TECH C does not have, nevertheless other processing systems have.

How to

Copy ctype.h,string.h,stdlib.h,LIBT.LIB to HI-TECH C working disk. Load appropriate header files which defines function you aim at by #include statement.

Link LIBT.LIB before LIBC.LIB. Thus we can use these functions in this package.

Re-compile

Prepare ELIBR which I made and execute below.

elibr -c 2 -o libt.lib libt.l

We can recompile by executing generated $exec.bat.

ELIBR is available at my web page or Vector program library.

About reproduction

This library is under license of HI-TECH C for CP/M Version 3.09 because I changed original header files of HI-TECH C for CP/M Version 3.09.

Cited from original Z80READ.ME below.

The HI-TECH Z80 CP/M C compiler V3.09 is provided free of charge for any
use, private or commercial, strictly as-is. No warranty or product
support is offered or implied.

You may use this software for whatever you like, providing you acknowledge
that the copyright to this software remains with HI-TECH Software.

The author Tatsu have the copyrights of appended functions.

Function references

These functions are available by including stdlib.h.

VOID swab(s,t,n)
char *s;
char *t;
int n;
Copy "n" bytes from "s" to "t" exchanging byte order within 2 bytes unit.
Valuable "n" must even.
char *bsearch(key,base,membs,size,compar)
char *key;
char *base;
unsigned membs;
unsigned size;
int (*compar)();
Returns address of the result of binary search which finds same value as valuable "key" in array"base".
Array "base" is consisted by "membs" units of "size" bytes elements sorted by ascending order.
It uses function which returns values below with 2 pointers x, y as argument. This function is given as "compar".
*x > *y positive number
*x > *y zero
*x > *y negative number
Returns address of element which has same value as "key" and returns NULL if it is not found.
Prepare sufficient free area because it uses recursive call for simple processing.

Reference of character processing functions

These functions are available by including ctype.h

int iscsymf(c);
int iscsym(c);

These functions returns TRUE when satisfies conditions below and if not returns FALSE.

int iscsymf(c);
Whether it is first character of symbols in Language C.
int iscsym(c);
Whether it is second character of symbols or later in Language C.

Reference of strings processing functions

These functions are available by including string.h.

int strcmpi(s,t)
int stricmp(s,t)
unsigned char *s,*t;
It returns result of comparison between string s and t by lexical order.
It is not case sensitive.
s > t positive number
s = t zero
s < t negative number
char *strstr(str,str2)
char *str,*str2;
Searches strings str2 in strings str.
Returns address where it is find in the string.
Returns NULL if it is not found.
int strncmpi(s,t,len)
int strnicmp(s,t,len)
unsigned char *s,*t;
int len;
Returns values below by comparison between two strings s and t within len charanters by lexical order.
It is not case sensitive.
Functions strncmpi and strnicmp are same. These are defined in string.h and can be called by either name.
s > t positive number
s = t zero
s < t negative number
unsigned char *strrev(str)
unsigned char *str;
Reverts string and returns address of it.
ex)"012345"->"543210"
char *strtok(buf,mask)
char *buf;
char *mask;
Cuts out token from string buf using string mask as a separator.
We can do it repeatedly if give NULL to string buf after second time. String mask can be changed every time.
Returns NULL when token cannot be found.
char *strpbrk(s1,s2)
char *s1;
char *s2;
Returns pointer where any character appears in string s1.
Returns NULL if characters in string s2 is not found.
unsigned char *strset(str,ch)
unsigned char *str;
unsigned char ch;
Fulfill string "str” with character "ch".
unsigned char *strnset(str,ch,n)
unsigned char *str;
unsigned char ch;
int n;
Fill string "str” with valuable "n" characters of character "ch".
unsigned char *strdup(s)
unsigned char *s;
Reserve memory space on heap for string "s" and copy it there using malloc(). Length of string "s" and 1 bytes are reserved.
Returns address of stored string "s". Returns NULL when failed to reserve memories.
unsigned char *stpcpy(s,t)
unsigned char *s;
unsigned char *t;
Copy strings "t" to "s". Appropriate memory size is required. Returns pointer of final \0.
unsigned char ;*memccpy(dest,src,c,n)
unsigned char *dest;
unsigned char *src;
unsigned char c;
unsigned n;
Copy data from "src" to "dest" till copied character "c" or "n" bytes of data.
Returns pointer next to character "c" if character "c" is found, otherwise returns NULL.
int memicmp(s,t,n)
char *s;
char *t;
int n;
Returns result of comparison between "n" bytes long memory block from address "s" and "n" bytes long memory block from address "t".
s > t positive number
s = t zero
s < t negative number
memicmp is not case sensitive.
unsigned strspn(s,t)
char *s;
char *t;
Count characters from the top of string s to the character which is not contained by strings t. Terminal '\0' of valuable t is not compared.
unsigned strcspn(s,t)
char *s;
char *t;
Measure length from the top of string s to the character which is not contained by strings t. Terminal '\0' of valuable t is not compared.

References

  • Manual and header files of LSI C-86 Ver.3.30 trial version
  • Source files of character and strings processing functions of SMALL-C Ver.
  • Other books or articles about a sort of Language C