From 0cc9b20c15460213e488bf5e70963b941482f628 Mon Sep 17 00:00:00 2001 From: William Harrington Date: Tue, 14 Jan 2025 16:06:02 -0600 Subject: Add source. --- sdk/other/search.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 sdk/other/search.c (limited to 'sdk/other/search.c') diff --git a/sdk/other/search.c b/sdk/other/search.c new file mode 100644 index 0000000..15963bf --- /dev/null +++ b/sdk/other/search.c @@ -0,0 +1,46 @@ +/* + * File path search routines. + * $Id$ + * Copyright (c) 1997 by Tycho Softworks. + * For conditions of distribution and reuse see product license. + */ + +#include +#include +#include + +#ifdef QNX +#define PATHMARK "!" +#endif + +#ifndef PATHMARK +#define PATHMARK ":" +#endif + +char *search(const char *path, const char *file) +{ + static char buf[PATH_MAX + 1]; + char pbuf[PATH_MAX + 1]; + char *p; + + if(!path) + return NULL; + + strcpy(pbuf, path); + + p = strtok(pbuf, PATHMARK); + + while(p) + { + if(*p) + fncat(strcpy(buf, p), file); + else + strcpy(buf, file); + if(isfile(buf)) + return buf; + p = strtok(NULL, PATHMARK); + } + return NULL; +} + + -- cgit v1.2.3-54-g00ecf