MIT Information Systems

Macintosh Development

[Home] [About Us] [People] [Information Systems]
[Kerberos for Macintosh] [Applications] [Miscellaneous Documentation]


Utilities Library API Functions
int strcasecmp (const char *s1, const char *s2);
int strncasecmp (const char *s1, const char *s2, int n);
strcasecmp and strncasecmp compare C strings case-insensitively. strcasecmp compares the entire string and strncasecmp compares n characters of each string.

If the strings are equal, both functions return 0. If s1 is greater than s2 then both functions return a number greater than 0. If s1 is less than s2 then both functions return a number less than 0.

char *strtoken (const char *s, const char *delim, int index);
strtoken allows you to break the string s into a sequence of tokens delimited by the string delim. index is the index of the token you want (ie: if index is 2, you will get the second token). If s starts with delim, the first token will be an empty string. If there is no token at the index you provide, strtoken will return NULL.
char *strdup (const char *s);
strdup duplicates a string and returns a pointer to the copy. It allocates memory for the new string using malloc(), so use the MIT Support Library free() function to dispose of the duplicated string.
void swab (register char *src, register char *dest, register int n);
swab is a byte manipulation function. It copies n bytes from src to dest, exchanging adjacent bytes. n should be even. If it is odd, swab copies and exchanges n - 1 bytes and the disposition of the last byte is undefined. src and dest should not overlap.
int gettimeofday (struct timeval *tp, struct timezone *tz);
int settimeofday (struct timeval *tp, struct timezone *tz);
gettimeofday returns the current time of day in Unix time. settimeofday sets the time on the Macintosh, given tp in Unix time. Both functions properly convert between Macintosh and Unix time.

Currently neither function gets or sets tz, the timezone structure.

void mac_time_to_unix_time (time_t *time);
void unix_time_to_mac_time (time_t *time);
mac_time_to_unix_time and unix_time_to_mac_time convert time between Mac and Unix time. (The Unix epoch is 1/1/1970, the Mac epoch is 1/1/1904.)
void msl_time_to_unix_time (time_t *time);
void unix_time_to_msl_time (time_t *time);
msl_time_to_unix_time and unix_time_to_msl_time convert time between MSL and Unix time. (The Unix epoch is 1/1/1970, the MSL epoch is 1/1/1900.)

Questions or comments? Send mail to macdev@mit.edu
Last updated on $Date: 2003/11/19 20:50:38 $
Last modified by $Author: smcguire $