Next: Utility objects
Up: Function and Class Descriptions
Previous: Function and Class Descriptions
  Contents
Utility functions
Generally useful utility functions are located in the file utilities.C, with an associated header file utilities.h. These functions include:
- char *stringdup(char *)
Creates a duplicate of the given string.
- char *stringtoupper(char *)
Converts the given string to upper case; returns pointer to the same string.
- int strupcmp(char *a, char *b)
Compares string a to string b in a case-insensitive manner. Otherwise acts like a call to strcmp.
- int strupncmp(char *a, char *b, int n)
Like strupcmp, but only considers the first n characters.
- void breakup_filename(char *s, char **p, char **n
Takes the filename in string s and breaks it into the file name n and directory d. Space is allocated for both the name and path strings.
- char *command_tokenize(char *s, int *argc, char **argv)
Breaks the command string s into tokens, provides as pointers to the different token strings in argv (argv should be an array of pointers to char with enough items to hold a pointer for each token in the given string). argc is set to the total number of tokens found. Tokens are only searched for in the string until a # character is reached; the rest of the string s is then skipped if this comment character is found. If the first non-whitespace character is a # symbol, the routine returns NULL. A command string is a string of the form
<keyword> = <string>
If the equal sign is not present as the second token in the string, this routine returns NULL.
- char *str_tokenize(char *s, int *argc, char **argv)
Similar to command_tokenize, without the restriction of having the string in the format of a command string, instead s may be any string.
- double time_of_day(void)
Returns the elapsed time, in seconds, from some reference time (which may vary between different versions of Unix). Best used for calculating time differences, not for finding the ``current'' time.
- char *username(void)
Returns a pointer to a string with the username of the person running the program.
- int str2bool(char *s)
Returns 1 if the string s is any type of string indicating ``yes'' in some form, or 0 if the string indicates ``no'' in some form. If the routine cannot determine if yes or no was indicates, this returns -1.
- float *cross_prod(float *x1, float *x2, float *x3)
Calculates
, and returns a pointer to x1. The array x1 must be different than the storage used for x2 and x3.
- float dot_prod(float *x1, float *x2)
Returns the value of
.
- float *normalize(float *x)
Normalizes the vector ; returns a pointer to x.
- float norm(float *x)
Returns the norm (length) of a vector :
.
- void add(float *x1, float *x2, float *x3)
Computes quickly
.
- void subtract(float *x1, float *x2, float *x3)
Computes quickly
.
Next: Utility objects
Up: Function and Class Descriptions
Previous: Function and Class Descriptions
  Contents
vmd@ks.uiuc.edu