]> granicus.if.org Git - fcron/commitdiff
use fscanf(),fprintf(),etc size arguments dependent on the architecture
authorthib <thib>
Sat, 14 Apr 2007 16:59:02 +0000 (16:59 +0000)
committerthib <thib>
Sat, 14 Apr 2007 16:59:02 +0000 (16:59 +0000)
config.h.in
convert-fcrontab.c
fcronsighup.c
global.h

index 03d9818947bf62f07592e6885f038ec584ecd88d..83e9088944de77435264e211f4bdec086fdecef7 100644 (file)
@@ -21,7 +21,7 @@
  *  `LICENSE' that comes with the fcron source distribution.
  */
 
- /* $Id: config.h.in,v 1.60 2007-01-23 22:51:22 thib Exp $ */
+ /* $Id: config.h.in,v 1.61 2007-04-14 17:02:34 thib Exp $ */
 
 
 /* *********************************************************** */
 #define O_SYNC O_FSYNC
 #endif
 
+/* These SIZEOF_* constants are defined by the AC_CHECK_SIZEOF macro */
+#undef SIZEOF_TIME_T
+#undef SIZEOF_PID_T
+#undef SIZEOF_SHORT_INT
+#undef SIZEOF_INT
+#undef SIZEOF_LONG_INT
+#undef SIZEOF_LONG_LONG_INT
+
+/* We need all these types in global.h to know which conversion string we whould
+ * use when reading a pid_t or a time_t */
+#ifndef SIZEOF_PID_T
+#error "sizeof pid_t unknown."
+#endif
+
+#ifndef SIZEOF_TIME_T
+#error "sizeof time_t unknown."
+#endif
+
+#ifndef SIZEOF_SHORT_INT
+#error "sizeof short int unknown."
+#endif
+
+#ifndef SIZEOF_INT
+#error "sizeof int unknown."
+#endif
+
+#ifndef SIZEOF_LONG_INT
+#error "sizeof long int unknown."
+#endif
+
+#ifndef SIZEOF_LONG_LONG_INT
+#error "sizeof long long int unknown."
+#endif
+
index 22b14b37d88174d0682e68d68ac6ac9f1007d2af..9591db71f99fe36fa77d7464d3e389f344be4a0b 100644 (file)
  *  `LICENSE' that comes with the fcron source distribution.
  */
 
- /* $Id: convert-fcrontab.c,v 1.21 2006-05-20 16:27:46 thib Exp $ */
+ /* $Id: convert-fcrontab.c,v 1.22 2007-04-14 17:03:00 thib Exp $ */
 
 #include "convert-fcrontab.h"
-#include "global.h"
 
-char rcs_info[] = "$Id: convert-fcrontab.c,v 1.21 2006-05-20 16:27:46 thib Exp $";
+char rcs_info[] = "$Id: convert-fcrontab.c,v 1.22 2007-04-14 17:03:00 thib Exp $";
 
 void info(void);
 void usage(void);
@@ -185,7 +184,7 @@ convert_file(char *file_name)
     if ((file->cf_user = read_str(f, buf, sizeof(buf))) == NULL)
        die_e("Cannot read user's name");
 
-    if ( fscanf(f, "%ld", (long int *) &t_save) != 1 )
+    if ( fscanf(f, "%" ATTR_SIZE_TIMET  "d", CAST_TIMET_PTR &t_save) != 1 )
        error("could not get time and date of saving");
 
     /* read env variables */
index 34eb01fe2a310260fd1940ea9dbfc3d754cd81c6..ea03361889e3660ffba0bfe92fa760a2e4110112 100644 (file)
  *  `LICENSE' that comes with the fcron source distribution.
  */
 
- /* $Id: fcronsighup.c,v 1.11 2007-01-01 18:49:43 thib Exp $ */
+ /* $Id: fcronsighup.c,v 1.12 2007-04-14 16:59:02 thib Exp $ */
 
 #include "fcronsighup.h"
 #include "global.h"
 #include "allow.h"
 
-char rcs_info[] = "$Id: fcronsighup.c,v 1.11 2007-01-01 18:49:43 thib Exp $";
+char rcs_info[] = "$Id: fcronsighup.c,v 1.12 2007-04-14 16:59:02 thib Exp $";
 
 void usage(void);
 void sig_daemon(void);
@@ -83,7 +83,7 @@ read_pid(void)
     pid_t pid = 0;
     
     if ((fp = fopen(pidfile, "r")) != NULL) {
-       if ( fscanf(fp, "%d", (int *) &pid) < 1 )
+       if ( fscanf(fp, "%" ATTR_SIZE_PIDT "d", CAST_PIDT_PTR &pid) < 1 )
            error("Unable to read fcron daemon's pid (fscanf(fp,...))");
        fclose(fp);
     }
index 1cf25c7e75bf0629fabdebd55b4812ce514785e0..b9d00cc7b27de7e0bd12ecd6b09f89e86e5cb591 100644 (file)
--- a/global.h
+++ b/global.h
@@ -21,7 +21,7 @@
  *  `LICENSE' that comes with the fcron source distribution.
  */
 
- /* $Id: global.h,v 1.47 2007-01-23 22:49:03 thib Exp $ */
+ /* $Id: global.h,v 1.48 2007-04-14 17:02:20 thib Exp $ */
 
 
 /* 
@@ -234,6 +234,39 @@ typedef struct exe_t {
 } exe_t;
 
 
+#if SIZEOF_TIME_T == SIZEOF_SHORT_INT
+#define ATTR_SIZE_TIMET "h"
+#define CAST_TIMET_PTR (short int *)
+#elif SIZEOF_TIME_T == SIZEOF_INT
+#define ATTR_SIZE_TIMET ""
+#define CAST_TIMET_PTR (int *)
+#elif SIZEOF_TIME_T == SIZEOF_LONG_INT
+#define ATTR_SIZE_TIMET "l"
+#define CAST_TIMET_PTR (long int *)
+#elif SIZEOF_TIME_T == SIZEOF_LONG_LONG_INT
+#define ATTR_SIZE_TIMET "ll"
+#define CAST_TIMET_PTR (long long int *)
+#else
+#error "SIZEOF_TIME_T does not correspond with a known format."
+#endif
+
+#if SIZEOF_PID_T == SIZEOF_SHORT_INT
+#define ATTR_SIZE_PIDT "h"
+#define CAST_PIDT_PTR (short int *)
+#elif SIZEOF_PID_T == SIZEOF_INT
+#define ATTR_SIZE_PIDT ""
+#define CAST_PIDT_PTR (int *)
+#elif SIZEOF_PID_T == SIZEOF_LONG_INT
+#define ATTR_SIZE_PIDT "l"
+#define CAST_PIDT_PTR (long int *)
+#elif SIZEOF_PID_T == SIZEOF_LONG_LONG_INT
+#define ATTR_SIZE_PIDT "ll"
+#define CAST_PIDT_PTR (long long int *)
+#else
+#error "SIZEOF_PID_T does not correspond with a known format."
+#endif
+
+
 /* local header files : we include here the headers which may use some types defined
  *                      above. */