Changeset ec1bdc8 in mainline for uspace/lib/c/include/adt/measured_strings.h
- Timestamp:
- 2010-09-26T18:57:30Z (15 years ago)
- 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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/adt/measured_strings.h
r2a786f9 rec1bdc8 27 27 */ 28 28 29 /** @addtogroup net30 * @{29 /** @addtogroup libc 30 * @{ 31 31 */ 32 32 33 33 /** @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. 35 37 */ 36 38 37 #ifndef __NET_ERR_H__38 #define __NET_ERR_H__39 #ifndef LIBC_MEASURED_STRINGS_H_ 40 #define LIBC_MEASURED_STRINGS_H_ 39 41 40 #include < errno.h>42 #include <sys/types.h> 41 43 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 */ 47 typedef struct measured_string measured_string_t; 46 48 47 /** An actual stored error code. 49 /** Type definition of the character string with measured length pointer. 50 * @see measured_string 51 */ 52 typedef measured_string_t *measured_string_ref; 53 54 /** Character string with measured length. 48 55 * 56 * This structure has been designed for serialization of character strings 57 * between modules. 49 58 */ 50 #define ERROR_CODE error_check_return_value 59 struct measured_string { 60 /** Character string data. */ 61 char * value; 62 /** Character string length. */ 63 size_t length; 64 }; 51 65 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 66 extern measured_string_ref measured_string_create_bulk(const char *, size_t); 67 extern measured_string_ref measured_string_copy(measured_string_ref); 68 extern int measured_strings_receive(measured_string_ref *, char **, size_t); 69 extern int measured_strings_reply(const measured_string_ref, size_t); 70 extern int measured_strings_return(int, measured_string_ref *, char **, size_t); 71 extern int measured_strings_send(int, const measured_string_ref, size_t); 97 72 98 73 #endif
Note:
See TracChangeset
for help on using the changeset viewer.