diff m_option.c @ 28759:af274aef6b81

Add a 64 bit integer type to the suboption parser.
author reimar
date Mon, 02 Mar 2009 11:17:50 +0000
parents f8625bfd9aa5
children d5e0b9e3cefc
line wrap: on
line diff
--- a/m_option.c	Mon Mar 02 11:10:11 2009 +0000
+++ b/m_option.c	Mon Mar 02 11:17:50 2009 +0000
@@ -162,13 +162,20 @@
     return M_OPT_OUT_OF_RANGE;
   }
 
-  if(dst) VAL(dst) = tmp_int;
+  if(dst) {
+    if (opt->type->size == sizeof(int64_t))
+      *(int64_t *)dst = tmp_int;
+    else
+      VAL(dst) = tmp_int;
+  }
 
   return 1;
 }
 
 static char* print_int(const m_option_t* opt,  const void* val) {
   opt = NULL;
+  if (opt->type->size == sizeof(int64_t))
+    return dup_printf("%"PRId64, *(const int64_t *)val);
   return dup_printf("%d",VAL(val));
 }
 
@@ -185,6 +192,19 @@
   NULL
 };
 
+const m_option_type_t m_option_type_int64 = {
+  "Integer64",
+  "",
+  sizeof(int64_t),
+  0,
+  parse_int,
+  print_int,
+  copy_opt,
+  copy_opt,
+  NULL,
+  NULL
+};
+
 // Float
 
 #undef VAL