1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
/*
$Id: util.c,v 1.2 2002/02/10 21:05:25 matt Exp $
See COPYRIGHT for the license
*/
#include <sys/param.h>
#include <string.h>
#include <ctype.h>
#include "ssmtp.h"
/*
basename() --
*/
char *basename(char *path)
{
static char buf[MAXPATHLEN +1];
char *ptr;
ptr = strrchr(path, '/');
if(ptr) {
if(strncpy(buf, ++ptr, MAXPATHLEN) == (char *)NULL) {
die("basename() -- strncpy() failed");
}
}
else {
if(strncpy(buf, path, MAXPATHLEN) == (char *)NULL) {
die("basename() -- strncpy() failed");
}
}
buf[MAXPATHLEN] = (char)NULL;
return(buf);
}
/*
STRIP__leading_space() --
*/
char *STRIP__leading_space(char *str)
{
char *p;
p = str;
while(*p && isspace(*p)) p++;
return(p);
}
char *STRIP__trailing_space(char *str)
{
char *p;
p = (str + strlen(str));
while(isspace(*--p)) {
*p = (char)NULL;
}
return(p);
}
/*
CR_strip() -- Remove *last* CR from input
*/
bool_t CR_strip(char *str)
{
char *p;
if((p = strrchr(str, '\n'))) {
*p = (char)NULL;
return(True);
}
return(False);
}
|