diff --git a/ChangeLog b/ChangeLog index 5847f5b..446fa87 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-12-23 Marcelo Jimenez + + * Finished const-ifications as suggested by Erik Johansson in + SF Patch tracker [ 1587272 ]. + 2006-12-23 Marcelo Jimenez * Erik Johansson's patch for const-ified ixml diff --git a/upnp/src/api/upnpapi.c b/upnp/src/api/upnpapi.c index ee386af..60635cc 100644 --- a/upnp/src/api/upnpapi.c +++ b/upnp/src/api/upnpapi.c @@ -3712,7 +3712,7 @@ FreeHandle( int Upnp_Handle ) } /****************** End of FreeHandle *********************/ // **DBG**************************************************** -DBGONLY( +//DBGONLY( /************************************************************************** * Function: PrintHandleInfo @@ -3753,7 +3753,7 @@ DBGONLY( IXML_NodeList * NodeList1; IXML_Node * ChildNode1; unsigned short NodeType; - DOMString NodeValue; + const DOMString NodeValue; const DOMString NodeName; NodeList1 = ixmlNode_getChildNodes( tmpRoot ); for( i = 0; i < 100; i++ ) { @@ -3774,7 +3774,7 @@ DBGONLY( } /****************** End of printNodes *********************/ - ) // dbgonly +// ) // dbgonly //******************************************************** //* Name: getlocalhostname diff --git a/upnp/src/genlib/net/uri/uri.c b/upnp/src/genlib/net/uri/uri.c index 588ef4b..0698194 100644 --- a/upnp/src/genlib/net/uri/uri.c +++ b/upnp/src/genlib/net/uri/uri.c @@ -125,7 +125,7 @@ is_unreserved( char in ) * Note : ************************************************************************/ int -is_escaped( char *in ) +is_escaped( const char *in ) { if( ( in[0] == '%' ) && ( isxdigit( in[1] ) ) && isxdigit( in[2] ) ) { @@ -204,7 +204,7 @@ replace_escaped( char *in, * Note : ************************************************************************/ int -parse_uric( char *in, +parse_uric( const char *in, int max, token * out ) { @@ -496,12 +496,12 @@ token_cmp( token * in1, ************************************************************************/ int parse_port( int max, - char *port, + const char *port, unsigned short *out ) { - char *finger = port; - char *max_ptr = finger + max; + const char *finger = port; + const char *max_ptr = finger + max; unsigned short temp = 0; while( ( finger < max_ptr ) && ( isdigit( *finger ) ) ) { @@ -533,7 +533,7 @@ parse_port( int max, * Note : ************************************************************************/ int -parse_hostport( char *in, +parse_hostport( const char *in, int max, hostport_type * out ) { @@ -681,7 +681,7 @@ parse_hostport( char *in, * Note : ************************************************************************/ int -parse_scheme( char *in, +parse_scheme( const char *in, int max, token * out ) { @@ -994,7 +994,7 @@ resolve_rel_url( char *base_url, * Note : ************************************************************************/ int -parse_uri( char *in, +parse_uri( const char *in, int max, uri_type * out ) { @@ -1074,8 +1074,8 @@ parse_uri_and_unescape( char *in, if( ( ret = parse_uri( in, max, out ) ) != HTTP_SUCCESS ) return ret; if( out->pathquery.size > 0 ) - remove_escaped_chars( out->pathquery.buff, &out->pathquery.size ); + remove_escaped_chars( (char *)out->pathquery.buff, &out->pathquery.size ); if( out->fragment.size > 0 ) - remove_escaped_chars( out->fragment.buff, &out->fragment.size ); + remove_escaped_chars( (char *)out->fragment.buff, &out->fragment.size ); return HTTP_SUCCESS; } diff --git a/upnp/src/genlib/service_table/service_table.c b/upnp/src/genlib/service_table/service_table.c index 4caf592..0a8520b 100644 --- a/upnp/src/genlib/service_table/service_table.c +++ b/upnp/src/genlib/service_table/service_table.c @@ -398,7 +398,7 @@ FindServiceEventURLPath( service_table * table, ************************************************************************/ service_info * FindServiceControlURLPath( service_table * table, - char *controlURLPath ) + const char *controlURLPath ) { service_info *finger = NULL; uri_type parsed_url; diff --git a/upnp/src/inc/service_table.h b/upnp/src/inc/service_table.h index fb5062d..2b857ce 100644 --- a/upnp/src/inc/service_table.h +++ b/upnp/src/inc/service_table.h @@ -246,7 +246,7 @@ service_info * FindServiceEventURLPath( service_table *table, * Note : ************************************************************************/ service_info * FindServiceControlURLPath( service_table *table, - char * controlURLPath); + const char * controlURLPath); /************************************************************************ * Function : printService diff --git a/upnp/src/inc/uri.h b/upnp/src/inc/uri.h index 12f58fb..31f6a99 100644 --- a/upnp/src/inc/uri.h +++ b/upnp/src/inc/uri.h @@ -86,7 +86,7 @@ enum uriType { absolute, relative }; /* Buffer used in parsinghttp messages, urls, etc. generally this simply * holds a pointer into a larger array */ typedef struct TOKEN { - char * buff; + const char *buff; int size; } token; @@ -276,7 +276,7 @@ int token_cmp( token *in1, token *in2); * * Note : ************************************************************************/ -int parse_port(int max, char * port, unsigned short int * out); +int parse_port(int max, const char *port, unsigned short int *out); /************************************************************************ * Function : parse_hostport @@ -296,7 +296,7 @@ int parse_port(int max, char * port, unsigned short int * out); * * Note : ************************************************************************/ -int parse_hostport( char* in, int max, hostport_type *out ); +int parse_hostport(const char *in, int max, hostport_type *out ); /************************************************************************ * Function : remove_escaped_chars @@ -391,7 +391,7 @@ char * resolve_rel_url( char * base_url, char * rel_url); * * Note : ************************************************************************/ -int parse_uri( char * in, int max, uri_type * out); +int parse_uri(const char * in, int max, uri_type * out); /************************************************************************ * Function : parse_uri_and_unescape diff --git a/upnp/src/soap/soap_ctrlpt.c b/upnp/src/soap/soap_ctrlpt.c index 8027320..776e0db 100644 --- a/upnp/src/soap/soap_ctrlpt.c +++ b/upnp/src/soap/soap_ctrlpt.c @@ -246,18 +246,19 @@ get_node_value( IN IXML_Node * node ) ****************************************************************************/ static XINLINE int get_host_and_path( IN char *ctrl_url, - OUT memptr * host, - OUT memptr * path, + OUT const memptr *host, + OUT const memptr *path, OUT uri_type * url ) { if( parse_uri( ctrl_url, strlen( ctrl_url ), url ) != HTTP_SUCCESS ) { return -1; } - host->buf = url->hostport.text.buff; - host->length = url->hostport.text.size; + // This is done to ensure that the buffer is kept const + ((memptr *)host)->buf = (char *)url->hostport.text.buff; + ((memptr *)host)->length = url->hostport.text.size; - path->buf = url->pathquery.buff; - path->length = url->pathquery.size; + ((memptr *)path)->buf = (char *)url->pathquery.buff; + ((memptr *)path)->length = url->pathquery.size; return 0; } @@ -873,8 +874,8 @@ SoapGetServiceVarStatus( IN char *action_url, IN char *var_name, OUT char **var_value ) { - memptr host; // value for HOST header - memptr path; // ctrl path in first line in msg + const memptr host; // value for HOST header + const memptr path; // ctrl path in first line in msg uri_type url; membuffer request; int ret_code; diff --git a/upnp/src/soap/soap_device.c b/upnp/src/soap/soap_device.c index 6ebd268..da332a4 100644 --- a/upnp/src/soap/soap_device.c +++ b/upnp/src/soap/soap_device.c @@ -603,13 +603,13 @@ get_device_info( IN http_message_t * request, service_info *serv_info; char save_char; int ret_code = -1; // error by default - char *control_url; + const char *control_url; char *actionName = NULL; // null-terminate pathquery of url control_url = request->uri.pathquery.buff; save_char = control_url[request->uri.pathquery.size]; - control_url[request->uri.pathquery.size] = '\0'; + ((char *)control_url)[request->uri.pathquery.size] = '\0'; HandleLock( ); @@ -666,7 +666,7 @@ get_device_info( IN http_message_t * request, ret_code = 0; error_handler: - control_url[request->uri.pathquery.size] = save_char; // restore + ((char *)control_url)[request->uri.pathquery.size] = save_char; // restore HandleUnlock( ); return ret_code; }