CORSIKA add-on package IACT/ATMO:  Version 1.63 (November 2020)
Functions | Variables
fileopen.c File Reference

Allow searching of files in declared include paths (fopen replacement). More...

#include "initial.h"
#include "straux.h"
#include "fileopen.h"
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
Include dependency graph for fileopen.c:

Functions

void addexepath (const char *name)
 Add a path to the list of execution paths, if not already there. More...
 
void addpath (const char *name)
 Add a path to the list of include paths, if not already there. More...
 
static FILE * cmp_popen (const char *fname, const char *mode, int compression)
 Helper function for opening a compressed file through a fifo. More...
 
void disable_permissive_pipes ()
 Disable the permissive execution of pipes. More...
 
void enable_permissive_pipes ()
 Enable the permissive execution of pipes. More...
 
static FILE * exe_popen (const char *fname, const char *mode)
 Helper function for opening a pipe from or to a given program. More...
 
int fileclose (FILE *f)
 Close a file or fifo but not if it is one of the standard streams. More...
 
FILE * fileopen (const char *fname, const char *mode)
 Search for a file in the include path list and open it if possible. More...
 
static void fileopen_env_init (void)
 
static FILE * fopenx (const char *fname, const char *mode)
 
static void freeexepath ()
 Free a whole list of execution path elements. More...
 
static void freepath ()
 Free a whole list of include path elements. More...
 
struct incpathget_include_path (void)
 
void initexepath (const char *default_exe_path)
 
void initpath (const char *default_path)
 Init the path list, with default_path as the only entry. More...
 
void listpath (char *buffer, size_t bufsize)
 Show the list of include paths. More...
 
static FILE * popenx (const char *fname, const char *mode)
 
void set_permissive_pipes (int p)
 Enable or disable the permissive execution of pipes. More...
 
static FILE * ssh_popen (const char *fname, const char *mode, int compression)
 Helper function for opening a file on a remote SSH server.
 
static FILE * uri_popen (const char *fname, const char *mode, int compression)
 Helper function for opening a file with a URI (http:// etc.). More...
 

Variables

static int foei_done = 0
 
static int parallel = 0
 
static int permissive_pipes = 0
 Allow any execution pipe command if this variable is non-zero. More...
 
static struct incpathroot_exe_path = NULL
 The starting element for execution paths. More...
 
static struct incpathroot_path = NULL
 The starting element of include paths. More...
 
static int verbose = 0
 Use to decide if open/close success/failure is reported.
 
static int with_exec = 1
 
static int with_fallback = 1
 

Detailed Description

The functions provided in this file provide an enhanced replacement fileopen() for the C standard library's fopen() function. The enhancements are in several areas:

Author
Konrad Bernloehr
Date
Nov. 2000
CVS $Date: 2019/01/10 14:40:51 $ 
Version
CVS $Revision: 1.31 $ 

Function Documentation

◆ addexepath()

void addexepath ( const char *  name)

The path name is always copied to a newly allocated memory location. This path name can actually be a colon-separated list, as for initexepath().

References addpath(), root_exe_path, and root_path.

◆ addpath()

void addpath ( const char *  name)

The path name is always copied to a newly allocated memory location. This path name can actually be a colon-separated list, as for initpath(). Also environment variables (indicated by starting with '$', e.g. "$HOME") are accepted (and may expand into colon-separated list) but no mixed expansion (like "$HOME/bin").

References getword(), incpath::next, incpath::path, and root_path.

Here is the caller graph for this function:

◆ cmp_popen()

static FILE* cmp_popen ( const char *  fname,
const char *  mode,
int  compression 
)
static

◆ disable_permissive_pipes()

void disable_permissive_pipes ( void  )

References permissive_pipes.

Here is the caller graph for this function:

◆ enable_permissive_pipes()

void enable_permissive_pipes ( void  )

References permissive_pipes, and root_exe_path.

Here is the caller graph for this function:

◆ exe_popen()

static FILE* exe_popen ( const char *  fname,
const char *  mode 
)
static

◆ fileclose()

int fileclose ( FILE *  f)
Here is the caller graph for this function:

◆ fileopen()

FILE* fileopen ( const char *  fname,
const char *  mode 
)
Here is the caller graph for this function:

◆ freeexepath()

static void freeexepath ( )
static

◆ freepath()

static void freepath ( )
static

◆ initpath()

void initpath ( const char *  default_path)

◆ listpath()

void listpath ( char *  buffer,
size_t  bufsize 
)

References incpath::path, and root_path.

◆ set_permissive_pipes()

void set_permissive_pipes ( int  p)

◆ uri_popen()

static FILE * uri_popen ( const char *  fname,
const char *  mode,
int  compression 
)
static

Variable Documentation

◆ permissive_pipes

int permissive_pipes = 0
static

◆ root_exe_path

struct incpath* root_exe_path = NULL
static

◆ root_path

struct incpath* root_path = NULL
static