Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3911 → Rev 3912

/branches/network/uspace/srv/net/structures/char_map.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
27,57 → 27,51
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/** @file
* A character string to integer map header file.
* Character string to integer map.
*/
 
#ifndef __CHAR_MAP_H__
#define __CHAR_MAP_H__
 
/** An invalid assigned value used also if an entry does not exist.
/** Invalid assigned value used also if an entry does not exist.
*/
#define CHAR_MAP_NULL ( -1 )
 
/** A type definition of a character string to integer map.
/** Type definition of the character string to integer map.
* @see char_map
*/
typedef struct char_map char_map_t;
 
/** A type definition of a character string to integer map pointer.
/** Type definition of the character string to integer map pointer.
* @see char_map
*/
typedef char_map_t * char_map_ref;
 
/** A character string to integer map item.
/** Character string to integer map item.
* This structure recursivelly contains itself as a character by character tree.
* The actually mapped character string consists o fall the parent characters and the actual one.
*/
struct char_map{
 
/** An actually mapped character.
/** Actually mapped character.
*/
char c;
 
/** A stored integral value.
/** Stored integral value.
*/
int value;
 
/** A next character array size.
/** Next character array size.
*/
int size;
 
/** The first free position in the next character array.
/** First free position in the next character array.
*/
int next;
 
/** The next character array.
/** Next character array.
*/
char_map_ref * items;
 
/** The consistency check magic value.
/** Consistency check magic value.
*/
int magic;
};
84,13 → 78,13
 
/** Adds the value with the key to the map.
* @param map The character string to integer map. Input/output parameter.
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter.
* @param identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found. Input parameter.
* @param value The integral value to be stored for the key character string. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the map is not valid.
* @returns EINVAL if the identifier parameter is NULL.
* @returns EINVAL if the length parameter zero (0) and the identifier parameter is an empty character string (the first character is the terminating zero ('\0) character.
* @returns EINVAL if the length parameter zero (0) and the identifier parameter is an empty character string (the first character is the terminating zero ('\\0') character.
* @returns EEXIST if the key character string is already used.
* @returns Other error codes as defined for the char_map_add_item() function.
*/
104,8 → 98,8
/** Excludes the value assigned to the key from the map.
* The entry is cleared from the map.
* @param map The character string to integer map. Input/output parameter.
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter.
* @param identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found. Input parameter.
* @returns The integral value assigned to the key character string.
* @returns CHAR_MAP_NULL if the key is not assigned a value.
*/
113,8 → 107,8
 
/** Returns the value assigned to the key from the map.
* @param map The character string to integer map. Input parameter.
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter.
* @param identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found. Input parameter.
* @returns The integral value assigned to the key character string.
* @returns CHAR_MAP_NULL if the key is not assigned a value.
*/
131,19 → 125,19
* @param map The character string to integer map. Input/output parameter.
* @returns EOK on success.
* @returns EINVAL if the map parameter is NULL.
* @returns ENOMEM if there is no memory left.
* @returns ENOMEM if there is not enough memory left.
*/
int char_map_initialize( char_map_ref map );
 
/** Adds or updates the value with the key to the map.
* @param map The character string to integer map. Input/output parameter.
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter.
* @param identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found. Input parameter.
* @param value The integral value to be stored for the key character string. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the map is not valid.
* @returns EINVAL if the identifier parameter is NULL.
* @returns EINVAL if the length parameter zero (0) and the identifier parameter is an empty character string (the first character is the terminating zero ('\0) character.
* @returns EINVAL if the length parameter zero (0) and the identifier parameter is an empty character string (the first character is the terminating zero ('\\0) character.
* @returns EEXIST if the key character string is already used.
* @returns Other error codes as defined for the char_map_add_item() function.
*/