[continued from previous message]
+ commentfile = fopen(optarg,"r");
+ if (!commentfile) {
+ int errcode = errno;
+ lib_error(CATGETS(elm_msg_cat, MeSet, MeFileNotReadable,
+ "File %.50s is not readable: %s"),
+ optarg, strerror(errcode));
+ err++;
+ goto fail;
+
+ }
+ break;
+
+ case 'd' :
+ #if DEBUG
+ set_debugging(optarg);
+ #else
+ lib_error(CATGETS(elm_msg_cat, ElmSet, ElmArgsIngoringDebug,
+ "Warning: system created without debugging enabled - request ignored\n"));
+ #endif
+ break;
+
+ case 'r':
+ set_user_rc_location(optarg);
+ break;
+
+ case 'w' :
+ targetfile = optarg;
+ if (0 != access(targetfile,WRITE_ACCESS)) {
+ int errcode = errno;
+
+ if (errcode != ENOENT) {
+ lib_error(CATGETS(elm_msg_cat, MeSet, MeFileNotWriteable,
+ "File %.50s is not writeable: %s"),
+ targetfile, strerror(errcode));
+ err++;
+ goto fail;
+ }
+ }
+ break;
+ case '?':
+ err = 1;
+ goto fail;
+ }
+ }
+
+ elm_sfprintf(version_buff, sizeof version_buff,
+ FRM("%s PL%s"), VERSION, PATCHLEVEL);
+
+ #ifdef DEBUG
+ {
+ int d UNUSED_VAROK = panic_dprint("\n\
+ ======================================================\n\
+ Debug output of the ELMTAGFILTERENTS program (version %s).\n",
+ version_buff);
+
+ #if 0
+ if (d >= 50) {
+ panic_dprint("WARNING: Edit manually out sensitive information from that file!\n");
+
+ lower_prompt("WARNING: Debug file may include passwords -- edit it!");
+ sleep(5+sleepmsg);
+ }
+ #endif
+ }
+ #endif
+
+ if (!global)
+ read_rc_file(read_flags);
+ else
+ post_init_check(read_flags);
+
+ if (optind < argc) {
+ int errcount = 0;
+ int need_rewrite = 0;
+
+ MAP = parse_tagfilter_entities(argv[optind],&errcount,&cs,&pl,
+ global ? SYSTEM_RC : LOCAL_RC,
+ & need_rewrite);
+
+ if (!MAP || errcount) {
+ err = 1;
+ goto fail;
+ }
+ }
+
+ if (config_merge) {
+ int errcount = 0;
+
+ if (!MAP) {
+ lib_error(CATGETS(elm_msg_cat, MeSet, MeConfigMergeMap,
+ "Config merge (-c) requires map as argument"));
+ err++;
+ goto fail;
+ }
+
+ if (targetfile) {
+ lib_error(CATGETS(elm_msg_cat, MeSet, MeConfigMergeNoW,
+ "Config merge (-c) Can not used with -w"));
+ err++;
+ goto fail;
+ }
+
+ if (pl)
+ free_editor_propline(&pl);
+
+
+ if (global) {
+ if (!change_tagfilter_entities(& system_tagfilter_entities_conf,
+ MAP,SYSTEM_RC,
+ system_tagfilter_entfile,&errcount)) {
+ err++;
+ }
+
+ free_tagfilter_entities_conf(&MAP);
+
+ MAP = system_tagfilter_entities_conf;
+ targetfile = system_tagfilter_entfile;
+ cs = system_tagfilter_entities_cs;
+ pl = system_tagfilter_entities_pl;
+
+ } else {
+ if (!change_tagfilter_entities(& user_tagfilter_entities_conf,
+ MAP, LOCAL_RC,
+ user_tagfilter_entfile,&errcount
+ )) {
+ err++;
+ }
+
+ free_tagfilter_entities_conf(&MAP);
+
+ MAP = user_tagfilter_entities_conf;
+ targetfile = user_tagfilter_entfile;
+ cs = user_tagfilter_entities_cs;
+ pl = user_tagfilter_entities_pl;
+ }
+
+ if (errcount) {
+ err = 1;
+ }
+
+ if (0 != access(targetfile,WRITE_ACCESS)) {
+ int errcode = errno;
+
+ if (errcode != ENOENT) {
+ lib_error(CATGETS(elm_msg_cat, MeSet, MeFileNotWriteable,
+ "File %.50s is not writeable: %s"),
+ targetfile, strerror(errcode));
+ err++;
+ goto fail;
+ }
+ }
+ }
+
+
+ if (!MAP) {
+ if (global) {
+ MAP = system_tagfilter_entities_conf;
+ cs = system_tagfilter_entities_cs;
+ pl = system_tagfilter_entities_pl;
+ } else {
+ MAP = user_tagfilter_entities_conf;
+ cs = user_tagfilter_entities_cs;
+ pl = user_tagfilter_entities_pl;
+ }
+ }
+
+
+ if (targetfile) {
+ char * tmp = elm_message(FRM("%s.N"),targetfile);
+ int errcode = can_open(tmp,"w");
+ FILE *f;
+
+ if (errcode) {
+ lib_error(CATGETS(elm_msg_cat, MeSet, MeFileNotWriteable,
+ "File %.50s is not writeable: %s"),
+ tmp, strerror(errcode));
+
+ err++;
+ goto fail_dump;
+ }
+
+ f = fopen(tmp,"w");
+ if (!f) {
+ errcode = errno;
+ lib_error(CATGETS(elm_msg_cat, MeSet, MeFileNotWriteable,
+ "File %.50s is not writeable: %s"),
+ tmp, strerror(errcode));
+
+ err++;
+ goto fail_dump;
+ }
+
+ if (! dump_tagfilter_entities(f,MAP,commentfile,
+ "ELMTAGFILTERENTS",version_buff,
+ cs,pl,
+ global ? SYSTEM_RC : LOCAL_RC,
+ &errcode)) {
+ if (errcode)
+ lib_error(CATGETS(elm_msg_cat, MeSet, MeConfFileWriteFailedC,
+ "Failed to write config file %.50s: %s"),
+ tmp,strerror(errcode));
+ else
+ lib_error(CATGETS(elm_msg_cat, MeSet, MeConfFileWriteFailed,
+ "Failed to write config file %.50s"),
+ tmp);
+ fclose(f);
+
+ err++;
+ goto fail_dump;
+ }
+
+ if (EOF == fclose(f)) {
+ errcode = errno;
+ lib_error(CATGETS(elm_msg_cat, MeSet, MeFileNotWriteable,
+ "File %.50s is not writeable: %s"),
+ tmp, strerror(errcode));
+
+ err++;
+ goto fail_dump;
+ }
+ if (0 != rename(tmp,targetfile)) {
+ errcode = errno;
+ lib_error(CATGETS(elm_msg_cat, MeSet, MeFileNotRenamed,
+ "Failed to rename temporary file to %.50s: %.30s"),
+ targetfile, strerror(errcode));
+
+ err++;
+ goto fail_dump;
+ }
+ log_config(targetfile);
+
+ fail_dump:
+
+ free(tmp);
+
+ } else {
+ int errcode = 0;
+
+ if (! dump_tagfilter_entities(stdout,MAP,commentfile,
+ "ELMTAGFILTERENTS",version_buff,
+ cs,pl,
+ global ? SYSTEM_RC : LOCAL_RC,
+ &errcode)) {
+
+ if (errcode)
+ lib_error(CATGETS(elm_msg_cat, MeSet, MeConfPrintFailedC,
+ "Failed to print config: %s"),
+ strerror(errcode));
+ else
+ lib_error(CATGETS(elm_msg_cat, MeSet, MeConfPrintFailed,
+ "Failed to print config"));
+
+ err++;
+ goto fail;
+ }
+ }
+
+ fail:
+ if (commentfile)
+ fclose(commentfile);
+
+ if (MAP &&
+ MAP != system_tagfilter_entities_conf &&
+ MAP != user_tagfilter_entities_conf)
+ free_tagfilter_entities_conf(&MAP);
+
+ if (err)
+ lib_error(CATGETS(elm_msg_cat, MeSet, MeProgFailed,
+ "%s failed; exit code=%d"),
+ argv[0],err);
+
+ return err;
+ }
+
+ /*
+ * Local Variables:
+ * mode:c
+ * c-basic-offset:4
+ * buffer-file-coding-system: iso-8859-1
+ * End:
+ */
+
Index: elmME+.2.5.alpha63-cvs/utils/elmterminal.c
*** elmME+.2.5.alpha62/utils/elmterminal.c Fri Dec 21 13:21:43 2018
--- elmME+.2.5.alpha63-cvs/utils/elmterminal.c Wed Dec 13 18:55:32 2023 ***************
*** 1,7 ****
! static char rcsid[] = "@(#)$Id: elmterminal.c,v 2.9 2018/12/21 11:21:43 hurtta Exp $";
/******************************************************************************
! * The Elm (ME+) Mail System - $Revision: 2.9 $ $State: Exp $
*
* Author: Kari Hurtta <
hurtta+elm@siilo.FMI.FI>
* (was
hurtta+elm@posti.FMI.FI,
hurtta+elm@ozone.FMI.FI) --- 1,7 ----
! static char rcsid[] = "@(#)$Id: elmterminal.c,v 2.10 2023/12/13 16:55:32 hurtta Exp $";
/******************************************************************************
! * The Elm (ME+) Mail System - $Revision: 2.10 $ $State: Exp $
*
* Author: Kari Hurtta <
hurtta+elm@siilo.FMI.FI>
* (was
hurtta+elm@posti.FMI.FI,
hurtta+elm@ozone.FMI.FI) ***************
*** 153,171 ****
}
#endif
! if (!global)
! read_rc_file(read_flags);
! else
! post_init_che