Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3845 → Rev 3846

/branches/network/uspace/srv/net/measured_strings.c
27,11 → 27,12
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/**
* @file
/** @file
* A character string with measured length implementation file.
* @see measured_strings.h
*/
 
#include <errno.h>
39,6 → 40,7
#include <stdio.h>
#include <string.h>
#include <unistd.h>
 
#include <ipc/ipc.h>
 
#include "err.h"
45,7 → 47,13
#include "measured_strings.h"
#include "modules.h"
 
size_t * prepare_lengths( measured_string_ref strings, size_t count );
/** Computes the lengths of the measured strings in the given array.
* @param strings The measured strings array to be processed. Input parameter.
* @param count The measured strings array size. Input parameter.
* @returns The computed sizes array.
* @returns NULL if there is no memory left.
*/
size_t * prepare_lengths( const measured_string_ref strings, size_t count );
 
measured_string_ref measured_string_create_bulk( const char * string, size_t length ){
measured_string_ref new;
57,7 → 65,9
if( ! new ) return NULL;
new->length = length;
new->value = (( char * ) new ) + sizeof( measured_string_t );
memcpy( new->value, string, new->length + 1 );
// append terminating zero explicitly - to be safe
memcpy( new->value, string, new->length );
new->value[ new->length ] = '\0';
return new;
}
 
64,10 → 74,10
int measured_strings_receive( measured_string_ref * strings, char ** data, size_t count ){
ERROR_DECLARE;
 
size_t * lengths;
int index;
size_t length;
char * next;
size_t * lengths;
int index;
size_t length;
char * next;
ipc_callid_t callid;
 
if(( ! strings ) || ( ! data ) || ( count <= 0 )){
117,12 → 127,12
return EOK;
}
 
int measured_strings_reply( measured_string_ref strings, size_t count ){
int measured_strings_reply( const measured_string_ref strings, size_t count ){
ERROR_DECLARE;
 
size_t * lengths;
int index;
size_t length;
size_t * lengths;
int index;
size_t length;
ipc_callid_t callid;
 
if(( ! strings ) || ( count <= 0 )){
156,7 → 166,7
ERROR_DECLARE;
 
size_t * lengths;
int index;
int index;
char * next;
 
if(( phone <= 0 ) || ( ! strings ) || ( ! data ) || ( count <= 0 )){
193,11 → 203,11
return EOK;
}
 
int measured_strings_send( int phone, measured_string_ref strings, size_t count ){
int measured_strings_send( int phone, const measured_string_ref strings, size_t count ){
ERROR_DECLARE;
 
size_t * lengths;
int index;
int index;
 
if(( phone <= 0 ) || ( ! strings ) || ( count <= 0 )){
return EINVAL;
217,9 → 227,9
return EOK;
}
 
size_t * prepare_lengths( measured_string_ref strings, size_t count ){
size_t * prepare_lengths( const measured_string_ref strings, size_t count ){
size_t * lengths;
int index;
int index;
size_t length;
 
lengths = ( size_t * ) malloc( sizeof( size_t ) * ( count + 1 ));