CWB
Macros | Functions | Variables
options.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <dirent.h>
#include "options.h"
#include "print-modes.h"
#include "output.h"
#include "corpmanag.h"
#include "concordance.h"
#include "../cl/attributes.h"
#include "../cl/macros.h"

Macros

#define DEFAULT_EXTERNAL_SORTING_COMMAND   "sort -k 2 -k 1n "
 
#define DEFAULT_EXTERNAL_GROUPING_COMMAND   "sort %s -k 1,1n -k 2,2n | uniq -c | sort -k 1,1nr -k 2,2n -k 3,3n"
 

Functions

char * expand_filename (char *fname)
 The return value is a newly-allocated string. More...
 
void cqp_usage (void)
 Prints the usage message for the different CQP applications to standard error and then shuts down the program with exit status 1. More...
 
void print_option_value (int opt)
 
void print_option_values ()
 Prints out the values of all the CQP configuration options. More...
 
void set_default_option_values (void)
 Sets all the CQP options to their default values. More...
 
int find_option (char *s)
 Finds the index of an option. More...
 
void execute_side_effects (int opt)
 Carries out any "side effects" of setting an option. More...
 
int validate_string_option_value (int opt, char *value)
 
int validate_integer_option_value (int opt, int value)
 
char * set_string_option_value (char *opt_name, char *value)
 Sets a string-valued option. More...
 
char * set_integer_option_value (char *opt_name, int value)
 Sets an integer-valued option. More...
 
char * set_context_option_value (char *opt_name, char *sval, int ival)
 
void parse_options (int ac, char *av[])
 Parses program options and sets their default values. More...
 

Variables

CQPOption cqpoptions []
 Global array of options for CQP. More...
 

Macro Definition Documentation

#define DEFAULT_EXTERNAL_GROUPING_COMMAND   "sort %s -k 1,1n -k 2,2n | uniq -c | sort -k 1,1nr -k 2,2n -k 3,3n"
#define DEFAULT_EXTERNAL_SORTING_COMMAND   "sort -k 2 -k 1n "

Function Documentation

void cqp_usage ( void  )

Prints the usage message for the different CQP applications to standard error and then shuts down the program with exit status 1.

References cqp, cqpcl, cqpserver, progname, and which_app.

Referenced by parse_options().

void execute_side_effects ( int  opt)
char* expand_filename ( char *  fname)

The return value is a newly-allocated string.

References CL_MAX_FILENAME_LENGTH, CL_MAX_LINE_LENGTH, and cl_strdup().

Referenced by set_string_option_value().

int find_option ( char *  s)

Finds the index of an option.

Return the index in the global options array of the option with name s. This should be never called from outside.

See also
cqpoptions
Parameters
sName of the option to find (or abbreviation); matched case-insensitively.
Returns
Index of element in cqpoptions corresponding to the name s, or -1 if no corresponding element was found.

References _cqpoption::opt_name.

Referenced by parse_options(), print_option_value(), print_option_values(), set_context_option_value(), set_integer_option_value(), and set_string_option_value().

void parse_options ( int  ac,
char *  av[] 
)
void print_option_value ( int  opt)
void print_option_values ( )

Prints out the values of all the CQP configuration options.

References find_option(), _cqpoption::opt_name, OPTION_CQP, print_option_value(), silent, and user_level.

char* set_context_option_value ( char *  opt_name,
char *  sval,
int  ival 
)
void set_default_option_values ( void  )
char* set_integer_option_value ( char *  opt_name,
int  value 
)

Sets an integer-valued option.

An error string (function-internal constant, do NOT free) is returned if the type of the option does not correspond to the function which is called. Upon success, NULL is returned.

Parameters
opt_nameThe name of the option to set.
valueIts new value.
Returns
NULL if all OK; otherwise a string describing the problem.

References execute_side_effects(), find_option(), OptBoolean, OptContext, OptInteger, set_context_option_value(), and validate_integer_option_value().

Referenced by open_stream().

char* set_string_option_value ( char *  opt_name,
char *  value 
)

Sets a string-valued option.

An error string (function-internal constant, do NOT free) is returned if the type of the option does not correspond to the function which is called. Upon success, NULL is returned.

set_string_option_value does NOT strdup the value!

Parameters
opt_nameThe name of the option to set.
valueIts new value.
Returns
NULL if all OK; otherwise a string describing the problem.

References execute_side_effects(), expand_filename(), find_option(), OptContext, OptString, set_context_option_value(), and validate_string_option_value().

Referenced by do_SimpleVariableReference(), do_StringConstraint(), and open_stream().

int validate_integer_option_value ( int  opt,
int  value 
)
int validate_string_option_value ( int  opt,
char *  value 
)

Referenced by set_string_option_value().

Variable Documentation

CQPOption cqpoptions[]

Global array of options for CQP.