pike.git / src / post_modules / Nettle / hash.cmod

version» Context lines:

pike.git/src/post_modules/Nettle/hash.cmod:1:   /* -*- c -*-   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: hash.cmod,v 1.31 2008/07/31 14:52:27 mast Exp $ + || $Id: hash.cmod,v 1.32 2009/02/24 22:52:48 grubba Exp $   */      #include "global.h"   #include "interpret.h"   #include "svalue.h"   #include "threads.h"      /* For this_object() */   #include "object.h"   #include "module_support.h"
pike.git/src/post_modules/Nettle/hash.cmod:43:       va_start(args, format);    vfprintf(stderr, format, args);    va_end(args);   }   #else   #define werror(x)   #endif      static struct program *Fd_ref_program = NULL; + static struct program *Fd_program = NULL;      /*! @module Nettle */      /*! @class HashInfo    *!    *! Represents information about a hash algorithm, such as    *! name, digest size, and internal block size.    */   PIKECLASS HashInfo   {
pike.git/src/post_modules/Nettle/hash.cmod:159:    void *ctx;    int len, fd;    char *read_buffer;    PIKE_STAT_T st;    struct pike_string *out;    const struct nettle_hash *meta = THIS->meta;       if (!meta)    Pike_error("HashInfo not properly initialized.\n");    -  /* Verify that the input is a Stdio.Fd_ref */ +  /* Verify that the input is a Stdio.Fd or Stdio.Fd_ref */ +  if (!Fd_program) +  { +  push_text("files.Fd"); +  SAFE_APPLY_MASTER("resolv",1); +  Fd_program = program_from_svalue(Pike_sp-1); +  if (!Fd_program) { +  pop_stack(); +  Pike_error("Unable to resolv files.Fd.\n"); +  } +  add_ref(Fd_program); +  pop_stack( ); +  } +     if (!Fd_ref_program)    {    push_text("files.Fd_ref");    SAFE_APPLY_MASTER("resolv",1);    Fd_ref_program = program_from_svalue(Pike_sp-1);    if (!Fd_ref_program) {    pop_stack();    Pike_error("Unable to resolv files.Fd_ref.\n");    }    add_ref(Fd_ref_program);    pop_stack( );    }    -  if (!get_storage(in, Fd_ref_program ) ) -  Pike_error("Object not Fd_ref or subclass.\n"); +  if (!get_storage(in, Fd_program) && !get_storage(in, Fd_ref_program) ) +  Pike_error("Object not Fd or Fd_ref or subclass.\n");       safe_apply(in, "query_fd", 0);    fd = Pike_sp[-1].u.integer;    pop_stack();       if (fd_fstat(fd, &st)<0)    Pike_error("File not found!\n");       if (!S_ISREG(st.st_mode))    Pike_error("Non-regular file.\n");
pike.git/src/post_modules/Nettle/hash.cmod:611:   hash_init(void)   {    werror("Nettle, hash init\n");    INIT;   }      void   hash_exit(void)   {    werror("Nettle, hash exit\n"); +  if (Fd_program) { +  free_program( Fd_program ); +  }    if (Fd_ref_program) {    free_program( Fd_ref_program );    }    EXIT;   }      #endif /* HAVE_LIBNETTLE */