home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume22
/
bigb
/
part01
/
misc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-13
|
2KB
|
67 lines
/* Assorted small routines */
#include "bigb.h"
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <pwd.h>
/* Construct a string representing the time given as a parameter */
PUBLIC char *date(time_t the_time)
{
char *buffer;
buffer=asctime(localtime(&the_time));
buffer[24]='\0'; /* Dump the \n */
return(buffer);
}
/* Neaten up a string. This removes all spaces,tabs and newlines, it also
* ensures that all text before the first '=' is lower case.
*/
PUBLIC void neaten(char *data)
{
char buffer[128];
char *ptr;
int found_equals;
/* This looks a bit strange but it is correct, this subroutine is used */
/* in 2 circumstances, 'variable=value' and plain 'value', the variable */
/* name needs to be made lower case but nothing else does, so if there */
/* is no equals sign set the found_equals flag to TRUE to stop any */
/* upper case -> lower case conversions from the start */
if (strchr(data,'=') != CNULL)
found_equals = FALSE;
else
found_equals = TRUE;
for (ptr=data ; *ptr!='\0' ; ptr++) {
if (*ptr == '=')
found_equals = TRUE;
if (!found_equals && isupper(*ptr))
*ptr = tolower(*ptr);
if (isspace(*ptr)) { /* Remove all whitespace */
strcpy(buffer, ptr+1);
strcpy(ptr,buffer);
}
}
/* If after all that it was a comment then nullify string */
if (*data == '#')
*data='\0';
}
/* Print the warning message to the screen and log file */
PUBLIC void print_warning(const char *text)
{
/* Print to the stdout ( console ) , <BEEP> WARNING: message */
fprintf(error_display_chan,"%c%c%cWARNING: %s%c%c",
(char) 10, (char) 13,(char) 7,
text,
(char) 10, (char) 13);
/* Print the raw warning to the log file */
fprintf(error_file_chan, "%s\n", text);
}