home *** CD-ROM | disk | FTP | other *** search
- /*{{{}}}*/
- /*{{{ #includes*/
- #ifdef CONFIG_H
- # include "config.h"
- #endif
-
- #include <sys/types.h>
- #include <ctype.h>
- #include <string.h>
- #include <pwd.h>
- #include <stdlib.h>
- #include <limits.h>
- #include <stdio.h>
- #include <unistd.h>
-
- #include <h/envvar_str.h>
- #include <h/os.h>
- #include <lib/ori_add_lib.h>
- /*}}} */
-
- /*{{{ dir_name*/
- /* Get the directory part of a given filename s, copy it to d with the
- * trailing / and return d. If no directory is inside s, 0 is returned
- */
- unsigned char *dir_name(unsigned char * const d,unsigned char const *s)
- {
- unsigned char *c,*path_end;
-
- for (c=path_end=d;;)
- { unsigned char x;
-
- x= *s;
- switch (x)
- { case '\0':
- if (path_end==d)
- return(0);
- else
- { *path_end='\0';
- return(d);
- }
- case PATH_C:
- path_end=c+1;
- default:
- *c++=x;
- s++;
- continue;
- }
- }
- }
- /*}}} */
- /*{{{ join_fd*/
- /* if argument f is not a absolut path, and argument df is leaded by a
- * directory part, copy dirname(df)/f to f and return f.
- * In all other cases return 0.
- */
- unsigned char *join_fd(unsigned char * const f,unsigned char const*const df)
- {
- unsigned char d_buff[_POSIX_PATH_MAX+1];
-
- if (!IS_ROOT(f) && dir_name(d_buff,df))
- { strcat((char*)d_buff,(char*)f);
- strcpy((char*)f,(char*)d_buff);
-
- return(f);
- }
-
- return(0);
- }
- /*}}} */
-