capture_file.h (Qt): missing ]
[metze/wireshark/wip.git] / capture_stop_conditions.c
index 1eb7a443cdaba58e5873d1d4c48cc1a67019e777..4a1d78119d3ee146701bd703b61fce8aa82f92f1 100644 (file)
@@ -1,10 +1,8 @@
 /* capture_stop_conditions.c
  * Implementation for 'stop condition handler'.
  *
- * $Id$
- *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
  * This program is free software; you can redistribute it and/or
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <config.h>
+
 #include <time.h>
 #include <string.h>
 #include <stdlib.h>
@@ -84,7 +84,7 @@ typedef struct _cnd_timeout_dat{
 static condition* _cnd_constr_timeout(condition* cnd, va_list ap){
   cnd_timeout_dat *data = NULL;
   /* allocate memory */
-  if((data = (cnd_timeout_dat*)malloc(sizeof(cnd_timeout_dat))) == NULL)
+  if((data = (cnd_timeout_dat*)g_malloc(sizeof(cnd_timeout_dat))) == NULL)
     return NULL;
   /* initialize user data */
   data->start_time = time(NULL);
@@ -101,7 +101,7 @@ static condition* _cnd_constr_timeout(condition* cnd, va_list ap){
  */
 static void _cnd_destr_timeout(condition* cnd){
   /* free memory */
-  free(cnd_get_user_data(cnd));
+  g_free(cnd_get_user_data(cnd));
 } /* END _cnd_destr_timeout() */
 
 /*
@@ -119,8 +119,8 @@ static gboolean _cnd_eval_timeout(condition* cnd, va_list ap _U_){
   gint32 elapsed_time;
   /* check timeout here */
   if(data->timeout_s == 0) return FALSE; /* 0 == infinite */
-  elapsed_time = time(NULL) - data->start_time;
-  if(elapsed_time > data->timeout_s) return TRUE;
+  elapsed_time = (gint32) (time(NULL) - data->start_time);
+  if(elapsed_time >= data->timeout_s) return TRUE;
   return FALSE;
 } /* END _cnd_eval_timeout()*/
 
@@ -143,7 +143,7 @@ const char* CND_CLASS_CAPTURESIZE = "cnd_class_capturesize";
 
 /* structure that contains user supplied data for this condition */
 typedef struct _cnd_capturesize_dat{
-  long max_capture_size;
+  guint64 max_capture_size;
 }cnd_capturesize_dat;
 
 /*
@@ -159,10 +159,12 @@ typedef struct _cnd_capturesize_dat{
 static condition* _cnd_constr_capturesize(condition* cnd, va_list ap){
   cnd_capturesize_dat *data = NULL;
   /* allocate memory */
-  if((data = (cnd_capturesize_dat*)malloc(sizeof(cnd_capturesize_dat))) == NULL)
+  if((data = (cnd_capturesize_dat*)g_malloc(sizeof(cnd_capturesize_dat))) == NULL)
     return NULL;
   /* initialize user data */
-  data->max_capture_size = va_arg(ap, long);
+  data->max_capture_size = va_arg(ap, guint64);
+  if (data->max_capture_size > ((guint64)INT_MAX + 1))
+    data->max_capture_size = (guint64)INT_MAX + 1;
   cnd_set_user_data(cnd, (void*)data);
   return cnd;
 } /* END _cnd_constr_capturesize() */
@@ -175,7 +177,7 @@ static condition* _cnd_constr_capturesize(condition* cnd, va_list ap){
  */
 static void _cnd_destr_capturesize(condition* cnd){
   /* free memory */
-  free(cnd_get_user_data(cnd));
+  g_free(cnd_get_user_data(cnd));
 } /* END _cnd_destr_capturesize() */
 
 /*
@@ -192,7 +194,7 @@ static gboolean _cnd_eval_capturesize(condition* cnd, va_list ap){
   cnd_capturesize_dat* data = (cnd_capturesize_dat*)cnd_get_user_data(cnd);
   /* check capturesize here */
   if(data->max_capture_size == 0) return FALSE; /* 0 == infinite */
-  if(va_arg(ap, long) >= data->max_capture_size){
+  if(va_arg(ap, guint64) >= data->max_capture_size){
     return TRUE;
   }
   return FALSE;
@@ -206,3 +208,16 @@ static gboolean _cnd_eval_capturesize(condition* cnd, va_list ap){
  */
 static void _cnd_reset_capturesize(condition *cnd _U_){
 } /* END _cnd_reset_capturesize() */
+
+/*
+ * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
+ *
+ * Local Variables:
+ * c-basic-offset: 2
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=2 tabstop=8 expandtab:
+ * :indentSize=2:tabSize=8:noTabs=true:
+ */