Skip to content
Snippets Groups Projects
Select Git revision
  • 9712641a3d85327b15238e2a6ca7d6eb9ca3c6fe
  • master default protected
  • streebog
  • gost28147
  • master-updates
  • ed448
  • shake256
  • curve448
  • ecc-sqrt
  • gosthash94cp
  • cmac64
  • block16-refactor
  • siv-mode
  • cmac-layout
  • delete-des-compat
  • delete-rsa_blind
  • aes-struct-layout
  • release-3.4-fixes
  • struct-layout
  • attribute-deprecated
  • rename-data-symbols
  • nettle_3.5.1_release_20190627
  • nettle_3.5_release_20190626
  • nettle_3.5rc1
  • nettle_3.4.1_release_20181204
  • nettle_3.4.1rc1
  • nettle_3.4_release_20171119
  • nettle_3.4rc2
  • nettle_3.4rc1
  • nettle_3.3_release_20161001
  • nettle_3.2_release_20160128
  • nettle_3.1.1_release_20150424
  • nettle_3.1_release_20150407
  • nettle_3.1rc3
  • nettle_3.1rc2
  • nettle_3.1rc1
  • nettle_3.0_release_20140607
  • nettle_2.7.1_release_20130528
  • nettle_2.7_release_20130424
  • nettle_2.6_release_20130116
  • nettle_2.5_release_20120707
41 results

memxor.h

Blame
  • Forked from Nettle / nettle
    Source project has a limited visibility.
    • Niels Möller's avatar
      ef3668b2
      *** empty log message *** · ef3668b2
      Niels Möller authored
      Rev: src/nettle/ChangeLog:1.10
      Rev: src/nettle/aes.h:1.4
      Rev: src/nettle/arcfour.h:1.3
      Rev: src/nettle/blowfish.h:1.7
      Rev: src/nettle/cast128.h:1.3
      Rev: src/nettle/des.h:1.4
      Rev: src/nettle/md5.h:1.3
      Rev: src/nettle/memxor.h:1.2
      Rev: src/nettle/serpent.h:1.5
      Rev: src/nettle/sha1.h:1.3
      Rev: src/nettle/twofish.h:1.4
      ef3668b2
      History
      *** empty log message ***
      Niels Möller authored
      Rev: src/nettle/ChangeLog:1.10
      Rev: src/nettle/aes.h:1.4
      Rev: src/nettle/arcfour.h:1.3
      Rev: src/nettle/blowfish.h:1.7
      Rev: src/nettle/cast128.h:1.3
      Rev: src/nettle/des.h:1.4
      Rev: src/nettle/md5.h:1.3
      Rev: src/nettle/memxor.h:1.2
      Rev: src/nettle/serpent.h:1.5
      Rev: src/nettle/sha1.h:1.3
      Rev: src/nettle/twofish.h:1.4
    add_efun.c 2.72 KiB
    /*\
    ||| This file a part of uLPC, and is copyright by Fredrik Hubinette
    ||| uLPC is distributed as GPL (General Public License)
    ||| See the files COPYING and DISCLAIMER for more information.
    \*/
    #include "add_efun.h"
    #include "macros.h"
    #include "program.h"
    #include "lpc_types.h"
    #include "stralloc.h"
    #include "memory.h"
    #include "interpret.h"
    
    static struct hash_table *efun_hash = 0;
    
    struct efun *lookup_efun(struct lpc_string *name)
    {
      struct hash_entry *h;
    
      if(!efun_hash) return 0;
      h=hash_lookup(efun_hash, name);
      if(!h) return 0;
      return BASEOF(h, efun, link);
    }
    
    void low_add_efun(struct lpc_string *name, struct svalue *fun)
    {
      struct efun *parent;
      
      parent=lookup_efun(name);
    
      if(!parent)
      {
        if(!fun) return;
    
        parent=ALLOC_STRUCT(efun);
        copy_shared_string(parent->link.s,name);
        efun_hash=hash_insert(efun_hash, &parent->link);
      }else{
        free_svalue(& parent->function);
    
        /* Disable efun */
        if(!fun)
        {
          efun_hash=hash_unlink(efun_hash, &parent->link);
          free_string(parent->link.s);
          free((char *)parent);
          return;
        }
      }
    
      assign_svalue_no_free(& parent->function, fun);
    }
    
    
    struct callable *make_callable(c_fun fun,
    			       char *name,
    			       char *type,
    			       INT16 flags,
    			       optimize_fun optimize,
    			       docode_fun docode)
    {
      struct callable *f;
      f=ALLOC_STRUCT(callable);
      f->refs=1;
      f->function=fun;
      f->name=make_shared_string(name);
      f->type=parse_type(type);
      f->flags=flags;
      f->docode=docode;
      f->optimize=optimize;
      return f;
    }
    
    void really_free_callable(struct callable *fun)
    {
      free_string(fun->type);
      free_string(fun->name);
      free((char *)fun);
    }
    
    void add_efun2(char *name,
    	       c_fun fun,
    	       char *type,
    	       INT16 flags,
    	       optimize_fun optimize,
    	       docode_fun docode)
    {
      struct svalue s;
      struct lpc_string *n;
    
      n=make_shared_string(name);
      s.type=T_FUNCTION;
      s.subtype=-1;
      s.u.efun=make_callable(fun, name, type, flags, optimize, docode);
      low_add_efun(n, &s);
      free_svalue(&s);
      free_string(n);
    }
    
    void add_efun(char *name, c_fun fun, char *type, INT16 flags)
    {
      add_efun2(name,fun,type,flags,0,0);
    }
    
    static void push_efun_entry(struct hash_entry *h)
    {
      struct efun *f;
      check_stack(1);
      f=BASEOF(h, efun, link);
      push_string(f->link.s);
      f->link.s->refs++;
      copy_svalues_recursively_no_free(sp,& f->function,1,0);
      sp++;
    }
    
    void push_all_efuns_on_stack()
    {
      if(efun_hash)
        map_hashtable(efun_hash,push_efun_entry);
    }
    
    static void free_one_hashtable_entry(struct hash_entry *h)
    {
      struct efun *f;
      f=BASEOF(h, efun, link);
      free_svalue(& f->function);
      free((char *)f);
    }
    
    void cleanup_added_efuns()
    {
      if(efun_hash)
      {
        free_hashtable(efun_hash,free_one_hashtable_entry);
        efun_hash=0;
      }
      
    }