Fixing STRDIR in path.c and prototyping errors
This commit was SVN r177.
Этот коммит содержится в:
родитель
07ad5a5ec3
Коммит
3b2c1b6dd7
@ -6,16 +6,10 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <lam_config>
|
||||
#include "lam_config.h"
|
||||
#include "lam/util/argv.h"
|
||||
#include "lam/util/malloc.h"
|
||||
|
||||
#if 0
|
||||
#include <args.h>
|
||||
#include <laminternal.h>
|
||||
#include <sfh.h>
|
||||
#endif
|
||||
|
||||
/** @file **/
|
||||
|
||||
/**
|
||||
@ -27,9 +21,16 @@
|
||||
#define PATHENVSEP ':'
|
||||
#endif
|
||||
|
||||
static void path_env_load(char *, int *, char ***);
|
||||
static char *path_access(char *, char *, int);
|
||||
static char *list_env_get(char *, char **);
|
||||
/**
|
||||
* Directory seperator
|
||||
*/
|
||||
|
||||
#define STRDIR '/'
|
||||
#define STRSDIR "/"
|
||||
|
||||
static void path_env_load(char *path, int *pargc, char ***pargv);
|
||||
static char *path_access(char *fname, char *path, int mode);
|
||||
static char *list_env_get(char *var, char **list);
|
||||
|
||||
/**
|
||||
* Locates a file with certain permissions
|
||||
@ -51,15 +52,15 @@ static char *list_env_get(char *, char **);
|
||||
char *
|
||||
lam_path_findv(char *fname, char **pathv, int mode, char **envv)
|
||||
{
|
||||
char *fullpath; /* full pathname of search file */
|
||||
char *delimit; /* ptr to first delimiter in prefix */
|
||||
char *env; /* ptr to environment var */
|
||||
char *pfix; /* prefix directory */
|
||||
char *fullpath;
|
||||
char *delimit;
|
||||
char *env;
|
||||
char *pfix;
|
||||
int i;
|
||||
/*
|
||||
* If absolute path is given, return it without searching.
|
||||
*/
|
||||
if (*fname == STRDIR) {
|
||||
if (STRDIR == *fname) {
|
||||
return(path_access(fname, "", mode));
|
||||
}
|
||||
/*
|
||||
@ -89,7 +90,7 @@ lam_path_findv(char *fname, char **pathv, int mode, char **envv)
|
||||
fullpath = path_access(fname, env, mode);
|
||||
} else {
|
||||
pfix = LAM_MALLOC((unsigned) strlen(env) + strlen(delimit) + 1);
|
||||
if (pfix == NULL){
|
||||
if (NULL == pfix){
|
||||
return(0);
|
||||
}
|
||||
strcpy(pfix, env);
|
||||
@ -148,10 +149,10 @@ lam_path_find(char *fname, char **pathv, int mode)
|
||||
char *
|
||||
lam_path_env_findv(char *fname, int mode, char **envv, char *wrkdir)
|
||||
{
|
||||
char **dirv; /* search directories */
|
||||
char *fullpath; /* full pathname */
|
||||
char *path; /* value of PATH */
|
||||
int dirc; /* # search directories */
|
||||
char **dirv;
|
||||
char *fullpath;
|
||||
char *path;
|
||||
int dirc;
|
||||
int i;
|
||||
int found_dot = 0;
|
||||
/*
|
||||
@ -216,12 +217,14 @@ lam_path_env_find(char *fname, int mode)
|
||||
/**
|
||||
* Forms a complete pathname and checks it for existance and permissions
|
||||
*
|
||||
* @param fname File name
|
||||
* @param path Path prefix
|
||||
* @param mode Target permissions which must be satisfied
|
||||
* Accepts:
|
||||
* -fname File name
|
||||
* -path Path prefix
|
||||
* -mode Target permissions which must be satisfied
|
||||
*
|
||||
* @retval Full pathname of located file Success
|
||||
* @retval NULL Failure
|
||||
* Returns:
|
||||
* -Full pathname of located file Success
|
||||
* -NULL Failure
|
||||
*/
|
||||
static char *
|
||||
path_access(char *fname, char *path, int mode)
|
||||
@ -258,9 +261,10 @@ path_access(char *fname, char *path, int mode)
|
||||
*
|
||||
* Loads argument array with $PATH env var.
|
||||
*
|
||||
* @param path String contiaing the $PATH
|
||||
* @param argc Pointer to argc
|
||||
* @param argv Pointer to list of argv
|
||||
* Accepts
|
||||
* -path String contiaing the $PATH
|
||||
* -argc Pointer to argc
|
||||
* -argv Pointer to list of argv
|
||||
*
|
||||
*/
|
||||
static void
|
||||
@ -303,11 +307,13 @@ path_env_load(char *path, int *pargc, char ***pargv)
|
||||
/**
|
||||
* Gets value of variable in list or environment. Looks in the list first
|
||||
*
|
||||
* @param var String variable
|
||||
* @param list Pointer to environment list
|
||||
* Accepts:
|
||||
* -var String variable
|
||||
* -list Pointer to environment list
|
||||
*
|
||||
* @retval List Pointer to environment list Success
|
||||
* @retval NULL Failure
|
||||
* Returns:
|
||||
* -List Pointer to environment list Success
|
||||
* -NULL Failure
|
||||
*/
|
||||
static char *
|
||||
list_env_get(char *var, char **list)
|
||||
|
@ -5,9 +5,9 @@
|
||||
#ifndef LAM_PATH_H
|
||||
#define LAM_PATH_H
|
||||
|
||||
char *lam_path_find (char *, char **, int);
|
||||
char *lam_path_env_find (char *, int);
|
||||
char *lam_path_findv (char *, char **, int, char **);
|
||||
char *lam_path_env_findv (char *, int, char **, char *);
|
||||
char *lam_path_find (char *fname, char **pathv, int mode);
|
||||
char *lam_path_env_find (char *fname, int mode);
|
||||
char *lam_path_findv (char *fname, char **pathv, int mode, char **envv);
|
||||
char *lam_path_env_findv (char *fname, int mode, char **envv, char *wrkdir);
|
||||
|
||||
#endif /* LAM_PATH_H */
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user