diff --git a/src/alg.cpp b/src/alg.cpp index beacf0ae..a04bc41c 100644 --- a/src/alg.cpp +++ b/src/alg.cpp @@ -653,7 +653,7 @@ void alg_despeckle(struct ctx_cam *cam) { int diffs,width,height,done,i,len; unsigned char *out, *common_buffer; - if (!cam->conf->despeckle_filter || cam->current_image->diffs <= 0){ + if ((cam->conf->despeckle_filter == "") || cam->current_image->diffs <= 0){ if (cam->imgs.labelsize_max) cam->imgs.labelsize_max = 0; return; } @@ -663,7 +663,7 @@ void alg_despeckle(struct ctx_cam *cam) { width = cam->imgs.width; height = cam->imgs.height; done = 0; - len = strlen(cam->conf->despeckle_filter); + len = cam->conf->despeckle_filter.length(); common_buffer = cam->imgs.common_buffer; cam->current_image->total_labels = 0; cam->imgs.largest_label = 0; diff --git a/src/alg_sec.cpp b/src/alg_sec.cpp index e50e1354..11337c0c 100644 --- a/src/alg_sec.cpp +++ b/src/alg_sec.cpp @@ -502,7 +502,7 @@ void algsec_init(ctx_cam *cam){ #ifdef HAVE_OPENCV int retcd; - mythreadname_set("cv",cam->threadnr,cam->conf->camera_name); + mythreadname_set("cv",cam->threadnr,cam->conf->camera_name.c_str()); cam->algsec = new ctx_algsec; @@ -514,7 +514,7 @@ void algsec_init(ctx_cam *cam){ if (retcd == 0) algsec_start_handler(cam); - mythreadname_set("ml",cam->threadnr,cam->conf->camera_name); + mythreadname_set("ml",cam->threadnr,cam->conf->camera_name.c_str()); #else (void)cam; #endif diff --git a/src/conf.cpp b/src/conf.cpp index 73b1b423..bdb05748 100644 --- a/src/conf.cpp +++ b/src/conf.cpp @@ -151,6 +151,10 @@ struct ctx_parm config_parms[] = { "# Maximum number of frames to be captured per second.", 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { + "minimum_frame_time", + "# Mimimum frame time.", + 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, + { "rotate", "# Number of degrees to rotate image.", 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, @@ -669,7 +673,7 @@ struct ctx_parm config_parms[] = { "# Directory to read '.conf' files for cameras.\n" "##############################################################", 1, PARM_TYP_STRING, PARM_CAT_05, WEBUI_LEVEL_ADVANCED }, - { NULL, NULL, 0, (enum PARM_TYP)0, (enum PARM_CAT)0, (enum WEBUI_LEVEL)0 } + { "", "", 0, (enum PARM_TYP)0, (enum PARM_CAT)0, (enum WEBUI_LEVEL)0 } }; /* @@ -863,7 +867,7 @@ struct ctx_parm_depr config_parms_depr[] = { "\"process_id_file\" replaced with \"pid_file\"", "pid_file" }, - { NULL, NULL, NULL, NULL} + { "","","",""} }; /** Prints usage and options allowed from Command-line. */ @@ -897,28 +901,28 @@ static void conf_cmdline(struct ctx_motapp *motapp) { while ((c = getopt(motapp->argc, motapp->argv, "bc:d:hmns?p:k:l:")) != EOF) switch (c) { case 'c': - conf_edit_set(motapp, -1, (char*)"conf_filename", optarg); + conf_edit_set(motapp, -1, "conf_filename", optarg); break; case 'b': - conf_edit_set(motapp, -1, (char*)"daemon", (char*)"on"); + conf_edit_set(motapp, -1, "daemon", "on"); break; case 'n': - conf_edit_set(motapp, -1, (char*)"daemon", (char*)"off"); + conf_edit_set(motapp, -1, "daemon", "off"); break; case 's': - conf_edit_set(motapp, -1, (char*)"setup_mode", (char*)"on"); + conf_edit_set(motapp, -1, "setup_mode", "on"); break; case 'd': - conf_edit_set(motapp, -1, (char*)"log_level", optarg); + conf_edit_set(motapp, -1, "log_level", optarg); break; case 'k': - conf_edit_set(motapp, -1, (char*)"log_type", optarg); + conf_edit_set(motapp, -1, "log_type", optarg); break; case 'p': - conf_edit_set(motapp, -1, (char*)"pid_file", optarg); + conf_edit_set(motapp, -1, "pid_file", optarg); break; case 'l': - conf_edit_set(motapp, -1, (char*)"log_file", optarg); + conf_edit_set(motapp, -1, "log_file", optarg); break; case 'm': motapp->pause = TRUE; @@ -933,16 +937,16 @@ static void conf_cmdline(struct ctx_motapp *motapp) { optind = 1; } -static void conf_parm_camera(struct ctx_motapp *motapp, char *str) { +static void conf_parm_camera(struct ctx_motapp *motapp, std::string str) { int indx_cams, indx; - char parm_val[PATH_MAX]; + std::string parm_val; FILE *fp; - fp = fopen(str, "r"); + fp = fopen(str.c_str(), "r"); if (!fp) { MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO - ,_("Camera config file %s not found"), str); + ,_("Camera config file %s not found"), str.c_str()); return; } @@ -955,33 +959,28 @@ static void conf_parm_camera(struct ctx_motapp *motapp, char *str) { /* Index starts at zero (+1) plus another for our new camera(+2)*/ motapp->cam_list = (struct ctx_cam **)myrealloc( motapp->cam_list, sizeof(struct ctx_cam *) * (indx_cams + 2), "config_camera"); + motapp->cam_list[indx_cams] = new ctx_cam; memset(motapp->cam_list[indx_cams],0,sizeof(struct ctx_cam)); + motapp->cam_list[indx_cams]->conf = new ctx_config; - memset(motapp->cam_list[indx_cams]->conf,0,sizeof(ctx_config)); motapp->cam_list[indx_cams + 1] = NULL; conf_edit_dflt_cam(motapp->cam_list[indx_cams]); indx = 0; - while (config_parms[indx].parm_name != NULL) { - conf_edit_get(motapp->cam_list[0],(char *)config_parms[indx].parm_name + while (config_parms[indx].parm_name != "") { + conf_edit_get(motapp->cam_list[0],config_parms[indx].parm_name ,parm_val, config_parms[indx].parm_cat); - /* Once we adjust all the code to allow for "" being same as NULL we can remove this*/ - if ((config_parms[indx].parm_type == PARM_TYP_STRING) && (mystreq(parm_val,""))) { - conf_edit_set(motapp,indx_cams, (char *)config_parms[indx].parm_name, NULL); - } else { - conf_edit_set(motapp,indx_cams, (char *)config_parms[indx].parm_name, parm_val); - } + conf_edit_set(motapp,indx_cams, config_parms[indx].parm_name, parm_val); indx++; } /* Process the camera's config file and notify user on console. */ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO - ,_("Processing camera config file %s"), str); - snprintf(motapp->cam_list[indx_cams]->conf_filename - ,sizeof(motapp->cam_list[indx_cams]->conf_filename),"%s", str); + ,_("Processing camera config file %s"), str.c_str()); + str.copy(motapp->cam_list[indx_cams]->conf_filename,PATH_MAX); conf_process(motapp, fp, indx_cams); myfclose(fp); @@ -998,7 +997,7 @@ static void conf_parm_camera(struct ctx_motapp *motapp, char *str) { } /** Process camera_dir */ -static void conf_parm_camera_dir(struct ctx_motapp *motapp, char *str) { +static void conf_parm_camera_dir(struct ctx_motapp *motapp, std::string str) { DIR *dp; struct dirent *ep; size_t name_len; @@ -1006,7 +1005,7 @@ static void conf_parm_camera_dir(struct ctx_motapp *motapp, char *str) { char conf_file[PATH_MAX]; - dp = opendir(str); + dp = opendir(str.c_str()); if (dp != NULL) { while( (ep = readdir(dp)) ) { name_len = strlen(ep->d_name); @@ -1015,7 +1014,7 @@ static void conf_parm_camera_dir(struct ctx_motapp *motapp, char *str) { memset(conf_file, '\0', sizeof(conf_file)); snprintf(conf_file, sizeof(conf_file) - 1, "%s/%s", - str, ep->d_name); + str.c_str(), ep->d_name); MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO ,_("Processing config file %s"), conf_file ); conf_parm_camera(motapp, conf_file); @@ -1030,11 +1029,11 @@ static void conf_parm_camera_dir(struct ctx_motapp *motapp, char *str) { closedir(dp); } else { MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO - ,_("Camera directory config %s not found"), str); + ,_("Camera directory config %s not found"), str.c_str()); } /* Store the given config value to allow writing it out */ - conf_edit_set(motapp,0, (char *)"camera_dir", str); + conf_edit_set(motapp, 0, "camera_dir", str); return; } @@ -1044,6 +1043,7 @@ void conf_process(struct ctx_motapp *motapp, FILE *fp, int threadnbr) { char line[PATH_MAX], *cmd = NULL, *arg1 = NULL; char *beg = NULL, *end = NULL; + std::string parm_nm, parm_val; while (fgets(line, PATH_MAX-1, fp)) { if (!(line[0] == '#' || line[0] == ';' || strlen(line) < 2)) { @@ -1088,15 +1088,17 @@ void conf_process(struct ctx_motapp *motapp, FILE *fp, int threadnbr) { arg1 = beg; /* Argument starts here */ } /* Ignore camera/dir in sub files */ + parm_nm = std::string(cmd); + parm_val= std::string(arg1); if (threadnbr == -1){ - conf_edit_set(motapp, threadnbr, cmd, arg1); + conf_edit_set(motapp, threadnbr,parm_nm, parm_val); } else { if (mystreq(cmd,"camera_dir")) { - if (threadnbr == 0) conf_parm_camera_dir(motapp, arg1); + if (threadnbr == 0) conf_parm_camera_dir(motapp, parm_val); } else if (mystreq(cmd,"camera")) { - if (threadnbr == 0) conf_parm_camera(motapp, arg1); + if (threadnbr == 0) conf_parm_camera(motapp, parm_val); } else { - conf_edit_set(motapp, threadnbr, cmd, arg1); + conf_edit_set(motapp, threadnbr, parm_nm, parm_val); } } } @@ -1108,7 +1110,7 @@ void conf_process(struct ctx_motapp *motapp, FILE *fp, int threadnbr) { /** Write the configuration(s) to the log */ void conf_parms_log(struct ctx_cam **cam_list) { int i, threadnbr, diff_val; - char parm_val[PATH_MAX], parm_main[PATH_MAX]; + std::string parm_val, parm_main; MOTION_LOG(INF, TYPE_ALL, NO_ERRNO ,_("Writing configuration parameters from all files")); @@ -1117,38 +1119,38 @@ void conf_parms_log(struct ctx_cam **cam_list) { motion_log(INF, TYPE_ALL, NO_ERRNO,0 ,_("Camera %d - Config file: %s"), threadnbr, cam_list[threadnbr]->conf_filename); i = 0; - while (config_parms[i].parm_name != NULL) { + while (config_parms[i].parm_name != "") { diff_val = TRUE; conf_edit_get(cam_list[threadnbr], config_parms[i].parm_name , parm_val ,config_parms[i].parm_cat); if (threadnbr > 0){ conf_edit_get(cam_list[0], config_parms[i].parm_name , parm_main ,config_parms[i].parm_cat); - if (mystreq(parm_val, parm_main)) diff_val = FALSE; + if (parm_val == parm_main) diff_val = FALSE; } if (diff_val) { - if (mystreq(config_parms[i].parm_name, "netcam_url") || - mystreq(config_parms[i].parm_name, "netcam_userpass") || - mystreq(config_parms[i].parm_name, "netcam_highres") || - mystreq(config_parms[i].parm_name, "stream_cors_header") || - mystreq(config_parms[i].parm_name, "stream_authentication") || - mystreq(config_parms[i].parm_name, "webcontrol_authentication") || - mystreq(config_parms[i].parm_name, "webcontrol_cors_header") || - mystreq(config_parms[i].parm_name, "webcontrol_key") || - mystreq(config_parms[i].parm_name, "webcontrol_cert") || - mystreq(config_parms[i].parm_name, "database_user") || - mystreq(config_parms[i].parm_name, "database_password")) + if ((config_parms[i].parm_name == "netcam_url") || + (config_parms[i].parm_name == "netcam_userpass") || + (config_parms[i].parm_name == "netcam_highres") || + (config_parms[i].parm_name == "stream_cors_header") || + (config_parms[i].parm_name == "stream_authentication") || + (config_parms[i].parm_name == "webcontrol_authentication") || + (config_parms[i].parm_name == "webcontrol_cors_header") || + (config_parms[i].parm_name == "webcontrol_key") || + (config_parms[i].parm_name == "webcontrol_cert") || + (config_parms[i].parm_name == "database_user") || + (config_parms[i].parm_name == "database_password")) { motion_log(INF, TYPE_ALL, NO_ERRNO,0 - ,_("%-25s "), config_parms[i].parm_name); + ,_("%-25s "), config_parms[i].parm_name.c_str()); } else { - if (strncmp(config_parms[i].parm_name, "text", 4) || - strncmp(parm_val, " ", 1)){ + if ((config_parms[i].parm_name.compare(0,4,"text") == 0) || + (parm_val.compare(0,1, " ") != 0)){ motion_log(INF, TYPE_ALL, NO_ERRNO,0, "%-25s %s" - , config_parms[i].parm_name, parm_val); + , config_parms[i].parm_name.c_str(), parm_val.c_str()); } else { motion_log(INF, TYPE_ALL, NO_ERRNO,0, "%-25s \"%s\"" - , config_parms[i].parm_name, parm_val); + , config_parms[i].parm_name.c_str(), parm_val.c_str()); } } } @@ -1160,7 +1162,7 @@ void conf_parms_log(struct ctx_cam **cam_list) { /** Write the configuration(s) to file */ void conf_parms_write(struct ctx_cam **cam_list) { - char parm_val[PATH_MAX]; + std::string parm_val; int i, thread; char timestamp[32]; FILE *conffile; @@ -1182,35 +1184,38 @@ void conf_parms_write(struct ctx_cam **cam_list) { fprintf(conffile, "# at %s\n", timestamp); fprintf(conffile, "\n\n"); - for (i = 0; config_parms[i].parm_name; i++) { + i = 0; + while (config_parms[i].parm_name != ""){ conf_edit_get(cam_list[i], config_parms[i].parm_name , parm_val, config_parms[i].parm_cat); /* If config parameter has a value (not NULL) print it to the config file. */ - if (strlen(parm_val) > 0) { - fprintf(conffile, "%s\n", config_parms[i].parm_help); + if (parm_val != "") { + fprintf(conffile, "%s\n", config_parms[i].parm_help.c_str()); /* * If the option is a text_* and first char is a space put * quotation marks around to allow leading spaces. */ - if (strncmp(config_parms[i].parm_name, "text", 4) || strncmp(parm_val, " ", 1)){ - fprintf(conffile, "%s %s\n\n", config_parms[i].parm_name, parm_val); + if ((config_parms[i].parm_name.compare(0,4,"text") == 0) || + (parm_val.compare(0,1," ") == 0)){ + fprintf(conffile, "%s %s\n\n", config_parms[i].parm_name.c_str(), parm_val.c_str()); } else { - fprintf(conffile, "%s \"%s\"\n\n", config_parms[i].parm_name, parm_val); + fprintf(conffile, "%s \"%s\"\n\n", config_parms[i].parm_name.c_str(), parm_val.c_str()); } } else { if (thread == 0) { char value[PATH_MAX]; /* The 'camera_dir' option should keep the installed default value */ - if (mystreq(config_parms[i].parm_name, "camera_dir")){ + if (config_parms[i].parm_name == "camera_dir"){ sprintf(value, "%s", sysconfdir "/conf.d"); } else { sprintf(value, "%s", "value"); } - fprintf(conffile, "%s\n", config_parms[i].parm_help); - fprintf(conffile, "; %s %s\n\n", config_parms[i].parm_name, value); + fprintf(conffile, "%s\n", config_parms[i].parm_help.c_str()); + fprintf(conffile, "; %s %s\n\n", config_parms[i].parm_name.c_str(), value); } } + i++; } fprintf(conffile, "\n"); @@ -1221,9 +1226,8 @@ void conf_parms_write(struct ctx_cam **cam_list) { void conf_init_app(struct ctx_motapp *motapp, int argc, char *argv[]){ FILE *fp = NULL; - char filename[PATH_MAX]; + std::string filename; char path[PATH_MAX]; - int retcd; motapp->argc = argc; motapp->argv = argv; @@ -1232,13 +1236,9 @@ void conf_init_app(struct ctx_motapp *motapp, int argc, char *argv[]){ conf_cmdline(motapp); /* Get the filename if provided */ - if (motapp->conf_filename != NULL) { - retcd = snprintf(filename, PATH_MAX, "%s", motapp->conf_filename); - if ((retcd < 0) || (retcd > PATH_MAX)){ - MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, _("Error setting filename")); - exit(-1); - } - fp = fopen (filename, "r"); + if (motapp->conf_filename != "") { + filename = motapp->conf_filename; + fp = fopen (filename.c_str(), "r"); } if (!fp) { @@ -1246,41 +1246,29 @@ void conf_init_app(struct ctx_motapp *motapp, int argc, char *argv[]){ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, _("Error getcwd")); exit(-1); } - retcd = snprintf(filename, PATH_MAX, "%s/motion.conf", path); - if ((retcd < 0) || (retcd > PATH_MAX)){ - MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, _("Error setting filename")); - exit(-1); - } - fp = fopen (filename, "r"); + filename = path + std::string("/motion.conf"); + fp = fopen (filename.c_str(), "r"); } if (!fp) { - retcd = snprintf(filename, PATH_MAX, "%s/.motion/motion.conf", getenv("HOME")); - if ((retcd < 0) || (retcd > PATH_MAX)){ - MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, _("Error setting filename")); - exit(-1); - } - fp = fopen(filename, "r"); + filename = std::string(getenv("HOME")) + std::string("/.motion/motion.conf"); + fp = fopen(filename.c_str(), "r"); } if (!fp) { - retcd = snprintf(filename, PATH_MAX, "%s/motion.conf", sysconfdir); - if ((retcd < 0) || (retcd > PATH_MAX)){ - MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, _("Error setting filename")); - exit(-1); - } - fp = fopen(filename, "r"); + filename = std::string( sysconfdir ) + std::string("/motion.conf"); + fp = fopen(filename.c_str(), "r"); } if (!fp){ MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO - ,_("could not open configfile %s"), filename); + ,_("could not open configfile %s"), filename.c_str()); } /* Now we process the motion.conf config file and close it. */ if (fp) { - conf_edit_set(motapp, -1, (char*)"conf_filename", (char*)filename); + conf_edit_set(motapp, -1, "conf_filename", filename); conf_process(motapp, fp, -1); @@ -1298,36 +1286,28 @@ void conf_init_app(struct ctx_motapp *motapp, int argc, char *argv[]){ void conf_init_cams(struct ctx_motapp *motapp){ FILE *fp = NULL; - int retcd; + int indx; motapp->cam_list = (struct ctx_cam**)calloc(sizeof(struct ctx_cam *), 2); motapp->cam_list[0] = new ctx_cam; memset(motapp->cam_list[0],0,sizeof(struct ctx_cam)); - motapp->cam_list[0]->conf = new ctx_config; - memset(motapp->cam_list[0]->conf,0,sizeof(ctx_config)); - motapp->cam_list[1] = NULL; motapp->cam_list[0]->motapp = motapp; motapp->cam_list[0]->cam_list = motapp->cam_list; + motapp->cam_list[0]->conf = new ctx_config; conf_edit_dflt_cam(motapp->cam_list[0]); - if (motapp->conf_filename != NULL) { - retcd = snprintf(motapp->cam_list[0]->conf_filename - ,PATH_MAX,"%s",motapp->conf_filename); - if ((retcd < 0)|| (retcd > PATH_MAX)){ - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO - ,_("Error setting file name %s"), motapp->conf_filename); - exit(1); - } - fp = fopen (motapp->conf_filename, "r"); + if (motapp->conf_filename != "") { + motapp->conf_filename.copy(motapp->cam_list[0]->conf_filename,PATH_MAX); + fp = fopen (motapp->conf_filename.c_str(), "r"); } if (fp) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO - ,_("Processing thread 0 - config file %s"), motapp->conf_filename); + ,_("Processing thread 0 - config file %s"), motapp->conf_filename.c_str()); conf_process(motapp, fp, 0); myfclose(fp); } else { @@ -1335,7 +1315,12 @@ void conf_init_cams(struct ctx_motapp *motapp){ ,_("No config file to process, using default values")); } - motapp->cam_list[0]->pause = motapp->pause; + indx=0; + while (motapp->cam_list[indx] != NULL){ + motapp->cam_list[indx]->pause = motapp->pause; + motapp->cam_list[indx]->threadnr = indx; + indx++; + } return; } @@ -1345,7 +1330,6 @@ void conf_deinit(struct ctx_motapp *motapp) { indx = 0; while (motapp->cam_list[indx] != NULL){ - conf_edit_free(motapp->cam_list[indx]); delete motapp->cam_list[indx]->conf; delete motapp->cam_list[indx]; indx++; diff --git a/src/conf.hpp b/src/conf.hpp index b22508fe..14e622b7 100644 --- a/src/conf.hpp +++ b/src/conf.hpp @@ -21,30 +21,30 @@ struct ctx_config { /* Overall system configuration parameters */ int quiet; - char* camera_name; + std::string camera_name; int camera_id; - char* camera_dir; - char* target_dir; + std::string camera_dir; + std::string target_dir; /* Capture device configuration parameters */ - char* videodevice; - char* vid_control_params; + std::string videodevice; + std::string vid_control_params; int v4l2_palette; int input; int norm; unsigned long frequency; - char* tuner_device; + std::string tuner_device; int roundrobin_frames; int roundrobin_skip; int roundrobin_switchfilter; - char* netcam_url; - char* netcam_highres; - char* netcam_userpass; + std::string netcam_url; + std::string netcam_highres; + std::string netcam_userpass; int netcam_use_tcp; - char* mmalcam_name; - char* mmalcam_control_params; + std::string mmalcam_name; + std::string mmalcam_control_params; /* Image processing configuration parameters */ int width; @@ -52,14 +52,14 @@ int framerate; int minimum_frame_time; int rotate; - char* flip_axis; - char* locate_motion_mode; - char* locate_motion_style; - char* text_left; - char* text_right; + std::string flip_axis; + std::string locate_motion_mode; + std::string locate_motion_style; + std::string text_left; + std::string text_right; int text_changes; int text_scale; - char* text_event; + std::string text_event; /* Motion detection configuration parameters */ int emulate_motion; @@ -72,20 +72,20 @@ int threshold_tune; int secondary_interval; int secondary_method; - char* secondary_model; - char* secondary_config; + std::string secondary_model; + std::string secondary_config; int secondary_method2; - char* secondary_model2; - char* secondary_config2; + std::string secondary_model2; + std::string secondary_config2; int secondary_method3; - char* secondary_model3; - char* secondary_config3; + std::string secondary_model3; + std::string secondary_config3; int noise_level; int noise_tune; - char* despeckle_filter; - char* area_detect; - char* mask_file; - char* mask_privacy; + std::string despeckle_filter; + std::string area_detect; + std::string mask_file; + std::string mask_privacy; int smart_mask_speed; int lightswitch_percent; int lightswitch_frames; @@ -95,27 +95,27 @@ int post_capture; /* Script execution configuration parameters */ - char* on_event_start; - char* on_event_end; - char* on_picture_save; - char* on_area_detected; - char* on_motion_detected; - char* on_movie_start; - char* on_movie_end; - char* on_camera_lost; - char* on_camera_found; + std::string on_event_start; + std::string on_event_end; + std::string on_picture_save; + std::string on_area_detected; + std::string on_motion_detected; + std::string on_movie_start; + std::string on_movie_end; + std::string on_camera_lost; + std::string on_camera_found; /* Picture output configuration parameters */ - char* picture_output; + std::string picture_output; int picture_output_motion; - char* picture_type; + std::string picture_type; int picture_quality; - char* picture_exif; - char* picture_filename; + std::string picture_exif; + std::string picture_filename; /* Snapshot configuration parameters */ int snapshot_interval; - char* snapshot_filename; + std::string snapshot_filename; /* Movie output configuration parameters */ int movie_output; @@ -123,22 +123,22 @@ int movie_max_time; int movie_bps; int movie_quality; - char* movie_codec; + std::string movie_codec; int movie_passthrough; - char* movie_filename; + std::string movie_filename; int movie_extpipe_use; - char* movie_extpipe; + std::string movie_extpipe; /* Timelapse movie configuration parameters */ int timelapse_interval; - char* timelapse_mode; + std::string timelapse_mode; int timelapse_fps; - char* timelapse_codec; - char* timelapse_filename; + std::string timelapse_codec; + std::string timelapse_filename; /* Loopback device configuration parameters */ - char* video_pipe; - char* video_pipe_motion; + std::string video_pipe; + std::string video_pipe_motion; /* Webcontrol configuration parameters */ int webcontrol_port; @@ -147,19 +147,19 @@ int webcontrol_parms; int webcontrol_interface; int webcontrol_auth_method; - char* webcontrol_authentication; + std::string webcontrol_authentication; int webcontrol_tls; - char* webcontrol_cert; - char* webcontrol_key; - char* webcontrol_cors_header; + std::string webcontrol_cert; + std::string webcontrol_key; + std::string webcontrol_cors_header; /* Live stream configuration parameters */ int stream_port; int stream_localhost; int stream_auth_method; - char* stream_authentication; + std::string stream_authentication; int stream_tls; - char* stream_cors_header; + std::string stream_cors_header; int stream_preview_scale; int stream_preview_newline; int stream_preview_method; @@ -169,28 +169,28 @@ int stream_maxrate; /* Database and SQL configuration parameters */ - char* database_type; - char* database_dbname; - char* database_host; + std::string database_type; + std::string database_dbname; + std::string database_host; int database_port; - char* database_user; - char* database_password; + std::string database_user; + std::string database_password; int database_busy_timeout; int sql_log_picture; int sql_log_snapshot; int sql_log_movie; int sql_log_timelapse; - char* sql_query_start; - char* sql_query_stop; - char* sql_query; + std::string sql_query_start; + std::string sql_query_stop; + std::string sql_query; int track_type; int track_auto; int track_step_angle_x; int track_step_angle_y; int track_move_wait; - char* track_generic_move; + std::string track_generic_move; }; enum PARM_CAT{ @@ -209,8 +209,8 @@ /** Current parameters in the config file */ struct ctx_parm { - const char* parm_name; /* name for this parameter */ - const char* parm_help; /* short explanation for parameter */ + const std::string parm_name; /* name for this parameter */ + const std::string parm_help; /* short explanation for parameter */ int main_thread; /* belong only to main thread when value>0 */ enum PARM_TYP parm_type; /* char string of either bool,int,string,etc. */ enum PARM_CAT parm_cat; @@ -219,10 +219,10 @@ /** Deprecated parameters in the config file */ struct ctx_parm_depr{ - const char* parm_name; /* Name of the deprecated option */ - const char* last_version; /* Last version this option was used in */ - const char* info; /* Short text on why it was deprecated (removed, replaced with, etc) */ - const char* newname; /* Name of the new parameter */ + const std::string parm_name; /* Name of the deprecated option */ + const std::string last_version; /* Last version this option was used in */ + const std::string info; /* Short text on why it was deprecated (removed, replaced with, etc) */ + const std::string newname; /* Name of the new parameter */ }; extern struct ctx_parm config_parms[]; diff --git a/src/conf_edit.cpp b/src/conf_edit.cpp index 2ef526cf..cb6acde5 100644 --- a/src/conf_edit.cpp +++ b/src/conf_edit.cpp @@ -20,6 +20,7 @@ */ #include +#include #include "motion.hpp" #include "util.hpp" #include "logger.hpp" @@ -29,490 +30,408 @@ enum PARM_ACT{ PARM_ACT_DFLT ,PARM_ACT_SET ,PARM_ACT_GET - ,PARM_ACT_FREE }; -static void conf_edit_get_string(char *parm, char *arg1) { - if (parm == NULL){ - snprintf(arg1, PATH_MAX,"%s",""); +static void conf_edit_set_bool(int &parm_dest, std::string &parm_in) { + if ((parm_in == "1") || (parm_in == "yes") || (parm_in == "on")) { + parm_dest = TRUE; } else { - snprintf(arg1,PATH_MAX,"%s",parm); + parm_dest = FALSE; } } -static void conf_edit_get_int(int parm, char *arg1) { - snprintf(arg1, 20, "%d", parm); -} -static void conf_edit_get_bool(int parm, char *arg1) { - if (parm == TRUE){ - snprintf(arg1, PATH_MAX, "%s", "on"); +static void conf_edit_get_bool(std::string &parm_dest, int &parm_in) { + if (parm_in == TRUE){ + parm_dest = "on"; } else { - snprintf(arg1, PATH_MAX, "%s", "off"); - } -} -static void conf_edit_set_string(char **parm_cam, char *arg1) { - if (*parm_cam != NULL) free(*parm_cam); - if (arg1 == NULL){ - *parm_cam = NULL; - } else { - *parm_cam = (char*)mymalloc(strlen(arg1)+1); - snprintf(*parm_cam, strlen(arg1)+1, "%s", arg1); + parm_dest = "off"; } } -static void conf_edit_daemon(struct ctx_motapp *motapp, char *arg1, enum PARM_ACT pact) { +static void conf_edit_daemon(struct ctx_motapp *motapp, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ motapp->daemon = FALSE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - motapp->daemon = TRUE; - } else { - motapp->daemon = FALSE; - } + conf_edit_set_bool(motapp->daemon, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(motapp->daemon, arg1); + conf_edit_get_bool(parm, motapp->daemon); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","daemon",_("daemon")); } -static void conf_edit_setup_mode(struct ctx_motapp *motapp, char *arg1, int pact) { +static void conf_edit_setup_mode(struct ctx_motapp *motapp, std::string &parm, int pact) { if (pact == PARM_ACT_DFLT){ motapp->setup_mode = FALSE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - motapp->setup_mode = TRUE; - } else { - motapp->setup_mode = FALSE; - } + conf_edit_set_bool(motapp->setup_mode, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(motapp->setup_mode, arg1); + conf_edit_get_bool(parm, motapp->setup_mode); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","setup_mode",_("setup_mode")); } -static void conf_edit_conf_filename(struct ctx_motapp *motapp, char *arg1, enum PARM_ACT pact) { +static void conf_edit_conf_filename(struct ctx_motapp *motapp, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&motapp->conf_filename,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&motapp->conf_filename,NULL); + motapp->conf_filename = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&motapp->conf_filename,arg1); + motapp->conf_filename = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(motapp->conf_filename,arg1); + parm = motapp->conf_filename; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","log_file",_("log_file")); } -static void conf_edit_pid_file(struct ctx_motapp *motapp, char *arg1, int pact) { +static void conf_edit_pid_file(struct ctx_motapp *motapp, std::string &parm, int pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&motapp->pid_file,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&motapp->pid_file,NULL); + motapp->pid_file = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&motapp->pid_file,arg1); + motapp->pid_file = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(motapp->pid_file,arg1); + parm = motapp->pid_file; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","pid_file",_("pid_file")); } -static void conf_edit_log_file(struct ctx_motapp *motapp, char *arg1, enum PARM_ACT pact) { +static void conf_edit_log_file(struct ctx_motapp *motapp, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&motapp->log_file,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&motapp->log_file,NULL); + motapp->log_file = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&motapp->log_file,arg1); + motapp->log_file = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(motapp->log_file,arg1); + parm = motapp->log_file; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","log_file",_("log_file")); } -static void conf_edit_log_level(struct ctx_motapp *motapp, char *arg1, enum PARM_ACT pact) { +static void conf_edit_log_level(struct ctx_motapp *motapp, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ motapp->log_level = 6; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 1) || (parm_in > 9)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid log_level %d"),parm_in); } else { motapp->log_level = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(motapp->log_level, arg1); + parm = std::to_string(motapp->log_level); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","log_level",_("log_level")); } -static void conf_edit_log_type(struct ctx_motapp *motapp, char *arg1, enum PARM_ACT pact) { +static void conf_edit_log_type(struct ctx_motapp *motapp, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&motapp->log_type_str,(char*)"ALL"); - } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&motapp->log_type_str, NULL); + motapp->log_type_str = "ALL"; } else if (pact == PARM_ACT_SET){ - if (arg1 == NULL){ - conf_edit_set_string(&motapp->log_type_str,(char*)"ALL"); + if ((parm == "ALL") || (parm == "COR") || + (parm == "STR") || (parm == "ENC") || + (parm == "NET") || (parm == "DBL") || + (parm == "EVT") || (parm == "TRK") || + (parm == "VID") || (parm == "ALL")) { + motapp->log_type_str = parm; } else { - if (mystreq(arg1,"ALL") || mystreq(arg1,"COR") || - mystreq(arg1,"STR") || mystreq(arg1,"ENC") || - mystreq(arg1,"NET") || mystreq(arg1,"DBL") || - mystreq(arg1,"EVT") || mystreq(arg1,"TRK") || - mystreq(arg1,"VID") || mystreq(arg1,"ALL")) { - conf_edit_set_string(&motapp->log_type_str, arg1); - } else { - conf_edit_set_string(&motapp->log_type_str,(char*)"ALL"); - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid log_level %s"),arg1); - } + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid log_type %s"),parm); } - conf_edit_set_string(&motapp->log_type_str,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(motapp->log_type_str,arg1); + parm = motapp->log_type_str; } - return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","log_type",_("log_type")); } -static void conf_edit_native_language(struct ctx_motapp *motapp, char *arg1, enum PARM_ACT pact) { +static void conf_edit_native_language(struct ctx_motapp *motapp, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ motapp->native_language = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - motapp->native_language = TRUE; - } else { - motapp->native_language = FALSE; - } + conf_edit_set_bool(motapp->native_language, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(motapp->native_language, arg1); + conf_edit_get_bool(parm, motapp->native_language); } return; - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_changes",_("text_changes")); + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","native_language",_("native_language")); } -static void conf_edit_quiet(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +/************************************************************************/ +/************************************************************************/ +/************************************************************************/ + +static void conf_edit_quiet(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ cam->conf->quiet = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->quiet = TRUE; - } else { - cam->conf->quiet = FALSE; - } + conf_edit_set_bool(cam->conf->quiet, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->quiet, arg1); + conf_edit_get_bool(parm, cam->conf->quiet); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","quiet",_("quiet")); } -static void conf_edit_camera_name(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_camera_name(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf->camera_name,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->camera_name,NULL); + cam->conf->camera_name= ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->camera_name,arg1); + cam->conf->camera_name = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->camera_name,arg1); + parm = cam->conf->camera_name; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","camera_name",_("camera_name")); } -static void conf_edit_camera_id(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_camera_id(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->camera_id = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if (parm_in < 0) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid camera_id %d"),parm_in); } else { cam->conf->camera_id = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->camera_id, arg1); + parm = std::to_string(cam->conf->camera_id); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","camera_id",_("camera_id")); } -static void conf_edit_camera_dir(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_camera_dir(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf->camera_dir,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->camera_dir,NULL); + cam->conf->camera_dir = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->camera_dir,arg1); + cam->conf->camera_dir = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->camera_dir,arg1); + parm = cam->conf->camera_dir; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","camera_dir",_("camera_dir")); } -static void conf_edit_target_dir(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->target_dir,(char*)"."); - } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf->target_dir,NULL); +static void conf_edit_target_dir(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->target_dir = "."; } else if (pact == PARM_ACT_SET){ - if (arg1 == NULL){ - conf_edit_set_string(&cam->conf->target_dir,(char*)"."); - } else { - conf_edit_set_string(&cam->conf->target_dir,arg1); - } + cam->conf->target_dir = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->target_dir,arg1); + parm = cam->conf->target_dir; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","target_dir",_("target_dir")); } -static void conf_edit_videodevice(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->videodevice,(char*)"/dev/video0"); - } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf->videodevice,NULL); +static void conf_edit_videodevice(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->videodevice = "/dev/video0"; } else if (pact == PARM_ACT_SET){ - if (arg1 == NULL){ - conf_edit_set_string(&cam->conf->videodevice,(char*)"/dev/video0"); - } else { - conf_edit_set_string(&cam->conf->videodevice,arg1); - } + cam->conf->videodevice = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->videodevice,arg1); + parm = cam->conf->videodevice; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","videodevice",_("videodevice")); } -static void conf_edit_vid_control_params(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->vid_control_params,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->vid_control_params,NULL); +static void conf_edit_vid_control_params(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->vid_control_params = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->vid_control_params,arg1); + cam->conf->vid_control_params = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->vid_control_params,arg1); + parm = cam->conf->vid_control_params; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","vid_control_params",_("vid_control_params")); } -static void conf_edit_v4l2_palette(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_v4l2_palette(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->v4l2_palette = 17; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in >21)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid v4l2_palette %d"),parm_in); } else { cam->conf->v4l2_palette = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->v4l2_palette, arg1); + parm = std::to_string(cam->conf->v4l2_palette); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","v4l2_palette",_("v4l2_palette")); } -static void conf_edit_input(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_input(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->input = -1; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < -1) || (parm_in > 7)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid input %d"),parm_in); } else { cam->conf->input = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->input, arg1); + parm = std::to_string(cam->conf->input); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","input",_("input")); } -static void conf_edit_norm(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_norm(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->norm = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 3)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid norm %d"),parm_in); } else { cam->conf->norm = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->norm, arg1); + parm = std::to_string(cam->conf->norm); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","norm",_("norm")); } -static void conf_edit_frequency(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_frequency(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->frequency = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 999999)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid frequency %d"),parm_in); } else { cam->conf->frequency = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->frequency, arg1); + parm = std::to_string(cam->conf->frequency); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","frequency",_("frequency")); } -static void conf_edit_tuner_device(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->tuner_device,(char*)"/dev/tuner0"); - } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf->tuner_device,NULL); +static void conf_edit_tuner_device(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->tuner_device = "/dev/tuner0"; } else if (pact == PARM_ACT_SET){ - if (arg1 == NULL){ - conf_edit_set_string(&cam->conf->tuner_device,(char*)"/dev/tuner0"); - } else { - conf_edit_set_string(&cam->conf->tuner_device,arg1); - } + cam->conf->tuner_device = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->tuner_device,arg1); + parm = cam->conf->tuner_device; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","tuner_device",_("tuner_device")); } -static void conf_edit_roundrobin_frames(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_roundrobin_frames(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->roundrobin_frames = 1; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 1) || (parm_in > 2147483647)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid roundrobin_frames %d"),parm_in); } else { cam->conf->roundrobin_frames = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->roundrobin_frames, arg1); + parm = std::to_string(cam->conf->roundrobin_frames); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","roundrobin_frames",_("roundrobin_frames")); } -static void conf_edit_roundrobin_skip(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_roundrobin_skip(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->roundrobin_skip = 1; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 1) || (parm_in > 2147483647)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid roundrobin_skip %d"),parm_in); } else { cam->conf->roundrobin_skip = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->roundrobin_skip, arg1); + parm = std::to_string(cam->conf->roundrobin_skip); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","roundrobin_skip",_("roundrobin_skip")); } -static void conf_edit_roundrobin_switchfilter(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_roundrobin_switchfilter(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf->roundrobin_switchfilter = FALSE; + cam->conf->roundrobin_switchfilter = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->roundrobin_switchfilter = TRUE; - } else { - cam->conf->roundrobin_switchfilter = FALSE; - } + conf_edit_set_bool(cam->conf->roundrobin_switchfilter, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->roundrobin_switchfilter, arg1); + conf_edit_get_bool(parm, cam->conf->roundrobin_switchfilter); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","roundrobin_switchfilter",_("roundrobin_switchfilter")); } -static void conf_edit_netcam_url(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_netcam_url(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf->netcam_url,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->netcam_url,NULL); + cam->conf->netcam_url = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->netcam_url,arg1); + cam->conf->netcam_url = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->netcam_url,arg1); + parm = cam->conf->netcam_url; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","netcam_url",_("netcam_url")); } -static void conf_edit_netcam_highres(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_netcam_highres(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf->netcam_highres,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->netcam_highres,NULL); + cam->conf->netcam_highres = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->netcam_highres,arg1); + cam->conf->netcam_highres = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->netcam_highres,arg1); + parm = cam->conf->netcam_highres; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","netcam_highres",_("netcam_highres")); } -static void conf_edit_netcam_userpass(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_netcam_userpass(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf->netcam_userpass,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->netcam_userpass,NULL); + cam->conf->netcam_userpass = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->netcam_userpass,arg1); + cam->conf->netcam_userpass = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->netcam_userpass,arg1); + parm = cam->conf->netcam_userpass; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","netcam_userpass",_("netcam_userpass")); } -static void conf_edit_netcam_use_tcp(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_netcam_use_tcp(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ cam->conf->netcam_use_tcp = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->netcam_use_tcp = TRUE; - } else { - cam->conf->netcam_use_tcp = FALSE; - } + conf_edit_set_bool(cam->conf->netcam_use_tcp, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->netcam_use_tcp, arg1); + conf_edit_get_bool(parm, cam->conf->netcam_use_tcp); } return; } -static void conf_edit_mmalcam_name(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->mmalcam_name,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->mmalcam_name,NULL); +static void conf_edit_mmalcam_name(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->mmalcam_name = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->mmalcam_name,arg1); + cam->conf->mmalcam_name = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->mmalcam_name,arg1); + parm = cam->conf->mmalcam_name; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","mmalcam_name",_("mmalcam_name")); } -static void conf_edit_mmalcam_control_params(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_mmalcam_control_params(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf->mmalcam_control_params,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->mmalcam_control_params,NULL); + cam->conf->mmalcam_control_params = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->mmalcam_control_params,arg1); + cam->conf->mmalcam_control_params = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->mmalcam_control_params,arg1); + parm = cam->conf->mmalcam_control_params; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","mmalcam_control_params",_("mmalcam_control_params")); } -static void conf_edit_width(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_width(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->width = 640; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 64) || (parm_in > 9999)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid width %d"),parm_in); } else if (parm_in % 8) { @@ -526,17 +445,17 @@ static void conf_edit_width(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) cam->conf->width = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->width, arg1); + parm = std::to_string(cam->conf->width); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","width",_("width")); } -static void conf_edit_height(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_height(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->height = 480; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 64) || (parm_in > 9999)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid height %d"),parm_in); } else if (parm_in % 8) { @@ -550,51 +469,51 @@ static void conf_edit_height(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact cam->conf->height = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->height, arg1); + parm = std::to_string(cam->conf->height); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","height",_("height")); } -static void conf_edit_framerate(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_framerate(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->framerate = 15; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 2) || (parm_in > 100)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid framerate %d"),parm_in); } else { cam->conf->framerate = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->framerate, arg1); + parm = std::to_string(cam->conf->framerate); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","framerate",_("framerate")); } -static void conf_edit_minimum_frame_time(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_minimum_frame_time(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->minimum_frame_time = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 2147483647)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid minimum_frame_time %d"),parm_in); } else { cam->conf->minimum_frame_time = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->minimum_frame_time, arg1); + parm = std::to_string(cam->conf->minimum_frame_time); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","minimum_frame_time",_("minimum_frame_time")); } -static void conf_edit_rotate(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_rotate(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->rotate = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in != 0) && (parm_in != 90) && (parm_in != 180) && (parm_in != 270) ) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid rotate %d"),parm_in); @@ -602,1317 +521,1147 @@ static void conf_edit_rotate(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact cam->conf->rotate = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->rotate, arg1); + parm = std::to_string(cam->conf->rotate); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","rotate",_("rotate")); } -static void conf_edit_flip_axis(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->flip_axis,(char*)"none"); - } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf->flip_axis,NULL); +static void conf_edit_flip_axis(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->flip_axis = "none"; } else if (pact == PARM_ACT_SET){ - if (arg1 == NULL){ - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid flip_axis %s"),arg1); + if ((parm == "none") || (parm == "v") || (parm == "h")) { + cam->conf->flip_axis = parm; } else { - if (mystreq(arg1,"none") || mystreq(arg1,"v") || mystreq(arg1,"h")) { - conf_edit_set_string(&cam->conf->flip_axis, arg1); - } else { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid flip_axis %s"),arg1); - } + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid flip_axis %s"), parm); } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->flip_axis,arg1); + parm = cam->conf->flip_axis; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","flip_axis",_("flip_axis")); } -static void conf_edit_locate_motion_mode(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->locate_motion_mode,(char*)"off"); - } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf->locate_motion_mode,NULL); +static void conf_edit_locate_motion_mode(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->locate_motion_mode = "off"; } else if (pact == PARM_ACT_SET){ - if (arg1 == NULL){ - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid locate_motion_mode %s"),arg1); + if ((parm == "off") || (parm == "on") || (parm == "preview")) { + cam->conf->locate_motion_mode = parm; } else { - if (mystreq(arg1,"off") || mystreq(arg1,"on") || mystreq(arg1,"preview")) { - conf_edit_set_string(&cam->conf->locate_motion_mode, arg1); - } else { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid locate_motion_mode %s"),arg1); - } + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid locate_motion_mode %s"), parm); } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->locate_motion_mode,arg1); + parm = cam->conf->locate_motion_mode; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","locate_motion_mode",_("locate_motion_mode")); } -static void conf_edit_locate_motion_style(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->locate_motion_style,(char*)"box"); - } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf->locate_motion_style,NULL); +static void conf_edit_locate_motion_style(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->locate_motion_style = "box"; } else if (pact == PARM_ACT_SET){ - if (arg1 == NULL){ - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid locate_motion_style %s"),arg1); + if ((parm == "box") || (parm == "redbox") || + (parm == "cross") || (parm == "redcross")) { + cam->conf->locate_motion_style = parm; } else { - if (mystreq(arg1,"box") || mystreq(arg1,"redbox") || - mystreq(arg1,"cross") || mystreq(arg1,"redcross")) { - conf_edit_set_string(&cam->conf->locate_motion_style, arg1); - } else { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid locate_motion_style %s"),arg1); - } + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid locate_motion_style %s"), parm); } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->locate_motion_style,arg1); + parm = cam->conf->locate_motion_style; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","locate_motion_style",_("locate_motion_style")); } -static void conf_edit_text_left(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->text_left,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->text_left,NULL); +static void conf_edit_text_left(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->text_left = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->text_left,arg1); + cam->conf->text_left = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->text_left,arg1); + parm = cam->conf->text_left; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_left",_("text_left")); } -static void conf_edit_text_right(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->text_right,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->text_right,NULL); +static void conf_edit_text_right(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->text_right = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->text_right,arg1); + cam->conf->text_right = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->text_right,arg1); + parm = cam->conf->text_right; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_right",_("text_right")); } -static void conf_edit_text_changes(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_text_changes(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ cam->conf->text_changes = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->text_changes = TRUE; - } else { - cam->conf->text_changes = FALSE; - } + conf_edit_set_bool(cam->conf->text_changes, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->text_changes, arg1); + conf_edit_get_bool(parm, cam->conf->text_changes); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_changes",_("text_changes")); } -static void conf_edit_text_scale(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_text_scale(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->text_scale = 1; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 1) || (parm_in > 10)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid text_scale %d"),parm_in); } else { cam->conf->text_scale = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->text_scale, arg1); + parm = std::to_string(cam->conf->text_scale); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_scale",_("text_scale")); } -static void conf_edit_text_event(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->text_event,(char*)"%Y%m%d%H%M%S"); - } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf->text_event,NULL); +static void conf_edit_text_event(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->text_event = "%Y%m%d%H%M%S"; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->text_event,arg1); + cam->conf->text_event = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->text_event,arg1); + parm = cam->conf->text_event; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_event",_("text_event")); } -static void conf_edit_emulate_motion(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_emulate_motion(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf->emulate_motion = FALSE; + cam->conf->emulate_motion = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->emulate_motion = TRUE; - } else { - cam->conf->emulate_motion = FALSE; - } + conf_edit_set_bool(cam->conf->emulate_motion, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->emulate_motion, arg1); + conf_edit_get_bool(parm, cam->conf->emulate_motion); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","emulate_motion",_("emulate_motion")); } -static void conf_edit_primary_method(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_primary_method(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->threshold = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 1)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid primary method %d"),parm_in); } else { cam->conf->primary_method = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->primary_method, arg1); + parm = std::to_string(cam->conf->primary_method); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","primary_method",_("primary_method")); } -static void conf_edit_threshold(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_threshold(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->threshold = 1500; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 1) || (parm_in > 2147483647)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid threshold %d"),parm_in); } else { cam->conf->threshold = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->threshold, arg1); + parm = std::to_string(cam->conf->threshold); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold",_("threshold")); } -static void conf_edit_threshold_maximum(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_threshold_maximum(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->threshold_maximum = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) ) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid threshold_maximum %d"),parm_in); } else { cam->conf->threshold_maximum = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->threshold_maximum, arg1); + parm = std::to_string(cam->conf->threshold_maximum); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold_maximum",_("threshold_maximum")); } -static void conf_edit_threshold_sdevx(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_threshold_sdevx(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->threshold_sdevx = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) ) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid threshold_sdevx %d"),parm_in); } else { cam->conf->threshold_sdevx = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->threshold_sdevx, arg1); + parm = std::to_string(cam->conf->threshold_sdevx); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold_sdevx",_("threshold_sdevx")); } -static void conf_edit_threshold_sdevy(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_threshold_sdevy(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->threshold_sdevy = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) ) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid threshold_sdevy %d"),parm_in); } else { cam->conf->threshold_sdevy = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->threshold_sdevy, arg1); + parm = std::to_string(cam->conf->threshold_sdevy); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold_sdevy",_("threshold_sdevy")); } -static void conf_edit_threshold_sdevxy(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_threshold_sdevxy(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->threshold_sdevxy = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) ) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid threshold_sdevxy %d"),parm_in); } else { cam->conf->threshold_sdevxy = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->threshold_sdevxy, arg1); + parm = std::to_string(cam->conf->threshold_sdevxy); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold_sdevxy",_("threshold_sdevxy")); } -static void conf_edit_threshold_tune(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_threshold_tune(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf->threshold_tune = FALSE; + cam->conf->threshold_tune = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->threshold_tune = TRUE; - } else { - cam->conf->threshold_tune = FALSE; - } + conf_edit_set_bool(cam->conf->threshold_tune, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->threshold_tune, arg1); + conf_edit_get_bool(parm, cam->conf->threshold_tune); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold_tune",_("threshold_tune")); } -static void conf_edit_secondary_interval(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_secondary_interval(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->secondary_interval = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) ) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid secondary_interval %d"),parm_in); } else { cam->conf->secondary_interval = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->secondary_interval, arg1); + parm = std::to_string(cam->conf->secondary_interval); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_interval",_("secondary_interval")); } -static void conf_edit_secondary_method(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_secondary_method(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->secondary_method = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) ) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid secondary_method %d"),parm_in); } else { cam->conf->secondary_method = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->secondary_method, arg1); + parm = std::to_string(cam->conf->secondary_method); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_method",_("secondary_method")); } -static void conf_edit_secondary_model(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_secondary_model(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf->secondary_model,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->secondary_model,NULL); + cam->conf->secondary_model = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->secondary_model,arg1); + cam->conf->secondary_model = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->secondary_model,arg1); + parm = cam->conf->secondary_model; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_model",_("secondary_model")); } -static void conf_edit_secondary_config(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_secondary_config(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf->secondary_config,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->secondary_config,NULL); + cam->conf->secondary_config = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->secondary_config,arg1); + cam->conf->secondary_config = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->secondary_config,arg1); + parm = cam->conf->secondary_config; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_config",_("secondary_config")); } -static void conf_edit_secondary_method2(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_secondary_method2(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->secondary_method2 = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) ) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid secondary_method2 %d"),parm_in); } else { cam->conf->secondary_method2 = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->secondary_method2, arg1); + parm = std::to_string(cam->conf->secondary_method2); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_method2",_("secondary_method2")); } -static void conf_edit_secondary_model2(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_secondary_model2(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf->secondary_model2,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->secondary_model2,NULL); + cam->conf->secondary_model2 = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->secondary_model2,arg1); + cam->conf->secondary_model2 = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->secondary_model2,arg1); + parm = cam->conf->secondary_model2; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_model2",_("secondary_model2")); } -static void conf_edit_secondary_config2(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_secondary_config2(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf->secondary_config2,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->secondary_config2,NULL); + cam->conf->secondary_config2 = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->secondary_config2,arg1); + cam->conf->secondary_config2 = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->secondary_config2,arg1); + parm = cam->conf->secondary_config2; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_config2",_("secondary_config2")); } -static void conf_edit_secondary_method3(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_secondary_method3(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->secondary_method3 = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) ) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid secondary_method3 %d"),parm_in); } else { cam->conf->secondary_method3 = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->secondary_method3, arg1); + parm = std::to_string(cam->conf->secondary_method3); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_method3",_("secondary_method3")); } -static void conf_edit_secondary_model3(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_secondary_model3(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf->secondary_model3,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->secondary_model3,NULL); + cam->conf->secondary_model3 = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->secondary_model3,arg1); + cam->conf->secondary_model3 = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->secondary_model3,arg1); + parm = cam->conf->secondary_model3; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_model3",_("secondary_model3")); } -static void conf_edit_secondary_config3(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_secondary_config3(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf->secondary_config3,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->secondary_config3,NULL); + cam->conf->secondary_config3 = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->secondary_config3,arg1); + cam->conf->secondary_config3 = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->secondary_config3,arg1); + parm = cam->conf->secondary_config3; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_config3",_("secondary_config3")); } -static void conf_edit_noise_level(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_noise_level(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->noise_level = 32; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 1) || (parm_in > 255)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid noise_level %d"),parm_in); } else { cam->conf->noise_level = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->noise_level, arg1); + parm = std::to_string(cam->conf->noise_level); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","noise_level",_("noise_level")); } -static void conf_edit_noise_tune(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_noise_tune(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf->noise_tune = FALSE; + cam->conf->noise_tune = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->noise_tune = TRUE; - } else { - cam->conf->noise_tune = FALSE; - } + conf_edit_set_bool(cam->conf->noise_tune, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->noise_tune, arg1); + conf_edit_get_bool(parm, cam->conf->noise_tune); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","noise_tune",_("noise_tune")); } -static void conf_edit_despeckle_filter(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_despeckle_filter(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf->despeckle_filter,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->despeckle_filter,NULL); + cam->conf->despeckle_filter = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->despeckle_filter,arg1); + cam->conf->despeckle_filter = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->despeckle_filter,arg1); + parm = cam->conf->despeckle_filter; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","despeckle_filter",_("despeckle_filter")); } -static void conf_edit_area_detect(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->area_detect,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->area_detect,NULL); +static void conf_edit_area_detect(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->area_detect = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->area_detect,arg1); + cam->conf->area_detect = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->area_detect,arg1); + parm = cam->conf->area_detect; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","area_detect",_("area_detect")); } -static void conf_edit_mask_file(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->mask_file,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->mask_file,NULL); +static void conf_edit_mask_file(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->mask_file = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->mask_file,arg1); + cam->conf->mask_file = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->mask_file,arg1); + parm = cam->conf->mask_file; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","mask_file",_("mask_file")); } -static void conf_edit_mask_privacy(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_mask_privacy(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf->mask_privacy,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->mask_privacy,NULL); + cam->conf->mask_privacy = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->mask_privacy,arg1); + cam->conf->mask_privacy = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->mask_privacy,arg1); + parm = cam->conf->mask_privacy; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","mask_privacy",_("mask_privacy")); } -static void conf_edit_smart_mask_speed(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_smart_mask_speed(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->smart_mask_speed = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 10)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid smart_mask_speed %d"),parm_in); } else { cam->conf->smart_mask_speed = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->smart_mask_speed, arg1); + parm = std::to_string(cam->conf->smart_mask_speed); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","smart_mask_speed",_("smart_mask_speed")); } -static void conf_edit_lightswitch_percent(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_lightswitch_percent(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->lightswitch_percent = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 100)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid lightswitch_percent %d"),parm_in); } else { cam->conf->lightswitch_percent = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->lightswitch_percent, arg1); + parm = std::to_string(cam->conf->lightswitch_percent); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","lightswitch_percent",_("lightswitch_percent")); } -static void conf_edit_lightswitch_frames(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_lightswitch_frames(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->lightswitch_frames = 5; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 1) || (parm_in > 1000)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid lightswitch_frames %d"),parm_in); } else { cam->conf->lightswitch_frames = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->lightswitch_frames, arg1); + parm = std::to_string(cam->conf->lightswitch_frames); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","lightswitch_frames",_("lightswitch_frames")); } -static void conf_edit_minimum_motion_frames(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_minimum_motion_frames(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->minimum_motion_frames = 1; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 1) || (parm_in > 10000)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid minimum_motion_frames %d"),parm_in); } else { cam->conf->minimum_motion_frames = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->minimum_motion_frames, arg1); + parm = std::to_string(cam->conf->minimum_motion_frames); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","minimum_motion_frames",_("minimum_motion_frames")); } -static void conf_edit_event_gap(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_event_gap(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->event_gap = 60; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 2147483647)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid event_gap %d"),parm_in); } else { cam->conf->event_gap = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->event_gap, arg1); + parm = std::to_string(cam->conf->event_gap); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","event_gap",_("event_gap")); } -static void conf_edit_pre_capture(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_pre_capture(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->pre_capture = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 10000)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid pre_capture %d"),parm_in); } else { cam->conf->pre_capture = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->pre_capture, arg1); + parm = std::to_string(cam->conf->pre_capture); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","pre_capture",_("pre_capture")); } -static void conf_edit_post_capture(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_post_capture(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->post_capture = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 2147483647)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid post_capture %d"),parm_in); } else { cam->conf->post_capture = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->post_capture, arg1); + parm = std::to_string(cam->conf->post_capture); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","post_capture",_("post_capture")); } -static void conf_edit_on_event_start(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->on_event_start,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->on_event_start,NULL); +static void conf_edit_on_event_start(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->on_event_start = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->on_event_start,arg1); + cam->conf->on_event_start = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->on_event_start,arg1); + parm = cam->conf->on_event_start; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_event_start",_("on_event_start")); } -static void conf_edit_on_event_end(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->on_event_end,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->on_event_end,NULL); +static void conf_edit_on_event_end(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->on_event_end = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->on_event_end,arg1); + cam->conf->on_event_end = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->on_event_end,arg1); + parm = cam->conf->on_event_end; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_event_end",_("on_event_end")); } -static void conf_edit_on_picture_save(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->on_picture_save,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->on_picture_save,NULL); +static void conf_edit_on_picture_save(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->on_picture_save = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->on_picture_save,arg1); + cam->conf->on_picture_save = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->on_picture_save,arg1); + parm = cam->conf->on_picture_save; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_picture_save",_("on_picture_save")); } -static void conf_edit_on_area_detected(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->on_area_detected,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->on_area_detected,NULL); +static void conf_edit_on_area_detected(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->on_area_detected = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->on_area_detected,arg1); + cam->conf->on_area_detected = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->on_area_detected,arg1); + parm = cam->conf->on_area_detected; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_area_detected",_("on_area_detected")); } -static void conf_edit_on_motion_detected(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->on_motion_detected,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->on_motion_detected,NULL); +static void conf_edit_on_motion_detected(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->on_motion_detected = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->on_motion_detected,arg1); + cam->conf->on_motion_detected = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->on_motion_detected,arg1); + parm = cam->conf->on_motion_detected; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_motion_detected",_("on_motion_detected")); } -static void conf_edit_on_movie_start(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->on_movie_start,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->on_movie_start,NULL); +static void conf_edit_on_movie_start(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->on_movie_start = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->on_movie_start,arg1); + cam->conf->on_movie_start = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->on_movie_start,arg1); + parm = cam->conf->on_movie_start; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_movie_start",_("on_movie_start")); } -static void conf_edit_on_movie_end(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->on_movie_end,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->on_movie_end,NULL); +static void conf_edit_on_movie_end(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->on_movie_end = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->on_movie_end,arg1); + cam->conf->on_movie_end = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->on_movie_end,arg1); + parm = cam->conf->on_movie_end; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_movie_end",_("on_movie_end")); } -static void conf_edit_on_camera_lost(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->on_camera_lost,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->on_camera_lost,NULL); +static void conf_edit_on_camera_lost(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->on_camera_lost = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->on_camera_lost,arg1); + cam->conf->on_camera_lost = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->on_camera_lost,arg1); + parm = cam->conf->on_camera_lost; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_camera_lost",_("on_camera_lost")); } -static void conf_edit_on_camera_found(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->on_camera_found,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->on_camera_found,NULL); +static void conf_edit_on_camera_found(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->on_camera_found = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->on_camera_found,arg1); + cam->conf->on_camera_found = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->on_camera_found,arg1); + parm = cam->conf->on_camera_found; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_camera_found",_("on_camera_found")); } -static void conf_edit_picture_output(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->picture_output,(char*)"off"); - } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf->picture_output,NULL); +static void conf_edit_picture_output(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->picture_output = "off"; } else if (pact == PARM_ACT_SET){ - if (arg1 == NULL){ - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid picture_output %s"),arg1); + if ((parm == "on") || (parm == "off") || + (parm == "first") || (parm == "best")) { + cam->conf->picture_output = parm; } else { - if (mystreq(arg1,"on") || mystreq(arg1,"off") || - mystreq(arg1,"first") || mystreq(arg1,"best")) { - conf_edit_set_string(&cam->conf->picture_output, arg1); - } else { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid picture_output %s"),arg1); - } + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid picture_output %s"), parm); } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->picture_output,arg1); + parm = cam->conf->picture_output; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_output",_("picture_output")); } -static void conf_edit_picture_output_motion(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_picture_output_motion(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf->picture_output_motion = FALSE; + cam->conf->picture_output_motion = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->picture_output_motion = TRUE; - } else { - cam->conf->picture_output_motion = FALSE; - } + conf_edit_set_bool(cam->conf->picture_output_motion, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->picture_output_motion, arg1); + conf_edit_get_bool(parm, cam->conf->picture_output_motion); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_output_motion",_("picture_output_motion")); } -static void conf_edit_picture_type(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->picture_type,(char*)"jpeg"); - } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf->picture_type,NULL); +static void conf_edit_picture_type(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->picture_type = "jpeg"; } else if (pact == PARM_ACT_SET){ - if (arg1 == NULL){ - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid picture_type %s"),arg1); + if ((parm == "jpeg") || (parm == "webp") || (parm == "ppm")) { + cam->conf->picture_type = parm; } else { - if (mystreq(arg1,"jpeg") || mystreq(arg1,"webp") || - mystreq(arg1,"ppm")) { - conf_edit_set_string(&cam->conf->picture_type, arg1); - } else { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid picture_type %s"),arg1); - } + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid picture_type %s"), parm); } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->picture_type,arg1); + parm = cam->conf->picture_type; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_type",_("picture_type")); } -static void conf_edit_picture_quality(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_picture_quality(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->picture_quality = 75; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 1) || (parm_in > 100)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid picture_quality %d"),parm_in); } else { cam->conf->picture_quality = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->picture_quality, arg1); + parm = std::to_string(cam->conf->picture_quality); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_quality",_("picture_quality")); } -static void conf_edit_picture_exif(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->picture_exif,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->picture_exif,NULL); +static void conf_edit_picture_exif(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->picture_exif = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->picture_exif,arg1); + cam->conf->picture_exif = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->picture_exif,arg1); + parm = cam->conf->picture_exif; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_exif",_("picture_exif")); } -static void conf_edit_picture_filename(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->picture_filename,(char*)"%v-%Y%m%d%H%M%S-%q"); - } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf->picture_filename,NULL); +static void conf_edit_picture_filename(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->picture_filename = "%v-%Y%m%d%H%M%S-%q"; } else if (pact == PARM_ACT_SET){ - if (arg1 != NULL){ - conf_edit_set_string(&cam->conf->picture_filename,arg1); - } + cam->conf->picture_filename = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->picture_filename,arg1); + parm = cam->conf->picture_filename; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_filename",_("picture_filename")); } -static void conf_edit_snapshot_interval(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_snapshot_interval(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->snapshot_interval = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 2147483647)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid snapshot_interval %d"),parm_in); } else { cam->conf->snapshot_interval = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->snapshot_interval, arg1); + parm = std::to_string(cam->conf->snapshot_interval); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","snapshot_interval",_("snapshot_interval")); } -static void conf_edit_snapshot_filename(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->snapshot_filename,(char*)"%v-%Y%m%d%H%M%S-snapshot"); - } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf->snapshot_filename,NULL); +static void conf_edit_snapshot_filename(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->snapshot_filename = "%v-%Y%m%d%H%M%S-snapshot"; } else if (pact == PARM_ACT_SET){ - if (arg1 != NULL){ - conf_edit_set_string(&cam->conf->snapshot_filename,arg1); - } + cam->conf->snapshot_filename = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->snapshot_filename,arg1); + parm = cam->conf->snapshot_filename; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","snapshot_filename",_("snapshot_filename")); } -static void conf_edit_movie_output(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_movie_output(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ cam->conf->movie_output = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->movie_output = TRUE; - } else { - cam->conf->movie_output = FALSE; - } + conf_edit_set_bool(cam->conf->movie_output, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->movie_output, arg1); + conf_edit_get_bool(parm, cam->conf->movie_output); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_output",_("movie_output")); } -static void conf_edit_movie_output_motion(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_movie_output_motion(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf->movie_output_motion = FALSE; + cam->conf->movie_output_motion = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->movie_output_motion = TRUE; - } else { - cam->conf->movie_output_motion = FALSE; - } + conf_edit_set_bool(cam->conf->movie_output_motion, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->movie_output_motion, arg1); + conf_edit_get_bool(parm, cam->conf->movie_output_motion); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_output_motion",_("movie_output_motion")); } -static void conf_edit_movie_max_time(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_movie_max_time(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->movie_max_time = 120; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 2147483647)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid movie_max_time %d"),parm_in); } else { cam->conf->movie_max_time = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->movie_max_time, arg1); + parm = std::to_string(cam->conf->movie_max_time); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_max_time",_("movie_max_time")); } -static void conf_edit_movie_bps(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_movie_bps(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->movie_bps = 400000; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 9999999)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid movie_bps %d"),parm_in); } else { cam->conf->movie_bps = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->movie_bps, arg1); + parm = std::to_string(cam->conf->movie_bps); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_bps",_("movie_bps")); } -static void conf_edit_movie_quality(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_movie_quality(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->movie_quality = 60; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 100)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid movie_quality %d"),parm_in); } else { cam->conf->movie_quality = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->movie_quality, arg1); + parm = std::to_string(cam->conf->movie_quality); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_quality",_("movie_quality")); } -static void conf_edit_movie_codec(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->movie_codec,(char*)"mkv"); - } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf->movie_codec,NULL); +static void conf_edit_movie_codec(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->movie_codec = "mkv"; } else if (pact == PARM_ACT_SET){ - if (arg1 != NULL){ - conf_edit_set_string(&cam->conf->movie_codec,arg1); - } + cam->conf->movie_codec = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->movie_codec,arg1); + parm = cam->conf->movie_codec; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_codec",_("movie_codec")); } -static void conf_edit_movie_passthrough(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_movie_passthrough(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf->movie_passthrough = FALSE; + cam->conf->movie_passthrough = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->movie_passthrough = TRUE; - } else { - cam->conf->movie_passthrough = FALSE; - } + conf_edit_set_bool(cam->conf->movie_passthrough, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->movie_passthrough, arg1); + conf_edit_get_bool(parm, cam->conf->movie_passthrough); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_passthrough",_("movie_passthrough")); } -static void conf_edit_movie_filename(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->movie_filename,(char*)"%v-%Y%m%d%H%M%S"); - } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf->movie_filename,NULL); +static void conf_edit_movie_filename(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->movie_filename = "%v-%Y%m%d%H%M%S"; } else if (pact == PARM_ACT_SET){ - if (arg1 != NULL){ - conf_edit_set_string(&cam->conf->movie_filename,arg1); - } + cam->conf->movie_filename = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->movie_filename,arg1); + parm = cam->conf->movie_filename; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_filename",_("movie_filename")); } -static void conf_edit_movie_extpipe_use(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_movie_extpipe_use(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf->movie_extpipe_use = FALSE; + cam->conf->movie_extpipe_use = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->movie_extpipe_use = TRUE; - } else { - cam->conf->movie_extpipe_use = FALSE; - } + conf_edit_set_bool(cam->conf->movie_extpipe_use, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->movie_extpipe_use, arg1); + conf_edit_get_bool(parm, cam->conf->movie_extpipe_use); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_extpipe_use",_("movie_extpipe_use")); } -static void conf_edit_movie_extpipe(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact){ - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->movie_extpipe,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->movie_extpipe,NULL); +static void conf_edit_movie_extpipe(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->movie_extpipe = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->movie_extpipe,arg1); + cam->conf->movie_extpipe = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->movie_extpipe,arg1); + parm = cam->conf->movie_extpipe; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_extpipe",_("movie_extpipe")); } -static void conf_edit_timelapse_interval(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_timelapse_interval(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->timelapse_interval = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 2147483647)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_interval %d"),parm_in); } else { cam->conf->timelapse_interval = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->timelapse_interval, arg1); + parm = std::to_string(cam->conf->timelapse_interval); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_interval",_("timelapse_interval")); } -static void conf_edit_timelapse_mode(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->timelapse_mode,(char*)"daily"); - } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf->timelapse_mode,NULL); +static void conf_edit_timelapse_mode(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->timelapse_mode = "daily"; } else if (pact == PARM_ACT_SET){ - if (arg1 == NULL){ - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_mode %s"),arg1); + if ((parm == "hourly") || (parm == "daily") || + (parm == "weekly-sunday") || (parm == "weekly-monday") || + (parm == "monthly") || (parm == "manual")) { + cam->conf->timelapse_mode = parm; } else { - if (mystreq(arg1,"hourly") || mystreq(arg1,"daily") || - mystreq(arg1,"weekly-sunday") || mystreq(arg1,"weekly-monday") || - mystreq(arg1,"monthly") || mystreq(arg1,"manual")) { - conf_edit_set_string(&cam->conf->timelapse_mode, arg1); - } else { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_mode %s"),arg1); - } + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_mode %s"), parm); } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->timelapse_mode,arg1); + parm = cam->conf->timelapse_mode; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_mode",_("timelapse_mode")); } -static void conf_edit_timelapse_fps(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_timelapse_fps(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->timelapse_fps = 30; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 2) || (parm_in > 1000)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_fps %d"),parm_in); } else { cam->conf->timelapse_fps = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->timelapse_fps, arg1); + parm = std::to_string(cam->conf->timelapse_fps); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_fps",_("timelapse_fps")); } -static void conf_edit_timelapse_codec(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->timelapse_codec,(char*)"mpg"); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->timelapse_codec,NULL); +static void conf_edit_timelapse_codec(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->timelapse_codec = "mpg"; } else if (pact == PARM_ACT_SET){ - if (arg1 == NULL){ - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_codec %s"),arg1); + if ((parm == "mpg") || (parm == "mpeg4")) { + cam->conf->timelapse_codec = parm; } else { - if (mystreq(arg1,"mpg") || mystreq(arg1,"mpeg4")) { - conf_edit_set_string(&cam->conf->timelapse_codec, arg1); - } else { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_codec %s"),arg1); - } + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_codec %s"), parm); } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->timelapse_codec,arg1); + parm = cam->conf->timelapse_codec; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_codec",_("timelapse_codec")); } -static void conf_edit_timelapse_filename(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->timelapse_filename,(char*)"%Y%m%d-timelapse"); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->timelapse_filename,NULL); +static void conf_edit_timelapse_filename(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->timelapse_filename = "%Y%m%d-timelapse"; } else if (pact == PARM_ACT_SET){ - if (arg1 != NULL){ - conf_edit_set_string(&cam->conf->timelapse_filename,arg1); - } + cam->conf->timelapse_filename = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->timelapse_filename,arg1); + parm = cam->conf->timelapse_filename; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_filename",_("timelapse_filename")); } -static void conf_edit_video_pipe(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->video_pipe,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->video_pipe,NULL); +static void conf_edit_video_pipe(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->video_pipe = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->video_pipe,arg1); + cam->conf->video_pipe = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->video_pipe,arg1); + parm = cam->conf->video_pipe; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","video_pipe",_("video_pipe")); } -static void conf_edit_video_pipe_motion(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->video_pipe_motion,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->video_pipe_motion,NULL); +static void conf_edit_video_pipe_motion(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->video_pipe_motion = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->video_pipe_motion,arg1); + cam->conf->video_pipe_motion = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->video_pipe_motion,arg1); + parm = cam->conf->video_pipe_motion; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","video_pipe_motion",_("video_pipe_motion")); } -static void conf_edit_webcontrol_port(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_webcontrol_port(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->webcontrol_port = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 65535)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid webcontrol_port %d"),parm_in); } else { cam->conf->webcontrol_port = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->webcontrol_port, arg1); + parm = std::to_string(cam->conf->webcontrol_port); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_port",_("webcontrol_port")); } -static void conf_edit_webcontrol_ipv6(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_webcontrol_ipv6(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf->webcontrol_ipv6 = FALSE; + cam->conf->webcontrol_ipv6 = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->webcontrol_ipv6 = TRUE; - } else { - cam->conf->webcontrol_ipv6 = FALSE; - } + conf_edit_set_bool(cam->conf->webcontrol_ipv6, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->webcontrol_ipv6, arg1); + conf_edit_get_bool(parm, cam->conf->webcontrol_ipv6); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_ipv6",_("webcontrol_ipv6")); } -static void conf_edit_webcontrol_localhost(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_webcontrol_localhost(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ cam->conf->webcontrol_localhost = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->webcontrol_localhost = TRUE; - } else { - cam->conf->webcontrol_localhost = FALSE; - } + conf_edit_set_bool(cam->conf->webcontrol_localhost, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->webcontrol_localhost, arg1); + conf_edit_get_bool(parm, cam->conf->webcontrol_localhost); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_localhost",_("webcontrol_localhost")); } -static void conf_edit_webcontrol_parms(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_webcontrol_parms(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->webcontrol_parms = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 3)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid webcontrol_parms %d"),parm_in); } else { cam->conf->webcontrol_parms = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->webcontrol_parms, arg1); + parm = std::to_string(cam->conf->webcontrol_parms); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_parms",_("webcontrol_parms")); } -static void conf_edit_webcontrol_interface(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_webcontrol_interface(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->webcontrol_interface = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 2)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid webcontrol_interface %d"),parm_in); } else { cam->conf->webcontrol_interface = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->webcontrol_interface, arg1); + parm = std::to_string(cam->conf->webcontrol_interface); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_interface",_("webcontrol_interface")); } -static void conf_edit_webcontrol_auth_method(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_webcontrol_auth_method(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->webcontrol_auth_method = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 2)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid webcontrol_auth_method %d"),parm_in); } else { cam->conf->webcontrol_auth_method = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->webcontrol_auth_method, arg1); + parm = std::to_string(cam->conf->webcontrol_auth_method); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_auth_method",_("webcontrol_auth_method")); } -static void conf_edit_webcontrol_authentication(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->webcontrol_authentication,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->webcontrol_authentication,NULL); +static void conf_edit_webcontrol_authentication(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->webcontrol_authentication = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->webcontrol_authentication,arg1); + cam->conf->webcontrol_authentication = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->webcontrol_authentication,arg1); + parm = cam->conf->webcontrol_authentication; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_authentication",_("webcontrol_authentication")); } -static void conf_edit_webcontrol_tls(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_webcontrol_tls(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf->webcontrol_tls = FALSE; + cam->conf->webcontrol_tls = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->webcontrol_tls = TRUE; - } else { - cam->conf->webcontrol_tls = FALSE; - } + conf_edit_set_bool(cam->conf->webcontrol_tls, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->webcontrol_tls, arg1); + conf_edit_get_bool(parm, cam->conf->webcontrol_tls); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_tls",_("webcontrol_tls")); } -static void conf_edit_webcontrol_cert(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->webcontrol_cert,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->webcontrol_cert,NULL); +static void conf_edit_webcontrol_cert(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->webcontrol_cert = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->webcontrol_cert,arg1); + cam->conf->webcontrol_cert = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->webcontrol_cert,arg1); + parm = cam->conf->webcontrol_cert; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_cert",_("webcontrol_cert")); } -static void conf_edit_webcontrol_key(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->webcontrol_key,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->webcontrol_key,NULL); +static void conf_edit_webcontrol_key(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->webcontrol_key = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->webcontrol_key,arg1); + cam->conf->webcontrol_key = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->webcontrol_key,arg1); + parm = cam->conf->webcontrol_key; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_key",_("webcontrol_key")); } -static void conf_edit_webcontrol_cors_header(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->webcontrol_cors_header,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->webcontrol_cors_header,NULL); +static void conf_edit_webcontrol_cors_header(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + int retcd; + if (pact == PARM_ACT_DFLT) { + cam->conf->webcontrol_cors_header = ""; } else if (pact == PARM_ACT_SET){ // A complicated regex to validate a url found here: // https://stackoverflow.com/questions/38608116/how-to-check-a-specified-string-is-a-valid-url-or-not-using-c-code @@ -1922,103 +1671,91 @@ static void conf_edit_webcontrol_cors_header(struct ctx_cam *cam, char *arg1, en MOTION_LOG(ERR, TYPE_STREAM, NO_ERRNO,_("Error compiling regex in copy_uri")); return; } - // A single asterisk is also valid - if (mystrne(arg1, "*") && regexec(®ex, arg1, 0, NULL, 0) == REG_NOMATCH) { + retcd = regexec(®ex, parm.c_str(), 0, NULL, 0); + if ((parm != "*") && (retcd == REG_NOMATCH)) { MOTION_LOG(ERR, TYPE_STREAM, NO_ERRNO,_("Invalid origin for cors_header")); - regfree(®ex); - return; + } else { + cam->conf->webcontrol_cors_header = parm; } regfree(®ex); - conf_edit_set_string(&cam->conf->webcontrol_cors_header,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->webcontrol_cors_header,arg1); + parm = cam->conf->webcontrol_cors_header; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_cors_header",_("webcontrol_cors_header")); } -static void conf_edit_stream_port(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_stream_port(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->stream_port = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 65535)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid stream_port %d"),parm_in); } else { cam->conf->stream_port = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->stream_port, arg1); + parm = std::to_string(cam->conf->stream_port); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_port",_("stream_port")); } -static void conf_edit_stream_localhost(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_stream_localhost(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ cam->conf->stream_localhost = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->stream_localhost = TRUE; - } else { - cam->conf->stream_localhost = FALSE; - } + conf_edit_set_bool(cam->conf->stream_localhost, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->stream_localhost, arg1); + conf_edit_get_bool(parm, cam->conf->stream_localhost); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_localhost",_("stream_localhost")); } -static void conf_edit_stream_auth_method(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_stream_auth_method(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->stream_auth_method = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 2)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid stream_auth_method %d"),parm_in); } else { cam->conf->stream_auth_method = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->stream_auth_method, arg1); + parm = std::to_string(cam->conf->stream_auth_method); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_auth_method",_("stream_auth_method")); } -static void conf_edit_stream_authentication(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->stream_authentication,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->stream_authentication,NULL); +static void conf_edit_stream_authentication(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->stream_authentication = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->stream_authentication,arg1); + cam->conf->stream_authentication = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->stream_authentication,arg1); + parm = cam->conf->stream_authentication; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_authentication",_("stream_authentication")); } -static void conf_edit_stream_tls(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_stream_tls(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf->stream_tls = FALSE; + cam->conf->stream_tls = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->stream_tls = TRUE; - } else { - cam->conf->stream_tls = FALSE; - } + conf_edit_set_bool(cam->conf->stream_tls, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->stream_tls, arg1); + conf_edit_get_bool(parm, cam->conf->stream_tls); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_tls",_("stream_tls")); } -static void conf_edit_stream_cors_header(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->stream_cors_header,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->stream_cors_header,NULL); +static void conf_edit_stream_cors_header(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + int retcd; + if (pact == PARM_ACT_DFLT) { + cam->conf->stream_cors_header = ""; } else if (pact == PARM_ACT_SET){ // A complicated regex to validate a url found here: // https://stackoverflow.com/questions/38608116/how-to-check-a-specified-string-is-a-valid-url-or-not-using-c-code @@ -2028,703 +1765,628 @@ static void conf_edit_stream_cors_header(struct ctx_cam *cam, char *arg1, enum P MOTION_LOG(ERR, TYPE_STREAM, NO_ERRNO,_("Error compiling regex in copy_uri")); return; } - // A single asterisk is also valid - if (mystrne(arg1, "*") && regexec(®ex, arg1, 0, NULL, 0) == REG_NOMATCH) { + retcd = regexec(®ex, parm.c_str(), 0, NULL, 0); + if ((parm != "*") && (retcd == REG_NOMATCH)) { MOTION_LOG(ERR, TYPE_STREAM, NO_ERRNO,_("Invalid origin for cors_header")); - regfree(®ex); - return; + } else { + cam->conf->stream_cors_header = parm; } regfree(®ex); - conf_edit_set_string(&cam->conf->stream_cors_header,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->stream_cors_header,arg1); + parm = cam->conf->stream_cors_header; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_cors_header",_("stream_cors_header")); } -static void conf_edit_stream_preview_scale(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_stream_preview_scale(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->stream_preview_scale = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 1) || (parm_in > 1000)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid stream_preview_scale %d"),parm_in); } else { cam->conf->stream_preview_scale = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->stream_preview_scale, arg1); + parm = std::to_string(cam->conf->stream_preview_scale); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_preview_scale",_("stream_preview_scale")); } -static void conf_edit_stream_preview_newline(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_stream_preview_newline(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf->stream_preview_newline = FALSE; + cam->conf->stream_preview_newline = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->stream_preview_newline = TRUE; - } else { - cam->conf->stream_preview_newline = FALSE; - } + conf_edit_set_bool(cam->conf->stream_preview_newline, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->stream_preview_newline, arg1); + conf_edit_get_bool(parm, cam->conf->stream_preview_newline); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_preview_newline",_("stream_preview_newline")); } -static void conf_edit_stream_preview_method(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_stream_preview_method(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->stream_preview_method = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 4)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid stream_preview_method %d"),parm_in); } else { cam->conf->stream_preview_method = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->stream_preview_method, arg1); + parm = std::to_string(cam->conf->stream_preview_method); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_preview_method",_("stream_preview_method")); } -static void conf_edit_stream_quality(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_stream_quality(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->stream_quality = 50; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 1) || (parm_in > 100)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid stream_quality %d"),parm_in); } else { cam->conf->stream_quality = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->stream_quality, arg1); + parm = std::to_string(cam->conf->stream_quality); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_quality",_("stream_quality")); } -static void conf_edit_stream_grey(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_stream_grey(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ cam->conf->stream_grey = FALSE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->stream_grey = TRUE; - } else { - cam->conf->stream_grey = FALSE; - } + conf_edit_set_bool(cam->conf->stream_grey, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->stream_grey, arg1); + conf_edit_get_bool(parm, cam->conf->stream_grey); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_grey",_("stream_grey")); } -static void conf_edit_stream_motion(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_stream_motion(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ cam->conf->stream_motion = FALSE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->stream_motion = TRUE; - } else { - cam->conf->stream_motion = FALSE; - } + conf_edit_set_bool(cam->conf->stream_motion, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->stream_motion, arg1); + conf_edit_get_bool(parm, cam->conf->stream_motion); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_motion",_("stream_motion")); } -static void conf_edit_stream_maxrate(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_stream_maxrate(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->stream_maxrate = 1; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 1) || (parm_in > 100)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid stream_maxrate %d"),parm_in); } else { cam->conf->stream_maxrate = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->stream_maxrate, arg1); + parm = std::to_string(cam->conf->stream_maxrate); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_maxrate",_("stream_maxrate")); } -static void conf_edit_database_type(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->database_type,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->database_type,NULL); +static void conf_edit_database_type(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->database_type = ""; } else if (pact == PARM_ACT_SET){ - if (arg1 == NULL){ - conf_edit_set_string(&cam->conf->database_type, NULL); + if ((parm == "mysql") || (parm == "mariadb") || + (parm == "postgresql") || (parm == "sqlite3")) { + cam->conf->database_type = parm; } else { - if (mystreq(arg1,"mysql") || mystreq(arg1,"mariadb") || - mystreq(arg1,"postgresql") || mystreq(arg1,"sqlite3")) { - conf_edit_set_string(&cam->conf->database_type, arg1); - } else { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid database_type %s"),arg1); - } + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid database_type %s"), parm); } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->database_type,arg1); + parm = cam->conf->database_type; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_type",_("database_type")); } -static void conf_edit_database_dbname(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->database_dbname,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->database_dbname,NULL); +static void conf_edit_database_dbname(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->database_dbname = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->database_dbname,arg1); + cam->conf->database_dbname = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->database_dbname,arg1); + parm = cam->conf->database_dbname; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_dbname",_("database_dbname")); } -static void conf_edit_database_host(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->database_host,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->database_host,NULL); +static void conf_edit_database_host(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->database_host = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->database_host,arg1); + cam->conf->database_host = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->database_host,arg1); + parm = cam->conf->database_host; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_host",_("database_host")); } -static void conf_edit_database_port(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_database_port(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->database_port = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 65535)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid database_port %d"),parm_in); } else { cam->conf->database_port = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->database_port, arg1); + parm = std::to_string(cam->conf->database_port); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_port",_("database_port")); } -static void conf_edit_database_user(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->database_user,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->database_user,NULL); +static void conf_edit_database_user(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->database_user = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->database_user,arg1); + cam->conf->database_user = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->database_user,arg1); + parm = cam->conf->database_user; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_user",_("database_user")); } -static void conf_edit_database_password(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->database_password,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->database_password,NULL); +static void conf_edit_database_password(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->database_password = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->database_password,arg1); + cam->conf->database_password = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->database_password,arg1); + parm = cam->conf->database_password; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_password",_("database_password")); } -static void conf_edit_database_busy_timeout(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_database_busy_timeout(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->database_busy_timeout = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 10000)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid database_busy_timeout %d"),parm_in); } else { cam->conf->database_busy_timeout = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->database_busy_timeout, arg1); + parm = std::to_string(cam->conf->database_busy_timeout); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_busy_timeout",_("database_busy_timeout")); } -static void conf_edit_sql_log_picture(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_sql_log_picture(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ cam->conf->sql_log_picture = FALSE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->sql_log_picture = TRUE; - } else { - cam->conf->sql_log_picture = FALSE; - } + conf_edit_set_bool(cam->conf->sql_log_picture, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->sql_log_picture, arg1); + conf_edit_get_bool(parm, cam->conf->sql_log_picture); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_log_picture",_("sql_log_picture")); } -static void conf_edit_sql_log_snapshot(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_sql_log_snapshot(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf->sql_log_snapshot = FALSE; + cam->conf->sql_log_snapshot = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->sql_log_snapshot = TRUE; - } else { - cam->conf->sql_log_snapshot = FALSE; - } + conf_edit_set_bool(cam->conf->sql_log_snapshot, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->sql_log_snapshot, arg1); + conf_edit_get_bool(parm, cam->conf->sql_log_snapshot); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_log_snapshot",_("sql_log_snapshot")); } -static void conf_edit_sql_log_movie(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_sql_log_movie(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf->sql_log_movie = FALSE; + cam->conf->sql_log_movie = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->sql_log_movie = TRUE; - } else { - cam->conf->sql_log_movie = FALSE; - } + conf_edit_set_bool(cam->conf->sql_log_movie, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->sql_log_movie, arg1); + conf_edit_get_bool(parm, cam->conf->sql_log_movie); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_log_movie",_("sql_log_movie")); } -static void conf_edit_sql_log_timelapse(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_sql_log_timelapse(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf->sql_log_timelapse = FALSE; + cam->conf->sql_log_timelapse = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->sql_log_timelapse = TRUE; - } else { - cam->conf->sql_log_timelapse = FALSE; - } + conf_edit_set_bool(cam->conf->sql_log_timelapse, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->sql_log_timelapse, arg1); + conf_edit_get_bool(parm, cam->conf->sql_log_timelapse); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_log_timelapse",_("sql_log_timelapse")); } -static void conf_edit_sql_query_start(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->sql_query_start,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->sql_query_start,NULL); +static void conf_edit_sql_query_start(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->sql_query_start = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->sql_query_start,arg1); + cam->conf->sql_query_start = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->sql_query_start,arg1); + parm = cam->conf->sql_query_start; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_query_start",_("sql_query_start")); } -static void conf_edit_sql_query_stop(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->sql_query_stop,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->sql_query_stop,NULL); +static void conf_edit_sql_query_stop(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->sql_query_stop = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->sql_query_stop,arg1); + cam->conf->sql_query_stop = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->sql_query_stop,arg1); + parm = cam->conf->sql_query_stop; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_query_stop",_("sql_query_stop")); } -static void conf_edit_sql_query(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->sql_query,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->sql_query,NULL); +static void conf_edit_sql_query(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->sql_query = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->sql_query,arg1); + cam->conf->sql_query = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->sql_query,arg1); + parm = cam->conf->sql_query; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_query",_("sql_query")); } -static void conf_edit_track_type(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_track_type(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->track_type = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 5)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid track_type %d"),parm_in); } else { cam->conf->track_type = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->track_type, arg1); + parm = std::to_string(cam->conf->track_type); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_type",_("track_type")); } -static void conf_edit_track_auto(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_track_auto(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf->track_auto = FALSE; + cam->conf->track_auto = TRUE; } else if (pact == PARM_ACT_SET){ - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf->track_auto = TRUE; - } else { - cam->conf->track_auto = FALSE; - } + conf_edit_set_bool(cam->conf->track_auto, parm); } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf->track_auto, arg1); + conf_edit_get_bool(parm, cam->conf->track_auto); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_auto",_("track_auto")); } -static void conf_edit_track_move_wait(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_track_move_wait(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->track_move_wait = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 2147483647)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid track_move_wait %d"),parm_in); } else { cam->conf->track_move_wait = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->track_move_wait, arg1); + parm = std::to_string(cam->conf->track_move_wait); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_move_wait",_("track_move_wait")); } -static void conf_edit_track_generic_move(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { - if (pact == PARM_ACT_DFLT){ - conf_edit_set_string(&cam->conf->track_generic_move,NULL); - } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf->track_generic_move,NULL); +static void conf_edit_track_generic_move(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT) { + cam->conf->track_generic_move = ""; } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf->track_generic_move,arg1); + cam->conf->track_generic_move = parm; } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf->track_generic_move,arg1); + parm = cam->conf->track_generic_move; } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_generic_move",_("track_generic_move")); } -static void conf_edit_track_step_angle_x(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_track_step_angle_x(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->track_step_angle_x = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 2147483647)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid track_step_angle_x %d"),parm_in); } else { cam->conf->track_step_angle_x = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->track_step_angle_x, arg1); + parm = std::to_string(cam->conf->track_step_angle_x); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_step_angle_x",_("track_step_angle_x")); } -static void conf_edit_track_step_angle_y(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { +static void conf_edit_track_step_angle_y(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ cam->conf->track_step_angle_y = 0; } else if (pact == PARM_ACT_SET){ - parm_in = atoi(arg1); + parm_in = atoi(parm.c_str()); if ((parm_in < 0) || (parm_in > 2147483647)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid track_step_angle_y %d"),parm_in); } else { cam->conf->track_step_angle_y = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf->track_step_angle_y, arg1); + parm = std::to_string(cam->conf->track_step_angle_y); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_step_angle_y",_("track_step_angle_y")); } -static void conf_edit_cat00(struct ctx_motapp *motapp, const char *cmd, char *arg1, enum PARM_ACT pact) { - if (mystreq(cmd,"daemon") ){ conf_edit_daemon(motapp, arg1, pact); - } else if (mystreq(cmd,"conf_filename")){ conf_edit_conf_filename(motapp, arg1, pact); - } else if (mystreq(cmd,"setup_mode")) { conf_edit_setup_mode(motapp, arg1, pact); - } else if (mystreq(cmd,"pid_file")){ conf_edit_pid_file(motapp, arg1, pact); - } else if (mystreq(cmd,"log_file")){ conf_edit_log_file(motapp, arg1, pact); - } else if (mystreq(cmd,"log_level")){ conf_edit_log_level(motapp, arg1, pact); - } else if (mystreq(cmd,"log_type")){ conf_edit_log_type(motapp, arg1, pact); - } else if (mystreq(cmd,"native_language")){ conf_edit_native_language(motapp, arg1, pact); +static void conf_edit_cat00(struct ctx_motapp *motapp, std::string cmd, std::string &parm_val, enum PARM_ACT pact) { + + if (cmd == "daemon") { conf_edit_daemon(motapp, parm_val, pact); + } else if (cmd == "conf_filename"){ conf_edit_conf_filename(motapp, parm_val, pact); + } else if (cmd == "setup_mode") { conf_edit_setup_mode(motapp, parm_val, pact); + } else if (cmd == "pid_file"){ conf_edit_pid_file(motapp, parm_val, pact); + } else if (cmd == "log_file"){ conf_edit_log_file(motapp, parm_val, pact); + } else if (cmd == "log_level"){ conf_edit_log_level(motapp, parm_val, pact); + } else if (cmd == "log_type"){ conf_edit_log_type(motapp, parm_val, pact); + } else if (cmd == "native_language"){ conf_edit_native_language(motapp, parm_val, pact); } } -static void conf_edit_cat01(struct ctx_cam *cam, const char *cmd, char *arg1, enum PARM_ACT pact) { +static void conf_edit_cat01(struct ctx_cam *cam, std::string parm_nm, std::string &parm_val, enum PARM_ACT pact) { - if (mystreq(cmd,"quiet")){ conf_edit_quiet(cam, arg1, pact); - } else if (mystreq(cmd,"camera_dir")){ conf_edit_camera_dir(cam, arg1, pact); - } else if (mystreq(cmd,"camera_name")){ conf_edit_camera_name(cam, arg1, pact); - } else if (mystreq(cmd,"camera_id")){ conf_edit_camera_id(cam, arg1, pact); - } else if (mystreq(cmd,"target_dir")){ conf_edit_target_dir(cam, arg1, pact); - } else if (mystreq(cmd,"videodevice") ){ conf_edit_videodevice(cam, arg1, pact); - } else if (mystreq(cmd,"vid_control_params")) { conf_edit_vid_control_params(cam, arg1, pact); - } else if (mystreq(cmd,"v4l2_palette")){ conf_edit_v4l2_palette(cam, arg1, pact); - } else if (mystreq(cmd,"input")){ conf_edit_input(cam, arg1, pact); - } else if (mystreq(cmd,"norm")){ conf_edit_norm(cam, arg1, pact); - } else if (mystreq(cmd,"frequency")){ conf_edit_frequency(cam, arg1, pact); - } else if (mystreq(cmd,"tuner_device")){ conf_edit_tuner_device(cam, arg1, pact); - } else if (mystreq(cmd,"roundrobin_frames")){ conf_edit_roundrobin_frames(cam, arg1, pact); - } else if (mystreq(cmd,"roundrobin_skip")){ conf_edit_roundrobin_skip(cam, arg1, pact); - } else if (mystreq(cmd,"roundrobin_switchfilter")){ conf_edit_roundrobin_switchfilter(cam, arg1, pact); - } else if (mystreq(cmd,"netcam_url")){ conf_edit_netcam_url(cam, arg1, pact); - } else if (mystreq(cmd,"netcam_highres")){ conf_edit_netcam_highres(cam, arg1, pact); - } else if (mystreq(cmd,"netcam_userpass")){ conf_edit_netcam_userpass(cam, arg1, pact); - } else if (mystreq(cmd,"netcam_use_tcp")){ conf_edit_netcam_use_tcp(cam, arg1, pact); - } else if (mystreq(cmd,"mmalcam_name")){ conf_edit_mmalcam_name(cam, arg1, pact); - } else if (mystreq(cmd,"mmalcam_control_params")){ conf_edit_mmalcam_control_params(cam, arg1, pact); + if (parm_nm == "quiet"){ conf_edit_quiet(cam, parm_val, pact); + } else if (parm_nm == "camera_dir"){ conf_edit_camera_dir(cam, parm_val, pact); + } else if (parm_nm == "camera_name"){ conf_edit_camera_name(cam, parm_val, pact); + } else if (parm_nm == "camera_id"){ conf_edit_camera_id(cam, parm_val, pact); + } else if (parm_nm == "target_dir"){ conf_edit_target_dir(cam, parm_val, pact); + } else if (parm_nm == "videodevice"){ conf_edit_videodevice(cam, parm_val, pact); + } else if (parm_nm == "vid_control_params"){ conf_edit_vid_control_params(cam, parm_val, pact); + } else if (parm_nm == "v4l2_palette"){ conf_edit_v4l2_palette(cam, parm_val, pact); + } else if (parm_nm == "input"){ conf_edit_input(cam, parm_val, pact); + } else if (parm_nm == "norm"){ conf_edit_norm(cam, parm_val, pact); + } else if (parm_nm == "frequency"){ conf_edit_frequency(cam, parm_val, pact); + } else if (parm_nm == "tuner_device"){ conf_edit_tuner_device(cam, parm_val, pact); + } else if (parm_nm == "roundrobin_frames"){ conf_edit_roundrobin_frames(cam, parm_val, pact); + } else if (parm_nm == "roundrobin_skip"){ conf_edit_roundrobin_skip(cam, parm_val, pact); + } else if (parm_nm == "roundrobin_switchfilter"){ conf_edit_roundrobin_switchfilter(cam, parm_val, pact); + } else if (parm_nm == "netcam_url"){ conf_edit_netcam_url(cam, parm_val, pact); + } else if (parm_nm == "netcam_highres"){ conf_edit_netcam_highres(cam, parm_val, pact); + } else if (parm_nm == "netcam_userpass"){ conf_edit_netcam_userpass(cam, parm_val, pact); + } else if (parm_nm == "netcam_use_tcp"){ conf_edit_netcam_use_tcp(cam, parm_val, pact); + } else if (parm_nm == "mmalcam_name"){ conf_edit_mmalcam_name(cam, parm_val, pact); + } else if (parm_nm == "mmalcam_control_params"){conf_edit_mmalcam_control_params(cam, parm_val, pact); } } -static void conf_edit_cat02(struct ctx_cam *cam, const char *cmd, char *arg1, enum PARM_ACT pact) { +static void conf_edit_cat02(struct ctx_cam *cam, std::string parm_nm, std::string &parm_val, enum PARM_ACT pact) { - if (mystreq(cmd,"width")){ conf_edit_width(cam, arg1, pact); - } else if (mystreq(cmd,"height")){ conf_edit_height(cam, arg1, pact); - } else if (mystreq(cmd,"framerate")){ conf_edit_framerate(cam, arg1, pact); - } else if (mystreq(cmd,"minimum_frame_time")){ conf_edit_minimum_frame_time(cam, arg1, pact); - } else if (mystreq(cmd,"rotate")){ conf_edit_rotate(cam, arg1, pact); - } else if (mystreq(cmd,"flip_axis")){ conf_edit_flip_axis(cam, arg1, pact); - } else if (mystreq(cmd,"locate_motion_mode")){ conf_edit_locate_motion_mode(cam, arg1, pact); - } else if (mystreq(cmd,"locate_motion_style")){ conf_edit_locate_motion_style(cam, arg1, pact); - } else if (mystreq(cmd,"text_left")){ conf_edit_text_left(cam, arg1, pact); - } else if (mystreq(cmd,"text_right")){ conf_edit_text_right(cam, arg1, pact); - } else if (mystreq(cmd,"text_changes")){ conf_edit_text_changes(cam, arg1, pact); - } else if (mystreq(cmd,"text_scale")){ conf_edit_text_scale(cam, arg1, pact); - } else if (mystreq(cmd,"text_event")){ conf_edit_text_event(cam, arg1, pact); - } else if (mystreq(cmd,"emulate_motion")){ conf_edit_emulate_motion(cam, arg1, pact); - } else if (mystreq(cmd,"primary_method")){ conf_edit_primary_method(cam, arg1, pact); - } else if (mystreq(cmd,"threshold")){ conf_edit_threshold(cam, arg1, pact); - } else if (mystreq(cmd,"threshold_maximum")){ conf_edit_threshold_maximum(cam, arg1, pact); - } else if (mystreq(cmd,"threshold_sdevx")){ conf_edit_threshold_sdevx(cam, arg1, pact); - } else if (mystreq(cmd,"threshold_sdevy")){ conf_edit_threshold_sdevy(cam, arg1, pact); - } else if (mystreq(cmd,"threshold_sdevxy")){ conf_edit_threshold_sdevxy(cam, arg1, pact); - } else if (mystreq(cmd,"threshold_tune")){ conf_edit_threshold_tune(cam, arg1, pact); - } else if (mystreq(cmd,"secondary_interval")){ conf_edit_secondary_interval(cam, arg1, pact); - } else if (mystreq(cmd,"secondary_method")){ conf_edit_secondary_method(cam, arg1, pact); - } else if (mystreq(cmd,"secondary_model")){ conf_edit_secondary_model(cam, arg1, pact); - } else if (mystreq(cmd,"secondary_config")){ conf_edit_secondary_config(cam, arg1, pact); - } else if (mystreq(cmd,"secondary_method2")){ conf_edit_secondary_method2(cam, arg1, pact); - } else if (mystreq(cmd,"secondary_model2")){ conf_edit_secondary_model2(cam, arg1, pact); - } else if (mystreq(cmd,"secondary_config2")){ conf_edit_secondary_config2(cam, arg1, pact); - } else if (mystreq(cmd,"secondary_method3")){ conf_edit_secondary_method3(cam, arg1, pact); - } else if (mystreq(cmd,"secondary_model3")){ conf_edit_secondary_model3(cam, arg1, pact); - } else if (mystreq(cmd,"secondary_config3")){ conf_edit_secondary_config3(cam, arg1, pact); - } else if (mystreq(cmd,"noise_level")){ conf_edit_noise_level(cam, arg1, pact); - } else if (mystreq(cmd,"noise_tune")){ conf_edit_noise_tune(cam, arg1, pact); - } else if (mystreq(cmd,"despeckle_filter")){ conf_edit_despeckle_filter(cam, arg1, pact); - } else if (mystreq(cmd,"area_detect")){ conf_edit_area_detect(cam, arg1, pact); - } else if (mystreq(cmd,"mask_file")){ conf_edit_mask_file(cam, arg1, pact); - } else if (mystreq(cmd,"mask_privacy")){ conf_edit_mask_privacy(cam, arg1, pact); - } else if (mystreq(cmd,"smart_mask_speed")){ conf_edit_smart_mask_speed(cam, arg1, pact); - } else if (mystreq(cmd,"lightswitch_percent")){ conf_edit_lightswitch_percent(cam, arg1, pact); - } else if (mystreq(cmd,"lightswitch_frames")){ conf_edit_lightswitch_frames(cam, arg1, pact); - } else if (mystreq(cmd,"minimum_motion_frames")){ conf_edit_minimum_motion_frames(cam, arg1, pact); - } else if (mystreq(cmd,"event_gap")){ conf_edit_event_gap(cam, arg1, pact); - } else if (mystreq(cmd,"pre_capture")){ conf_edit_pre_capture(cam, arg1, pact); - } else if (mystreq(cmd,"post_capture")){ conf_edit_post_capture(cam, arg1, pact); + if (parm_nm == "width"){ conf_edit_width(cam, parm_val, pact); + } else if (parm_nm == "height"){ conf_edit_height(cam, parm_val, pact); + } else if (parm_nm == "framerate"){ conf_edit_framerate(cam, parm_val, pact); + } else if (parm_nm == "minimum_frame_time"){ conf_edit_minimum_frame_time(cam, parm_val, pact); + } else if (parm_nm == "rotate"){ conf_edit_rotate(cam, parm_val, pact); + } else if (parm_nm == "flip_axis"){ conf_edit_flip_axis(cam, parm_val, pact); + } else if (parm_nm == "locate_motion_mode"){ conf_edit_locate_motion_mode(cam, parm_val, pact); + } else if (parm_nm == "locate_motion_style"){ conf_edit_locate_motion_style(cam, parm_val, pact); + } else if (parm_nm == "text_left"){ conf_edit_text_left(cam, parm_val, pact); + } else if (parm_nm == "text_right"){ conf_edit_text_right(cam, parm_val, pact); + } else if (parm_nm == "text_changes"){ conf_edit_text_changes(cam, parm_val, pact); + } else if (parm_nm == "text_scale"){ conf_edit_text_scale(cam, parm_val, pact); + } else if (parm_nm == "text_event"){ conf_edit_text_event(cam, parm_val, pact); + } else if (parm_nm == "emulate_motion"){ conf_edit_emulate_motion(cam, parm_val, pact); + } else if (parm_nm == "primary_method"){ conf_edit_primary_method(cam, parm_val, pact); + } else if (parm_nm == "threshold"){ conf_edit_threshold(cam, parm_val, pact); + } else if (parm_nm == "threshold_maximum"){ conf_edit_threshold_maximum(cam, parm_val, pact); + } else if (parm_nm == "threshold_sdevx"){ conf_edit_threshold_sdevx(cam, parm_val, pact); + } else if (parm_nm == "threshold_sdevy"){ conf_edit_threshold_sdevy(cam, parm_val, pact); + } else if (parm_nm == "threshold_sdevxy"){ conf_edit_threshold_sdevxy(cam, parm_val, pact); + } else if (parm_nm == "threshold_tune"){ conf_edit_threshold_tune(cam, parm_val, pact); + } else if (parm_nm == "secondary_interval"){ conf_edit_secondary_interval(cam, parm_val, pact); + } else if (parm_nm == "secondary_method"){ conf_edit_secondary_method(cam, parm_val, pact); + } else if (parm_nm == "secondary_model"){ conf_edit_secondary_model(cam, parm_val, pact); + } else if (parm_nm == "secondary_config"){ conf_edit_secondary_config(cam, parm_val, pact); + } else if (parm_nm == "secondary_method2"){ conf_edit_secondary_method2(cam, parm_val, pact); + } else if (parm_nm == "secondary_model2"){ conf_edit_secondary_model2(cam, parm_val, pact); + } else if (parm_nm == "secondary_config2"){ conf_edit_secondary_config2(cam, parm_val, pact); + } else if (parm_nm == "secondary_method3"){ conf_edit_secondary_method3(cam, parm_val, pact); + } else if (parm_nm == "secondary_model3"){ conf_edit_secondary_model3(cam, parm_val, pact); + } else if (parm_nm == "secondary_config3"){ conf_edit_secondary_config3(cam, parm_val, pact); + } else if (parm_nm == "noise_level"){ conf_edit_noise_level(cam, parm_val, pact); + } else if (parm_nm == "noise_tune"){ conf_edit_noise_tune(cam, parm_val, pact); + } else if (parm_nm == "despeckle_filter"){ conf_edit_despeckle_filter(cam, parm_val, pact); + } else if (parm_nm == "area_detect"){ conf_edit_area_detect(cam, parm_val, pact); + } else if (parm_nm == "mask_file"){ conf_edit_mask_file(cam, parm_val, pact); + } else if (parm_nm == "mask_privacy"){ conf_edit_mask_privacy(cam, parm_val, pact); + } else if (parm_nm == "smart_mask_speed"){ conf_edit_smart_mask_speed(cam, parm_val, pact); + } else if (parm_nm == "lightswitch_percent"){ conf_edit_lightswitch_percent(cam, parm_val, pact); + } else if (parm_nm == "lightswitch_frames"){ conf_edit_lightswitch_frames(cam, parm_val, pact); + } else if (parm_nm == "minimum_motion_frames"){ conf_edit_minimum_motion_frames(cam, parm_val, pact); + } else if (parm_nm == "event_gap"){ conf_edit_event_gap(cam, parm_val, pact); + } else if (parm_nm == "pre_capture"){ conf_edit_pre_capture(cam, parm_val, pact); + } else if (parm_nm == "post_capture"){ conf_edit_post_capture(cam, parm_val, pact); } } -static void conf_edit_cat03(struct ctx_cam *cam, const char *cmd, char *arg1, enum PARM_ACT pact) { +static void conf_edit_cat03(struct ctx_cam *cam, std::string parm_nm, std::string &parm_val, enum PARM_ACT pact) { - if (mystreq(cmd,"on_event_start")){ conf_edit_on_event_start(cam, arg1, pact); - } else if (mystreq(cmd,"on_event_end")){ conf_edit_on_event_end(cam, arg1, pact); - } else if (mystreq(cmd,"on_picture_save")){ conf_edit_on_picture_save(cam, arg1, pact); - } else if (mystreq(cmd,"on_area_detected")){ conf_edit_on_area_detected(cam, arg1, pact); - } else if (mystreq(cmd,"on_motion_detected")){ conf_edit_on_motion_detected(cam, arg1, pact); - } else if (mystreq(cmd,"on_movie_start")){ conf_edit_on_movie_start(cam, arg1, pact); - } else if (mystreq(cmd,"on_movie_end")){ conf_edit_on_movie_end(cam, arg1, pact); - } else if (mystreq(cmd,"on_camera_lost")){ conf_edit_on_camera_lost(cam, arg1, pact); - } else if (mystreq(cmd,"on_camera_found")){ conf_edit_on_camera_found(cam, arg1, pact); - } else if (mystreq(cmd,"picture_output")){ conf_edit_picture_output(cam, arg1, pact); - } else if (mystreq(cmd,"picture_output_motion")){ conf_edit_picture_output_motion(cam, arg1, pact); - } else if (mystreq(cmd,"picture_type")){ conf_edit_picture_type(cam, arg1, pact); - } else if (mystreq(cmd,"picture_quality")){ conf_edit_picture_quality(cam, arg1, pact); - } else if (mystreq(cmd,"picture_exif")){ conf_edit_picture_exif(cam, arg1, pact); - } else if (mystreq(cmd,"picture_filename")){ conf_edit_picture_filename(cam, arg1, pact); - } else if (mystreq(cmd,"snapshot_interval")){ conf_edit_snapshot_interval(cam, arg1, pact); - } else if (mystreq(cmd,"snapshot_filename")){ conf_edit_snapshot_filename(cam, arg1, pact); - } else if (mystreq(cmd,"movie_output")){ conf_edit_movie_output(cam, arg1, pact); - } else if (mystreq(cmd,"movie_output_motion")){ conf_edit_movie_output_motion(cam, arg1, pact); - } else if (mystreq(cmd,"movie_max_time")){ conf_edit_movie_max_time(cam, arg1, pact); - } else if (mystreq(cmd,"movie_bps")){ conf_edit_movie_bps(cam, arg1, pact); - } else if (mystreq(cmd,"movie_quality")){ conf_edit_movie_quality(cam, arg1, pact); - } else if (mystreq(cmd,"movie_codec")){ conf_edit_movie_codec(cam, arg1, pact); - } else if (mystreq(cmd,"movie_passthrough")){ conf_edit_movie_passthrough(cam, arg1, pact); - } else if (mystreq(cmd,"movie_filename")){ conf_edit_movie_filename(cam, arg1, pact); - } else if (mystreq(cmd,"movie_extpipe_use")){ conf_edit_movie_extpipe_use(cam, arg1, pact); - } else if (mystreq(cmd,"movie_extpipe")){ conf_edit_movie_extpipe(cam, arg1, pact); - } else if (mystreq(cmd,"timelapse_interval")){ conf_edit_timelapse_interval(cam, arg1, pact); - } else if (mystreq(cmd,"timelapse_mode")){ conf_edit_timelapse_mode(cam, arg1, pact); - } else if (mystreq(cmd,"timelapse_fps")){ conf_edit_timelapse_fps(cam, arg1, pact); - } else if (mystreq(cmd,"timelapse_codec")){ conf_edit_timelapse_codec(cam, arg1, pact); - } else if (mystreq(cmd,"timelapse_filename")){ conf_edit_timelapse_filename(cam, arg1, pact); - } else if (mystreq(cmd,"video_pipe")){ conf_edit_video_pipe(cam, arg1, pact); - } else if (mystreq(cmd,"video_pipe_motion")){ conf_edit_video_pipe_motion(cam, arg1, pact); + if (parm_nm == "on_event_start"){ conf_edit_on_event_start(cam, parm_val, pact); + } else if (parm_nm == "on_event_end"){ conf_edit_on_event_end(cam, parm_val, pact); + } else if (parm_nm == "on_picture_save"){ conf_edit_on_picture_save(cam, parm_val, pact); + } else if (parm_nm == "on_area_detected"){ conf_edit_on_area_detected(cam, parm_val, pact); + } else if (parm_nm == "on_motion_detected"){ conf_edit_on_motion_detected(cam, parm_val, pact); + } else if (parm_nm == "on_movie_start"){ conf_edit_on_movie_start(cam, parm_val, pact); + } else if (parm_nm == "on_movie_end"){ conf_edit_on_movie_end(cam, parm_val, pact); + } else if (parm_nm == "on_camera_lost"){ conf_edit_on_camera_lost(cam, parm_val, pact); + } else if (parm_nm == "on_camera_found"){ conf_edit_on_camera_found(cam, parm_val, pact); + } else if (parm_nm == "picture_output"){ conf_edit_picture_output(cam, parm_val, pact); + } else if (parm_nm == "picture_output_motion"){ conf_edit_picture_output_motion(cam, parm_val, pact); + } else if (parm_nm == "picture_type"){ conf_edit_picture_type(cam, parm_val, pact); + } else if (parm_nm == "picture_quality"){ conf_edit_picture_quality(cam, parm_val, pact); + } else if (parm_nm == "picture_exif"){ conf_edit_picture_exif(cam, parm_val, pact); + } else if (parm_nm == "picture_filename"){ conf_edit_picture_filename(cam, parm_val, pact); + } else if (parm_nm == "snapshot_interval"){ conf_edit_snapshot_interval(cam, parm_val, pact); + } else if (parm_nm == "snapshot_filename"){ conf_edit_snapshot_filename(cam, parm_val, pact); + } else if (parm_nm == "movie_output"){ conf_edit_movie_output(cam, parm_val, pact); + } else if (parm_nm == "movie_output_motion"){ conf_edit_movie_output_motion(cam, parm_val, pact); + } else if (parm_nm == "movie_max_time"){ conf_edit_movie_max_time(cam, parm_val, pact); + } else if (parm_nm == "movie_bps"){ conf_edit_movie_bps(cam, parm_val, pact); + } else if (parm_nm == "movie_quality"){ conf_edit_movie_quality(cam, parm_val, pact); + } else if (parm_nm == "movie_codec"){ conf_edit_movie_codec(cam, parm_val, pact); + } else if (parm_nm == "movie_passthrough"){ conf_edit_movie_passthrough(cam, parm_val, pact); + } else if (parm_nm == "movie_filename"){ conf_edit_movie_filename(cam, parm_val, pact); + } else if (parm_nm == "movie_extpipe_use"){ conf_edit_movie_extpipe_use(cam, parm_val, pact); + } else if (parm_nm == "movie_extpipe"){ conf_edit_movie_extpipe(cam, parm_val, pact); + } else if (parm_nm == "timelapse_interval"){ conf_edit_timelapse_interval(cam, parm_val, pact); + } else if (parm_nm == "timelapse_mode"){ conf_edit_timelapse_mode(cam, parm_val, pact); + } else if (parm_nm == "timelapse_fps"){ conf_edit_timelapse_fps(cam, parm_val, pact); + } else if (parm_nm == "timelapse_codec"){ conf_edit_timelapse_codec(cam, parm_val, pact); + } else if (parm_nm == "timelapse_filename"){ conf_edit_timelapse_filename(cam, parm_val, pact); + } else if (parm_nm == "video_pipe"){ conf_edit_video_pipe(cam, parm_val, pact); + } else if (parm_nm == "video_pipe_motion"){ conf_edit_video_pipe_motion(cam, parm_val, pact); } } -static void conf_edit_cat04(struct ctx_cam *cam, const char *cmd, char *arg1, enum PARM_ACT pact) { - if (mystreq(cmd,"webcontrol_port")){ conf_edit_webcontrol_port(cam, arg1, pact); - } else if (mystreq(cmd,"webcontrol_ipv6")){ conf_edit_webcontrol_ipv6(cam, arg1, pact); - } else if (mystreq(cmd,"webcontrol_localhost")){ conf_edit_webcontrol_localhost(cam, arg1, pact); - } else if (mystreq(cmd,"webcontrol_parms")){ conf_edit_webcontrol_parms(cam, arg1, pact); - } else if (mystreq(cmd,"webcontrol_interface")){ conf_edit_webcontrol_interface(cam, arg1, pact); - } else if (mystreq(cmd,"webcontrol_auth_method")){ conf_edit_webcontrol_auth_method(cam, arg1, pact); - } else if (mystreq(cmd,"webcontrol_authentication")){ conf_edit_webcontrol_authentication(cam, arg1, pact); - } else if (mystreq(cmd,"webcontrol_tls")){ conf_edit_webcontrol_tls(cam, arg1, pact); - } else if (mystreq(cmd,"webcontrol_cert")){ conf_edit_webcontrol_cert(cam, arg1, pact); - } else if (mystreq(cmd,"webcontrol_key")){ conf_edit_webcontrol_key(cam, arg1, pact); - } else if (mystreq(cmd,"webcontrol_cors_header")){ conf_edit_webcontrol_cors_header(cam, arg1, pact); - } else if (mystreq(cmd,"stream_port")){ conf_edit_stream_port(cam, arg1, pact); - } else if (mystreq(cmd,"stream_localhost")){ conf_edit_stream_localhost(cam, arg1, pact); - } else if (mystreq(cmd,"stream_auth_method")){ conf_edit_stream_auth_method(cam, arg1, pact); - } else if (mystreq(cmd,"stream_authentication")){ conf_edit_stream_authentication(cam, arg1, pact); - } else if (mystreq(cmd,"stream_tls")){ conf_edit_stream_tls(cam, arg1, pact); - } else if (mystreq(cmd,"stream_cors_header")){ conf_edit_stream_cors_header(cam, arg1, pact); - } else if (mystreq(cmd,"stream_preview_scale")){ conf_edit_stream_preview_scale(cam, arg1, pact); - } else if (mystreq(cmd,"stream_preview_newline")){ conf_edit_stream_preview_newline(cam, arg1, pact); - } else if (mystreq(cmd,"stream_preview_method")){ conf_edit_stream_preview_method(cam, arg1, pact); - } else if (mystreq(cmd,"stream_quality")){ conf_edit_stream_quality(cam, arg1, pact); - } else if (mystreq(cmd,"stream_grey")){ conf_edit_stream_grey(cam, arg1, pact); - } else if (mystreq(cmd,"stream_motion")){ conf_edit_stream_motion(cam, arg1, pact); - } else if (mystreq(cmd,"stream_maxrate")){ conf_edit_stream_maxrate(cam, arg1, pact); +static void conf_edit_cat04(struct ctx_cam *cam, std::string parm_nm, std::string &parm_val, enum PARM_ACT pact) { + if (parm_nm == "webcontrol_port"){ conf_edit_webcontrol_port(cam, parm_val, pact); + } else if (parm_nm == "webcontrol_ipv6"){ conf_edit_webcontrol_ipv6(cam, parm_val, pact); + } else if (parm_nm == "webcontrol_localhost"){ conf_edit_webcontrol_localhost(cam, parm_val, pact); + } else if (parm_nm == "webcontrol_parms"){ conf_edit_webcontrol_parms(cam, parm_val, pact); + } else if (parm_nm == "webcontrol_interface"){ conf_edit_webcontrol_interface(cam, parm_val, pact); + } else if (parm_nm == "webcontrol_auth_method"){ conf_edit_webcontrol_auth_method(cam, parm_val, pact); + } else if (parm_nm == "webcontrol_authentication"){ conf_edit_webcontrol_authentication(cam, parm_val, pact); + } else if (parm_nm == "webcontrol_tls"){ conf_edit_webcontrol_tls(cam, parm_val, pact); + } else if (parm_nm == "webcontrol_cert"){ conf_edit_webcontrol_cert(cam, parm_val, pact); + } else if (parm_nm == "webcontrol_key"){ conf_edit_webcontrol_key(cam, parm_val, pact); + } else if (parm_nm == "webcontrol_cors_header"){ conf_edit_webcontrol_cors_header(cam, parm_val, pact); + } else if (parm_nm == "stream_port"){ conf_edit_stream_port(cam, parm_val, pact); + } else if (parm_nm == "stream_localhost"){ conf_edit_stream_localhost(cam, parm_val, pact); + } else if (parm_nm == "stream_auth_method"){ conf_edit_stream_auth_method(cam, parm_val, pact); + } else if (parm_nm == "stream_authentication"){ conf_edit_stream_authentication(cam, parm_val, pact); + } else if (parm_nm == "stream_tls"){ conf_edit_stream_tls(cam, parm_val, pact); + } else if (parm_nm == "stream_cors_header"){ conf_edit_stream_cors_header(cam, parm_val, pact); + } else if (parm_nm == "stream_preview_scale"){ conf_edit_stream_preview_scale(cam, parm_val, pact); + } else if (parm_nm == "stream_preview_newline"){ conf_edit_stream_preview_newline(cam, parm_val, pact); + } else if (parm_nm == "stream_preview_method"){ conf_edit_stream_preview_method(cam, parm_val, pact); + } else if (parm_nm == "stream_quality"){ conf_edit_stream_quality(cam, parm_val, pact); + } else if (parm_nm == "stream_grey"){ conf_edit_stream_grey(cam, parm_val, pact); + } else if (parm_nm == "stream_motion"){ conf_edit_stream_motion(cam, parm_val, pact); + } else if (parm_nm == "stream_maxrate"){ conf_edit_stream_maxrate(cam, parm_val, pact); } } -static void conf_edit_cat05(struct ctx_cam *cam, const char *cmd, char *arg1, enum PARM_ACT pact) { - if (mystreq(cmd,"database_type")){ conf_edit_database_type(cam, arg1, pact); - } else if (mystreq(cmd,"database_dbname")){ conf_edit_database_dbname(cam, arg1, pact); - } else if (mystreq(cmd,"database_host")){ conf_edit_database_host(cam, arg1, pact); - } else if (mystreq(cmd,"database_port")){ conf_edit_database_port(cam, arg1, pact); - } else if (mystreq(cmd,"database_user")){ conf_edit_database_user(cam, arg1, pact); - } else if (mystreq(cmd,"database_password")){ conf_edit_database_password(cam, arg1, pact); - } else if (mystreq(cmd,"database_busy_timeout")){ conf_edit_database_busy_timeout(cam, arg1, pact); - } else if (mystreq(cmd,"sql_log_picture")){ conf_edit_sql_log_picture(cam, arg1, pact); - } else if (mystreq(cmd,"sql_log_snapshot")){ conf_edit_sql_log_snapshot(cam, arg1, pact); - } else if (mystreq(cmd,"sql_log_movie")){ conf_edit_sql_log_movie(cam, arg1, pact); - } else if (mystreq(cmd,"sql_log_timelapse")){ conf_edit_sql_log_timelapse(cam, arg1, pact); - } else if (mystreq(cmd,"sql_query_start")){ conf_edit_sql_query_start(cam, arg1, pact); - } else if (mystreq(cmd,"sql_query_stop")){ conf_edit_sql_query_stop(cam, arg1, pact); - } else if (mystreq(cmd,"sql_query")){ conf_edit_sql_query(cam, arg1, pact); - } else if (mystreq(cmd,"track_type")){ conf_edit_track_type(cam, arg1, pact); - } else if (mystreq(cmd,"track_auto")){ conf_edit_track_auto(cam, arg1, pact); - } else if (mystreq(cmd,"track_move_wait")){ conf_edit_track_move_wait(cam, arg1, pact); - } else if (mystreq(cmd,"track_generic_move")){ conf_edit_track_generic_move(cam, arg1, pact); - } else if (mystreq(cmd,"track_step_angle_x")){ conf_edit_track_step_angle_x(cam, arg1, pact); - } else if (mystreq(cmd,"track_step_angle_y")){ conf_edit_track_step_angle_y(cam, arg1, pact); +static void conf_edit_cat05(struct ctx_cam *cam, std::string parm_nm, std::string &parm_val, enum PARM_ACT pact) { + if (parm_nm == "database_type"){ conf_edit_database_type(cam, parm_val, pact); + } else if (parm_nm == "database_dbname"){ conf_edit_database_dbname(cam, parm_val, pact); + } else if (parm_nm == "database_host"){ conf_edit_database_host(cam, parm_val, pact); + } else if (parm_nm == "database_port"){ conf_edit_database_port(cam, parm_val, pact); + } else if (parm_nm == "database_user"){ conf_edit_database_user(cam, parm_val, pact); + } else if (parm_nm == "database_password"){ conf_edit_database_password(cam, parm_val, pact); + } else if (parm_nm == "database_busy_timeout"){ conf_edit_database_busy_timeout(cam, parm_val, pact); + } else if (parm_nm == "sql_log_picture"){ conf_edit_sql_log_picture(cam, parm_val, pact); + } else if (parm_nm == "sql_log_snapshot"){ conf_edit_sql_log_snapshot(cam, parm_val, pact); + } else if (parm_nm == "sql_log_movie"){ conf_edit_sql_log_movie(cam, parm_val, pact); + } else if (parm_nm == "sql_log_timelapse"){ conf_edit_sql_log_timelapse(cam, parm_val, pact); + } else if (parm_nm == "sql_query_start"){ conf_edit_sql_query_start(cam, parm_val, pact); + } else if (parm_nm == "sql_query_stop"){ conf_edit_sql_query_stop(cam, parm_val, pact); + } else if (parm_nm == "sql_query"){ conf_edit_sql_query(cam, parm_val, pact); + } else if (parm_nm == "track_type"){ conf_edit_track_type(cam, parm_val, pact); + } else if (parm_nm == "track_auto"){ conf_edit_track_auto(cam, parm_val, pact); + } else if (parm_nm == "track_move_wait"){ conf_edit_track_move_wait(cam, parm_val, pact); + } else if (parm_nm == "track_generic_move"){ conf_edit_track_generic_move(cam, parm_val, pact); + } else if (parm_nm == "track_step_angle_x"){ conf_edit_track_step_angle_x(cam, parm_val, pact); + } else if (parm_nm == "track_step_angle_y"){ conf_edit_track_step_angle_y(cam, parm_val, pact); } } -void conf_edit_free(struct ctx_cam *cam) { - int indx; - enum PARM_CAT pcat; - - indx = 0; - while (config_parms[indx].parm_name != NULL) { - if (config_parms[indx].parm_type == PARM_TYP_STRING) { - pcat = config_parms[indx].parm_cat; - if (pcat == PARM_CAT_00) { - conf_edit_cat00(cam->motapp, config_parms[indx].parm_name, NULL,PARM_ACT_FREE); - } else if (pcat == PARM_CAT_01) { - conf_edit_cat01(cam, config_parms[indx].parm_name, NULL,PARM_ACT_FREE); - } else if (pcat == PARM_CAT_02) { - conf_edit_cat02(cam, config_parms[indx].parm_name, NULL, PARM_ACT_FREE); - } else if (pcat == PARM_CAT_03) { - conf_edit_cat03(cam, config_parms[indx].parm_name, NULL, PARM_ACT_FREE); - } else if (pcat == PARM_CAT_04) { - conf_edit_cat04(cam, config_parms[indx].parm_name, NULL, PARM_ACT_FREE); - } else if (pcat == PARM_CAT_05) { - conf_edit_cat05(cam, config_parms[indx].parm_name, NULL, PARM_ACT_FREE); - } - } - indx++; - } -} - void conf_edit_dflt_app(struct ctx_motapp *motapp) { - motapp->conf_filename = NULL; - motapp->log_file = NULL; - motapp->log_type_str = NULL; - motapp->pid_file = NULL; - conf_edit_daemon(motapp, NULL,PARM_ACT_DFLT); - conf_edit_setup_mode(motapp, NULL, PARM_ACT_DFLT); - conf_edit_pid_file(motapp, NULL, PARM_ACT_DFLT); - conf_edit_log_file(motapp, NULL, PARM_ACT_DFLT); - conf_edit_log_level(motapp, NULL, PARM_ACT_DFLT); - conf_edit_log_type(motapp, NULL, PARM_ACT_DFLT); - conf_edit_native_language(motapp, NULL, PARM_ACT_DFLT); + std::string dflt = ""; + + conf_edit_conf_filename(motapp, dflt, PARM_ACT_DFLT); + conf_edit_log_file(motapp, dflt, PARM_ACT_DFLT); + conf_edit_log_type(motapp, dflt, PARM_ACT_DFLT); + conf_edit_pid_file(motapp, dflt, PARM_ACT_DFLT); + conf_edit_daemon(motapp, dflt, PARM_ACT_DFLT); + conf_edit_setup_mode(motapp, dflt, PARM_ACT_DFLT); + conf_edit_pid_file(motapp, dflt, PARM_ACT_DFLT); + conf_edit_log_file(motapp, dflt, PARM_ACT_DFLT); + conf_edit_log_level(motapp, dflt, PARM_ACT_DFLT); + conf_edit_log_type(motapp, dflt, PARM_ACT_DFLT); + conf_edit_native_language(motapp, dflt, PARM_ACT_DFLT); } void conf_edit_dflt_cam(struct ctx_cam *cam) { int indx; enum PARM_CAT pcat; + std::string dflt = ""; indx = 0; - while (config_parms[indx].parm_name != NULL) { + while (config_parms[indx].parm_name != "") { pcat = config_parms[indx].parm_cat; if ((config_parms[indx].parm_cat != PARM_CAT_00)) { if (pcat == PARM_CAT_01) { - conf_edit_cat01(cam, config_parms[indx].parm_name, NULL,PARM_ACT_DFLT); + conf_edit_cat01(cam, config_parms[indx].parm_name, dflt,PARM_ACT_DFLT); } else if (pcat == PARM_CAT_02) { - conf_edit_cat02(cam, config_parms[indx].parm_name, NULL, PARM_ACT_DFLT); + conf_edit_cat02(cam, config_parms[indx].parm_name, dflt, PARM_ACT_DFLT); } else if (pcat == PARM_CAT_03) { - conf_edit_cat03(cam, config_parms[indx].parm_name, NULL, PARM_ACT_DFLT); + conf_edit_cat03(cam, config_parms[indx].parm_name, dflt, PARM_ACT_DFLT); } else if (pcat == PARM_CAT_04) { - conf_edit_cat04(cam, config_parms[indx].parm_name, NULL, PARM_ACT_DFLT); + conf_edit_cat04(cam, config_parms[indx].parm_name, dflt, PARM_ACT_DFLT); } else if (pcat == PARM_CAT_05) { - conf_edit_cat05(cam, config_parms[indx].parm_name, NULL, PARM_ACT_DFLT); + conf_edit_cat05(cam, config_parms[indx].parm_name, dflt, PARM_ACT_DFLT); } } indx++; } + } -int conf_edit_set_active(struct ctx_motapp *motapp, int threadnbr, char *cmd, char *arg1){ +int conf_edit_set_active(struct ctx_motapp *motapp, int threadnbr + , std::string parm_nm, std::string parm_val){ int indx; enum PARM_CAT pcat; indx = 0; - while (config_parms[indx].parm_name != NULL) { - if (mystreq(cmd, config_parms[indx].parm_name)) { + while (config_parms[indx].parm_name != "") { + if (parm_nm == config_parms[indx].parm_name) { pcat = config_parms[indx].parm_cat; if ((pcat == PARM_CAT_00) && (threadnbr == -1)) { - conf_edit_cat00(motapp, cmd, arg1, PARM_ACT_SET); + conf_edit_cat00(motapp, parm_nm, parm_val, PARM_ACT_SET); } else if ((config_parms[indx].parm_cat != PARM_CAT_00) && (threadnbr != -1)) { if (pcat == PARM_CAT_01) { - conf_edit_cat01(motapp->cam_list[threadnbr], cmd, arg1, PARM_ACT_SET); + conf_edit_cat01(motapp->cam_list[threadnbr], parm_nm, parm_val, PARM_ACT_SET); } else if (pcat == PARM_CAT_02) { - conf_edit_cat02(motapp->cam_list[threadnbr], cmd, arg1, PARM_ACT_SET); + conf_edit_cat02(motapp->cam_list[threadnbr], parm_nm, parm_val, PARM_ACT_SET); } else if (pcat == PARM_CAT_03) { - conf_edit_cat03(motapp->cam_list[threadnbr], cmd, arg1, PARM_ACT_SET); + conf_edit_cat03(motapp->cam_list[threadnbr], parm_nm, parm_val, PARM_ACT_SET); } else if (pcat == PARM_CAT_04) { - conf_edit_cat04(motapp->cam_list[threadnbr], cmd, arg1, PARM_ACT_SET); + conf_edit_cat04(motapp->cam_list[threadnbr], parm_nm, parm_val, PARM_ACT_SET); } else if (pcat == PARM_CAT_05) { - conf_edit_cat05(motapp->cam_list[threadnbr], cmd, arg1, PARM_ACT_SET); + conf_edit_cat05(motapp->cam_list[threadnbr], parm_nm, parm_val, PARM_ACT_SET); } } return 0; @@ -2735,80 +2397,80 @@ int conf_edit_set_active(struct ctx_motapp *motapp, int threadnbr, char *cmd, ch } -static void conf_edit_depr_vid(struct ctx_motapp *motapp - , int threadnbr, char *cmd, char *arg1, char*newname){ - - char parm_curr[PATH_MAX], parm_val[PATH_MAX]; - int retcd; +static void conf_edit_depr_vid(struct ctx_motapp *motapp, int threadnbr + , std::string parm_nm, std::string newname, std::string parm_val){ + std::string parm_curr, parm_new; conf_edit_vid_control_params(motapp->cam_list[threadnbr], parm_curr, PARM_ACT_GET); - if (strlen(parm_curr) == 0){ - if (mystreq(cmd,"power_line_frequency")) { - retcd = snprintf(parm_val, PATH_MAX,"%s=%s","\"power line frequency\"",arg1); + if (parm_curr == ""){ + if (parm_nm == "power_line_frequency"){ + parm_new = "\"power line frequency\"=" + parm_val; } else { - retcd = snprintf(parm_val, PATH_MAX,"%s=%s",cmd, arg1); + parm_new = parm_nm + "=" + parm_val; } } else { - if (mystreq(cmd,"power_line_frequency")) { - retcd = snprintf(parm_val, PATH_MAX,"%s,%s=%s",parm_curr, "\"power line frequency\"", arg1); + if (parm_nm == "power_line_frequency"){ + parm_new = parm_curr + ", \"power line frequency\"=" + parm_val; } else { - retcd = snprintf(parm_val, PATH_MAX,"%s,%s=%s",parm_curr, cmd, arg1); + parm_new = parm_curr +", " + parm_nm + "=" + parm_val; } } - - if ((retcd < 0) || (retcd > PATH_MAX)){ - MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "Error setting depreciated parameter"); - return; - } - conf_edit_set_active(motapp, threadnbr, newname,(char*)parm_val); + conf_edit_set_active(motapp, threadnbr, newname, parm_new); } -static void conf_edit_depr_web(struct ctx_motapp *motapp, int threadnbr, char *arg1, char*newname){ +static void conf_edit_depr_web(struct ctx_motapp *motapp, int threadnbr + , std::string newname, std::string &parm_val){ + std::string parm_new; - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - conf_edit_set_active(motapp, threadnbr, newname, (char*)"0" ); + if ((parm_val == "1") || (parm_val == "yes") || (parm_val == "on")) { + parm_new = "0"; } else { - conf_edit_set_active(motapp, threadnbr, newname, (char*)"1" ); + parm_new = "1"; } + conf_edit_set_active(motapp, threadnbr, newname, parm_new); } -static void conf_edit_depr_tdbl(struct ctx_motapp *motapp, int threadnbr, char *arg1, char*newname){ +static void conf_edit_depr_tdbl(struct ctx_motapp *motapp, int threadnbr + , std::string newname, std::string &parm_val){ + std::string parm_new; - if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - conf_edit_set_active(motapp, threadnbr, newname, (char*)"2"); + if ((parm_val == "1") || (parm_val == "yes") || (parm_val == "on")) { + parm_new = "2"; } else { - conf_edit_set_active(motapp, threadnbr, newname, (char*)"1" ); + parm_new = "1"; } + conf_edit_set_active(motapp, threadnbr, newname, parm_new); } -static int conf_edit_set_depr(struct ctx_motapp *motapp, int threadnbr, char *cmd, char *arg1){ +static int conf_edit_set_depr(struct ctx_motapp *motapp, int threadnbr + ,std::string &parm_nm, std::string &parm_val){ int indx; indx = 0; - while (config_parms_depr[indx].parm_name != NULL) { - if (mystreq(cmd, config_parms[indx].parm_name)) { + while (config_parms_depr[indx].parm_name != "") { + if (parm_nm == config_parms_depr[indx].parm_name) { MOTION_LOG(ALR, TYPE_ALL, NO_ERRNO, "%s after version %s" , config_parms_depr[indx].info , config_parms_depr[indx].last_version); - if (mystreq(config_parms_depr[indx].parm_name,"brightness") || - mystreq(config_parms_depr[indx].parm_name,"contrast") || - mystreq(config_parms_depr[indx].parm_name,"saturation") || - mystreq(config_parms_depr[indx].parm_name,"hue") || - mystreq(config_parms_depr[indx].parm_name,"power_line_frequency")) { - conf_edit_depr_vid(motapp, threadnbr, cmd, arg1, (char*)config_parms_depr[indx].newname); + if ((config_parms_depr[indx].parm_name == "brightness") || + (config_parms_depr[indx].parm_name == "contrast") || + (config_parms_depr[indx].parm_name == "saturation") || + (config_parms_depr[indx].parm_name == "hue") || + (config_parms_depr[indx].parm_name == "power_line_frequency")) { + conf_edit_depr_vid(motapp, threadnbr, parm_nm, config_parms_depr[indx].newname, parm_val); - } else if (mystreq(config_parms_depr[indx].parm_name,"webcontrol_html_output")) { - conf_edit_depr_web(motapp, threadnbr, arg1, (char*)config_parms_depr[indx].newname); + } else if ((config_parms_depr[indx].parm_name == "webcontrol_html_output")) { + conf_edit_depr_web(motapp, threadnbr, config_parms_depr[indx].newname, parm_val); - } else if (mystreq(config_parms_depr[indx].parm_name,"text_double")) { - conf_edit_depr_tdbl(motapp, threadnbr, arg1, (char*)config_parms_depr[indx].newname); + } else if ((config_parms_depr[indx].parm_name == "text_double")) { + conf_edit_depr_tdbl(motapp, threadnbr, config_parms_depr[indx].newname, parm_val); } else { - conf_edit_set_active(motapp, threadnbr, (char*)config_parms_depr[indx].newname, arg1); + conf_edit_set_active(motapp, threadnbr, config_parms_depr[indx].newname, parm_val); } return 0; } @@ -2817,33 +2479,90 @@ static int conf_edit_set_depr(struct ctx_motapp *motapp, int threadnbr, char *cm return -1; } -void conf_edit_set(struct ctx_motapp *motapp, int threadnbr, char *cmd, char *arg1){ +void conf_edit_get(struct ctx_cam *cam, std::string parm_nm, std::string &parm_val, enum PARM_CAT parm_cat){ - if (conf_edit_set_active(motapp, threadnbr, cmd, arg1) == 0) return; - - if (conf_edit_set_depr(motapp, threadnbr, cmd, arg1) == 0) return; - - if (threadnbr != -1){ - MOTION_LOG(ALR, TYPE_ALL, NO_ERRNO, _("Unknown config option \"%s\""), cmd); - } - -} - -int conf_edit_get(struct ctx_cam *cam, const char *cmd, char *arg1, enum PARM_CAT pcat) { - int retcd; - - retcd = 0; - if (pcat == PARM_CAT_00) { conf_edit_cat00(cam->motapp, cmd, arg1,PARM_ACT_GET); - } else if (pcat == PARM_CAT_01) { conf_edit_cat01(cam, cmd, arg1, PARM_ACT_GET); - } else if (pcat == PARM_CAT_02) { conf_edit_cat02(cam, cmd, arg1, PARM_ACT_GET); - } else if (pcat == PARM_CAT_03) { conf_edit_cat03(cam, cmd, arg1, PARM_ACT_GET); - } else if (pcat == PARM_CAT_04) { conf_edit_cat04(cam, cmd, arg1, PARM_ACT_GET); - } else if (pcat == PARM_CAT_05) { conf_edit_cat05(cam, cmd, arg1, PARM_ACT_GET); + if (parm_cat == PARM_CAT_00) { conf_edit_cat00(cam->motapp, parm_nm, parm_val, PARM_ACT_GET); + } else if (parm_cat == PARM_CAT_01) { conf_edit_cat01(cam, parm_nm, parm_val, PARM_ACT_GET); + } else if (parm_cat == PARM_CAT_02) { conf_edit_cat02(cam, parm_nm, parm_val, PARM_ACT_GET); + } else if (parm_cat == PARM_CAT_03) { conf_edit_cat03(cam, parm_nm, parm_val, PARM_ACT_GET); + } else if (parm_cat == PARM_CAT_04) { conf_edit_cat04(cam, parm_nm, parm_val, PARM_ACT_GET); + } else if (parm_cat == PARM_CAT_05) { conf_edit_cat05(cam, parm_nm, parm_val, PARM_ACT_GET); } else { MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO,"%s",_("Program coding error")); - retcd = -1; + parm_val = ""; + } + +} + +/* Interim overload until webu goes to c++ with std::string */ +void conf_edit_get(struct ctx_cam *cam, std::string parm_nm, char *parm_chr, enum PARM_CAT parm_cat){ + std::string parm_val(parm_chr); + + if (parm_cat == PARM_CAT_00) { conf_edit_cat00(cam->motapp, parm_nm, parm_val, PARM_ACT_GET); + } else if (parm_cat == PARM_CAT_01) { conf_edit_cat01(cam, parm_nm, parm_val, PARM_ACT_GET); + } else if (parm_cat == PARM_CAT_02) { conf_edit_cat02(cam, parm_nm, parm_val, PARM_ACT_GET); + } else if (parm_cat == PARM_CAT_03) { conf_edit_cat03(cam, parm_nm, parm_val, PARM_ACT_GET); + } else if (parm_cat == PARM_CAT_04) { conf_edit_cat04(cam, parm_nm, parm_val, PARM_ACT_GET); + } else if (parm_cat == PARM_CAT_05) { conf_edit_cat05(cam, parm_nm, parm_val, PARM_ACT_GET); + } else { + MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO,"%s",_("Program coding error")); + parm_val = ""; + } + + parm_val.copy(parm_chr,512); + +} +void conf_edit_set(struct ctx_motapp *motapp, int threadnbr + ,std::string parm_nm, std::string parm_val){ + + if (conf_edit_set_active(motapp, threadnbr, parm_nm, parm_val) == 0) return; + + if (conf_edit_set_depr(motapp, threadnbr, parm_nm, parm_val) == 0) return; + + if (threadnbr != -1){ + MOTION_LOG(ALR, TYPE_ALL, NO_ERRNO, _("Unknown config option \"%s\""), parm_nm.c_str()); + } + +} +void conf_edit_set(struct ctx_motapp *motapp, int threadnbr + ,const char *parm_nm_chr, std::string parm_val){ + std::string parm_nm(parm_nm_chr); + + if (conf_edit_set_active(motapp, threadnbr, parm_nm, parm_val) == 0) return; + + if (conf_edit_set_depr(motapp, threadnbr, parm_nm, parm_val) == 0) return; + + if (threadnbr != -1){ + MOTION_LOG(ALR, TYPE_ALL, NO_ERRNO, _("Unknown config option \"%s\""), parm_nm.c_str()); + } + +} + +void conf_edit_set(struct ctx_motapp *motapp, int threadnbr + ,std::string parm_nm, const char *parm_val_chr){ + std::string parm_val(parm_val_chr); + + if (conf_edit_set_active(motapp, threadnbr, parm_nm, parm_val) == 0) return; + + if (conf_edit_set_depr(motapp, threadnbr, parm_nm, parm_val) == 0) return; + + if (threadnbr != -1){ + MOTION_LOG(ALR, TYPE_ALL, NO_ERRNO, _("Unknown config option \"%s\""), parm_nm.c_str()); + } + +} +void conf_edit_set(struct ctx_motapp *motapp, int threadnbr + ,const char *parm_nm_chr, const char *parm_val_chr){ + std::string parm_val(parm_val_chr); + std::string parm_nm(parm_nm_chr); + + if (conf_edit_set_active(motapp, threadnbr, parm_nm, parm_val) == 0) return; + + if (conf_edit_set_depr(motapp, threadnbr, parm_nm, parm_val) == 0) return; + + if (threadnbr != -1){ + MOTION_LOG(ALR, TYPE_ALL, NO_ERRNO, _("Unknown config option \"%s\""), parm_nm.c_str()); } - return retcd; } diff --git a/src/conf_edit.hpp b/src/conf_edit.hpp index 851234b3..9fdad152 100644 --- a/src/conf_edit.hpp +++ b/src/conf_edit.hpp @@ -25,10 +25,15 @@ #ifndef _INCLUDE_CONF_EDIT_H_ #define _INCLUDE_CONF_EDIT_H_ -void conf_edit_set(struct ctx_motapp *motapp, int threadnbr, char *cmd, char *arg1); -int conf_edit_get(struct ctx_cam *cam, const char *cmd, char *arg1 , enum PARM_CAT pcat); +void conf_edit_set(struct ctx_motapp *motapp, int threadnbr,std::string parm_nm, std::string parm_val); +void conf_edit_set(struct ctx_motapp *motapp, int threadnbr,const char *parm_nm_chr, std::string parm_val); +void conf_edit_set(struct ctx_motapp *motapp, int threadnbr,std::string parm_nm, const char *parm_chr); +void conf_edit_set(struct ctx_motapp *motapp, int threadnbr,const char *parm_nm_chr, const char *parm_val_chr); + +void conf_edit_get(struct ctx_cam *cam, std::string parm_nm, std::string &parm_val, enum PARM_CAT parm_cat); +void conf_edit_get(struct ctx_cam *cam, std::string parm_nm, char *parm_chr, enum PARM_CAT parm_cat); + void conf_edit_dflt_app(struct ctx_motapp *motapp); void conf_edit_dflt_cam(struct ctx_cam *cam); -void conf_edit_free(struct ctx_cam *cam); #endif \ No newline at end of file diff --git a/src/dbse.cpp b/src/dbse.cpp index 11fec0e0..bd5fda17 100644 --- a/src/dbse.cpp +++ b/src/dbse.cpp @@ -31,14 +31,14 @@ static int dbse_global_edits(struct ctx_cam **cam_list){ int retcd = 0; - if (cam_list[0]->conf->database_dbname == NULL){ + if (cam_list[0]->conf->database_dbname == ""){ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Invalid database name")); retcd = -1; } - if (((mystreq(cam_list[0]->conf->database_type, "mysql")) || - (mystreq(cam_list[0]->conf->database_type, "mariadb")) || - (mystreq(cam_list[0]->conf->database_type, "pgsql"))) && + if ((((cam_list[0]->conf->database_type == "mysql")) || + ((cam_list[0]->conf->database_type == "mariadb")) || + ((cam_list[0]->conf->database_type == "pgsql"))) && (cam_list[0]->conf->database_port == 0)){ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Must specify database port for mysql/mariadb/pgsql")); @@ -48,8 +48,7 @@ static int dbse_global_edits(struct ctx_cam **cam_list){ if (retcd == -1){ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Database functionality disabled.")); - free((void *)cam_list[0]->conf->database_type); - cam_list[0]->conf->database_type = NULL; + cam_list[0]->conf->database_type = ""; } return retcd; @@ -61,7 +60,7 @@ void dbse_global_deinit(struct ctx_cam **cam_list){ int indx; #if defined(HAVE_MYSQL) - if (cam_list[0]->conf->database_type != NULL) { + if (cam_list[0]->conf->database_type != "") { if (mystreq(cam_list[0]->conf->database_type, "mysql")) { MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, _("Closing MYSQL")); mysql_library_end(); @@ -72,8 +71,8 @@ void dbse_global_deinit(struct ctx_cam **cam_list){ #endif /* HAVE_MYSQL */ #if defined(HAVE_MARIADB) - if (cam_list[0]->conf->database_type != NULL) { - if (mystreq(cam_list[0]->conf->database_type, "mariadb")) { + if (cam_list[0]->conf->database_type != "") { + if ((cam_list[0]->conf->database_type == "mariadb")) { MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, _("Closing MYSQL")); mysql_library_end(); } @@ -100,32 +99,30 @@ void dbse_global_init(struct ctx_cam **cam_list){ indx++; } - if (cam_list[0]->conf->database_type != NULL) { + if (cam_list[0]->conf->database_type != "") { if (dbse_global_edits(cam_list) == -1) return; MOTION_LOG(DBG, TYPE_DB, NO_ERRNO,_("Initializing database")); /* Initialize all the database items */ #if defined(HAVE_MYSQL) - if (mystreq(cam_list[0]->conf->database_type, "mysql")) { + if ((cam_list[0]->conf->database_type == "mysql")) { if (mysql_library_init(0, NULL, NULL)) { MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Could not initialize database %s") ,cam_list[0]->conf->database_type); - free((void *)cam_list[0]->conf->database_type); - cam_list[0]->conf->database_type = NULL; + cam_list[0]->conf->database_type = ""; return; } } #endif /* HAVE_MYSQL */ #if defined(HAVE_MARIADB) - if (mystreq(cam_list[0]->conf->database_type, "mariadb")) { + if ((cam_list[0]->conf->database_type == "mariadb")) { if (mysql_library_init(0, NULL, NULL)) { MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Could not initialize database %s") ,cam_list[0]->conf->database_type); - free((void *)cam_list[0]->conf->database_type); - cam_list[0]->conf->database_type = NULL; + cam_list[0]->conf->database_type = ""; return; } } @@ -135,8 +132,8 @@ void dbse_global_init(struct ctx_cam **cam_list){ /* database_sqlite3 == NULL if not changed causes each thread to create their own * sqlite3 connection this will only happens when using a non-threaded sqlite version */ cam_list[0]->dbse->database_sqlite3=NULL; - if ((mystreq(cam_list[0]->conf->database_type, "sqlite3")) && - cam_list[0]->conf->database_dbname) { + if ((cam_list[0]->conf->database_type == "sqlite3") && + (cam_list[0]->conf->database_dbname != "")) { MOTION_LOG(NTC, TYPE_DB, NO_ERRNO ,_("SQLite3 Database filename %s") ,cam_list[0]->conf->database_dbname); @@ -146,7 +143,7 @@ void dbse_global_init(struct ctx_cam **cam_list){ MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, _("SQLite3 is threadsafe")); MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, _("SQLite3 serialized %s") ,(sqlite3_config(SQLITE_CONFIG_SERIALIZED)?_("FAILED"):_("SUCCESS"))); - if (sqlite3_open(cam_list[0]->conf->database_dbname, &cam_list[0]->dbse->database_sqlite3) != SQLITE_OK) { + if (sqlite3_open(cam_list[0]->conf->database_dbname.c_str(), &cam_list[0]->dbse->database_sqlite3) != SQLITE_OK) { MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Can't open database %s : %s") ,cam_list[0]->conf->database_dbname @@ -155,8 +152,7 @@ void dbse_global_init(struct ctx_cam **cam_list){ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Could not initialize database %s") ,cam_list[0]->conf->database_dbname); - free((void *)cam_list[0]->conf->database_type); - cam_list[0]->conf->database_type = NULL; + cam_list[0]->conf->database_type = ""; return; } MOTION_LOG(NTC, TYPE_DB, NO_ERRNO,_("database_busy_timeout %d msec"), @@ -187,9 +183,11 @@ static void dbse_init_mysql(struct ctx_cam *cam){ cam->dbse->database_mysql = (MYSQL *) mymalloc(sizeof(MYSQL)); mysql_init(cam->dbse->database_mysql); - if (!mysql_real_connect(cam->dbse->database_mysql, cam->conf->database_host - , cam->conf->database_user, cam->conf->database_password, cam->conf->database_dbname + if (!mysql_real_connect(cam->dbse->database_mysql + , cam->conf->database_host.c_str(), cam->conf->database_user.c_str() + , cam->conf->database_password.c_str(), cam->conf->database_dbname.c_str() , cam->conf->database_port, NULL, 0)) { + MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Cannot connect to MySQL database %s on host %s with user %s") ,cam->conf->database_dbname, cam->conf->database_host @@ -199,8 +197,7 @@ static void dbse_init_mysql(struct ctx_cam *cam){ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Disabling database functionality")); dbse_global_deinit(cam->cam_list); - free((void *)cam->conf->database_type); - cam->conf->database_type = NULL; + cam->conf->database_type = ""; return; } #if (defined(MYSQL_VERSION_ID)) && (MYSQL_VERSION_ID > 50012) @@ -225,8 +222,9 @@ static void dbse_init_mariadb(struct ctx_cam *cam){ cam->dbse->database_mariadb = (MYSQL *) mymalloc(sizeof(MYSQL)); mysql_init(cam->dbse->database_mariadb); - if (!mysql_real_connect(cam->dbse->database_mariadb, cam->conf->database_host - , cam->conf->database_user, cam->conf->database_password, cam->conf->database_dbname + if (!mysql_real_connect(cam->dbse->database_mariadb + , cam->conf->database_host.c_str(), cam->conf->database_user.c_str() + , cam->conf->database_password.c_str(), cam->conf->database_dbname.c_str() , cam->conf->database_port, NULL, 0)) { MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Cannot connect to MySQL database %s on host %s with user %s") @@ -237,8 +235,7 @@ static void dbse_init_mariadb(struct ctx_cam *cam){ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Disabling database functionality")); dbse_global_deinit(cam->cam_list); - free((void *)cam->conf->database_type); - cam->conf->database_type = NULL; + cam->conf->database_type = ""; return; } #if (defined(MYSQL_VERSION_ID)) && (MYSQL_VERSION_ID > 50012) @@ -261,15 +258,14 @@ static void dbse_init_sqlite3(struct ctx_cam *cam){ } else { MOTION_LOG(NTC, TYPE_DB, NO_ERRNO ,_("SQLite3 Database filename %s"), cam->conf->database_dbname); - if (sqlite3_open(cam->conf->database_dbname, &cam->dbse->database_sqlite3) != SQLITE_OK) { + if (sqlite3_open(cam->conf->database_dbname.c_str(), &cam->dbse->database_sqlite3) != SQLITE_OK) { MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Can't open database %s : %s") ,cam->conf->database_dbname, sqlite3_errmsg(cam->dbse->database_sqlite3)); sqlite3_close(cam->dbse->database_sqlite3); MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Disabling database functionality")); - free((void *)cam->conf->database_type); - cam->conf->database_type = NULL; + cam->conf->database_type = ""; return; } MOTION_LOG(NTC, TYPE_DB, NO_ERRNO @@ -295,10 +291,10 @@ static void dbse_init_pgsql(struct ctx_cam *cam){ */ snprintf(connstring, 255, "dbname='%s' host='%s' user='%s' password='%s' port='%d'", - cam->conf->database_dbname, /* dbname */ - (cam->conf->database_host ? cam->conf->database_host : ""), /* host (may be blank) */ - (cam->conf->database_user ? cam->conf->database_user : ""), /* user (may be blank) */ - (cam->conf->database_password ? cam->conf->database_password : ""), /* password (may be blank) */ + cam->conf->database_dbname.c_str(), /* dbname */ + (cam->conf->database_host=="" ? cam->conf->database_host.c_str() : ""), /* host (may be blank) */ + (cam->conf->database_user=="" ? cam->conf->database_user.c_str() : ""), /* user (may be blank) */ + (cam->conf->database_password=="" ? cam->conf->database_password.c_str() : ""), /* password (may be blank) */ cam->conf->database_port ); @@ -309,8 +305,7 @@ static void dbse_init_pgsql(struct ctx_cam *cam){ ,cam->conf->database_dbname, PQerrorMessage(cam->dbse->database_pg)); MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Disabling database functionality")); - free((void *)cam->conf->database_type); - cam->conf->database_type = NULL; + cam->conf->database_type = ""; return; } #else @@ -322,16 +317,16 @@ static void dbse_init_pgsql(struct ctx_cam *cam){ void dbse_init(struct ctx_cam *cam){ - if (cam->conf->database_type) { + if (cam->conf->database_type != "") { MOTION_LOG(NTC, TYPE_DB, NO_ERRNO ,_("Database backend %s"), cam->conf->database_type); - if (mystreq(cam->conf->database_type, "mysql")) { + if (cam->conf->database_type == "mysql") { dbse_init_mysql(cam); - } else if (mystreq(cam->conf->database_type, "mariadb")) { + } else if (cam->conf->database_type == "mariadb") { dbse_init_mariadb(cam); - } else if (mystreq(cam->conf->database_type, "postgresql")) { + } else if (cam->conf->database_type == "postgresql") { dbse_init_pgsql(cam); - } else if (mystreq(cam->conf->database_type, "sqlite3")) { + } else if (cam->conf->database_type == "sqlite3") { dbse_init_sqlite3(cam); } else { MOTION_LOG(NTC, TYPE_DB, NO_ERRNO @@ -345,32 +340,32 @@ void dbse_init(struct ctx_cam *cam){ } void dbse_deinit(struct ctx_cam *cam){ - if (cam->conf->database_type) { + if (cam->conf->database_type != "") { MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, _("Closing database")); #if defined(HAVE_MYSQL) - if (mystreq(cam->conf->database_type, "mysql")) { + if (cam->conf->database_type == "mysql") { mysql_close(cam->dbse->database_mysql); cam->dbse->database_event_id = 0; } #endif /* HAVE_MYSQL */ #if defined(HAVE_MARIADB) - if (mystreq(cam->conf->database_type, "mariadb")) { + if (cam->conf->database_type == "mariadb") { mysql_close(cam->dbse->database_mariadb); cam->dbse->database_event_id = 0; } #endif /* HAVE_MYSQL */ #ifdef HAVE_PGSQL - if (mystreq(cam->conf->database_type, "postgresql")) { + if (cam->conf->database_type == "postgresql") { PQfinish(cam->dbse->database_pg); } #endif /* HAVE_PGSQL */ #ifdef HAVE_SQLITE3 /* Close the SQLite database */ - if (mystreq(cam->conf->database_type, "sqlite3")) { + if (cam->conf->database_type == "sqlite3") { sqlite3_close(cam->dbse->database_sqlite3); cam->dbse->database_sqlite3 = NULL; } @@ -389,6 +384,7 @@ void dbse_sqlmask_update(struct ctx_cam *cam){ cam->conf->sql_log_snapshot * FTYPE_IMAGE_SNAPSHOT + cam->conf->sql_log_movie * (FTYPE_MPEG + FTYPE_MPEG_MOTION) + cam->conf->sql_log_timelapse * FTYPE_MPEG_TIMELAPSE; + } static void dbse_mysql_exec(char *sqlquery,struct ctx_cam *cam, int save_id) { @@ -409,9 +405,9 @@ static void dbse_mysql_exec(char *sqlquery,struct ctx_cam *cam, int save_id) { cam->dbse->database_mysql = (MYSQL *) mymalloc(sizeof(MYSQL)); mysql_init(cam->dbse->database_mysql); - if (!mysql_real_connect(cam->dbse->database_mysql, cam->conf->database_host, - cam->conf->database_user, cam->conf->database_password, - cam->conf->database_dbname, cam->conf->database_port, NULL, 0)) { + if (!mysql_real_connect(cam->dbse->database_mysql, cam->conf->database_host.c_str(), + cam->conf->database_user.c_str(), cam->conf->database_password.c_str(), + cam->conf->database_dbname.c_str(), cam->conf->database_port, NULL, 0)) { MOTION_LOG(ALR, TYPE_DB, NO_ERRNO ,_("Cannot reconnect to MySQL" " database %s on host %s with user %s MySQL error was %s"), @@ -460,9 +456,9 @@ static void dbse_mariadb_exec(char *sqlquery,struct ctx_cam *cam, int save_id) { cam->dbse->database_mariadb = (MYSQL *) mymalloc(sizeof(MYSQL)); mysql_init(cam->dbse->database_mariadb); - if (!mysql_real_connect(cam->dbse->database_mariadb, cam->conf->database_host, - cam->conf->database_user, cam->conf->database_password, - cam->conf->database_dbname,cam->conf->database_port, NULL, 0)) { + if (!mysql_real_connect(cam->dbse->database_mariadb, cam->conf->database_host.c_str(), + cam->conf->database_user.c_str(), cam->conf->database_password.c_str(), + cam->conf->database_dbname.c_str(),cam->conf->database_port, NULL, 0)) { MOTION_LOG(ALR, TYPE_DB, NO_ERRNO ,_("Cannot reconnect to MySQL" " database %s on host %s with user %s MySQL error was %s"), @@ -563,7 +559,7 @@ void dbse_firstmotion(struct ctx_cam *cam){ char sqlquery[PATH_MAX]; - mystrftime(cam, sqlquery, sizeof(sqlquery), cam->conf->sql_query_start, + mystrftime(cam, sqlquery, sizeof(sqlquery), cam->conf->sql_query_start.c_str(), &cam->current_image->imgts, NULL, 0); if (strlen(sqlquery) <= 0) { @@ -571,13 +567,13 @@ void dbse_firstmotion(struct ctx_cam *cam){ return; } - if (mystreq(cam->conf->database_type, "mysql")) { + if (cam->conf->database_type == "mysql") { dbse_mysql_exec(sqlquery, cam, 1); - } else if (mystreq(cam->conf->database_type, "mariadb")) { + } else if (cam->conf->database_type == "mariadb") { dbse_mariadb_exec(sqlquery, cam, 1); - } else if (mystreq(cam->conf->database_type, "postgresql")) { + } else if (cam->conf->database_type == "postgresql") { dbse_pgsql_exec(sqlquery, cam, 1); - } else if (mystreq(cam->conf->database_type, "sqlite3")) { + } else if (cam->conf->database_type == "sqlite3") { dbse_sqlite3_exec(sqlquery, cam, 1); } @@ -586,7 +582,7 @@ void dbse_firstmotion(struct ctx_cam *cam){ void dbse_newfile(struct ctx_cam *cam, char *filename, int sqltype, struct timespec *ts1) { char sqlquery[PATH_MAX]; - mystrftime(cam, sqlquery, sizeof(sqlquery), cam->conf->sql_query, + mystrftime(cam, sqlquery, sizeof(sqlquery), cam->conf->sql_query.c_str(), ts1, filename, sqltype); if (strlen(sqlquery) <= 0) { @@ -594,13 +590,13 @@ void dbse_newfile(struct ctx_cam *cam, char *filename, int sqltype, struct times return; } - if (mystreq(cam->conf->database_type, "mysql")) { + if (cam->conf->database_type == "mysql") { dbse_mysql_exec(sqlquery, cam, 0); - } else if (mystreq(cam->conf->database_type, "mariadb")) { + } else if (cam->conf->database_type == "mariadb") { dbse_mariadb_exec(sqlquery, cam, 0); - } else if (mystreq(cam->conf->database_type, "postgresql")) { + } else if (cam->conf->database_type == "postgresql") { dbse_pgsql_exec(sqlquery, cam, 0); - } else if (mystreq(cam->conf->database_type, "sqlite3")) { + } else if (cam->conf->database_type == "sqlite3") { dbse_sqlite3_exec(sqlquery, cam, 0); } @@ -610,16 +606,16 @@ void dbse_fileclose(struct ctx_cam *cam, char *filename, int sqltype, struct tim char sqlquery[PATH_MAX]; - mystrftime(cam, sqlquery, sizeof(sqlquery), cam->conf->sql_query_stop, + mystrftime(cam, sqlquery, sizeof(sqlquery), cam->conf->sql_query_stop.c_str(), ts1, filename, sqltype); - if (mystreq(cam->conf->database_type, "mysql")) { + if (cam->conf->database_type == "mysql") { dbse_mysql_exec(sqlquery, cam, 0); - } else if (mystreq(cam->conf->database_type, "mariadb")) { + } else if (cam->conf->database_type == "mariadb") { dbse_mariadb_exec(sqlquery, cam, 0); - } else if (mystreq(cam->conf->database_type, "postgresql")) { + } else if (cam->conf->database_type == "postgresql") { dbse_pgsql_exec(sqlquery, cam, 0); - } else if (mystreq(cam->conf->database_type, "sqlite3")) { + } else if (cam->conf->database_type == "sqlite3") { dbse_sqlite3_exec(sqlquery, cam, 0); } diff --git a/src/event.cpp b/src/event.cpp index 271b8709..37a3938f 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -79,7 +79,7 @@ static const char *eventToString(motion_event e) * that the fork inherited from the parent in order not to pass * the open handles on to the shell */ -static void exec_command(struct ctx_cam *cam, char *command, char *filename, int filetype) +static void exec_command(struct ctx_cam *cam, const char *command, char *filename, int filetype) { char stamp[PATH_MAX]; mystrftime(cam, stamp, sizeof(stamp), command, &cam->current_image->imgts, filename, filetype); @@ -157,11 +157,11 @@ static void on_picture_save_command(struct ctx_cam *cam, motion_event evnt (void)img_data; (void)ts1; - if ((filetype & FTYPE_IMAGE_ANY) != 0 && cam->conf->on_picture_save) - exec_command(cam, cam->conf->on_picture_save, fname, filetype); + if ((filetype & FTYPE_IMAGE_ANY) != 0 && (cam->conf->on_picture_save != "")) + exec_command(cam, cam->conf->on_picture_save.c_str(), fname, filetype); - if ((filetype & FTYPE_MPEG_ANY) != 0 && cam->conf->on_movie_start) - exec_command(cam, cam->conf->on_movie_start, fname, filetype); + if ((filetype & FTYPE_MPEG_ANY) != 0 && (cam->conf->on_movie_start != "")) + exec_command(cam, cam->conf->on_movie_start.c_str(), fname, filetype); } static void on_motion_detected_command(struct ctx_cam *cam, motion_event evnt @@ -174,8 +174,8 @@ static void on_motion_detected_command(struct ctx_cam *cam, motion_event evnt (void)ftype; (void)ts1; - if (cam->conf->on_motion_detected) - exec_command(cam, cam->conf->on_motion_detected, NULL, 0); + if (cam->conf->on_motion_detected != "") + exec_command(cam, cam->conf->on_motion_detected.c_str(), NULL, 0); } static void event_sqlfirstmotion(struct ctx_cam *cam, motion_event evnt @@ -188,7 +188,7 @@ static void event_sqlfirstmotion(struct ctx_cam *cam, motion_event evnt (void)ftype; (void)ts1; - if (!(cam->conf->database_type)) { + if (cam->conf->database_type == "") { return; } else { dbse_firstmotion(cam); @@ -205,7 +205,7 @@ static void event_sqlnewfile(struct ctx_cam *cam, motion_event evnt (void)img_data; /* Only log the file types we want */ - if (!(cam->conf->database_type) || (sqltype & cam->dbse->sql_mask) == 0){ + if ((cam->conf->database_type == "") || (sqltype & cam->dbse->sql_mask) == 0){ return; } else { dbse_newfile(cam, fname, sqltype, ts1); @@ -223,7 +223,7 @@ static void event_sqlfileclose(struct ctx_cam *cam, motion_event evnt (void)img_data; /* Only log the file types we want */ - if (!(cam->conf->database_type) || (sqltype & cam->dbse->sql_mask) == 0){ + if ((cam->conf->database_type == "") || (sqltype & cam->dbse->sql_mask) == 0){ return; } else { dbse_fileclose(cam, fname, sqltype, ts1); @@ -242,8 +242,8 @@ static void on_area_command(struct ctx_cam *cam, motion_event evnt (void)ftype; (void)ts1; - if (cam->conf->on_area_detected) - exec_command(cam, cam->conf->on_area_detected, NULL, 0); + if (cam->conf->on_area_detected != "") + exec_command(cam, cam->conf->on_area_detected.c_str(), NULL, 0); } static void on_event_start_command(struct ctx_cam *cam, motion_event evnt @@ -256,8 +256,8 @@ static void on_event_start_command(struct ctx_cam *cam, motion_event evnt (void)ftype; (void)ts1; - if (cam->conf->on_event_start) - exec_command(cam, cam->conf->on_event_start, NULL, 0); + if (cam->conf->on_event_start != "") + exec_command(cam, cam->conf->on_event_start.c_str(), NULL, 0); } static void on_event_end_command(struct ctx_cam *cam, motion_event evnt @@ -270,8 +270,8 @@ static void on_event_end_command(struct ctx_cam *cam, motion_event evnt (void)ftype; (void)ts1; - if (cam->conf->on_event_end) - exec_command(cam, cam->conf->on_event_end, NULL, 0); + if (cam->conf->on_event_end != "") + exec_command(cam, cam->conf->on_event_end.c_str(), NULL, 0); } static void event_stream_put(struct ctx_cam *cam, motion_event evnt @@ -305,8 +305,8 @@ static void event_vlp_putpipe(struct ctx_cam *cam, motion_event evnt const char *imageext(struct ctx_cam *cam) { - if (mystreq(cam->conf->picture_type, "ppm")) return "ppm"; - if (mystreq(cam->conf->picture_type, "webp")) return "webp"; + if (cam->conf->picture_type == "ppm") return "ppm"; + if (cam->conf->picture_type == "webp") return "webp"; return "jpg"; } @@ -323,9 +323,9 @@ static void event_image_detect(struct ctx_cam *cam, motion_event evnt (void)ftype; if (cam->new_img & NEWIMG_ON) { - mystrftime(cam, filename, sizeof(filename), cam->conf->picture_filename, ts1, NULL, 0); + mystrftime(cam, filename, sizeof(filename), cam->conf->picture_filename.c_str(), ts1, NULL, 0); retcd = snprintf(fullfilename, PATH_MAX, "%s/%s.%s" - , cam->conf->target_dir, filename, imageext(cam)); + , cam->conf->target_dir.c_str(), filename, imageext(cam)); if ((retcd < 0) || (retcd >= PATH_MAX)){ MOTION_LOG(ERR, TYPE_EVENTS, NO_ERRNO ,_("Error creating image file name")); @@ -357,9 +357,9 @@ static void event_imagem_detect(struct ctx_cam *cam, motion_event evnt (void)ftype; if (conf->picture_output_motion) { - mystrftime(cam, filename, sizeof(filename), cam->conf->picture_filename, ts1, NULL, 0); + mystrftime(cam, filename, sizeof(filename), cam->conf->picture_filename.c_str(), ts1, NULL, 0); retcd = snprintf(fullfilenamem, PATH_MAX, "%s/%sm.%s" - , cam->conf->target_dir, filenamem, imageext(cam)); + , cam->conf->target_dir.c_str(), filenamem, imageext(cam)); if ((retcd < 0) || (retcd >= PATH_MAX)){ MOTION_LOG(ERR, TYPE_EVENTS, NO_ERRNO ,_("Error creating image motion file name")); @@ -377,58 +377,36 @@ static void event_image_snapshot(struct ctx_cam *cam, motion_event evnt char fullfilename[PATH_MAX]; char filename[PATH_MAX]; char filepath[PATH_MAX]; - int offset = 0; - int len = strlen(cam->conf->snapshot_filename); char linkpath[PATH_MAX]; - const char *snappath; + int offset; (void)evnt; (void)fname; (void)ftype; - if (len >= 9) - offset = len - 8; + offset = cam->conf->snapshot_filename.length() - 8; + if (offset < 0) offset = 1; - if (mystrne(cam->conf->snapshot_filename+offset, "lastsnap")) { - snappath = cam->conf->snapshot_filename; + if (cam->conf->snapshot_filename.compare(offset, 8, "lastsnap") != 0) { + mystrftime(cam, filepath, sizeof(filepath), cam->conf->snapshot_filename.c_str(), ts1, NULL, 0); + snprintf(filename, PATH_MAX, "%s.%s", filepath, imageext(cam)); + snprintf(fullfilename, PATH_MAX, "%s/%s", cam->conf->target_dir.c_str(), filename); - mystrftime(cam, filepath, sizeof(filepath), snappath, ts1, NULL, 0); - snprintf(filename, PATH_MAX, "%.*s.%s" - , (int)(PATH_MAX-1-strlen(filepath)-strlen(imageext(cam))) - , filepath, imageext(cam)); - snprintf(fullfilename, PATH_MAX, "%.*s/%.*s" - , (int)(PATH_MAX-1-strlen(filename)) - , cam->conf->target_dir - , (int)(PATH_MAX-1-strlen(cam->conf->target_dir)) - , filename); pic_save_norm(cam, fullfilename, img_data->image_norm, FTYPE_IMAGE_SNAPSHOT); event(cam, EVENT_FILECREATE, NULL, fullfilename, (void *)FTYPE_IMAGE_SNAPSHOT, ts1); - /* - * Update symbolic link *after* image has been written so that - * the link always points to a valid file. - */ - snprintf(linkpath, PATH_MAX, "%.*s/lastsnap.%s" - , (int)(PATH_MAX-strlen("/lastsnap.")-strlen(imageext(cam))) - , cam->conf->target_dir, imageext(cam)); - + /* Update symbolic link */ + snprintf(linkpath, PATH_MAX, "%s/lastsnap.%s", cam->conf->target_dir.c_str(), imageext(cam)); remove(linkpath); - if (symlink(filename, linkpath)) { MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO ,_("Could not create symbolic link [%s]"), filename); return; } } else { - mystrftime(cam, filepath, sizeof(filepath), cam->conf->snapshot_filename, ts1, NULL, 0); - snprintf(filename, PATH_MAX, "%.*s.%s" - , (int)(PATH_MAX-1-strlen(imageext(cam))) - , filepath, imageext(cam)); - snprintf(fullfilename, PATH_MAX, "%.*s/%.*s" - , (int)(PATH_MAX-1-strlen(filename)) - , cam->conf->target_dir - , (int)(PATH_MAX-1-strlen(cam->conf->target_dir)) - , filename); + mystrftime(cam, filepath, sizeof(filepath), cam->conf->snapshot_filename.c_str(), ts1, NULL, 0); + snprintf(filename, PATH_MAX, "%s.%s", filepath, imageext(cam)); + snprintf(fullfilename, PATH_MAX, "%s/%s", cam->conf->target_dir.c_str(), filename); remove(fullfilename); pic_save_norm(cam, fullfilename, img_data->image_norm, FTYPE_IMAGE_SNAPSHOT); event(cam, EVENT_FILECREATE, NULL, fullfilename, (void *)FTYPE_IMAGE_SNAPSHOT, ts1); @@ -455,10 +433,10 @@ static void event_image_preview(struct ctx_cam *cam, motion_event evnt saved_current_image = cam->current_image; cam->current_image = &cam->imgs.image_preview; - mystrftime(cam, filename, sizeof(filename), cam->conf->picture_filename + mystrftime(cam, filename, sizeof(filename), cam->conf->picture_filename.c_str() , &cam->imgs.image_preview.imgts, NULL, 0); retcd = snprintf(previewname, PATH_MAX, "%s/%s.%s" - , cam->conf->target_dir, filename, imageext(cam)); + , cam->conf->target_dir.c_str(), filename, imageext(cam)); if ((retcd < 0) || (retcd >= PATH_MAX)){ MOTION_LOG(ERR, TYPE_EVENTS, NO_ERRNO ,_("Error creating preview file name")); @@ -487,8 +465,8 @@ static void event_camera_lost(struct ctx_cam *cam, motion_event evnt (void)ftype; (void)ts1; - if (cam->conf->on_camera_lost) - exec_command(cam, cam->conf->on_camera_lost, NULL, 0); + if (cam->conf->on_camera_lost != "") + exec_command(cam, cam->conf->on_camera_lost.c_str(), NULL, 0); } static void event_camera_found(struct ctx_cam *cam, motion_event evnt @@ -501,8 +479,8 @@ static void event_camera_found(struct ctx_cam *cam, motion_event evnt (void)ftype; (void)ts1; - if (cam->conf->on_camera_found) - exec_command(cam, cam->conf->on_camera_found, NULL, 0); + if (cam->conf->on_camera_found != "") + exec_command(cam, cam->conf->on_camera_found.c_str(), NULL, 0); } static void on_movie_end_command(struct ctx_cam *cam, motion_event evnt @@ -515,8 +493,8 @@ static void on_movie_end_command(struct ctx_cam *cam, motion_event evnt (void)img_data; (void)ts1; - if ((filetype & FTYPE_MPEG_ANY) && cam->conf->on_movie_end) - exec_command(cam, cam->conf->on_movie_end, fname, filetype); + if ((filetype & FTYPE_MPEG_ANY) && (cam->conf->on_movie_end != "")) + exec_command(cam, cam->conf->on_movie_end.c_str(), fname, filetype); } static void event_extpipe_end(struct ctx_cam *cam, motion_event evnt @@ -546,24 +524,18 @@ static void event_create_extpipe(struct ctx_cam *cam, motion_event evnt int retcd; char stamp[PATH_MAX] = ""; - const char *moviepath; (void)evnt; (void)img_data; (void)fname; (void)ftype; - if ((cam->conf->movie_extpipe_use) && (cam->conf->movie_extpipe)) { - moviepath = cam->conf->movie_filename; + if ((cam->conf->movie_extpipe_use) && (cam->conf->movie_extpipe != "" )) { + mystrftime(cam, stamp, sizeof(stamp), cam->conf->movie_filename.c_str(), ts1, NULL, 0); + snprintf(cam->extpipefilename, PATH_MAX - 4, "%s/%s" + , cam->conf->target_dir.c_str(), stamp); - mystrftime(cam, stamp, sizeof(stamp), moviepath, ts1, NULL, 0); - snprintf(cam->extpipefilename, PATH_MAX - 4, "%.*s/%.*s" - , (int)(PATH_MAX-5-strlen(stamp)) - , cam->conf->target_dir - , (int)(PATH_MAX-5-strlen(cam->conf->target_dir)) - , stamp); - - if (access(cam->conf->target_dir, W_OK)!= 0) { + if (access(cam->conf->target_dir.c_str(), W_OK)!= 0) { /* Permission denied */ if (errno == EACCES) { MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO @@ -587,7 +559,8 @@ static void event_create_extpipe(struct ctx_cam *cam, motion_event evnt if (mycreate_path(cam->extpipefilename) == -1) return ; - mystrftime(cam, stamp, sizeof(stamp), cam->conf->movie_extpipe, ts1, cam->extpipefilename, 0); + mystrftime(cam, stamp, sizeof(stamp), cam->conf->movie_extpipe.c_str() + , ts1, cam->extpipefilename, 0); retcd = snprintf(cam->extpipecmdline, PATH_MAX, "%s", stamp); if ((retcd < 0 ) || (retcd >= PATH_MAX)){ diff --git a/src/exif.cpp b/src/exif.cpp index cf4ba627..7e29ba62 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -206,9 +206,9 @@ unsigned exif_prepare(unsigned char **exif, // use as much of it as is indicated by conf->frame_limit subtime = NULL; - if (cam->conf->picture_exif) { + if (cam->conf->picture_exif != "") { description =(char*) malloc(PATH_MAX); - mystrftime(cam, description, PATH_MAX-1, cam->conf->picture_exif, &ts1, NULL, 0); + mystrftime(cam, description, PATH_MAX-1, cam->conf->picture_exif.c_str(), &ts1, NULL, 0); } else { description = NULL; } diff --git a/src/logger.cpp b/src/logger.cpp index c0b70bf8..9a039082 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -262,10 +262,10 @@ void log_init(struct ctx_motapp *motapp){ } - if (motapp->log_file != NULL) { - if (mystrne(motapp->log_file,"syslog")) { + if (motapp->log_file != "") { + if (motapp->log_file != "syslog") { log_set_mode(LOGMODE_FILE); - log_set_logfile(motapp->log_file); + log_set_logfile(motapp->log_file.c_str()); if (logfile) { log_set_mode(LOGMODE_SYSLOG); MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO @@ -285,7 +285,7 @@ void log_init(struct ctx_motapp *motapp){ } MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "Motion %s Started",VERSION); - motapp->log_type = log_get_type(motapp->log_type_str); + motapp->log_type = log_get_type(motapp->log_type_str.c_str()); MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Using log type (%s) log level (%s)"), log_get_type_str(motapp->log_type), log_get_level_str(motapp->log_level)); diff --git a/src/motion.cpp b/src/motion.cpp index 538f3dd9..4e907d58 100644 --- a/src/motion.cpp +++ b/src/motion.cpp @@ -150,9 +150,9 @@ static void setup_signals(void){ static void motion_remove_pid(struct ctx_motapp *motapp) { if ((motapp->daemon) && - (motapp->pid_file) && + (motapp->pid_file != "") && (motapp->restart_all == FALSE)) { - if (!unlink(motapp->pid_file)){ + if (!unlink(motapp->pid_file.c_str())){ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Removed process id file (pid file).")); } else{ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, _("Error removing pid file")); @@ -187,8 +187,8 @@ static void motion_daemon(struct ctx_motapp *motapp) { * later when we have closed stdout. Otherwise Motion hangs in the terminal waiting * for an enter. */ - if (motapp->pid_file[0]) { - pidf = myfopen(motapp->pid_file, "w+"); + if (motapp->pid_file != "") { + pidf = myfopen(motapp->pid_file.c_str(), "w+"); if (pidf) { (void)fprintf(pidf, "%d\n", getpid()); @@ -261,6 +261,7 @@ static void motion_shutdown(struct ctx_motapp *motapp){ conf_deinit(motapp); vid_mutex_destroy(); + } static void motion_camera_ids(struct ctx_cam **cam_list){ @@ -574,17 +575,48 @@ static int motion_check_threadcount(struct ctx_motapp *motapp){ } +static void motion_init(struct ctx_motapp *motapp){ + + motapp->cam_list = NULL; + pthread_mutex_init(&motapp->global_lock, NULL); + + motapp->threads_running = 0; + motapp->finish_all = FALSE; + motapp->restart_all = FALSE; + + motapp->argc = 0; + motapp->argv = NULL; + + motapp->daemon = FALSE; + motapp->conf_filename=""; + motapp->pid_file=""; + motapp->log_file=""; + motapp->log_type_str=""; + motapp->log_level=0; + motapp->log_type=0; + motapp->setup_mode = FALSE; + motapp->pause = FALSE; + motapp->native_language = FALSE; + + motapp->webcontrol_running = FALSE; + motapp->webcontrol_finish = FALSE; + motapp->webcontrol_daemon = NULL; + memset(motapp->webcontrol_digest_rand,0,8); + + pthread_key_create(&tls_key_threadnr, NULL); + pthread_setspecific(tls_key_threadnr, (void *)(0)); + +} + /** Main entry point of Motion. */ int main (int argc, char **argv) { int indx; struct ctx_motapp *motapp; - motapp = (struct ctx_motapp*)mymalloc(sizeof(struct ctx_motapp)); + motapp = new ctx_motapp; - pthread_mutex_init(&motapp->global_lock, NULL); - pthread_key_create(&tls_key_threadnr, NULL); - pthread_setspecific(tls_key_threadnr, (void *)(0)); + motion_init(motapp); setup_signals(); @@ -644,7 +676,7 @@ int main (int argc, char **argv) { pthread_key_delete(tls_key_threadnr); pthread_mutex_destroy(&motapp->global_lock); - free(motapp); + delete motapp; return 0; } diff --git a/src/motion.hpp b/src/motion.hpp index 435e4676..093f1136 100644 --- a/src/motion.hpp +++ b/src/motion.hpp @@ -35,6 +35,7 @@ #include #include #include +#include #if defined(HAVE_PTHREAD_NP_H) #include @@ -260,21 +261,13 @@ struct ctx_stream { * own context */ struct ctx_cam { - pthread_t thread_id; + struct ctx_motapp *motapp; struct ctx_cam **cam_list; - - FILE *extpipe; - int extpipe_open; char conf_filename[PATH_MAX]; int from_conf_dir; int threadnr; - unsigned int daemon; - char pid_file[PATH_MAX]; - char log_file[PATH_MAX]; - char log_type_str[6]; - int log_level; - unsigned int log_type; + pthread_t thread_id; struct ctx_config *conf; struct ctx_track *track; @@ -292,6 +285,8 @@ struct ctx_cam { struct ctx_movie *movie_timelapse; struct ctx_stream stream; + FILE *extpipe; + int extpipe_open; int algsec_inuse; /*Bool for whether we have secondary detection*/ int track_posx; int track_posy; @@ -380,11 +375,12 @@ struct ctx_motapp { int argc; char **argv; + int daemon; - char *conf_filename; - char *pid_file; - char *log_file; - char *log_type_str; + std::string conf_filename; + std::string pid_file; + std::string log_file; + std::string log_type_str; int log_level; int log_type; int setup_mode; diff --git a/src/motion_loop.cpp b/src/motion_loop.cpp index cd6e974e..d8ac5085 100644 --- a/src/motion_loop.cpp +++ b/src/motion_loop.cpp @@ -143,7 +143,7 @@ static void mlp_ring_process(struct ctx_cam *cam, unsigned int max_images) { cam->current_image = &cam->imgs.image_ring[cam->imgs.ring_out]; if (cam->imgs.image_ring[cam->imgs.ring_out].shot < cam->conf->framerate) { - if (cam->log_level >= DBG) mlp_ring_process_debug(cam); + if (cam->motapp->log_level >= DBG) mlp_ring_process_debug(cam); event(cam, EVENT_IMAGE_DETECTED, &cam->imgs.image_ring[cam->imgs.ring_out], NULL, NULL, @@ -192,7 +192,7 @@ static void mlp_detected_trigger(struct ctx_cam *cam, struct ctx_image_data *img cam->eventtime = img->imgts.tv_sec; mystrftime(cam, cam->text_event_string, sizeof(cam->text_event_string), - cam->conf->text_event, &img->imgts, NULL, 0); + cam->conf->text_event.c_str(), &img->imgts, NULL, 0); event(cam, EVENT_FIRSTMOTION, img, NULL, NULL, &cam->imgs.image_ring[cam->imgs.ring_out].imgts); @@ -246,24 +246,24 @@ static int init_camera_type(struct ctx_cam *cam){ cam->camera_type = CAMERA_TYPE_UNKNOWN; - if (cam->conf->mmalcam_name) { + if (cam->conf->mmalcam_name != "") { cam->camera_type = CAMERA_TYPE_MMAL; return 0; } - if (cam->conf->netcam_url) { - if ((strncmp(cam->conf->netcam_url,"mjpeg",5) == 0) || - (strncmp(cam->conf->netcam_url,"http" ,4) == 0) || - (strncmp(cam->conf->netcam_url,"v4l2" ,4) == 0) || - (strncmp(cam->conf->netcam_url,"file" ,4) == 0) || - (strncmp(cam->conf->netcam_url,"rtmp" ,4) == 0) || - (strncmp(cam->conf->netcam_url,"rtsp" ,4) == 0)) { + if (cam->conf->netcam_url != "") { + if ((cam->conf->netcam_url.compare(0,5,"mjpeg") == 0) || + (cam->conf->netcam_url.compare(0,4,"http") == 0) || + (cam->conf->netcam_url.compare(0,4,"v4l2") == 0) || + (cam->conf->netcam_url.compare(0,4,"file") == 0) || + (cam->conf->netcam_url.compare(0,4,"rtmp") == 0) || + (cam->conf->netcam_url.compare(0,4,"rtsp") == 0)) { cam->camera_type = CAMERA_TYPE_NETCAM; } return 0; } - if (cam->conf->videodevice) { + if (cam->conf->videodevice != "") { cam->camera_type = CAMERA_TYPE_V4L2; return 0; } @@ -386,25 +386,10 @@ static void mlp_init_buffers(struct ctx_cam *cam){ static void mlp_init_values(struct ctx_cam *cam) { - /* cam has been initialized to 0 upon creation - * so we only need to initialize non zero values*/ + cam->event_nr=1; - clock_gettime(CLOCK_REALTIME, &cam->frame_last_ts); clock_gettime(CLOCK_REALTIME, &cam->frame_curr_ts); - - cam->event_nr = 1; - - /* These are soon to be changed to bools so we leave the init for now*/ - cam->detecting_motion = FALSE; - cam->event_user = FALSE; - cam->event_stop = FALSE; - cam->passflag = FALSE; //only purpose to flag first frame - cam->algsec_inuse = FALSE; - - /* Make sure to default the high res to zero */ - cam->imgs.width_high = 0; - cam->imgs.height_high = 0; - cam->imgs.size_high = 0; + clock_gettime(CLOCK_REALTIME, &cam->frame_last_ts); cam->noise = cam->conf->noise_level; @@ -461,7 +446,7 @@ static int mlp_init_cam_start(struct ctx_cam *cam) { /** mlp_init */ static int mlp_init(struct ctx_cam *cam) { - mythreadname_set("ml",cam->threadnr,cam->conf->camera_name); + mythreadname_set("ml",cam->threadnr,cam->conf->camera_name.c_str()); pthread_setspecific(tls_key_threadnr, (void *)((unsigned long)cam->threadnr)); @@ -680,10 +665,10 @@ static void mlp_mask_privacy(struct ctx_cam *cam){ static void mlp_areadetect(struct ctx_cam *cam){ int i, j, z = 0; - if ((cam->conf->area_detect) && + if ((cam->conf->area_detect != "" ) && (cam->event_nr != cam->areadetect_eventnbr) && (cam->current_image->flags & IMAGE_TRIGGER)) { - j = strlen(cam->conf->area_detect); + j = cam->conf->area_detect.length(); for (i = 0; i < j; i++) { z = cam->conf->area_detect[i] - 49; /* characters are stored as ascii 48-57 (0-9) */ if ((z >= 0) && (z < 9)) { @@ -1012,16 +997,16 @@ static void mlp_overlay(struct ctx_cam *cam){ } /* Add text in lower left corner of the pictures */ - if (cam->conf->text_left) { - mystrftime(cam, tmp, sizeof(tmp), cam->conf->text_left, + if (cam->conf->text_left != "") { + mystrftime(cam, tmp, sizeof(tmp), cam->conf->text_left.c_str(), &cam->current_image->imgts, NULL, 0); draw_text(cam->current_image->image_norm, cam->imgs.width, cam->imgs.height, 10, cam->imgs.height - (10 * cam->text_scale), tmp, cam->text_scale); } /* Add text in lower right corner of the pictures */ - if (cam->conf->text_right) { - mystrftime(cam, tmp, sizeof(tmp), cam->conf->text_right, + if (cam->conf->text_right != "") { + mystrftime(cam, tmp, sizeof(tmp), cam->conf->text_right.c_str(), &cam->current_image->imgts, NULL, 0); draw_text(cam->current_image->image_norm, cam->imgs.width, cam->imgs.height, cam->imgs.width - 10, cam->imgs.height - (10 * cam->text_scale), @@ -1167,11 +1152,11 @@ static void mlp_setupmode(struct ctx_cam *cam){ char msg[1024] = "\0"; char part[100]; - if (cam->conf->despeckle_filter) { + if (cam->conf->despeckle_filter != "") { snprintf(part, 99, _("Raw changes: %5d - changes after '%s': %5d"), cam->olddiffs, cam->conf->despeckle_filter, cam->current_image->diffs); strcat(msg, part); - if (strchr(cam->conf->despeckle_filter, 'l')) { + if (cam->conf->despeckle_filter.find('l') != std::string::npos) { snprintf(part, 99,_(" - labels: %3d"), cam->current_image->total_labels); strcat(msg, part); } @@ -1218,20 +1203,20 @@ static void mlp_timelapse(struct ctx_cam *cam){ (cam->frame_curr_ts.tv_sec % 60 < cam->frame_last_ts.tv_sec % 60) && cam->shots == 0) { - if (mystrceq(cam->conf->timelapse_mode, "daily")) { + if (cam->conf->timelapse_mode == "daily"){ if (timestamp_tm.tm_hour == 0) event(cam, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cam->current_image->imgts); - } else if (mystreq(cam->conf->timelapse_mode, "hourly")) { + } else if (cam->conf->timelapse_mode == "hourly"){ event(cam, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cam->current_image->imgts); - } else if (mystrceq(cam->conf->timelapse_mode, "weekly-sunday")) { + } else if (cam->conf->timelapse_mode == "weekly-sunday"){ if (timestamp_tm.tm_wday == 0 && timestamp_tm.tm_hour == 0) event(cam, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cam->current_image->imgts); - } else if (mystrceq(cam->conf->timelapse_mode, "weekly-monday") == 0) { + } else if (cam->conf->timelapse_mode == "weekly-monday"){ if (timestamp_tm.tm_wday == 1 && timestamp_tm.tm_hour == 0) event(cam, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cam->current_image->imgts); - } else if (mystrceq(cam->conf->timelapse_mode, "monthly")) { + } else if (cam->conf->timelapse_mode == "monthly"){ if (timestamp_tm.tm_mday == 1 && timestamp_tm.tm_hour == 0) event(cam, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cam->current_image->imgts); @@ -1280,34 +1265,37 @@ static void mlp_parmsupdate(struct ctx_cam *cam){ draw_init_scale(cam); /* Initialize and validate text_scale */ - if (mystrceq(cam->conf->picture_output, "on")) + if (cam->conf->picture_output == "on"){ cam->new_img = NEWIMG_ON; - else if (mystrceq(cam->conf->picture_output, "first")) + } else if (cam->conf->picture_output == "first"){ cam->new_img = NEWIMG_FIRST; - else if (mystrceq(cam->conf->picture_output, "best")) + } else if (cam->conf->picture_output == "best"){ cam->new_img = NEWIMG_BEST; - else if (mystrceq(cam->conf->picture_output, "center")) + } else if (cam->conf->picture_output == "center"){ cam->new_img = NEWIMG_CENTER; - else + } else { cam->new_img = NEWIMG_OFF; + } - if (mystrceq(cam->conf->locate_motion_mode, "on")) + if (cam->conf->locate_motion_mode == "on") { cam->locate_motion_mode = LOCATE_ON; - else if (mystrceq(cam->conf->locate_motion_mode, "preview")) + } else if (cam->conf->locate_motion_mode == "preview"){ cam->locate_motion_mode = LOCATE_PREVIEW; - else + } else { cam->locate_motion_mode = LOCATE_OFF; + } - if (mystrceq(cam->conf->locate_motion_style, "box")) + if (cam->conf->locate_motion_style == "box"){ cam->locate_motion_style = LOCATE_BOX; - else if (mystrceq(cam->conf->locate_motion_style, "redbox")) + } else if (cam->conf->locate_motion_style == "redbox"){ cam->locate_motion_style = LOCATE_REDBOX; - else if (mystrceq(cam->conf->locate_motion_style, "cross")) + } else if (cam->conf->locate_motion_style == "cross"){ cam->locate_motion_style = LOCATE_CROSS; - else if (mystrceq(cam->conf->locate_motion_style, "redcross")) + } else if (cam->conf->locate_motion_style == "redcross"){ cam->locate_motion_style = LOCATE_REDCROSS; - else + } else { cam->locate_motion_style = LOCATE_BOX; + } if (cam->conf->smart_mask_speed != cam->smartmask_speed || cam->smartmask_lastrate != cam->lastrate) { diff --git a/src/movie.cpp b/src/movie.cpp index cf8aa753..f0d541e9 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -1501,7 +1501,7 @@ static const char* movie_init_codec(struct ctx_cam *cam){ const char *codec; int codenbr; - codec = cam->conf->movie_codec; + codec = cam->conf->movie_codec.c_str(); if (mystreq(codec, "ogg")) { MOTION_LOG(WRN, TYPE_ENCODER, NO_ERRNO, "The ogg container is no longer supported. Changing to mpeg4"); codec = "mpeg4"; @@ -1527,26 +1527,20 @@ static const char* movie_init_codec(struct ctx_cam *cam){ int movie_init_norm(struct ctx_cam *cam, struct timespec *ts1){ char stamp[PATH_MAX]; - const char *moviepath; const char *codec; int retcd; - if (cam->conf->movie_filename){ - moviepath = cam->conf->movie_filename; - } else { - moviepath = "%v-%Y%m%d%H%M%S"; - } - mystrftime(cam, stamp, sizeof(stamp), moviepath, ts1, NULL, 0); + mystrftime(cam, stamp, sizeof(stamp), cam->conf->movie_filename.c_str(), ts1, NULL, 0); codec = movie_init_codec(cam); cam->movie_norm =(struct ctx_movie*) mymalloc(sizeof(struct ctx_movie)); if (mystreq(codec, "test")) { retcd = snprintf(cam->movie_norm->filename, PATH_MAX, "%s/%s_%s" - , cam->conf->target_dir, codec, stamp); + , cam->conf->target_dir.c_str(), codec, stamp); } else { retcd = snprintf(cam->movie_norm->filename, PATH_MAX, "%s/%s" - , cam->conf->target_dir, stamp); + , cam->conf->target_dir.c_str(), stamp); } if ((retcd < 0) || (retcd >= PATH_MAX)){ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO @@ -1574,7 +1568,7 @@ int movie_init_norm(struct ctx_cam *cam, struct timespec *ts1){ cam->movie_norm->base_pts = 0; cam->movie_norm->gop_cnt = 0; cam->movie_norm->codec_name = codec; - if (mystreq(cam->conf->movie_codec, "test")) { + if (cam->conf->movie_codec == "test") { cam->movie_norm->test_mode = TRUE; } else { cam->movie_norm->test_mode = FALSE; @@ -1590,26 +1584,19 @@ int movie_init_norm(struct ctx_cam *cam, struct timespec *ts1){ int movie_init_motion(struct ctx_cam *cam, struct timespec *ts1){ char stamp[PATH_MAX]; - const char *moviepath; const char *codec; int retcd; - if (cam->conf->movie_filename){ - moviepath = cam->conf->movie_filename; - } else { - moviepath = "%v-%Y%m%d%H%M%S"; - } - mystrftime(cam, stamp, sizeof(stamp), moviepath, ts1, NULL, 0); - + mystrftime(cam, stamp, sizeof(stamp), cam->conf->movie_filename.c_str(), ts1, NULL, 0); codec = movie_init_codec(cam); cam->movie_motion =(struct ctx_movie*)mymalloc(sizeof(struct ctx_movie)); if (mystreq(codec, "test")) { retcd = snprintf(cam->movie_motion->filename, PATH_MAX, "%s/%s_%sm" - , cam->conf->target_dir, codec, stamp); + , cam->conf->target_dir.c_str(), codec, stamp); } else { retcd = snprintf(cam->movie_motion->filename, PATH_MAX, "%s/%sm" - , cam->conf->target_dir, stamp); + , cam->conf->target_dir.c_str(), stamp); } if ((retcd < 0) || (retcd >= PATH_MAX)){ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO @@ -1630,7 +1617,7 @@ int movie_init_motion(struct ctx_cam *cam, struct timespec *ts1){ cam->movie_motion->base_pts = 0; cam->movie_motion->gop_cnt = 0; cam->movie_motion->codec_name = codec; - if (mystreq(cam->conf->movie_codec, "test")) { + if (cam->conf->movie_codec == "test") { cam->movie_motion->test_mode = TRUE; } else { cam->movie_motion->test_mode = FALSE; @@ -1649,24 +1636,17 @@ int movie_init_motion(struct ctx_cam *cam, struct timespec *ts1){ int movie_init_timelapse(struct ctx_cam *cam, struct timespec *ts1){ char tmp[PATH_MAX]; - const char *timepath; const char *codec_mpg = "mpg"; const char *codec_mpeg = "mpeg4"; int retcd; cam->movie_timelapse =(struct ctx_movie*)mymalloc(sizeof(struct ctx_movie)); - - if (cam->conf->timelapse_filename){ - timepath = cam->conf->timelapse_filename; - } else { - timepath = "%Y%m%d-timelapse"; - } - mystrftime(cam, tmp, sizeof(tmp), timepath, ts1, NULL, 0); + mystrftime(cam, tmp, sizeof(tmp), cam->conf->timelapse_filename.c_str(), ts1, NULL, 0); snprintf(cam->movie_timelapse->filename, PATH_MAX - 4, "%.*s/%.*s" , (int)(PATH_MAX-5-strlen(tmp)) - , cam->conf->target_dir - , (int)(PATH_MAX-5-strlen(cam->conf->target_dir)) + , cam->conf->target_dir.c_str() + , (int)(PATH_MAX-5-strlen(cam->conf->target_dir.c_str())) , tmp); if ((cam->imgs.size_high > 0) && (!cam->movie_passthrough)){ cam->movie_timelapse->width = cam->imgs.width_high; @@ -1690,10 +1670,10 @@ int movie_init_timelapse(struct ctx_cam *cam, struct timespec *ts1){ cam->movie_timelapse->passthrough = FALSE; cam->movie_timelapse->netcam_data = NULL; - if (mystreq(cam->conf->timelapse_codec,"mpg") || - mystreq(cam->conf->timelapse_codec,"swf") ){ + if ((cam->conf->timelapse_codec =="mpg") || + (cam->conf->timelapse_codec =="swf") ){ - if (mystreq(cam->conf->timelapse_codec,"swf")) { + if (cam->conf->timelapse_codec =="swf") { MOTION_LOG(WRN, TYPE_EVENTS, NO_ERRNO ,_("The swf container for timelapse no longer supported. Using mpg container.")); } diff --git a/src/netcam.cpp b/src/netcam.cpp index d2db6eb4..977abaab 100644 --- a/src/netcam.cpp +++ b/src/netcam.cpp @@ -1094,23 +1094,28 @@ static void netcam_set_v4l2(struct ctx_netcam *netcam){ static void netcam_set_path (struct ctx_cam *cam, struct ctx_netcam *netcam ) { - char *userpass = NULL; + char userpass[PATH_MAX]; struct url_t url; + int retcd; netcam->path = NULL; memset(&url, 0, sizeof(url)); + memset(userpass,0,PATH_MAX); if (netcam->high_resolution){ - netcam_url_parse(&url, cam->conf->netcam_highres); + netcam_url_parse(&url, cam->conf->netcam_highres.c_str()); } else { - netcam_url_parse(&url, cam->conf->netcam_url); + netcam_url_parse(&url, cam->conf->netcam_url.c_str()); } - if (cam->conf->netcam_userpass != NULL) { - userpass = mystrdup(cam->conf->netcam_userpass); + if (cam->conf->netcam_userpass != "") { + cam->conf->netcam_userpass.copy(userpass, PATH_MAX); } else if (url.userpass != NULL) { - userpass = mystrdup(url.userpass); + retcd = snprintf(userpass,PATH_MAX,"%s",url.userpass); + if ((retcd <0) || (retcd>=PATH_MAX)){ + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO,_("Error getting userpass")); + } } if (mystreq(url.service, "v4l2")) { @@ -1148,22 +1153,27 @@ static void netcam_set_path (struct ctx_cam *cam, struct ctx_netcam *netcam ) { sprintf(netcam->service, "%s",url.service); netcam_url_free(&url); - if (userpass) free (userpass); } static void netcam_set_parms (struct ctx_cam *cam, struct ctx_netcam *netcam ) { /* Set the parameters to be used with our camera */ + int retcd; if (netcam->high_resolution) { netcam->imgsize.width = 0; netcam->imgsize.height = 0; - snprintf(netcam->cameratype,29, "%s",_("High resolution")); + retcd = snprintf(netcam->cameratype,29, "%s",_("High resolution")); } else { netcam->imgsize.width = cam->conf->width; netcam->imgsize.height = cam->conf->height; - snprintf(netcam->cameratype,29, "%s",_("Normal resolution")); + retcd = snprintf(netcam->cameratype,29, "%s",_("Normal resolution")); } + if ((retcd <0) || (retcd >= 30)){ + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO + ,_("Error setting name of resolution %s."),netcam->cameratype); + } + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO ,_("Setting up %s stream."),netcam->cameratype); @@ -1175,7 +1185,6 @@ static void netcam_set_parms (struct ctx_cam *cam, struct ctx_netcam *netcam ) { netcam->src_fps = cam->conf->framerate; /* Default to conf fps */ netcam->motapp = cam->motapp; netcam->conf = cam->conf; - netcam->camera_name = cam->conf->camera_name; netcam->img_recv =(netcam_buff_ptr) mymalloc(sizeof(netcam_buff)); netcam->img_recv->ptr =(char*) mymalloc(NETCAM_BUFFSIZE); netcam->img_latest =(netcam_buff_ptr) mymalloc(sizeof(netcam_buff)); @@ -1186,6 +1195,7 @@ static void netcam_set_parms (struct ctx_cam *cam, struct ctx_netcam *netcam ) { netcam->handler_finished = TRUE; netcam->first_image = TRUE; netcam->reconnect_count = 0; + cam->conf->camera_name.copy(netcam->camera_name,PATH_MAX); snprintf(netcam->threadname, 15, "%s",_("Unknown")); @@ -1194,7 +1204,7 @@ static void netcam_set_parms (struct ctx_cam *cam, struct ctx_netcam *netcam ) { /* If this is the norm and we have a highres, then disable passthru on the norm */ if ((!netcam->high_resolution) && - (cam->conf->netcam_highres)) { + (cam->conf->netcam_highres != "")) { netcam->passthrough = FALSE; } else { netcam->passthrough = mycheck_passthrough(cam); @@ -1696,7 +1706,7 @@ int netcam_setup(struct ctx_cam *cam){ indx_cam = 1; indx_max = 1; - if (cam->conf->netcam_highres) indx_max = 2; + if (cam->conf->netcam_highres != "") indx_max = 2; while (indx_cam <= indx_max){ if (indx_cam == 1){ diff --git a/src/netcam.hpp b/src/netcam.hpp index 0d431781..28523933 100644 --- a/src/netcam.hpp +++ b/src/netcam.hpp @@ -96,7 +96,7 @@ struct ctx_netcam { char *path; /* The connection string to use for the camera */ char service[5]; /* String specifying the type of camera http, rtsp, v4l2 */ - const char *camera_name; /* The name of the camera as provided in the config file */ + char camera_name[PATH_MAX]; /* The name of the camera as provided in the config file */ char cameratype[30]; /* String specifying Normal or High for use in logging */ struct imgsize_context imgsize; /* The image size parameters */ diff --git a/src/picture.cpp b/src/picture.cpp index 144477ca..7f264c94 100644 --- a/src/picture.cpp +++ b/src/picture.cpp @@ -267,14 +267,17 @@ static void pic_write(struct ctx_cam *cam, FILE *picture, unsigned char *image, height = cam->imgs.height; } - if (mystreq(cam->conf->picture_type, "ppm")) { + if (cam->conf->picture_type == "ppm") { pic_save_ppm(picture, image, width, height); - } else if (mystreq(cam->conf->picture_type, "webp")) { - pic_save_webp(picture, image, width, height, quality, cam, &(cam->current_image->imgts), &(cam->current_image->location)); - } else if (mystreq(cam->conf->picture_type, "grey")) { - pic_save_grey(picture, image, width, height, quality, cam, &(cam->current_image->imgts), &(cam->current_image->location)); + } else if (cam->conf->picture_type == "webp") { + pic_save_webp(picture, image, width, height, quality, cam + , &(cam->current_image->imgts), &(cam->current_image->location)); + } else if (cam->conf->picture_type == "grey") { + pic_save_grey(picture, image, width, height, quality, cam + , &(cam->current_image->imgts), &(cam->current_image->location)); } else { - pic_save_yuv420p(picture, image, width, height, quality, cam, &(cam->current_image->imgts), &(cam->current_image->location)); + pic_save_yuv420p(picture, image, width, height, quality, cam + , &(cam->current_image->imgts), &(cam->current_image->location)); } } @@ -496,8 +499,8 @@ void pic_init_privacy(struct ctx_cam *cam){ cam->imgs.mask_privacy_high = NULL; cam->imgs.mask_privacy_high_uv = NULL; - if (cam->conf->mask_privacy) { - if ((picture = myfopen(cam->conf->mask_privacy, "r"))) { + if (cam->conf->mask_privacy != "") { + if ((picture = myfopen(cam->conf->mask_privacy.c_str(), "r"))) { MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, _("Opening privacy mask file")); /* * NOTE: The mask is expected to have the output dimensions. I.e., the mask @@ -521,7 +524,7 @@ void pic_init_privacy(struct ctx_cam *cam){ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO ,_("Error opening mask file %s"), cam->conf->mask_privacy); /* Try to write an empty mask file to make it easier for the user to edit it */ - pic_write_mask(cam, cam->conf->mask_privacy); + pic_write_mask(cam, cam->conf->mask_privacy.c_str() ); } if (!cam->imgs.mask_privacy) { @@ -589,8 +592,8 @@ void pic_init_mask(struct ctx_cam *cam){ FILE *picture; /* Load the mask file if any */ - if (cam->conf->mask_file) { - if ((picture = myfopen(cam->conf->mask_file, "r"))) { + if (cam->conf->mask_file != "") { + if ((picture = myfopen(cam->conf->mask_file.c_str(), "r"))) { /* * NOTE: The mask is expected to have the output dimensions. I.e., the mask * applies to the already rotated image, not the capture image. Thus, use @@ -606,7 +609,7 @@ void pic_init_mask(struct ctx_cam *cam){ * Try to write an empty mask file to make it easier * for the user to edit it */ - pic_write_mask(cam, cam->conf->mask_file); + pic_write_mask(cam, cam->conf->mask_file.c_str()); } if (!cam->imgs.mask) { diff --git a/src/track.cpp b/src/track.cpp index 6310160f..97ffc6fc 100644 --- a/src/track.cpp +++ b/src/track.cpp @@ -415,7 +415,8 @@ static int generic_move(struct ctx_cam *cam, enum track_action action, int manua cam->track->posx += cent->x; cam->track->posy += cent->y; - mystrftime(cam, fmtcmd, sizeof(fmtcmd), cam->conf->track_generic_move, &cam->current_image->imgts, NULL, 0); + mystrftime(cam, fmtcmd, sizeof(fmtcmd), cam->conf->track_generic_move.c_str() + , &cam->current_image->imgts, NULL, 0); if (!fork()) { int i; @@ -507,12 +508,12 @@ int track_center(struct ctx_cam *cam, int dev, if (cam->conf->track_type == TRACK_TYPE_UVC){ return uvc_center(cam, dev, xoff, yoff); } else if (cam->conf->track_type == TRACK_TYPE_GENERIC) { - if (cam->conf->track_generic_move){ + if (cam->conf->track_generic_move != ""){ cent.x = -cam->track->posx; cent.y = -cam->track->posy; return generic_move(cam, TRACK_CENTER, manual,0 ,0 ,¢ , NULL); } else { - return 10; // FIX ME. I chose to return something reasonable. + return 10; } } @@ -531,7 +532,7 @@ int track_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent if (cam->conf->track_type == TRACK_TYPE_UVC){ return uvc_move(cam, dev, cent, imgs, manual); } else if (cam->conf->track_type == TRACK_TYPE_GENERIC) { - if (cam->conf->track_generic_move) { + if (cam->conf->track_generic_move != "") { return generic_move(cam, TRACK_MOVE, manual, 0, 0, cent, imgs); } else { return cam->conf->track_move_wait; diff --git a/src/util.cpp b/src/util.cpp index 00a248af..2a36e19b 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -447,8 +447,8 @@ size_t mystrftime(const struct ctx_cam *cam, char *s, size_t max, const char *us break; case '$': // thread name - if (cam->conf->camera_name && cam->conf->camera_name[0]) - snprintf(tempstr, PATH_MAX, "%s", cam->conf->camera_name); + if (cam->conf->camera_name != "") + cam->conf->camera_name.copy(tempstr, PATH_MAX); else ++pos_userformat; break; diff --git a/src/video_common.cpp b/src/video_common.cpp index 2401eb8e..9ded602e 100644 --- a/src/video_common.cpp +++ b/src/video_common.cpp @@ -547,7 +547,7 @@ int vid_parms_parse(struct ctx_cam *cam){ } vdevctx->usrctrl_count = 0; - if (cam->conf->vid_control_params != NULL){ + if (cam->conf->vid_control_params != ""){ MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO,_("Parsing controls: %s"),cam->conf->vid_control_params); indx_parm = 0; diff --git a/src/video_common.hpp b/src/video_common.hpp index da77b5a3..aa278b8a 100644 --- a/src/video_common.hpp +++ b/src/video_common.hpp @@ -19,7 +19,7 @@ struct video_dev { struct video_dev *next; int usage_count; int fd_device; - const char *videodevice; + char videodevice[PATH_MAX]; int input; int norm; int width; diff --git a/src/video_loopback.cpp b/src/video_loopback.cpp index 72b05aa8..58c6eb76 100644 --- a/src/video_loopback.cpp +++ b/src/video_loopback.cpp @@ -227,12 +227,12 @@ void vlp_init(struct ctx_cam *cam){ #if defined(HAVE_V4L2) && !defined(BSD) /* open video loopback devices if enabled */ - if (cam->conf->video_pipe) { + if (cam->conf->video_pipe != "") { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO ,_("Opening video loopback device for normal pictures")); /* vid_startpipe should get the output dimensions */ - cam->pipe = vlp_startpipe(cam->conf->video_pipe, cam->imgs.width, cam->imgs.height); + cam->pipe = vlp_startpipe(cam->conf->video_pipe.c_str(), cam->imgs.width, cam->imgs.height); if (cam->pipe < 0) { MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO @@ -243,12 +243,12 @@ void vlp_init(struct ctx_cam *cam){ cam->pipe = -1; } - if (cam->conf->video_pipe_motion) { + if (cam->conf->video_pipe_motion != "") { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO ,_("Opening video loopback device for motion pictures")); /* vid_startpipe should get the output dimensions */ - cam->mpipe = vlp_startpipe(cam->conf->video_pipe_motion, cam->imgs.width, cam->imgs.height); + cam->mpipe = vlp_startpipe(cam->conf->video_pipe_motion.c_str(), cam->imgs.width, cam->imgs.height); if (cam->mpipe < 0) { MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO diff --git a/src/video_v4l2.cpp b/src/video_v4l2.cpp index ef95988b..facb8cb8 100644 --- a/src/video_v4l2.cpp +++ b/src/video_v4l2.cpp @@ -1082,8 +1082,8 @@ static int v4l2_device_open(struct ctx_cam *cam, struct video_dev *curdev) { MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO ,_("Using videodevice %s and input %d") ,cam->conf->videodevice, cam->conf->input); + cam->conf->videodevice.copy(curdev->videodevice,PATH_MAX); - curdev->videodevice = cam->conf->videodevice; curdev->fd_device = -1; fd_device = -1; @@ -1258,7 +1258,7 @@ int v4l2_start(struct ctx_cam *cam) { /* If device is already open and initialized use it*/ curdev = videodevices; while (curdev) { - if (mystreq(cam->conf->videodevice, curdev->videodevice)) { + if (mystreq(cam->conf->videodevice.c_str(), curdev->videodevice)) { retcd = v4l2_vdev_init(cam); if (retcd == 0) retcd = vid_parms_parse(cam); if (retcd == 0) retcd = v4l2_imgs_set(cam, curdev); diff --git a/src/webu.cpp b/src/webu.cpp index 9daf997e..436bce8b 100644 --- a/src/webu.cpp +++ b/src/webu.cpp @@ -675,9 +675,9 @@ static int webu_process_config_set(struct webui_ctx *webui) { */ snprintf(temp_name, WEBUI_LEN_PARM, "%s", webui->uri_parm1); indx=0; - while (config_parms_depr[indx].parm_name != NULL) { - if (mystreq(config_parms_depr[indx].parm_name,webui->uri_parm1)){ - snprintf(temp_name, WEBUI_LEN_PARM, "%s", config_parms_depr[indx].newname); + while (config_parms_depr[indx].parm_name != "") { + if (mystreq(config_parms_depr[indx].parm_name.c_str() ,webui->uri_parm1)){ + snprintf(temp_name, WEBUI_LEN_PARM, "%s", config_parms_depr[indx].newname.c_str()); break; } indx++; @@ -686,33 +686,33 @@ static int webu_process_config_set(struct webui_ctx *webui) { * webcontrol_parms level. */ indx=0; - while (config_parms[indx].parm_name != NULL) { + while (config_parms[indx].parm_name != "") { if (((webui->thread_nbr != 0) && (config_parms[indx].main_thread)) || (config_parms[indx].webui_level > webui->camlst[0]->conf->webcontrol_parms) || (config_parms[indx].webui_level == WEBUI_LEVEL_NEVER) ) { indx++; continue; } - if (mystreq(temp_name, config_parms[indx].parm_name)) break; + if (mystreq(temp_name, config_parms[indx].parm_name.c_str())) break; indx++; } /* If we found the parm, assign it. If the loop above did not find the parm * then we ignore the request */ - if (config_parms[indx].parm_name != NULL){ + if (config_parms[indx].parm_name != ""){ if (strlen(webui->uri_parm1) > 0){ conf_edit_set(webui->camlst[webui->thread_nbr]->motapp,webui->thread_nbr - , (char *)config_parms[indx].parm_name, webui->uri_parm1); + ,config_parms[indx].parm_name, webui->uri_parm1); /*If we are updating vid parms, set the flag to update the device.*/ - if (mystreq(config_parms[indx].parm_name, "vid_control_params") && + if ((config_parms[indx].parm_name == "vid_control_params") && (webui->camlst[webui->thread_nbr]->vdev != NULL)){ webui->camlst[webui->thread_nbr]->vdev->update_parms = TRUE; } /* If changing language, do it now */ - if (mystreq(config_parms[indx].parm_name, "native_language")){ + if (config_parms[indx].parm_name == "native_language"){ if (webui->camlst[webui->thread_nbr]->motapp->native_language){ mytranslate_text("", 1); MOTION_LOG(INF, TYPE_ALL, NO_ERRNO,_("Native Language : on")); @@ -1028,35 +1028,35 @@ static void webu_mhd_auth_parse(struct webui_ctx *webui, int ctrl){ webui->auth_pass = NULL; if (ctrl){ - auth_len = strlen(webui->cam->conf->webcontrol_authentication); - col_pos =(char*) strstr(webui->cam->conf->webcontrol_authentication,":"); + auth_len = webui->cam->conf->webcontrol_authentication.length(); + col_pos =(char*) strstr(webui->cam->conf->webcontrol_authentication.c_str() ,":"); if (col_pos == NULL){ webui->auth_user = (char*)mymalloc(auth_len+1); webui->auth_pass = (char*)mymalloc(2); snprintf(webui->auth_user, auth_len + 1, "%s" - ,webui->cam->conf->webcontrol_authentication); + ,webui->cam->conf->webcontrol_authentication.c_str()); snprintf(webui->auth_pass, 2, "%s",""); } else { webui->auth_user = (char*)mymalloc(auth_len - strlen(col_pos) + 1); webui->auth_pass =(char*)mymalloc(strlen(col_pos)); snprintf(webui->auth_user, auth_len - strlen(col_pos) + 1, "%s" - ,webui->cam->conf->webcontrol_authentication); + ,webui->cam->conf->webcontrol_authentication.c_str()); snprintf(webui->auth_pass, strlen(col_pos), "%s", col_pos + 1); } } else { - auth_len = strlen(webui->cam->conf->stream_authentication); - col_pos =(char*) strstr(webui->cam->conf->stream_authentication,":"); + auth_len = strlen(webui->cam->conf->stream_authentication.c_str()); + col_pos =(char*) strstr(webui->cam->conf->stream_authentication.c_str(),":"); if (col_pos == NULL){ webui->auth_user = (char*)mymalloc(auth_len+1); webui->auth_pass = (char*)mymalloc(2); snprintf(webui->auth_user, auth_len + 1, "%s" - ,webui->cam->conf->stream_authentication); + ,webui->cam->conf->stream_authentication.c_str()); snprintf(webui->auth_pass, 2, "%s",""); } else { webui->auth_user = (char*)mymalloc(auth_len - strlen(col_pos) + 1); webui->auth_pass = (char*)mymalloc(strlen(col_pos)); snprintf(webui->auth_user, auth_len - strlen(col_pos) + 1, "%s" - ,webui->cam->conf->stream_authentication); + ,webui->cam->conf->stream_authentication.c_str()); snprintf(webui->auth_pass, strlen(col_pos), "%s", col_pos + 1); } } @@ -1081,7 +1081,7 @@ static int webu_mhd_auth(struct webui_ctx *webui, int ctrl){ if (ctrl){ /* Authentication for the webcontrol*/ - if (webui->cam->conf->webcontrol_authentication == NULL){ + if (webui->cam->conf->webcontrol_authentication == ""){ webui->authenticated = TRUE; if (webui->cam->conf->webcontrol_auth_method != 0){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("No webcontrol user:pass provided")); @@ -1099,7 +1099,7 @@ static int webu_mhd_auth(struct webui_ctx *webui, int ctrl){ } else { /* Authentication for the streams */ - if (webui->cam->conf->stream_authentication == NULL){ + if (webui->cam->conf->stream_authentication == ""){ webui->authenticated = TRUE; if (webui->cam->conf->stream_auth_method != 0){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("No stream user:pass provided")); @@ -1143,9 +1143,9 @@ static int webu_mhd_send(struct webui_ctx *webui, int ctrl) { if (webui->cam != NULL){ if (ctrl){ - if (webui->cam->conf->webcontrol_cors_header != NULL){ + if (webui->cam->conf->webcontrol_cors_header != ""){ MHD_add_response_header (response, MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN - , webui->cam->conf->webcontrol_cors_header); + , webui->cam->conf->webcontrol_cors_header.c_str()); } if (webui->cam->conf->webcontrol_interface == 1){ MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "text/plain;"); @@ -1153,9 +1153,9 @@ static int webu_mhd_send(struct webui_ctx *webui, int ctrl) { MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html"); } } else { - if (webui->cam->conf->stream_cors_header != NULL){ + if (webui->cam->conf->stream_cors_header !=""){ MHD_add_response_header (response, MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN - , webui->cam->conf->stream_cors_header); + , webui->cam->conf->stream_cors_header.c_str()); } MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html"); } @@ -1652,12 +1652,12 @@ static void webu_mhd_checktls(struct mhdstart_ctx *mhdst){ */ if (mhdst->ctrl){ if (mhdst->camlst[0]->conf->webcontrol_tls){ - if ((mhdst->camlst[0]->conf->webcontrol_cert == NULL) || (mhdst->tls_cert == NULL)) { + if ((mhdst->camlst[0]->conf->webcontrol_cert == "") || (mhdst->tls_cert == NULL)) { MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("SSL/TLS requested but no cert file provided. SSL/TLS disabled")); mhdst->camlst[0]->conf->webcontrol_tls = 0; } - if ((mhdst->camlst[0]->conf->webcontrol_key == NULL) || (mhdst->tls_key == NULL)) { + if ((mhdst->camlst[0]->conf->webcontrol_key == "") || (mhdst->tls_key == NULL)) { MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("SSL/TLS requested but no key file provided. SSL/TLS disabled")); mhdst->camlst[0]->conf->webcontrol_tls = 0; @@ -1665,12 +1665,12 @@ static void webu_mhd_checktls(struct mhdstart_ctx *mhdst){ } } else { if (mhdst->camlst[mhdst->indxthrd]->conf->stream_tls){ - if ((mhdst->camlst[0]->conf->webcontrol_cert == NULL) || (mhdst->tls_cert == NULL)) { + if ((mhdst->camlst[0]->conf->webcontrol_cert == "") || (mhdst->tls_cert == NULL)) { MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("SSL/TLS requested but no cert file provided. SSL/TLS disabled")); mhdst->camlst[mhdst->indxthrd]->conf->stream_tls = 0; } - if ((mhdst->camlst[0]->conf->webcontrol_key == NULL) || (mhdst->tls_key == NULL)) { + if ((mhdst->camlst[0]->conf->webcontrol_key == "") || (mhdst->tls_key == NULL)) { MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("SSL/TLS requested but no key file provided. SSL/TLS disabled")); mhdst->camlst[mhdst->indxthrd]->conf->stream_tls = 0; @@ -1893,8 +1893,8 @@ static void webu_init_ctrl(struct ctx_motapp *motapp){ struct mhdstart_ctx mhdst; unsigned int randnbr; - mhdst.tls_cert = webu_mhd_loadfile(motapp->cam_list[0]->conf->webcontrol_cert); - mhdst.tls_key = webu_mhd_loadfile(motapp->cam_list[0]->conf->webcontrol_key); + mhdst.tls_cert = webu_mhd_loadfile(motapp->cam_list[0]->conf->webcontrol_cert.c_str()); + mhdst.tls_key = webu_mhd_loadfile(motapp->cam_list[0]->conf->webcontrol_key.c_str()); mhdst.ctrl = TRUE; mhdst.indxthrd = 0; mhdst.camlst = motapp->cam_list; @@ -1948,8 +1948,8 @@ static void webu_init_strm(struct ctx_cam **cam_list){ struct mhdstart_ctx mhdst; unsigned int randnbr; - mhdst.tls_cert = webu_mhd_loadfile(cam_list[0]->conf->webcontrol_cert); - mhdst.tls_key = webu_mhd_loadfile(cam_list[0]->conf->webcontrol_key); + mhdst.tls_cert = webu_mhd_loadfile(cam_list[0]->conf->webcontrol_cert.c_str()); + mhdst.tls_key = webu_mhd_loadfile(cam_list[0]->conf->webcontrol_key.c_str()); mhdst.ctrl = FALSE; mhdst.indxthrd = 0; mhdst.camlst = cam_list; diff --git a/src/webu_html.cpp b/src/webu_html.cpp index e22129fc..a547404d 100644 --- a/src/webu_html.cpp +++ b/src/webu_html.cpp @@ -254,7 +254,7 @@ static void webu_html_navbar_camera(struct webui_ctx *webui) { if (webui->cam_threads == 1){ /* Only Motion.conf file */ - if (webui->camlst[0]->conf->camera_name == NULL){ + if (webui->camlst[0]->conf->camera_name == ""){ snprintf(response, sizeof (response), "
\n" " \n" @@ -272,7 +272,7 @@ static void webu_html_navbar_camera(struct webui_ctx *webui) { " %s\n" ,_("Cameras") ,webui->camlst[0]->camera_id - ,webui->camlst[0]->conf->camera_name); + ,webui->camlst[0]->conf->camera_name.c_str()); webu_write(webui, response); } } else if (webui->cam_threads > 1){ @@ -287,7 +287,7 @@ static void webu_html_navbar_camera(struct webui_ctx *webui) { webu_write(webui, response); for (indx=1;indx <= webui->cam_count;indx++){ - if (webui->camlst[indx]->conf->camera_name == NULL){ + if (webui->camlst[indx]->conf->camera_name == ""){ snprintf(response, sizeof (response), " %s %d\n" ,webui->camlst[indx]->camera_id @@ -296,7 +296,7 @@ static void webu_html_navbar_camera(struct webui_ctx *webui) { snprintf(response, sizeof (response), " %s\n" ,webui->camlst[indx]->camera_id - ,webui->camlst[indx]->conf->camera_name + ,webui->camlst[indx]->conf->camera_name.c_str() ); } webu_write(webui, response); @@ -452,7 +452,7 @@ static void webu_html_config(struct webui_ctx *webui) { */ val_temp=(char*) malloc(PATH_MAX); indx_parm = 0; - while (config_parms[indx_parm].parm_name != NULL){ + while (config_parms[indx_parm].parm_name != ""){ if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf->webcontrol_parms) || (config_parms[indx_parm].webui_level == WEBUI_LEVEL_NEVER)){ @@ -465,7 +465,7 @@ static void webu_html_config(struct webui_ctx *webui) { snprintf(response, sizeof (response), " \n", - config_parms[indx_parm].parm_name); + config_parms[indx_parm].parm_name.c_str()); webu_write(webui, response); } else { snprintf(response, sizeof (response),"\" >%s (%s)\n", - config_parms[indx_parm].parm_name - ,_(config_parms[indx_parm].parm_name)); + config_parms[indx_parm].parm_name.c_str() + ,_(config_parms[indx_parm].parm_name.c_str())); webu_write(webui, response); } @@ -801,7 +801,7 @@ static void webu_html_script_camera_thread(struct webui_ctx *webui) { webu_write(webui, response); } - if (webui->camlst[indx]->conf->camera_name == NULL){ + if (webui->camlst[indx]->conf->camera_name == ""){ snprintf(response, sizeof (response), " header=\"

%s %d (%s)

\"\n" @@ -815,7 +815,7 @@ static void webu_html_script_camera_thread(struct webui_ctx *webui) { snprintf(response, sizeof (response), " header=\"

%s (%s)

\"\n" - , webui->camlst[indx]->conf->camera_name + , webui->camlst[indx]->conf->camera_name.c_str() ,(!webui->camlst[indx]->running_cam)? _("Not running") : (webui->camlst[indx]->lost_connection)? _("Lost connection"): (webui->camlst[indx]->pause)? _("Paused"):_("Active") diff --git a/src/webu_stream.cpp b/src/webu_stream.cpp index 9978b3b3..2328a561 100644 --- a/src/webu_stream.cpp +++ b/src/webu_stream.cpp @@ -295,9 +295,9 @@ int webu_stream_mjpeg(struct webui_ctx *webui) { return MHD_NO; } - if (webui->cam->conf->stream_cors_header != NULL){ + if (webui->cam->conf->stream_cors_header != ""){ MHD_add_response_header (response, MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN - , webui->cam->conf->stream_cors_header); + , webui->cam->conf->stream_cors_header.c_str()); } MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE @@ -335,9 +335,9 @@ int webu_stream_static(struct webui_ctx *webui) { return MHD_NO; } - if (webui->cam->conf->stream_cors_header != NULL){ + if (webui->cam->conf->stream_cors_header != ""){ MHD_add_response_header (response, MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN - , webui->cam->conf->stream_cors_header); + , webui->cam->conf->stream_cors_header.c_str()); } MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "image/jpeg;"); diff --git a/src/webu_text.cpp b/src/webu_text.cpp index e0cd5c45..44050680 100644 --- a/src/webu_text.cpp +++ b/src/webu_text.cpp @@ -40,7 +40,7 @@ static void webu_text_seteol(struct webui_ctx *webui) { static void webu_text_camera_name(struct webui_ctx *webui) { char response[WEBUI_LEN_RESP]; - if (webui->camlst[webui->thread_nbr]->conf->camera_name == NULL){ + if (webui->camlst[webui->thread_nbr]->conf->camera_name == ""){ snprintf(response,sizeof(response), "Camera %s %s\n" ,webui->uri_camid,webui->text_eol @@ -48,7 +48,7 @@ static void webu_text_camera_name(struct webui_ctx *webui) { } else { snprintf(response,sizeof(response), "Camera %s %s\n" - ,webui->camlst[webui->thread_nbr]->conf->camera_name + ,webui->camlst[webui->thread_nbr]->conf->camera_name.c_str() ,webui->text_eol ); } @@ -149,7 +149,7 @@ static void webu_text_page_basic(struct webui_ctx *webui) { if (webui->cam_threads > 1){ for (indx = 1; indx < webui->cam_threads; indx++) { - if (webui->camlst[indx]->conf->camera_name == NULL){ + if (webui->camlst[indx]->conf->camera_name == ""){ snprintf(response, sizeof (response), "Camera %d
\n" , webui->camlst[indx]->camera_id @@ -159,7 +159,7 @@ static void webu_text_page_basic(struct webui_ctx *webui) { snprintf(response, sizeof (response), "Camera %s
\n" , webui->camlst[indx]->camera_id - ,webui->camlst[indx]->conf->camera_name); + ,webui->camlst[indx]->conf->camera_name.c_str()); webu_write(webui, response); } } @@ -175,7 +175,7 @@ static void webu_text_list_raw(struct webui_ctx *webui) { char val_parm[PATH_MAX]; indx_parm = 0; - while (config_parms[indx_parm].parm_name != NULL){ + while (config_parms[indx_parm].parm_name != ""){ if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf->webcontrol_parms) || (config_parms[indx_parm].webui_level == WEBUI_LEVEL_NEVER) || @@ -192,7 +192,7 @@ static void webu_text_list_raw(struct webui_ctx *webui) { } snprintf(response, sizeof (response), " %s = %s \n" - ,config_parms[indx_parm].parm_name + ,config_parms[indx_parm].parm_name.c_str() ,val_parm ); webu_write(webui, response); @@ -222,7 +222,7 @@ static void webu_text_list_basic(struct webui_ctx *webui) { webu_write(webui, response); indx_parm = 0; - while (config_parms[indx_parm].parm_name != NULL){ + while (config_parms[indx_parm].parm_name != ""){ if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf->webcontrol_parms) || (config_parms[indx_parm].webui_level == WEBUI_LEVEL_NEVER) || @@ -240,8 +240,8 @@ static void webu_text_list_basic(struct webui_ctx *webui) { snprintf(response, sizeof (response), "
  • %s = %s
  • \n" ,webui->uri_camid - ,config_parms[indx_parm].parm_name - ,config_parms[indx_parm].parm_name + ,config_parms[indx_parm].parm_name.c_str() + ,config_parms[indx_parm].parm_name.c_str() ,val_parm); webu_write(webui, response); @@ -280,7 +280,7 @@ static void webu_text_set_menu(struct webui_ctx *webui) { webu_write(webui, response); indx_parm = 0; - while (config_parms[indx_parm].parm_name != NULL){ + while (config_parms[indx_parm].parm_name != ""){ if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf->webcontrol_parms) || (config_parms[indx_parm].webui_level == WEBUI_LEVEL_NEVER) || @@ -297,8 +297,8 @@ static void webu_text_set_menu(struct webui_ctx *webui) { } snprintf(response, sizeof(response), "\n" - ,config_parms[indx_parm].parm_name - ,config_parms[indx_parm].parm_name + ,config_parms[indx_parm].parm_name.c_str() + ,config_parms[indx_parm].parm_name.c_str() ); webu_write(webui, response); @@ -334,12 +334,12 @@ static void webu_text_set_query(struct webui_ctx *webui) { webu_text_camera_name(webui); indx_parm = 0; - while (config_parms[indx_parm].parm_name != NULL){ + while (config_parms[indx_parm].parm_name != ""){ if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf->webcontrol_parms) || (config_parms[indx_parm].webui_level == WEBUI_LEVEL_NEVER) || ((webui->thread_nbr != 0) && (config_parms[indx_parm].main_thread != 0)) || - (mystrne(webui->uri_parm1, config_parms[indx_parm].parm_name))) { + (mystrne(webui->uri_parm1, config_parms[indx_parm].parm_name.c_str()))) { indx_parm++; continue; } @@ -354,8 +354,8 @@ static void webu_text_set_query(struct webui_ctx *webui) { "
    \n" "%s \n" "\n" - ,config_parms[indx_parm].parm_name - ,config_parms[indx_parm].parm_name + ,config_parms[indx_parm].parm_name.c_str() + ,config_parms[indx_parm].parm_name.c_str() ,val_parm ); webu_write(webui, response); @@ -415,7 +415,7 @@ static void webu_text_get_menu(struct webui_ctx *webui) { webu_write(webui, response); indx_parm = 0; - while (config_parms[indx_parm].parm_name != NULL){ + while (config_parms[indx_parm].parm_name != ""){ if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf->webcontrol_parms) || (config_parms[indx_parm].webui_level == WEBUI_LEVEL_NEVER) || @@ -426,8 +426,8 @@ static void webu_text_get_menu(struct webui_ctx *webui) { snprintf(response, sizeof(response), "\n" - ,config_parms[indx_parm].parm_name - ,config_parms[indx_parm].parm_name + ,config_parms[indx_parm].parm_name.c_str() + ,config_parms[indx_parm].parm_name.c_str() ); webu_write(webui, response); @@ -885,21 +885,21 @@ void webu_text_get_query(struct webui_ctx *webui) { */ snprintf(temp_name, WEBUI_LEN_PARM, "%s", webui->uri_value1); indx_parm=0; - while (config_parms_depr[indx_parm].parm_name != NULL) { - if (mystreq(config_parms_depr[indx_parm].parm_name, webui->uri_value1)){ - snprintf(temp_name, WEBUI_LEN_PARM, "%s", config_parms_depr[indx_parm].newname); + while (config_parms_depr[indx_parm].parm_name != "") { + if (mystreq(config_parms_depr[indx_parm].parm_name.c_str(), webui->uri_value1)){ + snprintf(temp_name, WEBUI_LEN_PARM, "%s", config_parms_depr[indx_parm].newname.c_str()); break; } indx_parm++; } indx_parm = 0; - while (config_parms[indx_parm].parm_name != NULL){ + while (config_parms[indx_parm].parm_name != ""){ if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf->webcontrol_parms) || (config_parms[indx_parm].webui_level == WEBUI_LEVEL_NEVER) || mystrne(webui->uri_parm1,"query") || - mystrne(temp_name, config_parms[indx_parm].parm_name)){ + mystrne(temp_name, config_parms[indx_parm].parm_name.c_str())){ indx_parm++; continue; } @@ -910,7 +910,7 @@ void webu_text_get_query(struct webui_ctx *webui) { conf_edit_get(webui->camlst[0], config_parms[indx_parm].parm_name , val_parm, config_parms[indx_parm].parm_cat); } - if (mystrne(webui->uri_value1, config_parms[indx_parm].parm_name)){ + if (mystrne(webui->uri_value1, config_parms[indx_parm].parm_name.c_str())){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO , _("'%s' option is depreciated. New option name is `%s'") ,webui->uri_value1, config_parms[indx_parm].parm_name); @@ -927,14 +927,14 @@ void webu_text_get_query(struct webui_ctx *webui) { "
      \n" "
    • %s = %s
    • \n" "
    \n" - ,config_parms[indx_parm].parm_name + ,config_parms[indx_parm].parm_name.c_str() ,val_parm ); } else { snprintf(response, sizeof (response), "%s = %s %s\n" "Done %s\n" - ,config_parms[indx_parm].parm_name + ,config_parms[indx_parm].parm_name.c_str() ,val_parm ,webui->text_eol, webui->text_eol ); @@ -945,7 +945,7 @@ void webu_text_get_query(struct webui_ctx *webui) { break; } - if (config_parms[indx_parm].parm_name == NULL){ + if (config_parms[indx_parm].parm_name == ""){ webu_text_badreq(webui); } @@ -1007,8 +1007,8 @@ void webu_text_connection(struct webui_ctx *webui) { snprintf(response,sizeof(response) , "Camera %d%s%s %s %s\n" ,webui->camlst[indx]->camera_id - ,webui->camlst[indx]->conf->camera_name ? " -- " : "" - ,webui->camlst[indx]->conf->camera_name ? webui->camlst[indx]->conf->camera_name : "" + ,webui->camlst[indx]->conf->camera_name!="" ? " -- " : "" + ,webui->camlst[indx]->conf->camera_name!="" ? webui->camlst[indx]->conf->camera_name.c_str() : "" ,(!webui->camlst[indx]->running_cam)? "NOT RUNNING" : (webui->camlst[indx]->lost_connection)? "Lost connection": "Connection OK" ,webui->text_eol @@ -1019,8 +1019,8 @@ void webu_text_connection(struct webui_ctx *webui) { snprintf(response,sizeof(response) , "Camera %d%s%s %s %s\n" ,webui->cam->camera_id - ,webui->cam->conf->camera_name ? " -- " : "" - ,webui->cam->conf->camera_name ? webui->cam->conf->camera_name : "" + ,webui->cam->conf->camera_name!="" ? " -- " : "" + ,webui->cam->conf->camera_name!="" ? webui->cam->conf->camera_name.c_str() : "" ,(!webui->cam->running_cam)? "NOT RUNNING" : (webui->cam->lost_connection)? "Lost connection": "Connection OK" ,webui->text_eol