home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 June
/
SIMTEL_0692.cdr
/
msdos
/
zoo
/
stuff2.arc
/
SLASH.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-03-21
|
2KB
|
65 lines
/*
Stuff 2.0.
Checksum: 1637129305 (verify with "brik")
(C) Copyright 1988 Rahul Dhesi. Permission is granted to copy and
distribute this file in modified or unmodified form, whether for
noncommercial or commercial use, provided (a) this copyright notice
is preserved, (b) no attempt is made to restrict redistribution of
this file, and (c) this file is not distributed as part of any
collection whose redistribution is restricted by a compilation
copyright.
*/
#include "stuff.h"
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stddef.h>
/*
forceslash() Removes slashes from a pathname
*/
void forceslash (char *pathname)
{
char *s;
for (s = pathname; *s != '\0'; s++)
if (*s == '\\')
*s = '/';
}
/*
findlast() finds last occurrence of character from 'component' in 'str'
*/
char *findlast (char *str, char *component)
{
char *p;
assert (str != NULL && *str != '\0');
assert (component != NULL && *component != '\0');
if (str == NULL || *str == '\0' || component == NULL || *component == '\0')
return (NULL);
p = str + strlen (str) - 1; /* p points to end of str */
while (p > str && strchr (component, *p) == NULL)
p--;
/* exit loop when found char, or reached beginning, or both */
if (strchr (component, *p) != NULL)
return (p);
else
return (NULL);
}
/* returns pointer to last char of string */
char *lastptr (char *str)
{
if (str == NULL || *str == '\0')
return (NULL);
else
return (str + strlen(str) - 1);
}