Sebastián Pastor / EtheriosCloudConnector
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers rci_binary_string.h Source File

rci_binary_string.h

00001 /*
00002  * Copyright (c) 2013 Digi International Inc.,
00003  * All rights not expressly granted are reserved.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
00007  * You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
00010  * =======================================================================
00011  */
00012 
00013 static uint8_t const * rcistr_data(rcistr_t const * const string)
00014 {
00015     return string->data;
00016 }
00017 
00018 static void clear_rcistr(rcistr_t * const string)
00019 {
00020     string->data = NULL;
00021     string->length = 0;
00022 }
00023 
00024 static connector_bool_t rcistr_valid(rcistr_t const * const string)
00025 {
00026     return connector_bool((string->data != NULL) && (string->length != 0));
00027 }
00028 
00029 static void adjust_char_pointer(uint8_t * const new_base, uint8_t const * const old_base, uint8_t * * const pointer)
00030 {
00031     size_t const offset = (size_t)(*pointer - old_base);
00032 
00033     *pointer = (new_base + offset);
00034 }
00035 
00036 static void adjust_rcistr(uint8_t * const new_base, uint8_t const * const old_base, rcistr_t * const string)
00037 {
00038     uint8_t * pointer = (uint8_t *) string->data;
00039 
00040     adjust_char_pointer(new_base, old_base, &pointer);
00041     string->data = pointer;
00042 }
00043 
00044 
00045 
00046