Beispiel #1
0
void compile_topology(int kflag)
{
    extern char	*compile_string(char *, int);

    char	*so_file;
    int		n;

#if	defined(APPEND_DOT_TO_LDPATH)
    {
	extern int	putenv(char *);
	char		*newenv, *oldenv;

	if((oldenv = findenv("LD_LIBRARY_PATH", NULL)) == (char *)NULL)
	    newenv	= strdup("LD_LIBRARY_PATH=\".\"");
	else {
	    sprintf(chararray,"LD_LIBRARY_PATH=\"%s:.\"", oldenv);
	    newenv	= strdup(chararray);
	}
	putenv(newenv);
    }
#endif

    for(n=0 ; n<_NNODES ; n++) {
	so_file	= compile_string(NP[n].nattr.compile, kflag);
	if(nerrors)
	    cleanup(1);
	dynamic_load(n, so_file);
	if(nerrors)
	    cleanup(1);
    }
}
    bool dynamic_link( const char* library, const dynamic_link_descriptor descriptors[], size_t required, dynamic_link_handle *handle, int flags ) {
        // TODO: May global_symbols_link find weak symbols?
        dynamic_link_handle library_handle = ( flags & DYNAMIC_LINK_GLOBAL ) ? global_symbols_link( library, descriptors, required ) : 0;

        if ( !library_handle && ( flags & DYNAMIC_LINK_LOAD ) )
            library_handle = dynamic_load( library, descriptors, required );

        if ( !library_handle && ( flags & DYNAMIC_LINK_WEAK ) )
            return weak_symbol_link( descriptors, required );

        save_library_handle( library_handle, handle );
        return true;
    }
Beispiel #3
0
static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
{
    dynamic_data_ctx *ctx = dynamic_get_data_ctx(e);
    int initialised;

    if (!ctx) {
        ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ENGINE_R_NOT_LOADED);
        return 0;
    }
    initialised = ((ctx->dynamic_dso == NULL) ? 0 : 1);
    /* All our control commands require the ENGINE to be uninitialised */
    if (initialised) {
        ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ENGINE_R_ALREADY_LOADED);
        return 0;
    }
    switch (cmd) {
    case DYNAMIC_CMD_SO_PATH:
        /* a NULL 'p' or a string of zero-length is the same thing */
        if (p && (strlen((const char *)p) < 1))
            p = NULL;
        OPENSSL_free(ctx->DYNAMIC_LIBNAME);
        if (p)
            ctx->DYNAMIC_LIBNAME = OPENSSL_strdup(p);
        else
            ctx->DYNAMIC_LIBNAME = NULL;
        return (ctx->DYNAMIC_LIBNAME ? 1 : 0);
    case DYNAMIC_CMD_NO_VCHECK:
        ctx->no_vcheck = ((i == 0) ? 0 : 1);
        return 1;
    case DYNAMIC_CMD_ID:
        /* a NULL 'p' or a string of zero-length is the same thing */
        if (p && (strlen((const char *)p) < 1))
            p = NULL;
        OPENSSL_free(ctx->engine_id);
        if (p)
            ctx->engine_id = OPENSSL_strdup(p);
        else
            ctx->engine_id = NULL;
        return (ctx->engine_id ? 1 : 0);
    case DYNAMIC_CMD_LIST_ADD:
        if ((i < 0) || (i > 2)) {
            ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ENGINE_R_INVALID_ARGUMENT);
            return 0;
        }
        ctx->list_add_value = (int)i;
        return 1;
    case DYNAMIC_CMD_LOAD:
        return dynamic_load(e, ctx);
    case DYNAMIC_CMD_DIR_LOAD:
        if ((i < 0) || (i > 2)) {
            ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ENGINE_R_INVALID_ARGUMENT);
            return 0;
        }
        ctx->dir_load = (int)i;
        return 1;
    case DYNAMIC_CMD_DIR_ADD:
        /* a NULL 'p' or a string of zero-length is the same thing */
        if (!p || (strlen((const char *)p) < 1)) {
            ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ENGINE_R_INVALID_ARGUMENT);
            return 0;
        }
        {
            char *tmp_str = OPENSSL_strdup(p);
            if (!tmp_str) {
                ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ERR_R_MALLOC_FAILURE);
                return 0;
            }
            sk_OPENSSL_STRING_insert(ctx->dirs, tmp_str, -1);
        }
        return 1;
    default:
        break;
    }
    ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED);
    return 0;
}
Beispiel #4
0
                    " Fragmentation = %d (%d%%)\n",
          df->nkeys,nblocks,key_length,block_length,
          4*nblocks,lost,(lost*100)/block_length,
          (key_length*100)/block_length,
          fragments,(fragments*100)/nblocks);
  stack = oldstack;
}


/* used in the defrag routine */
void transfer_key(dfile *old,dfile *new,int key)
{
  int data_length,new_key,start_block,old_length,new_length;
  char *oldstack;
  oldstack=stack;
  data_length=dynamic_load(old,key,stack);
  if (data_length<=0) return;
  stack+=data_length;
  new_key=dynamic_save(new,oldstack,data_length,0);
  if (new_key<=0) handle_error("Failed to write new file on defrag");
  (void) get_int(&old_length,(char *)(old->keylist+key*2+1));
  (void) get_int(&new_length,(char *)(new->keylist+new_key*2+1));
  if (old_length!=new_length) {
    printf("key = %d\nnew_key = %d\nold_length = %d\nnew_length = %d\ndata_length = %d\n",
           key,new_key,old_length,new_length,data_length);
    handle_error("lengths dont match on defrag");
  }
  (void) get_int(&start_block,(char *)(new->keylist+new_key*2));
  (void) store_int((char *)(old->keylist+key*2),start_block);
  stack=oldstack;
}