Back to home page

Enduro/X

 
 

    


0001 /**
0002  * @brief BFLD_PTR type support
0003  *
0004  * @file fld_ptr.c
0005  */
0006 /* -----------------------------------------------------------------------------
0007  * Enduro/X Middleware Platform for Distributed Transaction Processing
0008  * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0009  * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0010  * This software is released under one of the following licenses:
0011  * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0012  * See LICENSE file for full text.
0013  * -----------------------------------------------------------------------------
0014  * AGPL license:
0015  *
0016  * This program is free software; you can redistribute it and/or modify it under
0017  * the terms of the GNU Affero General Public License, version 3 as published
0018  * by the Free Software Foundation;
0019  *
0020  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0021  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0022  * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0023  * for more details.
0024  *
0025  * You should have received a copy of the GNU Affero General Public License along 
0026  * with this program; if not, write to the Free Software Foundation, Inc.,
0027  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0028  *
0029  * -----------------------------------------------------------------------------
0030  * A commercial use license is available from Mavimax, Ltd
0031  * contact@mavimax.com
0032  * -----------------------------------------------------------------------------
0033  */
0034 
0035 /*---------------------------Includes-----------------------------------*/
0036 #include <stdio.h>
0037 #include <stdarg.h>
0038 #include <memory.h>
0039 #include <stdlib.h>
0040 #include <regex.h>
0041 #include <ubf.h>
0042 #include <ubf_int.h>
0043 #include <ndebug.h>
0044 #include <ferror.h>
0045 #include <errno.h>
0046 #include <ubf_tls.h>
0047 #include <fdatatype.h>
0048 
0049 /*---------------------------Externs------------------------------------*/
0050 /*---------------------------Macros-------------------------------------*/
0051 /*---------------------------Enums--------------------------------------*/
0052 /*---------------------------Typedefs-----------------------------------*/
0053 /*---------------------------Globals------------------------------------*/
0054 /*---------------------------Statics------------------------------------*/
0055 /*---------------------------Prototypes---------------------------------*/
0056 
0057 /**
0058  * Compare two pointers
0059  * @param t type descriptor
0060  * @param val1 value 1 compare
0061  * @param len1 not used
0062  * @param val2 value 2 to compare
0063  * @param len2 not used
0064  * @param mode compare mode standard (UBF_CMP_MODE_STD) or true/false
0065  * @return returns -1 (ptr1 < ptr2), 0 (ptr1==ptr2), 1 (ptr1 > ptr2)
0066  */
0067 expublic int ndrx_cmp_ptr (struct dtype_ext1 *t, char *val1, BFLDLEN len1, 
0068         char *val2, BFLDLEN len2, long mode)
0069 {
0070     char **p1 = (char **)val1;
0071     char **p2 = (char **)val2;
0072     
0073     if (mode & UBF_CMP_MODE_STD)
0074     {
0075         int res = *p1 - *p2;
0076         
0077         if (res > 0)
0078             return 1;
0079         else if (res < 0)
0080             return -1;
0081         else
0082             return 0;
0083     }
0084     else
0085     {
0086         return (*p1==*p2);
0087     }
0088 }
0089 
0090 /**
0091  * Dump to log the field value
0092  * @param t field type descr
0093  * @param text debug msg
0094  * @param data data to print
0095  * @param len not used
0096  */
0097 expublic void ndrx_dump_ptr (struct dtype_ext1 *t, char *text, char *data, int *len)
0098 {
0099     if (NULL!=data)
0100     {
0101         void **ptr = (void **)data;
0102         UBF_LOG(log_debug, "%s:\n[%p]", text, *ptr);
0103     }
0104     else
0105     {
0106         UBF_LOG(log_debug, "%s:\n[null]", text);
0107     }
0108 }
0109 
0110 /* vim: set ts=4 sw=4 et smartindent: */