struct signatures_s * retrieve_signatures() { // Read signatures from spoon.conf, and add them to a linked list. FILE *config; char *header, *footer, *ext; int len; struct signatures_s *sigs = (struct signatures_s *) malloc(sizeof(struct signatures_s)); config = fopen("spoon.conf", "r"); while (fscanf(config, "%ms %ms %ms %d", &ext, &header, &footer, &len) != EOF) { append_signature(sigs, make_signature(atoh(header), atoh(footer), ext, len)); } fclose(config); return sigs; }
void write_signature_file(const char * write_filepath, mpz_t hash) { signature_attr attr; gen_signature_attr(&attr); gen_keys_pair(&attr); signature sign; mpz_init(sign.r); mpz_init(sign.s); make_signature(&sign, &attr, hash); FILE * stream = open_wrapper(write_filepath, "wb"); mpz_out_wrapper(stream, sign.r); mpz_out_wrapper(stream, sign.s); close_wrapper(stream); mpz_clear(sign.r); mpz_clear(sign.s); free_keys_pair(&attr); free_signature_attr(&attr); }
static void make_prototype(compile_t* c, reachable_type_t* t, reachable_method_t* m) { if(m->intrinsic) return; // Behaviours and actor constructors also have handler functions. bool handler = false; switch(ast_id(m->r_fun)) { case TK_NEW: handler = t->underlying == TK_ACTOR; break; case TK_BE: handler = true; break; default: {} } make_signature(t, m); switch(t->underlying) { case TK_PRIMITIVE: case TK_STRUCT: case TK_CLASS: case TK_ACTOR: break; default: return; } if(handler) { // Generate the sender prototype. const char* sender_name = genname_be(m->full_name); m->func = codegen_addfun(c, sender_name, m->func_type); // Change the return type to void for the handler. size_t count = LLVMCountParamTypes(m->func_type); size_t buf_size = count * sizeof(LLVMTypeRef); LLVMTypeRef* tparams = (LLVMTypeRef*)ponyint_pool_alloc_size(buf_size); LLVMGetParamTypes(m->func_type, tparams); LLVMTypeRef handler_type = LLVMFunctionType(c->void_type, tparams, (int)count, false); ponyint_pool_free_size(buf_size, tparams); // Generate the handler prototype. m->func_handler = codegen_addfun(c, m->full_name, handler_type); make_function_debug(c, t, m, m->func_handler); } else { // Generate the function prototype. m->func = codegen_addfun(c, m->full_name, m->func_type); make_function_debug(c, t, m, m->func); } }