Update of /cvsroot/mahogany/M/lib/dspam
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13893

Modified Files:
        config.h lht.c lht.h libdspam.c libdspam.h libdspam_objects.h 
        sqlite_drv.c storage_driver.h tbt.c util.c 
Log Message:
use longlong_t instead of non-portable long long and correct printf() format spec for 
long long values

Index: config.h
===================================================================
RCS file: /cvsroot/mahogany/M/lib/dspam/config.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -u -2 -r1.2 -r1.3
--- config.h    7 Jul 2004 23:43:00 -0000       1.2
+++ config.h    9 Jul 2004 21:23:21 -0000       1.3
@@ -108,3 +108,11 @@
 #endif
 
+#ifndef longlong_t
+#define longlong_t long long
+#endif
+
+#ifndef LL_FMT_SPEC
+#define LL_FMT_SPEC "ll"
+#endif
+
 #endif

Index: lht.c
===================================================================
RCS file: /cvsroot/mahogany/M/lib/dspam/lht.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -u -2 -r1.2 -r1.3
--- lht.c       7 Jul 2004 23:43:00 -0000       1.2
+++ lht.c       9 Jul 2004 21:23:21 -0000       1.3
@@ -41,5 +41,5 @@
 
 static struct lht_node *
-lht_node_create (unsigned long long key)
+lht_node_create (unsigned longlong_t key)
 {
   struct lht_node *node;
@@ -117,5 +117,5 @@
 
 int
-lht_getfrequency (struct lht *lht, unsigned long long key)
+lht_getfrequency (struct lht *lht, unsigned longlong_t key)
 {
   unsigned long hash_code;
@@ -137,5 +137,5 @@
 
 char *
-lht_gettoken (struct lht *lht, unsigned long long key)
+lht_gettoken (struct lht *lht, unsigned longlong_t key)
 {
   unsigned long hash_code;
@@ -157,5 +157,5 @@
 
 int
-lht_getspamstat (struct lht *lht, unsigned long long key,
+lht_getspamstat (struct lht *lht, unsigned longlong_t key,
                  struct _ds_spam_stat *s)
 {
@@ -185,5 +185,5 @@
 
 int
-lht_delete (struct lht *lht, unsigned long long key)
+lht_delete (struct lht *lht, unsigned longlong_t key)
 {
   unsigned long hash_code;
@@ -269,5 +269,5 @@
 
 int
-lht_hit (struct lht *lht, unsigned long long key, const char *token_name)
+lht_hit (struct lht *lht, unsigned longlong_t key, const char *token_name)
 {
   unsigned long hash_code;
@@ -333,5 +333,5 @@
 
 int
-lht_setfrequency (struct lht *lht, unsigned long long key,
+lht_setfrequency (struct lht *lht, unsigned longlong_t key,
                   int frequency)
 {
@@ -388,5 +388,5 @@
 
 int
-lht_settoken (struct lht *lht, unsigned long long key, const char *token_name)
+lht_settoken (struct lht *lht, unsigned longlong_t key, const char *token_name)
 {
   unsigned long hash_code;
@@ -452,5 +452,5 @@
 
 int
-lht_setspamstat (struct lht *lht, unsigned long long key,
+lht_setspamstat (struct lht *lht, unsigned longlong_t key,
                  struct _ds_spam_stat *s)
 {
@@ -513,5 +513,5 @@
 
 int
-lht_addspamstat (struct lht *lht, unsigned long long key,
+lht_addspamstat (struct lht *lht, unsigned longlong_t key,
                  struct _ds_spam_stat *s)
 {

Index: lht.h
===================================================================
RCS file: /cvsroot/mahogany/M/lib/dspam/lht.h,v
retrieving revision 1.1.3.1
retrieving revision 1.2
diff -b -u -2 -r1.1.3.1 -r1.2
--- lht.h       7 Jul 2004 23:27:20 -0000       1.1.3.1
+++ lht.h       9 Jul 2004 21:23:21 -0000       1.2
@@ -39,5 +39,5 @@
   unsigned long size;
   unsigned long items;
-  unsigned long long whitelist_token;
+  unsigned longlong_t whitelist_token;
   struct lht_node **tbl;
   struct nt *order;
@@ -48,5 +48,5 @@
 struct lht_node
 {
-  unsigned long long key;
+  unsigned longlong_t key;
   struct lht_node *next;
 
@@ -69,26 +69,26 @@
 
 /* read-only functions */
-int    lht_getfrequency(struct lht *lht, unsigned long long key);
-char * lht_gettoken    (struct lht *lht, unsigned long long key);
-int    lht_getspamstat (struct lht *lht, unsigned long long key,
+int    lht_getfrequency(struct lht *lht, unsigned longlong_t key);
+char * lht_gettoken    (struct lht *lht, unsigned longlong_t key);
+int    lht_getspamstat (struct lht *lht, unsigned longlong_t key,
                         struct _ds_spam_stat *s);
 
 /* read-write functions */
-int lht_setfrequency   (struct lht *lht, unsigned long long key, 
+int lht_setfrequency   (struct lht *lht, unsigned longlong_t key, 
                         int frequency);
 
-int lht_settoken       (struct lht *lht, unsigned long long key,
+int lht_settoken       (struct lht *lht, unsigned longlong_t key,
                         const char *token_name);
 
-int lht_setspamstat    (struct lht *lht, unsigned long long key, 
+int lht_setspamstat    (struct lht *lht, unsigned longlong_t key, 
                         struct _ds_spam_stat *s);
 
-int lht_addspamstat     (struct lht *lht, unsigned long long key,
+int lht_addspamstat     (struct lht *lht, unsigned longlong_t key,
                          struct _ds_spam_stat *s);
 
-int lht_hit            (struct lht *lht, unsigned long long key, 
+int lht_hit            (struct lht *lht, unsigned longlong_t key, 
                         const char *token_name);
 
-int lht_delete         (struct lht *lht, unsigned long long key);
+int lht_delete         (struct lht *lht, unsigned longlong_t key);
 
 /* iteration functions */

Index: libdspam.c
===================================================================
RCS file: /cvsroot/mahogany/M/lib/dspam/libdspam.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -b -u -2 -r1.3 -r1.4
--- libdspam.c  8 Jul 2004 07:44:07 -0000       1.3
+++ libdspam.c  9 Jul 2004 21:23:21 -0000       1.4
@@ -410,5 +410,5 @@
   int spammy = 0;
 
-  unsigned long long whitelist_token = 0;
+  unsigned longlong_t whitelist_token = 0;
   int do_whitelist = 0;
 
@@ -446,5 +446,5 @@
               (i * sizeof (struct _ds_signature_token)),
               sizeof (struct _ds_signature_token));
-      snprintf (x, sizeof (x), "E: %llu", t.token);
+      snprintf (x, sizeof (x), "E: %" LL_FMT_SPEC "u", t.token);
       lht_hit (freq, t.token, x);
       lht_setfrequency (freq, t.token, t.frequency);
@@ -600,5 +600,5 @@
       char *url_ptr = url_body;
       int url_length;
-      unsigned long long crc;
+      unsigned longlong_t crc;
 
       token = strstr (url_ptr, "http://";);
@@ -642,5 +642,5 @@
       char *url_ptr = url_body;
       int url_length;
-      unsigned long long crc;
+      unsigned longlong_t crc;
 
       url_ptr = url_body;
@@ -1023,5 +1023,5 @@
 #endif
   {
-    unsigned long long crc;
+    unsigned longlong_t crc;
     char *token_name;
 
@@ -1431,5 +1431,5 @@
   while (node_lht != NULL)
   {
-    unsigned long long crc;
+    unsigned longlong_t crc;
 
     crc = node_lht->key;
@@ -1657,5 +1657,5 @@
 
 int
-_ds_calc_stat (DSPAM_CTX * CTX, unsigned long long token,
+_ds_calc_stat (DSPAM_CTX * CTX, unsigned longlong_t token,
                struct _ds_spam_stat *s)
 {
@@ -1770,5 +1770,5 @@
   int len = 0;
   int is_received;
-  unsigned long long crc;
+  unsigned longlong_t crc;
   char *tweaked_token;
 
@@ -1853,5 +1853,5 @@
   char combined_token[256];
   int len;
-  unsigned long long crc;
+  unsigned longlong_t crc;
   char *tweaked_token;
 

Index: libdspam.h
===================================================================
RCS file: /cvsroot/mahogany/M/lib/dspam/libdspam.h,v
retrieving revision 1.1.3.1
retrieving revision 1.2
diff -b -u -2 -r1.1.3.1 -r1.2
--- libdspam.h  7 Jul 2004 23:26:58 -0000       1.1.3.1
+++ libdspam.h  9 Jul 2004 21:23:21 -0000       1.2
@@ -19,4 +19,8 @@
 */
 
+#ifdef HAVE_CONFIG_H
+#include <auto-config.h>
+#endif
+
 #include "lht.h"
 #include "nodetree.h"
@@ -89,5 +93,5 @@
 
 int _ds_calc_stat              (DSPAM_CTX * CTX, 
-                                unsigned long long token,
+                                unsigned longlong_t token,
                                 struct _ds_spam_stat *);
 

Index: libdspam_objects.h
===================================================================
RCS file: /cvsroot/mahogany/M/lib/dspam/libdspam_objects.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -u -2 -r1.2 -r1.3
--- libdspam_objects.h  7 Jul 2004 23:43:00 -0000       1.2
+++ libdspam_objects.h  9 Jul 2004 21:23:21 -0000       1.3
@@ -22,4 +22,8 @@
 #  define _LIBDSPAM_OBJECTS_H
 
+#ifdef HAVE_CONFIG_H
+#include <auto-config.h>
+#endif
+
 #if ((defined(__sun__) && defined(__svr4__)) || (defined(__sun) && 
defined(__SUNPRO_C))) && !defined(u_int32_t) && !defined(__BIT_TYPES_DEFINED__)
 #define __BIT_TYPES_DEFINED__
@@ -193,5 +197,5 @@
 struct _ds_signature_token
 {
-  unsigned long long token;
+  unsigned longlong_t token;
   unsigned char frequency;
 };

Index: sqlite_drv.c
===================================================================
RCS file: /cvsroot/mahogany/M/lib/dspam/sqlite_drv.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -b -u -2 -r1.5 -r1.6
--- sqlite_drv.c        8 Jul 2004 11:03:15 -0000       1.5
+++ sqlite_drv.c        9 Jul 2004 21:23:21 -0000       1.6
@@ -235,5 +235,5 @@
   char scratch[1024];
   struct _ds_spam_stat stat;
-  unsigned long long token = 0;
+  unsigned longlong_t token = 0;
   char *err=NULL, **row;
   int nrow, ncolumn, get_one = 0, i;
@@ -267,5 +267,5 @@
   while (node_lht != NULL)
   {
-    snprintf (scratch, sizeof (scratch), "'%llu'", node_lht->key);
+    snprintf (scratch, sizeof (scratch), "'%" LL_FMT_SPEC "u'", node_lht->key);
     buffer_cat (query, scratch);
     node_lht->s.innocent_hits = 0;
@@ -424,5 +424,5 @@
         snprintf(insert, sizeof (insert),
                  "insert into dspam_token_data(token, spam_hits, "
-                 "innocent_hits, last_hit) values('%llu', %ld, %ld, "
+                 "innocent_hits, last_hit) values('%" LL_FMT_SPEC "u', %ld, %ld, "
                  "date('now'))",
                  node_lht->key,
@@ -439,5 +439,5 @@
     if (stat2.disk == 'Y')
     {
-      snprintf (scratch, sizeof (scratch), "'%llu'", node_lht->key);
+      snprintf (scratch, sizeof (scratch), "'%" LL_FMT_SPEC "u'", node_lht->key);
       buffer_cat (query, scratch);
       update_one = 1;
@@ -481,5 +481,5 @@
 
 int
-_ds_get_spamrecord (DSPAM_CTX * CTX, unsigned long long token,
+_ds_get_spamrecord (DSPAM_CTX * CTX, unsigned longlong_t token,
                     struct _ds_spam_stat *stat)
 {
@@ -498,5 +498,5 @@
   snprintf (query, sizeof (query),
             "select spam_hits, innocent_hits from dspam_token_data "
-            "where token = '%llu' ", token);
+            "where token = '%" LL_FMT_SPEC "u' ", token);
 
   stat->probability = 0.0;
@@ -525,5 +525,5 @@
 
 int
-_ds_set_spamrecord (DSPAM_CTX * CTX, unsigned long long token,
+_ds_set_spamrecord (DSPAM_CTX * CTX, unsigned longlong_t token,
                     struct _ds_spam_stat *stat)
 {
@@ -548,5 +548,5 @@
               "insert into dspam_token_data(token, spam_hits, "
               "innocent_hits, last_hit)"
-              " values('%llu', %ld, %ld, date('now'))",
+              " values('%" LL_FMT_SPEC "u', %ld, %ld, date('now'))",
               token, stat->spam_hits, stat->innocent_hits);
     result = sqlite_exec(s->dbh, query, NULL, NULL, &err);
@@ -559,5 +559,5 @@
               "set spam_hits = %ld, "
               "innocent_hits = %ld "
-              "where token = %lld", stat->spam_hits,
+              "where token = %" LL_FMT_SPEC "d", stat->spam_hits,
               stat->innocent_hits, token);
     if (CTX->training_mode == DST_TUM) {
@@ -1264,5 +1264,5 @@
 
 int
-_ds_del_spamrecord (DSPAM_CTX * CTX, unsigned long long token)
+_ds_del_spamrecord (DSPAM_CTX * CTX, unsigned longlong_t token)
 {
   struct _sqlite_drv_storage *s = (struct _sqlite_drv_storage *) CTX->storage;
@@ -1277,5 +1277,5 @@
                                                                                 
   snprintf (query, sizeof (query),
-            "delete from dspam_token_data where token = \"%llu\"",
+            "delete from dspam_token_data where token = \"%" LL_FMT_SPEC "u\"",
             token);
                                                                                 
@@ -1325,5 +1325,5 @@
   while (node_lht != NULL)
   {
-    snprintf (scratch, sizeof (scratch), "'%llu'", node_lht->key);
+    snprintf (scratch, sizeof (scratch), "'%" LL_FMT_SPEC "u'", node_lht->key);
     buffer_cat (query, scratch);
     node_lht = c_lht_next (freq, &c_lht);

Index: storage_driver.h
===================================================================
RCS file: /cvsroot/mahogany/M/lib/dspam/storage_driver.h,v
retrieving revision 1.1.3.2
retrieving revision 1.2
diff -b -u -2 -r1.1.3.2 -r1.2
--- storage_driver.h    8 Jul 2004 07:40:56 -0000       1.1.3.2
+++ storage_driver.h    9 Jul 2004 21:23:21 -0000       1.2
@@ -27,5 +27,5 @@
 struct _ds_storage_record
 {
-  unsigned long long token;
+  unsigned longlong_t token;
   long spam_hits;
   long innocent_hits;
@@ -74,9 +74,9 @@
 int _ds_delall_spamrecords (DSPAM_CTX * CTX, struct lht *lht);
 
-int _ds_get_spamrecord (DSPAM_CTX * CTX, unsigned long long token,
+int _ds_get_spamrecord (DSPAM_CTX * CTX, unsigned longlong_t token,
                         struct _ds_spam_stat *stat);
-int _ds_set_spamrecord (DSPAM_CTX * CTX, unsigned long long token,
+int _ds_set_spamrecord (DSPAM_CTX * CTX, unsigned longlong_t token,
                         struct _ds_spam_stat *stat);
-int _ds_del_spamrecord (DSPAM_CTX * CTX, unsigned long long token);
+int _ds_del_spamrecord (DSPAM_CTX * CTX, unsigned longlong_t token);
 
 /* Iteration calls */

Index: tbt.c
===================================================================
RCS file: /cvsroot/mahogany/M/lib/dspam/tbt.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -u -2 -r1.2 -r1.3
--- tbt.c       7 Jul 2004 23:43:00 -0000       1.2
+++ tbt.c       9 Jul 2004 21:23:21 -0000       1.3
@@ -31,5 +31,5 @@
 
 static struct tbt_node *
-tbt_node_create (double probability, unsigned long long token, int type)
+tbt_node_create (double probability, unsigned longlong_t token, int type)
 {
   struct tbt_node *node;
@@ -144,5 +144,5 @@
 
 int
-tbt_add (struct tbt *tbt, double probability, unsigned long long token,
+tbt_add (struct tbt *tbt, double probability, unsigned longlong_t token,
          unsigned long frequency, int complexity)
 {

Index: util.c
===================================================================
RCS file: /cvsroot/mahogany/M/lib/dspam/util.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -u -2 -r1.2 -r1.3
--- util.c      7 Jul 2004 23:43:00 -0000       1.2
+++ util.c      9 Jul 2004 21:23:21 -0000       1.3
@@ -433,9 +433,9 @@
 }
 
-unsigned long long
+unsigned longlong_t
 _ds_getcrc64 (const char *s)
 {
-  static unsigned long long CRCTable[256];
-  unsigned long long crc = 0;
+  static unsigned longlong_t CRCTable[256];
+  unsigned longlong_t crc = 0;
   static int init = 0;
                                                                                 
@@ -447,5 +447,5 @@
     {
       int j;
-      unsigned long long part = i;
+      unsigned longlong_t part = i;
       for (j = 0; j < 8; j++)
       {
@@ -460,7 +460,7 @@
   for (; *s; s++)
   {
-    unsigned long long temp1 = crc >> 8;
-    unsigned long long temp2 =
-      CRCTable[(crc ^ (unsigned long long) *s) & 0xff];
+    unsigned longlong_t temp1 = crc >> 8;
+    unsigned longlong_t temp2 =
+      CRCTable[(crc ^ (unsigned longlong_t) *s) & 0xff];
     crc = temp1 ^ temp2;
   }



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to