Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
check_octstr.c File Reference
#include <string.h>
#include "gwlib/gwlib.h"

Go to the source code of this file.

Functions

static int signof (int n)
 
static void check_comparisons (void)
 
int main (void)
 

Function Documentation

static void check_comparisons ( void  )
static

Definition at line 74 of file check_octstr.c.

References octstr_case_compare(), octstr_compare(), octstr_create, octstr_destroy(), panic, and signof().

Referenced by main().

75 {
76  static const char *tab[] = {
77  "",
78  "a",
79  "ab",
80  "abc",
81  "abc, "ABC", }; static const int n = sizeof(tab) / sizeof(tab[0]); int i, j; int sign_str, sign_oct; Octstr *os1, *os2; for (i = 0; i < n; ++i) { os1 = octstr_create(tab[i]); for (j = 0; j < n; ++j) { os2 = octstr_create(tab[j]); sign_str = signof(strcmp(tab[i], tab[j])); sign_oct = signof(octstr_compare(os1, os2)); if (sign_str != sign_oct) panic(0, "strcmp (%d) and octstr_compare (%d) differ for " "`%s' and `%s'", sign_str, sign_oct, tab[i], tab[j]); sign_str = signof(strcasecmp(tab[i], tab[j])); sign_oct = signof(octstr_case_compare(os1, os2)); if (sign_str != sign_oct) panic(0, "strcasecmp (%d) and octstr_case_compare (%d) " "differ for `%s' and `%s'", sign_str, sign_oct, tab[i], tab[j]); octstr_destroy(os2); } octstr_destroy(os1); } } ",
82  "ABC, }; static const int n = sizeof(tab) / sizeof(tab[0]); int i, j; int sign_str, sign_oct; Octstr *os1, *os2; for (i = 0; i < n; ++i) { os1 = octstr_create(tab[i]); for (j = 0; j < n; ++j) { os2 = octstr_create(tab[j]); sign_str = signof(strcmp(tab[i], tab[j])); sign_oct = signof(octstr_compare(os1, os2)); if (sign_str != sign_oct) panic(0, "strcmp (%d) and octstr_compare (%d) differ for " "`%s' and `%s'", sign_str, sign_oct, tab[i], tab[j]); sign_str = signof(strcasecmp(tab[i], tab[j])); sign_oct = signof(octstr_case_compare(os1, os2)); if (sign_str != sign_oct) panic(0, "strcasecmp (%d) and octstr_case_compare (%d) " "differ for `%s' and `%s'", sign_str, sign_oct, tab[i], tab[j]); octstr_destroy(os2); } octstr_destroy(os1); } } ",
83  };
84  static const int n = sizeof(tab) / sizeof(tab[0]);
85  int i, j;
86  int sign_str, sign_oct;
87  Octstr *os1, *os2;
88 
89  for (i = 0; i < n; ++i) {
90  os1 = octstr_create(tab[i]);
91  for (j = 0; j < n; ++j) {
92  os2 = octstr_create(tab[j]);
93 
94  sign_str = signof(strcmp(tab[i], tab[j]));
95  sign_oct = signof(octstr_compare(os1, os2));
96  if (sign_str != sign_oct)
97  panic(0, "strcmp (%d) and octstr_compare (%d) differ for "
98  "`%s' and `%s'", sign_str, sign_oct, tab[i], tab[j]);
99 
100  sign_str = signof(strcasecmp(tab[i], tab[j]));
101  sign_oct = signof(octstr_case_compare(os1, os2));
102  if (sign_str != sign_oct)
103  panic(0, "strcasecmp (%d) and octstr_case_compare (%d) "
104  "differ for `%s' and `%s'", sign_str, sign_oct,
105  tab[i], tab[j]);
106 
107  octstr_destroy(os2);
108  }
109  octstr_destroy(os1);
110  }
111 }
int octstr_case_compare(const Octstr *os1, const Octstr *os2)
Definition: octstr.c:901
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
#define octstr_create(cstr)
Definition: octstr.h:125
static int signof(int n)
Definition: check_octstr.c:65
Definition: octstr.c:118
#define panic
Definition: log.h:87
int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)
Definition: octstr.c:869
int main ( void  )

Definition at line 114 of file check_octstr.c.

References check_comparisons(), GW_INFO, gwlib_init(), gwlib_shutdown(), and log_set_output_level().

115 {
116  gwlib_init();
119  gwlib_shutdown();
120  return 0;
121 }
void log_set_output_level(enum output_level level)
Definition: log.c:217
Definition: log.h:69
void gwlib_shutdown(void)
Definition: gwlib.c:94
void gwlib_init(void)
Definition: gwlib.c:78
static void check_comparisons(void)
Definition: check_octstr.c:74
static int signof ( int  n)
static

Definition at line 65 of file check_octstr.c.

Referenced by check_comparisons().

66 {
67  if (n < 0)
68  return -1;
69  if (n == 0)
70  return 0;
71  return 1;
72 }
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.