applib/sdnv-c.h
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 /*
       
     2  *    Copyright 2006 Intel Corporation
       
     3  * 
       
     4  *    Licensed under the Apache License, Version 2.0 (the "License");
       
     5  *    you may not use this file except in compliance with the License.
       
     6  *    You may obtain a copy of the License at
       
     7  * 
       
     8  *        http://www.apache.org/licenses/LICENSE-2.0
       
     9  * 
       
    10  *    Unless required by applicable law or agreed to in writing, software
       
    11  *    distributed under the License is distributed on an "AS IS" BASIS,
       
    12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    13  *    See the License for the specific language governing permissions and
       
    14  *    limitations under the License.
       
    15  */
       
    16 
       
    17 #ifndef _SDNV_C_H_
       
    18 #define _SDNV_C_H_
       
    19 
       
    20 #ifdef __cplusplus
       
    21 extern "C" {
       
    22 #endif 
       
    23 
       
    24 #include <sys/types.h>
       
    25 
       
    26 /**
       
    27  * Return the number of bytes needed to encode the given value.
       
    28  */
       
    29 extern size_t sdnv_encoding_len(u_int64_t val);
       
    30 
       
    31 /**
       
    32  * Convert the given 64-bit integer into an SDNV.
       
    33  *
       
    34  * @return The number of bytes used, or -1 on error.
       
    35  */
       
    36 extern int sdnv_encode(u_int64_t val, u_char* bp, size_t len);
       
    37 
       
    38 /**
       
    39  * Convert an SDNV pointed to by bp into a unsigned 64-bit
       
    40  * integer.
       
    41  *
       
    42  * @return The number of bytes of bp consumed, or -1 on error.
       
    43  */
       
    44 extern int sdnv_decode(const u_char* bp, size_t len, u_int64_t* val);
       
    45 
       
    46 #ifdef __cplusplus
       
    47 }
       
    48 #endif
       
    49 
       
    50 #endif /* _SDNV_C_H_ */