motion  4.3.0
About: Motion monitors the video signal from one or more cameras and is able to detect motion.
  Fossies Dox: motion-Release-4.3.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

conf.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  config
struct  config_param
struct  dep_config_param


typedef struct context **(* conf_copy_func) (struct context **, const char *, int)


struct context ** conf_load (struct context **)
struct context ** copy_string (struct context **, const char *, int)
struct context ** copy_uri (struct context **, const char *, int)
struct context ** conf_cmdparse (struct context **, const char *, const char *)
struct context ** read_camera_dir (struct context **, const char *, int)
void conf_output_parms (struct context **cnt)
const char * config_type (config_param *)
void conf_print (struct context **)
char * mystrdup (const char *)
char * mystrcpy (char *, const char *)


const typedef char *(* conf_print_func )(struct context **, char **, int, unsigned int)
config_param config_params []
dep_config_param dep_config_params []

Typedef Documentation

◆ conf_copy_func

typedef struct context**(* conf_copy_func) (struct context **, const char *, int)

typedef for a param copy function.

Definition at line 196 of file conf.h.

Function Documentation

◆ conf_cmdparse()

struct context** conf_cmdparse ( struct context **  cnt,
const char *  cmd,
const char *  arg1 

conf_cmdparse Sets a config option given by 'cmd' to the value given by 'arg1'. Based on the name of the option it searches through the struct 'config_params' for an option where the config_params[i].param_name matches the option. By calling the function pointed to by config_params[i].copy the option gets assigned.

Returns context struct.

Definition at line 2048 of file conf.c.

References _, ALR, config_params, config_type(), config_param::copy, dep_config_param::copy, copy_vid_ctrl(), dep_config_params, MOTION_LOG, NO_ERRNO, and TYPE_ALL.

Referenced by conf_process(), mlp_timelapse(), and webu_process_config_set().

◆ conf_load()

struct context** conf_load ( struct context **  cnt)

conf_load Is the main function, called from motion.c The function sets the important context structure "cnt" including loading the config parameters from config files and Command-line. The following takes place in the function:

  • The default start values for cnt stored in the struct conf_template are copied to cnt[0] which is the default context structure common to all threads.
  • All config (cnt.conf) struct members pointing to a string are changed so that they point to a malloc'ed piece of memory containing a copy of the string given in conf_template.
  • motion.conf is opened and processed. The process populates the cnt[0] and for each camera config file it populates a cnt[1], cnt[2]... for each camera.
  • Finally it processes the options given in the Command-line. This is done for each camera cnt[i] so that the Command-line options overrides any option given by motion.conf or a camera config file.

Returns context struct.

Definition at line 2307 of file conf.c.

References _, ALR, config::argc, config::argv, context::conf, conf_cmdline(), context::conf_filename, conf_process(), conf_template, config_parms_intl(), CRT, ERR, config::log_file, context::log_file, log_level, config::log_level, context::log_level, config::log_type, log_type_str, context::log_type_str, malloc_strings(), MOTION_LOG, myfclose(), mystrcpy(), NO_ERRNO, NTC, config::pid_file, context::pid_file, SHOW_ERRNO, and TYPE_ALL.

Referenced by cntlist_create().

◆ conf_output_parms()

void conf_output_parms ( struct context **  cnt)

conf_output_parms Dump config options to log, useful for support purposes. Redact sensitive information and re-add quotation marks where needed (see conf_print). Not using the MOTION_LOG macro here to skip the function naming, and produce a slightly cleaner dump.

Returns nothing

Definition at line 2457 of file conf.c.

References _, context::conf_filename, config_params, INF, MOTION_LOG, motion_log(), NO_ERRNO, config_param::param_name, and TYPE_ALL.

Referenced by motion_startup().

◆ conf_print()

void conf_print ( struct context **  cnt)

conf_print Is used to write out the config file(s) motion.conf and any camera config files. The function is called when using http remote control.

Returns nothing.

Definition at line 2209 of file conf.c.

References _, context::conf_filename, config_params, MOTION_LOG, myfclose(), myfopen(), NO_ERRNO, NTC, config_param::param_name, config_param::print, and TYPE_ALL.

Referenced by webu_process_action().

◆ config_type()

const char* config_type ( config_param configparam)

config_type Returns a pointer to string containing value the type of config parameter passed.

Returns const char *.

Definition at line 2883 of file conf.c.

References config_param::copy, copy_bool(), copy_int(), copy_string(), and copy_uri().

Referenced by conf_cmdparse().

◆ copy_string()

struct context** copy_string ( struct context **  cnt,
const char *  str,
int  val_ptr 

copy_string Assigns a new string value to a config option. Strings are handled differently from bool and int. the char *conf->option that we are working on is free()'d (if memory for it has already been malloc()'d), and set to a freshly malloc()'d string with the value from str, or NULL if str is blank.

Returns context struct.

Definition at line 2630 of file conf.c.

References mystrcpy(), and context::threadnr.

Referenced by config_type(), context_destroy(), copy_uri(), malloc_strings(), and read_camera_dir().

◆ copy_uri()

struct context** copy_uri ( struct context **  ,
const char *  ,

Definition at line 2783 of file conf.c.

References _, copy_string(), ERR, MOTION_LOG, NO_ERRNO, and TYPE_STREAM.

Referenced by config_type(), context_destroy(), and malloc_strings().

◆ mystrcpy()

char* mystrcpy ( char *  to,
const char *  from 

mystrcpy Is used to assign string type fields (e.g. config options) In a way so that we the memory is malloc'ed to fit the string. If a field is already pointing to a string (not NULL) the memory of the old string is free'd and new memory is malloc'ed and filled with the new string is copied into the the memory and with the char pointer pointing to the new string.

from - pointer to the new string we want to copy to - the pointer to the current string (or pointing to NULL) If not NULL the memory it points to is free'd.

Returns pointer to the new string which is in malloc'ed memory FIXME The strings that are malloc'ed with this function should be freed when the motion program is terminated normally instead of relying on the OS to clean up.

Definition at line 2828 of file conf.c.

References mystrdup().

Referenced by conf_load(), copy_string(), and motion_startup().

◆ mystrdup()

char* mystrdup ( const char *  from)

mystrdup Truncates the string to the length given by the environment variable PATH_MAX to ensure that config options can always contain a really long path but no more than that.

Returns a pointer to a freshly malloc()'d string with the same value as the string that the input parameter 'from' points to, or NULL if the from string is 0 characters.

Definition at line 2851 of file conf.c.

References mymalloc().

Referenced by create_path(), header_strdup(), malloc_strings(), motion_init(), mystrcpy(), netcam_read_first_header(), and netcam_setup_ftp().

◆ read_camera_dir()

struct context** read_camera_dir ( struct context **  cnt,
const char *  str,
int  val 

read_camera_dir Read the directory finding all *.conf files in the path When found calls config_camera

Definition at line 3011 of file conf.c.

References _, ALR, config_camera(), copy_string(), EXTENSION, context::from_conf_dir, MOTION_LOG, NO_ERRNO, NTC, SHOW_ERRNO, and TYPE_ALL.

Referenced by context_destroy().

Variable Documentation

◆ conf_print_func

const typedef char*(* conf_print_func) (struct context **, char **, int, unsigned int)

Definition at line 197 of file conf.h.

◆ config_params

◆ dep_config_params

dep_config_param dep_config_params[]