Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

lcmaps_utils.c File Reference

the utilities for the LCMAPS More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <stdarg.h>
#include <grp.h>
#include "lcmaps_defines.h"
#include "lcmaps_types.h"
#include "lcmaps_log.h"

Go to the source code of this file.

Functions

int fexist (char *)
 check the existence of file corresponding to <path>

char * lcmaps_genfilename (char *prefixp, char *pathp, char *suffixp)
 Generate an absolute file name.

char * lcmaps_getfexist (int n,...)
 Picks the first existing file in argument list.

char * lcmaps_findfile (char *name)
 Checks for file in standard directories.

int lcmaps_tokenize (const char *command, char **args, int *n, char *sep)
 Break the argument string up into tokens.

int lcmaps_get_gidlist (const char *username, int *ngroups, gid_t **group_list)
 Finds the list of gids for user in the group file (/etc/group).


Detailed Description

the utilities for the LCMAPS

Author:
Martijn Steenbakkers for the EU DataGrid.

Definition in file lcmaps_utils.c.


Function Documentation

int fexist char *  path  )  [static]
 

check the existence of file corresponding to <path>

Parameters:
path absolute filename to be checked.
Return values:
1 file exists.
0 failure.

Definition at line 133 of file lcmaps_utils.c.

Referenced by lcmaps_getfexist().

char* lcmaps_findfile char *  name  ) 
 

Checks for file in standard directories.

The directories that are checked are:

  • current directory
  • "modules"
  • LCMAPS_ETC_HOME
  • LCMAPS_MOD_HOME
  • LCMAPS_LIB_HOME

Parameters:
name string containing the file name
Returns:
pointer to a string containing the absolute path to the file, which has to be freed or NULL.

Definition at line 218 of file lcmaps_utils.c.

References LCMAPS_ETC_HOME, lcmaps_genfilename(), lcmaps_getfexist(), LCMAPS_LIB_HOME, and LCMAPS_MOD_HOME.

Referenced by PluginInit().

char* lcmaps_genfilename char *  prefixp,
char *  pathp,
char *  suffixp
 

Generate an absolute file name.

Given a starting prefix, a relative or absolute path, and a suffix an absolute file name is generated. Uses the prefix only if the path is relative. (Copied (and modified) from GLOBUS gatekeeper.c)

Parameters:
prefixp string containing the prefix to be prepended.
pathp relative/absolute path to file name.
suffixp string containing the suffix to be appended.
Returns:
pointer to a string containing the absolute path to the file, which has to be freed.

Definition at line 76 of file lcmaps_utils.c.

Referenced by lcmaps_findfile(), lcmaps_setup(), and startPluginManager().

int lcmaps_get_gidlist const char *  username,
int *  ngroups,
gid_t **  group_list
 

Finds the list of gids for user in the group file (/etc/group).

Returns a list of gid_t which should be freed by calling program.

Parameters:
username the name of the user
ngroups ptr to int which will be filled with the number of gids
group_list ptr to an array of gid_t
Return values:
0 success
-1 realloc failure
-2 getgrent failure
1 failure

Definition at line 407 of file lcmaps_utils.c.

References lcmaps_log(), and lcmaps_log_debug().

char* lcmaps_getfexist int  n,
... 
 

Picks the first existing file in argument list.

Parameters:
n the number of paths presented in the following argument list.
... variable argument list of paths.
Returns:
filename found or NULL

Definition at line 176 of file lcmaps_utils.c.

References fexist().

Referenced by lcmaps_findfile().

int lcmaps_tokenize const char *  command,
char **  args,
int *  n,
char *  sep
 

Break the argument string up into tokens.

Breakup the command in to arguments, pointing the args array at the tokens. Replace white space at the end of each token with a null. A token maybe in quotes. (Copied (and modified) from GLOBUS gatekeeper.c)

Parameters:
command the command line to be parsed
args pointer to an array of pointers to be filled
n size of the array, on input, and set to size used on output
sep string of separating characters
Return values:
0 succes
-1 malloc error
-2 too many args
-3 quote not matched

Definition at line 292 of file lcmaps_utils.c.

Referenced by lcmaps_setup(), and parse_args_plugin().


Generated on Sun May 29 21:22:12 2005 for lcmaps by doxygen 1.3.5