Navigation


Changeset 738:d666051658bd in freeDiameter for include/freeDiameter/libfdproto.h


Ignore:
Timestamp:
Mar 2, 2011, 6:21:59 PM (13 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Fix broken 'almostcasecmp' logic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/libfdproto.h

    r736 r738  
    621621
    622622/* A roughly case-insensitive variant, which actually only compares ASCII chars (0-127) in a case-insentitive maneer
    623   -- this should be OK with (old) DNS names. Not sure how it works with IDN...
    624   -- it also clearly does not support locales where a lowercase letter uses more space than upper case, such as ß -> ss
    625  It is slower than fd_os_cmp...
    626  This function should give the same order as fd_os_cmp, except when it finds 2 strings to be equal.
     623  -- it does not support locales where a lowercase letter uses more space than upper case, such as ß -> ss
     624 It is slower than fd_os_cmp.
    627625 Note that the result is NOT the same as strcasecmp !!!
    628  */
    629 int fd_os_almostcasecmp_int(uint8_t * os1, size_t os1sz, uint8_t * os2, size_t os2sz);
    630 #define fd_os_almostcasecmp(_o1, _l1, _o2, _l2)  fd_os_almostcasecmp_int((os0_t)(_o1), _l1, (os0_t)(_o2), _l2)
     626 
     627 This function gives the same order as fd_os_cmp, except when it finds 2 strings to be equal.
     628 However this is not always sufficient:
     629        for example fd_os_cmp gives: "Ac" < "aB" < "aa"
     630        if you attempt to fd_os_almostcasesrch "Aa" you will actually have to go past "aB" which is > "Aa".
     631        Therefore you can use the maybefurther parameter.
     632        This parameter is 1 on return if os1 may have been stored further that os2 (assuming os2 values are ordered by fd_os_cmp)
     633        and 0 if we are sure that it is not the case.
     634        When looping through a list of fd_os_cmp classified values, this parameter must be used to stop looping, in addition to the comp result.
     635 */
     636int fd_os_almostcasesrch_int(uint8_t * os1, size_t os1sz, uint8_t * os2, size_t os2sz, int * maybefurther);
     637#define fd_os_almostcasesrch(_o1, _l1, _o2, _l2, _mb)  fd_os_almostcasesrch_int((os0_t)(_o1), _l1, (os0_t)(_o2), _l2, _mb)
    631638
    632639/* Analyze a DiameterURI and return its components.
Note: See TracChangeset for help on using the changeset viewer.