Ignore:
Timestamp:
2010-09-26T18:57:30Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3fe57ea7
Parents:
2a786f9 (diff), 70ce016 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~jakub/helenos/net.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/adt/measured_strings.h

    r2a786f9 rec1bdc8  
    2727 */
    2828
    29 /** @addtogroup net
    30  * @{
     29/** @addtogroup libc
     30 *  @{
    3131 */
    3232
    3333/** @file
    34  * Common error processing codes and routines.
     34 * Character string with measured length.
     35 * The structure has been designed for serialization of character strings
     36 * between modules.
    3537 */
    3638
    37 #ifndef __NET_ERR_H__
    38 #define __NET_ERR_H__
     39#ifndef LIBC_MEASURED_STRINGS_H_
     40#define LIBC_MEASURED_STRINGS_H_
    3941
    40 #include <errno.h>
     42#include <sys/types.h>
    4143
    42 #ifdef CONFIG_DEBUG
    43         #include <stdio.h>
    44         #include <str_error.h>
    45 #endif
     44/** Type definition of the character string with measured length.
     45 *  @see measured_string
     46 */
     47typedef struct measured_string measured_string_t;
    4648
    47 /** An actual stored error code.
     49/** Type definition of the character string with measured length pointer.
     50 *  @see measured_string
     51 */
     52typedef measured_string_t *measured_string_ref;
     53
     54/** Character string with measured length.
    4855 *
     56 * This structure has been designed for serialization of character strings
     57 * between modules.
    4958 */
    50 #define ERROR_CODE  error_check_return_value
     59struct measured_string {
     60        /** Character string data. */
     61        char * value;
     62        /** Character string length. */
     63        size_t length;
     64};
    5165
    52 /** An error processing routines declaration.
    53  *
    54  * This has to be declared in the block where the error processing
    55  * is desired.
    56  *
    57  */
    58 #define ERROR_DECLARE  int ERROR_CODE
    59 
    60 /** Store the value as an error code and checks if an error occurred.
    61  *
    62  * @param[in] value The value to be checked. May be a function call.
    63  * @return False if the value indicates success (EOK).
    64  * @return True otherwise.
    65  *
    66  */
    67 #ifdef CONFIG_DEBUG
    68 
    69 #define ERROR_OCCURRED(value) \
    70         (((ERROR_CODE = (value)) != EOK) \
    71         && ({ \
    72                 fprintf(stderr, "libsocket error at %s:%d (%s)\n", \
    73                 __FILE__, __LINE__, str_error(ERROR_CODE)); \
    74                 1; \
    75         }))
    76 
    77 #else
    78 
    79 #define ERROR_OCCURRED(value)  ((ERROR_CODE = (value)) != EOK)
    80 
    81 #endif
    82 
    83 #define ERROR_NONE(value)       !ERROR_OCCURRED((value))
    84 
    85 /** Error propagation
    86  *
    87  * Check if an error occurred and immediately exit the actual
    88  * function returning the error code.
    89  *
    90  * @param[in] value The value to be checked. May be a function call.
    91  *
    92  */
    93 
    94 #define ERROR_PROPAGATE(value) \
    95         if (ERROR_OCCURRED(value)) \
    96                 return ERROR_CODE
     66extern measured_string_ref measured_string_create_bulk(const char *, size_t);
     67extern measured_string_ref measured_string_copy(measured_string_ref);
     68extern int measured_strings_receive(measured_string_ref *, char **, size_t);
     69extern int measured_strings_reply(const measured_string_ref, size_t);
     70extern int measured_strings_return(int, measured_string_ref *, char **, size_t);
     71extern int measured_strings_send(int, const measured_string_ref, size_t);
    9772
    9873#endif
Note: See TracChangeset for help on using the changeset viewer.