generic.c | generic.c | |||
---|---|---|---|---|
skipping to change at line 169 | skipping to change at line 169 | |||
if (generic->interface != NULL) { | if (generic->interface != NULL) { | |||
string = generic->interface->sprint(generic->data); | string = generic->interface->sprint(generic->data); | |||
if (string != NULL) { | if (string != NULL) { | |||
fprintf(file, "<%s>\n", generic->interface->URI); | fprintf(file, "<%s>\n", generic->interface->URI); | |||
fprintf(file, "%s", string); | fprintf(file, "%s", string); | |||
fprintf(file, "</%s>\n", generic->interface->URI); | fprintf(file, "</%s>\n", generic->interface->URI); | |||
free(string); | free(string); | |||
} | } | |||
} | } | |||
generic = generic->next; | generic = generic->next; | |||
if (generic != NULL) | ||||
fprintf(file, "\n"); | ||||
} | } | |||
} | } | |||
/************************************************************************** *** | /************************************************************************** *** | |||
* Reading function * | * Reading function * | |||
************************************************************************** ***/ | ************************************************************************** ***/ | |||
/** | /** | |||
* osl_generic_sread function: | * osl_generic_sread function: | |||
* this function reads a list of generics from a string complying to the | * this function reads a list of generics from a string complying to the | |||
skipping to change at line 409 | skipping to change at line 411 | |||
x = x->next; | x = x->next; | |||
} | } | |||
return generic_number; | return generic_number; | |||
} | } | |||
/** | /** | |||
* osl_generic_equal function: | * osl_generic_equal function: | |||
* this function returns true if the two generic structures are the same, | * this function returns true if the two generic structures are the same, | |||
* false otherwise. This functions considers two generic structures as equa l | * false otherwise. This functions considers two generic structures as equa l | |||
* independently of the order of the nodes. TODO: make it dependent on the | * independently of the order of the nodes. | |||
* order. | * \param[in] x1 The first generic structure. | |||
* \param x1 The first generic structure. | * \param[in] x2 The second generic structure. | |||
* \param x2 The second generic structure. | ||||
* \return 1 if x1 and x2 are the same (content-wise), 0 otherwise. | * \return 1 if x1 and x2 are the same (content-wise), 0 otherwise. | |||
*/ | */ | |||
int osl_generic_equal(osl_generic_p x1, osl_generic_p x2) { | int osl_generic_equal(osl_generic_p x1, osl_generic_p x2) { | |||
int x1_generic_number, x2_generic_number; | int x1_generic_number, x2_generic_number; | |||
int found, equal; | int found, equal; | |||
osl_generic_p backup_x2 = x2; | osl_generic_p backup_x2 = x2; | |||
if (x1 == x2) | if (x1 == x2) | |||
return 1; | return 1; | |||
skipping to change at line 466 | skipping to change at line 467 | |||
x1 = x1->next; | x1 = x1->next; | |||
} | } | |||
return 1; | return 1; | |||
} | } | |||
/** | /** | |||
* osl_generic_has_URI function: | * osl_generic_has_URI function: | |||
* this function returns 1 if the generic provided as parameter has | * this function returns 1 if the generic provided as parameter has | |||
* a given URI, 0 other wise. | * a given URI, 0 other wise. | |||
* \param x The generic structure to test. | * \param[in] x The generic structure to test. | |||
* \param URI The URI value to test. | * \param[in] URI The URI value to test. | |||
* \return 1 if x has the provided URI, 0 otherwise. | * \return 1 if x has the provided URI, 0 otherwise. | |||
*/ | */ | |||
int osl_generic_has_URI(osl_generic_p x, char * URI) { | int osl_generic_has_URI(osl_generic_p x, char * URI) { | |||
if ((x == NULL) || | if ((x == NULL) || | |||
(x->interface == NULL) || | (x->interface == NULL) || | |||
(x->interface->URI == NULL) || | (x->interface->URI == NULL) || | |||
(strcmp(x->interface->URI, URI))) | (strcmp(x->interface->URI, URI))) | |||
return 0; | return 0; | |||
return 1; | return 1; | |||
} | } | |||
/** | /** | |||
* osl_generic_lookup function: | * osl_generic_lookup function: | |||
* this function returns the first generic with a given URI in the | * this function returns the first generic with a given URI in the | |||
* generic list provided as parameter and NULL if it doesn't find such | * generic list provided as parameter and NULL if it doesn't find such | |||
* a generic. | * a generic. | |||
* \param x The generic list where to search a given generic URI. | * \param[in] x The generic list where to search a given generic URI. | |||
* \param URI The URI of the generic we are looking for. | * \param[in] URI The URI of the generic we are looking for. | |||
* \return The first generic of the requested URI in the list. | * \return The first generic of the requested URI in the list. | |||
*/ | */ | |||
void * osl_generic_lookup(osl_generic_p x, char * URI) { | void * osl_generic_lookup(osl_generic_p x, char * URI) { | |||
while (x != NULL) { | while (x != NULL) { | |||
if (osl_generic_has_URI(x, URI)) | if (osl_generic_has_URI(x, URI)) | |||
return x->data; | return x->data; | |||
x = x->next; | x = x->next; | |||
} | } | |||
return NULL; | return NULL; | |||
} | } | |||
/** | ||||
* osl_generic_shell function: | ||||
* this function creates and returns a generic structure "shell" which | ||||
* embed the data and interface provided as parameters. | ||||
* \param[in] data Data to put in the generic shell. | ||||
* \param[in] interface Interface to put in the generic shell. | ||||
* \return A new generic structure containing the data and interface. | ||||
*/ | ||||
osl_generic_p osl_generic_shell(void * data, osl_interface_p interface) { | ||||
osl_generic_p generic = NULL; | ||||
if ((data == NULL) || (interface == NULL)) | ||||
OSL_warning("shell created with some empty elements inside"); | ||||
generic = osl_generic_malloc(); | ||||
generic->data = data; | ||||
generic->interface = interface; | ||||
return generic; | ||||
} | ||||
End of changes. 5 change blocks. | ||||
8 lines changed or deleted | 9 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |