/*********************************************** !!!! DO NOT EDIT THIS FILE !!!! This file was auto-generated by Build.PL from lib/KinoSearch/Util/VerifyArgs.pm See KinoSearch::Docs::DevGuide for details. ***********************************************/ #line 85 "lib/KinoSearch/Util/VerifyArgs.pm" #include "KinoSearchUtilVerifyArgs.h" HV* Kino_Verify_do_build_args_hash(char* defaults_hash_name, I32 stack_st) { HV *defaults_hash, *args_hash; char *key; I32 key_len; STRLEN len; SV *key_sv, *val_sv, *val_copy_sv; I32 stack_pos; dXSARGS; /* create the args hash and mortalize it */ args_hash = newHV(); args_hash = (HV*)sv_2mortal( (SV*)args_hash ); /* NOTE: the defaults hash must be declared using "our" */ defaults_hash = get_hv(defaults_hash_name, 0); if (defaults_hash == NULL) Kino_confess("Can't find hash named %s", defaults_hash_name); /* make the args hash a copy of the defaults hash */ (void)hv_iterinit(defaults_hash); while ((val_sv = hv_iternextsv(defaults_hash, &key, &key_len))) { val_copy_sv = newSVsv(val_sv); hv_store(args_hash, key, key_len, val_copy_sv, 0); } /* verify and copy hash-style params into args hash from stack */ if ((items - stack_st) % 2 != 0) Kino_confess("Expecting hash-style params, " "got odd number of args"); stack_pos = stack_st; while (stack_pos < items) { key_sv = ST(stack_pos++); key = SvPV(key_sv, len); key_len = len; if (!hv_exists(args_hash, key, key_len)) { Kino_confess("Invalid parameter: '%s'", key); } val_sv = ST(stack_pos++); val_copy_sv = newSVsv(val_sv); hv_store(args_hash, key, key_len, val_copy_sv, 0); } return args_hash; } SV* Kino_Verify_extract_arg(HV* hash, char* key, I32 key_len) { SV** sv_ptr; sv_ptr = hv_fetch(hash, key, key_len, 0); if (sv_ptr == NULL) Kino_confess("Failed to retrieve hash entry '%s'", key); return *sv_ptr; }