Change lfta code generation form C to C++
[com/gs-lite.git] / include / lfta / rts_external.h
index 0f0127c..7d5ff95 100644 (file)
@@ -1,6 +1,12 @@
 #ifndef RTS_STRING_H
 #define RTS_STRING_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
 /* ------------------------------------------------
  Copyright 2014 AT&T Intellectual Property
  Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,6 +23,8 @@
  ------------------------------------------- */
 
 #include <stdint.h>
+#include<math.h>
+
 
 #include "gsconfig.h"
 #include "gstypes.h"
@@ -67,27 +75,77 @@ gs_retval_t str_exists_substr( struct gs_string * str1, struct gs_string * str2)
 
 gs_retval_t str_compare( struct gs_string * str1, struct gs_string * str2);
 
+/* String equality */
+
+gs_retval_t str_equal( struct gs_string * str1, struct gs_string * str2);
 
 /*     Construct a string constant */
 
-gs_retval_t str_constructor(struct gs_string *s, gs_sp_t l);
+gs_retval_t str_constructor(struct gs_string *s, gs_csp_t l);
+
+/*     string hash     */
 
+#define string_hash(s) lfta_V_STR_to_hash((*(s)))
 
 /* External Function definitions */
 
-#define LLMIN(x,y) ((x)<(y)?(x):(y))
-#define LLMAX(x,y) ((x)<(y)?(y):(x))
-#define UMIN(x,y) ((x)<(y)?(x):(y))
-#define UMAX(x,y) ((x)<(y)?(y):(x))
+#define ULLMIN(x,y) (unsigned long long)(((x)<(y)?(x):(y)))
+#define ULLMAX(x,y) (unsigned long long)(((x)<(y)?(y):(x)))
+#define LLMIN(x,y) (long long int)(((x)<(y)?(x):(y)))
+#define LLMAX(x,y) (long long int)(((x)<(y)?(y):(x)))
+#define UMIN(x,y) (unsigned int)(((x)<(y)?(x):(y)))
+#define UMAX(x,y) (unsigned int)(((x)<(y)?(y):(x)))
+#define LMIN(x,y) (int)(((x)<(y)?(x):(y)))
+#define LMAX(x,y) (int)(((x)<(y)?(y):(x)))
+#define FMIN(x,y) (double)(((x)<(y)?(x):(y)))
+#define FMAX(x,y) (double)(((x)<(y)?(y):(x)))
+
 // type conversion
 #define INT(c) ((int)(c))
 #define UINT(c) ((unsigned int)(c))
 #define ULLONG(c) ((unsigned long long)(c))
+#define LLONG(c) ((long long int)(c))
 #define FLOAT(c) ((double)(c))
 
+// comparison
+#define EQ(x,y) ((x)==(y))
+#define GEQ(x,y) ((x)>=(y))
+#define GE(x,y) ((x)>(y))
+#define LEQ(x,y) ((x)<=(y))
+#define LE(x,y) ((x)<(y))
+
+// if_else
+#define if_else_f(x,y,z) (double)(((x)==0?(z):(y)))
+#define if_else_ll(x,y,z) (long long int)(((x)==0?(z):(y)))
+#define if_else_ul(x,y,z) (unsigned long long)(((x)==0?(z):(y)))
+#define if_else_u(x,y,z) (unsigned int)(((x)==0?(z):(y)))
+#define if_else_i(x,y,z) (int)(((x)==0?(z):(y)))
+
 //     Cast away temporality
 #define non_temporal(x)(x)
 
+//     endian swap
+#define endian_swap_ui(x) ( (( (x) & 0xFF000000) >> 24) | (( (x) & 0x00FF0000) >> 8) | (( (x) & 0x0000FF00) << 8) | (( (x) & 0x000000FF) << 24) ) 
+
+
+//     Access math libraries
+#define sqrt(x) sqrt(x)
+#define pow(x,y) pow((x),(y))
+#define sin(x) sin(x)
+#define cos(x) cos(x)
+#define tan(x) tan(x)
+#define asin(x) asin(x)
+#define acos(x) acos(x)
+#define atan(x) atan(x)
+#define log(x) log(x)
+#define log2(x) log2(x)
+#define log10(x) log10(x)
+#define ceil(x) ceil(x)
+#define floor(x) floor(x)
+#define fmod(x) fmod(x)
+#define trunc(x) trunc(x)
+
+
 
 
 gs_uint32_t str_match_offset( gs_uint32_t offset, struct gs_string * s1, struct gs_string * s2);
@@ -105,13 +163,18 @@ gs_uint32_t str_partial_regex_match(struct gs_string* str,
 gs_retval_t deregister_handle_for_str_partial_regex_match_slot_1(
                                                                  gs_param_handle_t
                                                                  handle);
-
+// ----------------------------------
+//     Substring functions
 inline static gs_retval_t str_truncate(struct gs_string * result, struct gs_string *str, gs_uint32_t length) {
        result->data=str->data;
        result->length=(str->length<length)?str->length:length;
        return 0;
 }
+gs_retval_t str_suffix(struct gs_string * ret, struct gs_string *s, gs_uint32_t n);
+gs_retval_t get_list_entry(struct gs_string * ret, struct gs_string *l, struct gs_string *sep, gs_uint32_t pos);
 
+
+// ----------------------------------
 //     constant string conversions
 gs_param_handle_t register_handle_for_strtoi_c_slot_0(struct FTA * f, struct gs_string* istr) ;
 gs_retval_t deregister_handle_for_strtoi_c_slot_0(gs_param_handle_t h) ;
@@ -150,4 +213,8 @@ gs_retval_t deregister_handle_for_signaturelib_get_content_id_slot_2(gs_param_ha
 gs_uint32_t signaturelib_get_fqdn(struct gs_string* result);
 gs_uint32_t signaturelib_get_channel_type(struct gs_string* result);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif