/* xyz */

/*
 * Copyright (c) 1994-2004 by Wayne C. Gramlich.
 * All rights reserved.
 */

/*
 * This file implements an interface to save memory objects:
 */

#ifndef UNIX_ASSERT_H
#include "unix_assert.h"
#endif 

#ifndef LIBC_EXPORTS_H
#include "libc_exports.h"
#endif

#ifndef STHEADERS_H
#include "stheaders.h"
#endif

#ifndef STDLIB_H
#include "stdlib.h"
#endif

#ifndef STR_EXPORTS_H
#include "str_exports.h"
#endif

#ifndef UNIX_ASSERT_H
#include "unix_assert.h"
#endif

#ifdef LINUX

#ifndef UNIX_DLFCN_H
#include "unix_dlfcn.h"
#endif

#endif /* LINUX */

#ifndef UNIX_STDIO_H
#include "unix_stdio.h"
#endif

typedef void *String;
typedef void *Out_stream;


extern Str string__unix_string(String);


void *
save1__read_helper(
	String file_name,
	String symbol_name)
{
#ifdef SOLARIS
	Str file_name_str;
	Str symbol_name_str;
	void *shared_object;
	void *symbol;

	file_name_str = string__unix_string(file_name);
	symbol_name_str = string__unix_string(symbol_name);
	shared_object = dlopen(file_name_str, RTLD_LAZY);
	if (shared_object == (void *)0) {
	    (void)printf("dlopen failed: %s\n", dlerror());
	    assert(0);
	}
	symbol = dlsym(shared_object, symbol_name_str);
	assert(symbol != (void *)0);
	return (void *)((unsigned)symbol + 4);
#endif /* SOLARIS */
#ifdef LINUX
	Str file_name_str;
	Str symbol_name_str;
	void *shared_object;
	void *symbol;

	file_name_str = string__unix_string(file_name);
	symbol_name_str = string__unix_string(symbol_name);
	shared_object = dlopen(file_name_str, RTLD_LAZY);
	if (shared_object == (void *)0) {
	    (void)printf("dlopen failed: %s\n", dlerror());
	    assert(0);
	}
	symbol = dlsym(shared_object, symbol_name_str);
	assert(symbol != (void *)0);
	return (void *)((unsigned)symbol + 4);
	/* assert(0);
	return (void *)0; */
#endif /* LINUX */
#ifdef WINDOWS
	assert(0);
#endif /* WINDOWS */
}






