--- freem/src/iniconf.c 2025/04/09 19:52:02 1.5
+++ freem/src/iniconf.c 2025/04/13 04:22:43 1.9
@@ -1,5 +1,5 @@
/*
- * $Id: iniconf.c,v 1.5 2025/04/09 19:52:02 snw Exp $
+ * $Id: iniconf.c,v 1.9 2025/04/13 04:22:43 snw Exp $
* Function implementations for reading
* FreeM configuration files
*
@@ -25,6 +25,18 @@
* along with FreeM. If not, see .
*
* $Log: iniconf.c,v $
+ * Revision 1.9 2025/04/13 04:22:43 snw
+ * Fix snprintf calls
+ *
+ * Revision 1.8 2025/04/10 15:31:25 snw
+ * Attempt to fix DosCopy calls for OS/2
+ *
+ * Revision 1.7 2025/04/10 15:27:39 snw
+ * Detect Devuan distribution and fix OS/2 problem with iniconf.c
+ *
+ * Revision 1.6 2025/04/10 01:24:38 snw
+ * Remove C++ style comments
+ *
* Revision 1.5 2025/04/09 19:52:02 snw
* Eliminate as many warnings as possible while building with -Wall
*
@@ -53,6 +65,10 @@
#include
#include "mpsdef.h"
+#if defined(__OS2__)
+# include
+#endif
+
extern char config_file[4096];
#if !defined(PATH_MAX) && defined(_SCO_DS)
@@ -71,6 +87,11 @@ extern char config_file[4096];
# include
#endif
+#if !defined(PATH_MAX)
+# define PATH_MAX 4096
+#endif
+
+
/* ini_keyvalue *ini_head; */
int get_conf(char *section, char *key, char *value)
@@ -197,6 +218,8 @@ int read_profile_string(char *file, char
char *cursec;
char *line;
int lnum = 0;
+
+ curkey = (char *) NULL;
fullsec = (char *) malloc(CONF_BUFSIZE);
NULLPTRCHK(fullsec,"read_profile_string");
@@ -210,14 +233,14 @@ int read_profile_string(char *file, char
- snprintf(fullsec, CONF_BUFSIZE, "[%s]%c", section, '\0');
+ snprintf(fullsec, CONF_BUFSIZE - 1, "[%s]%c", section, '\0');
strcpy(cursec, "[]");
fp = fopen(file, "r");
- while(fgets(line, CONF_BUFSIZE, fp) != NULL) {
+ while(fgets(line, CONF_BUFSIZE - 1, fp) != NULL) {
++lnum;
if(line[0] == '[') {
@@ -300,7 +323,7 @@ int modify_profile_string(char *file, ch
char tmps[255];
int changed = FALSE;
- snprintf (output_filename, 4095, "%s.tmp", file);
+ snprintf (output_filename, sizeof (output_filename) - 1, "%s.tmp", file);
if ((input_fp = fopen (file, "r")) == NULL) {
return FALSE;
@@ -331,7 +354,7 @@ int modify_profile_string(char *file, ch
/* is this key the one we're changing? */
if (strcmp (key, current_key) == 0) {
/* yes; modify it and write out*/
- snprintf (tmps, 255, "%s=%s\n", current_key, value);
+ snprintf (tmps, sizeof (tmps) - 1, "%s=%s\n", current_key, value);
fputs (tmps, output_fp);
changed = TRUE;
@@ -364,7 +387,7 @@ int modify_profile_string(char *file, ch
#if !defined(__OS2__)
cp (file, output_filename);
#else
- DosCopy (output_filename, file);
+ DosCopy (output_filename, file, 1);
#endif
return changed;