⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 omapi.c

📁 DHCP服务器源码
💻 C
📖 第 1 页 / 共 5 页
字号:
		}		dfree (class -> billed_leases, file, line);		class -> billed_leases = (struct lease **)0;	}	if (class -> hash) {		class_free_hash_table (&class -> hash, file, line);		class -> hash = (class_hash_t *)0;	}	data_string_forget (&class -> hash_string, file, line);	if (class -> expr)		expression_dereference (&class -> expr, file, line);	if (class -> submatch)		expression_dereference (&class -> submatch, file, line);	if (class -> group)		group_dereference (&class -> group, file, line);	if (class -> statements)		executable_statement_dereference (&class -> statements,						  file, line);	if (class -> superclass)		class_dereference (&class -> superclass, file, line);#endif	return ISC_R_SUCCESS;}isc_result_t dhcp_class_signal_handler (omapi_object_t *h,					const char *name, va_list ap){	struct class *class;	isc_result_t status;	int updatep = 0;	if (h -> type != dhcp_type_class)		return ISC_R_INVALIDARG;	class = (struct class *)h;	/* Can't write classs yet. */	/* Try to find some inner object that can take the value. */	if (h -> inner && h -> inner -> type -> signal_handler) {		status = ((*(h -> inner -> type -> signal_handler))			  (h -> inner, name, ap));		if (status == ISC_R_SUCCESS)			return status;	}	if (updatep)		return ISC_R_SUCCESS;	return ISC_R_NOTFOUND;}isc_result_t dhcp_class_stuff_values (omapi_object_t *c,				      omapi_object_t *id,				      omapi_object_t *h){	struct class *class;	isc_result_t status;	if (h -> type != dhcp_type_class)		return ISC_R_INVALIDARG;	class = (struct class *)h;	/* Can't stuff class values yet. */	/* Write out the inner object, if any. */	if (h -> inner && h -> inner -> type -> stuff_values) {		status = ((*(h -> inner -> type -> stuff_values))			  (c, id, h -> inner));		if (status == ISC_R_SUCCESS)			return status;	}	return ISC_R_SUCCESS;}isc_result_t dhcp_class_lookup (omapi_object_t **lp,				omapi_object_t *id, omapi_object_t *ref){	omapi_value_t *tv = (omapi_value_t *)0;	isc_result_t status;	struct class *class;	/* Can't look up classs yet. */	/* If we get to here without finding a class, no valid key was	   specified. */	if (!*lp)		return ISC_R_NOKEYS;	return ISC_R_SUCCESS;}isc_result_t dhcp_class_create (omapi_object_t **lp,				omapi_object_t *id){	return ISC_R_NOTIMPLEMENTED;}isc_result_t dhcp_class_remove (omapi_object_t *lp,				omapi_object_t *id){	return ISC_R_NOTIMPLEMENTED;}isc_result_t dhcp_subclass_set_value  (omapi_object_t *h,				       omapi_object_t *id,				       omapi_data_string_t *name,				       omapi_typed_data_t *value){	struct subclass *subclass;	isc_result_t status;	int foo;	if (h -> type != dhcp_type_subclass)		return ISC_R_INVALIDARG;	subclass = (struct subclass *)h;	/* No values to set yet. */	/* Try to find some inner object that can take the value. */	if (h -> inner && h -> inner -> type -> set_value) {		status = ((*(h -> inner -> type -> set_value))			  (h -> inner, id, name, value));		if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED)			return status;	}			  	return ISC_R_UNKNOWNATTRIBUTE;}isc_result_t dhcp_subclass_get_value (omapi_object_t *h, omapi_object_t *id,				      omapi_data_string_t *name,				      omapi_value_t **value){	struct subclass *subclass;	isc_result_t status;	if (h -> type != dhcp_type_subclass)		return ISC_R_INVALIDARG;	subclass = (struct subclass *)h;	/* No values to get yet. */	/* Try to find some inner object that can provide the value. */	if (h -> inner && h -> inner -> type -> get_value) {		status = ((*(h -> inner -> type -> get_value))			  (h -> inner, id, name, value));		if (status == ISC_R_SUCCESS)			return status;	}	return ISC_R_UNKNOWNATTRIBUTE;}isc_result_t dhcp_subclass_signal_handler (omapi_object_t *h,					   const char *name, va_list ap){	struct subclass *subclass;	isc_result_t status;	int updatep = 0;	if (h -> type != dhcp_type_subclass)		return ISC_R_INVALIDARG;	subclass = (struct subclass *)h;	/* Can't write subclasss yet. */	/* Try to find some inner object that can take the value. */	if (h -> inner && h -> inner -> type -> signal_handler) {		status = ((*(h -> inner -> type -> signal_handler))			  (h -> inner, name, ap));		if (status == ISC_R_SUCCESS)			return status;	}	if (updatep)		return ISC_R_SUCCESS;	return ISC_R_NOTFOUND;}isc_result_t dhcp_subclass_stuff_values (omapi_object_t *c,					 omapi_object_t *id,					 omapi_object_t *h){	struct subclass *subclass;	isc_result_t status;	if (h -> type != dhcp_type_subclass)		return ISC_R_INVALIDARG;	subclass = (struct subclass *)h;	/* Can't stuff subclass values yet. */	/* Write out the inner object, if any. */	if (h -> inner && h -> inner -> type -> stuff_values) {		status = ((*(h -> inner -> type -> stuff_values))			  (c, id, h -> inner));		if (status == ISC_R_SUCCESS)			return status;	}	return ISC_R_SUCCESS;}isc_result_t dhcp_subclass_lookup (omapi_object_t **lp,				   omapi_object_t *id, omapi_object_t *ref){	omapi_value_t *tv = (omapi_value_t *)0;	isc_result_t status;	struct subclass *subclass;	/* Can't look up subclasss yet. */	/* If we get to here without finding a subclass, no valid key was	   specified. */	if (!*lp)		return ISC_R_NOKEYS;	return ISC_R_SUCCESS;}isc_result_t dhcp_subclass_create (omapi_object_t **lp,				   omapi_object_t *id){	return ISC_R_NOTIMPLEMENTED;}isc_result_t dhcp_subclass_remove (omapi_object_t *lp,				   omapi_object_t *id){	return ISC_R_NOTIMPLEMENTED;}isc_result_t binding_scope_set_value (struct binding_scope *scope, int createp,				      omapi_data_string_t *name,				      omapi_typed_data_t *value){	struct binding *bp;	char *nname;	struct binding_value *nv;	nname = dmalloc (name -> len + 1, MDL);	if (!nname)		return ISC_R_NOMEMORY;	memcpy (nname, name -> value, name -> len);	nname [name -> len] = 0;	bp = find_binding (scope, nname);	if (!bp && !createp) {		dfree (nname, MDL);		return ISC_R_UNKNOWNATTRIBUTE;	} 	if (!value) {		dfree (nname, MDL);		if (!bp)			return ISC_R_UNKNOWNATTRIBUTE;		binding_value_dereference (&bp -> value, MDL);		return ISC_R_SUCCESS;	}	nv = (struct binding_value *)0;	if (!binding_value_allocate (&nv, MDL)) {		dfree (nname, MDL);		return ISC_R_NOMEMORY;	}	switch (value -> type) {	      case omapi_datatype_int:		nv -> type = binding_numeric;		nv -> value.intval = value -> u.integer;		break;	      case omapi_datatype_string:	      case omapi_datatype_data:		if (!buffer_allocate (&nv -> value.data.buffer,				      value -> u.buffer.len, MDL)) {			binding_value_dereference (&nv, MDL);			dfree (nname, MDL);			return ISC_R_NOMEMORY;		}		memcpy (&nv -> value.data.buffer -> data [1],			value -> u.buffer.value, value -> u.buffer.len);		nv -> value.data.len = value -> u.buffer.len;		break;	      case omapi_datatype_object:		binding_value_dereference (&nv, MDL);		dfree (nname, MDL);		return ISC_R_INVALIDARG;	}	if (!bp) {		bp = dmalloc (sizeof *bp, MDL);		if (!bp) {			binding_value_dereference (&nv, MDL);			dfree (nname, MDL);			return ISC_R_NOMEMORY;		}		memset (bp, 0, sizeof *bp);		bp -> name = nname;		nname = (char *)0;		bp -> next = scope -> bindings;		scope -> bindings = bp;	} else {		if (bp -> value)			binding_value_dereference (&bp -> value, MDL);		dfree (nname, MDL);	}	binding_value_reference (&bp -> value, nv, MDL);	binding_value_dereference (&nv, MDL);	return ISC_R_SUCCESS;}isc_result_t binding_scope_get_value (omapi_value_t **value,				      struct binding_scope *scope,				      omapi_data_string_t *name){	struct binding *bp;	omapi_typed_data_t *td;	isc_result_t status;	char *nname;	nname = dmalloc (name -> len + 1, MDL);	if (!nname)		return ISC_R_NOMEMORY;	memcpy (nname, name -> value, name -> len);	nname [name -> len] = 0;	bp = find_binding (scope, nname);	dfree (nname, MDL);	if (!bp)		return ISC_R_UNKNOWNATTRIBUTE;	if (!bp -> value)		return ISC_R_UNKNOWNATTRIBUTE;	switch (bp -> value -> type) {	      case binding_boolean:		td = (omapi_typed_data_t *)0;		status = omapi_typed_data_new (MDL, &td, omapi_datatype_int,					       bp -> value -> value.boolean);		break;	      case binding_numeric:		td = (omapi_typed_data_t *)0;		status = omapi_typed_data_new (MDL, &td, omapi_datatype_int,					       (int)					       bp -> value -> value.intval);		break;	      case binding_data:		td = (omapi_typed_data_t *)0;		status = omapi_typed_data_new (MDL, &td, omapi_datatype_data,					       bp -> value -> value.data.len);		if (status != ISC_R_SUCCESS)			return status;		memcpy (&td -> u.buffer.value [0],			bp -> value -> value.data.data,			bp -> value -> value.data.len);		break;		/* Can't return values for these two (yet?). */	      case binding_dns:	      case binding_function:		return ISC_R_INVALIDARG;	}	if (status != ISC_R_SUCCESS)		return status;	status = omapi_value_new (value, MDL);	if (status != ISC_R_SUCCESS) {		omapi_typed_data_dereference (&td, MDL);		return status;	}		omapi_data_string_reference (&(*value) -> name, name, MDL);	omapi_typed_data_reference (&(*value) -> value, td, MDL);	omapi_typed_data_dereference (&td, MDL);	return ISC_R_SUCCESS;}isc_result_t binding_scope_stuff_values (omapi_object_t *c,					 struct binding_scope *scope){	struct binding *bp;	unsigned len;	isc_result_t status;	for (bp = scope -> bindings; bp; bp = bp -> next) {	    if (bp -> value) {		if (bp -> value -> type == binding_dns ||		    bp -> value -> type == binding_function)			continue;		/* Stuff the name. */		len = strlen (bp -> name);		status = omapi_connection_put_uint16 (c, len);		if (status != ISC_R_SUCCESS)		    return status;		status = omapi_connection_copyin (c,						  (unsigned char *)bp -> name,						  len);		if (status != ISC_R_SUCCESS)			return status;		switch (bp -> value -> type) {		  case binding_boolean:		    status = omapi_connection_put_uint32 (c,							  sizeof (u_int32_t));		    if (status != ISC_R_SUCCESS)			return status;		    status = (omapi_connection_put_uint32			      (c,			       ((u_int32_t)(bp -> value -> value.boolean))));		    break;		  case binding_data:		    status = (omapi_connection_put_uint32			      (c, bp -> value -> value.data.len));		    if (status != ISC_R_SUCCESS)			return status;		    if (bp -> value -> value.data.len) {			status = (omapi_connection_copyin				  (c, bp -> value -> value.data.data,				   bp -> value -> value.data.len));			if (status != ISC_R_SUCCESS)			    return status;		    }		    break;		  case binding_numeric:		    status = (omapi_connection_put_uint32			      (c, sizeof (u_int32_t)));		    if (status != ISC_R_SUCCESS)			    return status;		    status = (omapi_connection_put_uint32			      (c, ((u_int32_t)				   (bp -> value -> value.intval))));		    break;		    /* NOTREACHED */		  case binding_dns:		  case binding_function:		    break;		}	    }	}	return ISC_R_SUCCESS;}/* vim: set tabstop=8: */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -