#include "ccp4_parser.h"
Go to the source code of this file.
Defines | |
#define | CCP4_MAXLINE 200 |
#define | CCP4_MAXTOKS 3 |
#define | CCP4_MAXNAMES 150 |
#define | CCP4_MODULO 100000 |
#define | CGEN_ERRNO(n) (CCP4_ERR_GEN | (n)) |
#define | CGENERR_Ok 0 |
#define | CGENERR_AllocFail 1 |
#define | CGENERR_CantSetEnvironment 2 |
#define | CGENERR_MaxNamesExceeded 3 |
#define | CGENERR_EOptionUseError 4 |
#define | CGENERR_DOptionUseError 5 |
#define | CGENERR_LogicalNameUseError 6 |
#define | CGENERR_CantOpenEnvFile 7 |
#define | CGENERR_CantOpenDefFile 8 |
#define | CGENERR_ParseEnvFail 9 |
#define | CGENERR_ParseDefFail 10 |
#define | CGENERR_CantFindInFile 11 |
#define | CGENERR_EnvPathFail 12 |
#define | CGENERR_DefPathFail 13 |
#define | CGENERR_CantGetClibd 14 |
#define | CGENERR_CantGetCcp4Scr 15 |
Functions | |
void | ccp4f_mem_tidy (void) |
int | ccperror (int ierr, const char *message) |
int | ccperror_noexit (int ierr, const char *message) |
int | ccp4printf (int level, char *format,...) |
int | ccp4fyp (int argc, char **argv) |
int | ccp4setenv (char *logical_name, char *value, char **envname, char **envtype, char **envext, int *ienv, int no_overwrt) |
int | ccpexists (char *filename) |
int | ccpputenv (char *logical_name, char *file_name) |
void | ccp4_banner (void) |
#define CCP4_MAXLINE 200 |
Maximum number of characters in lines read from environ.def and default.def files (ccp4fyp)
#define CCP4_MAXNAMES 150 |
Maximum number of logical names that can be read and stored from environ.def (ccp4fyp)
#define CCP4_MAXTOKS 3 |
Maximum number of tokens in lines read from environ.def and default.def files (ccp4fyp)
#define CCP4_MODULO 100000 |
To guarantee that process id is always 5 characters, take the id number modulo 100,000
void ccp4_banner | ( | void | ) |
Write CCP4 banner to standard output.
int ccp4fyp | ( | int | argc, | |
char ** | argv | |||
) |
Initialise environment for CCP4 programs and parse command line arguments.
This function processes the command line arguments supplied via the argv array, and performs initialisations of the CCP4 environment within the program based on these arguments.
CCP4 programs which use ccp4fyp should be called with the following syntax:
<progname> [switches] <logical_name1> <value1> <logical_name2> <value2>...
The command switches all start with a hyphen (-) and immediately follow the program name. The remainer of the arguments are logical name-value pairs.
On successful completion ccp4fyp returns 0 (zero). On encountering an error, ccp4fyp registers the error condition via ccp4_signal and returns a non-zero value.
[in] | argc | number of command line arguments passed to main |
[in] | argv | array of command line parameters passed to main |
int ccp4printf | ( | int | level, | |
char * | format, | |||
... | ||||
) |
Wrapper for vprintf
A wrapper for vprintf - acts like printf with an additional argument which is checked against the reference verbosity level.
If the supplied message is less than or equal to the reference verbosity level then the format string and remaining arguments are passed to vprintf to be printed on stdout. Otherwise nothing is printed.
The format string has the same format as the format strings passed to printf, with the remaining arguments being the values (if any) to be inserted into placeholders in the format string.
int ccp4setenv | ( | char * | logical_name, | |
char * | value, | |||
char ** | envname, | |||
char ** | envtype, | |||
char ** | envext, | |||
int * | ienv, | |||
int | no_overwrt | |||
) |
Set environment variables
Set up file names and associate with logical_name in environment.
Associates logical_name with value. It is passed arrays of name, type and extension for ienv number of name lines read from environ.def, which may be used to modify the value before assignment.
If no_overwrt is true then any existing logical_names are not redefined.
ccp4setenv returns 0 on sucess, non-zero values on failure. In the case of failure an error code is registered with ccp4_signal and a non-zero value is returned to the calling subprogram.
int ccperror | ( | int | ierr, | |
const char * | message | |||
) |
Error reporting and program termination
ccperror is called with a message level ierr and a message string. The exact behaviour is determined by the value of ierr:
ierr=-1 also reports last system error and terminates. The text in message is sent to standard output, and to standard error for ierr=1 (or -1).
[in] | ierr | error message level |
[in] | message | text to be displayed |
int ccperror_noexit | ( | int | ierr, | |
const char * | message | |||
) |
Error reporting without program termination
ccperror_noexit is called with a message level ierr and a message string, The exact behaviour is determined by the value of ierr:
[in] | ierr | error message level |
[in] | message | text to be displayed |
int ccpexists | ( | char * | filename | ) |
Check if named file exists and can be opened for reading
The check is performed by attempting to fopen the file for read only, then immediately closing the file. If this method proves to be unsatisfactory then it may be necessary to investigate using access or stat instead.
int ccpputenv | ( | char * | logical_name, | |
char * | file_name | |||
) |
Wrapper for the ccp4_utils_setenv command.
Set environment variable logical_name to have value file_name. It must be supplied with a logical name (the name of a variable which will be set in the environment) and a file name (the value which will be assigned to that variable).
Returns 1 if successful and 0 otherwise.
Notes: