int __bro_id_clone(BroID *dst, BroID *src) { BroString *string; D_ENTER; if (! __bro_object_clone((BroObject *) dst, (BroObject *) src)) D_RETURN_(FALSE); if (! (string = bro_string_copy(&src->name))) D_RETURN_(FALSE); dst->name = *string; free(string); dst->scope = src->scope; dst->is_export = src->is_export; dst->is_const = src->is_const; dst->is_enum_const = src->is_enum_const; dst->is_type = src->is_type; dst->offset = src->offset; dst->infer_return_type = src->infer_return_type; dst->weak_ref = src->weak_ref; if (src->type && ! (dst->type = (BroType *) __bro_sobject_copy((BroSObject *) src->type))) D_RETURN_(FALSE); if (src->val && ! (dst->val = (BroVal *) __bro_sobject_copy((BroSObject *) src->val))) D_RETURN_(FALSE); if (src->attrs && ! (dst->attrs = (BroAttrs *) __bro_sobject_copy((BroSObject *) src->attrs))) D_RETURN_(FALSE); D_RETURN_(TRUE); }
static int __bro_val_clone(BroVal *dst, BroVal *src) { D_ENTER; if (! __bro_object_clone((BroObject *) dst, (BroObject *) src)) { D(("Cloning parent failed.\n")); D_RETURN_(FALSE); } if (src->val_type && ! (dst->val_type = (BroType *) __bro_sobject_copy((BroSObject *) src->val_type))) { D(("Cloning type failed.\n")); D_RETURN_(FALSE); } if (src->val_attrs && ! (dst->val_attrs = (BroRecordVal *) __bro_sobject_copy((BroSObject *) src->val_attrs))) { D(("Cloning attributes failed.\n")); D_RETURN_(FALSE); } switch (dst->val_type->internal_tag) { case BRO_INTTYPE_INT: case BRO_INTTYPE_UNSIGNED: /* Hack for ports */ if (src->val_type->tag == BRO_TYPE_PORT) dst->val_port = src->val_port; else dst->val_int64 = src->val_int64; break; case BRO_INTTYPE_IPADDR: dst->val_addr = src->val_addr; break; case BRO_INTTYPE_DOUBLE: dst->val_double = src->val_double; break; case BRO_INTTYPE_STRING: bro_string_assign(&src->val_str, &dst->val_str); break; case BRO_INTTYPE_SUBNET: dst->val_subnet = src->val_subnet; break; case BRO_INTTYPE_OTHER: /* That's okay, handled in subtype */ break; default: D(("Unknown internal type tag: %i\n", dst->val_type->internal_tag)); D_RETURN_(FALSE); } D_RETURN_(TRUE); }