#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdarg.h>
#include "ccp4_fortran.h"
#include "ccp4_utils.h"
#include "ccp4_parser.h"
#include "ccp4_general.h"
#include "ccp4_program.h"
#include "cmtzlib.h"
#include "csymlib.h"
#include "ccp4_errno.h"
Functions | |
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) |
void ccp4_banner | ( | void | ) |
Write CCP4 banner to standard output.
References CCP4_PATCH_LEVEL, ccp4_prog_vers(), ccp4_utils_date(), ccp4_utils_time(), ccp4_utils_username(), ccp4ProgramName(), and GPP4_VERSION_NO.
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 |
References CCP4_MAXLINE, CCP4_MAXNAMES, CCP4_MAXTOKS, ccp4_parse(), ccp4_parse_delimiters(), ccp4_parse_end(), ccp4_parse_reset(), ccp4_parse_start(), ccp4_prog_vers(), ccp4_signal(), ccp4_utils_basename(), ccp4_utils_joinfilenames(), ccp4_utils_malloc(), ccp4_utils_pathname(), ccp4_utils_realloc(), ccp4printf(), ccp4ProgramName(), ccp4ProgramTime(), ccp4setenv(), ccp4VerbosityLevel(), ccpputenv(), CCP4PARSERTOKEN::fullstring, GPP4_VERSION_NO, strtoupper(), and CCP4PARSERARRAY::token.
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.
References ccp4VerbosityLevel().
Referenced by ccp4fyp(), and ccperror_noexit().
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.
References CCP4_MAXNAMES, CCP4_MODULO, ccp4_signal(), ccp4_utils_basename(), ccp4_utils_extension(), ccp4_utils_malloc(), ccp4_utils_pathname(), ccp4_utils_realloc(), ccp4ProgramName(), ccpexists(), ccpputenv(), and strmatch().
Referenced by ccp4fyp().
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 |
References ccperror_noexit().
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 |
References ccp4printf(), ccp4ProgramName(), ccp4ProgramTime(), html_log_output(), and summary_output().
Referenced by ccperror().
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.
Referenced by ccp4setenv().
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:
References ccp4_utils_malloc(), and ccp4_utils_setenv().
Referenced by ccp4fyp(), and ccp4setenv().