1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
/*
Clif - A C-like Interpreter Framework
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997 T. Hruz, L. Koren
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* load.c
*
* Function load for a dynamic loading of intrinsic functions.
*/
#include "mystdio.h"
#include "load.h"
#ifndef PROTO
#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined(__STDC__)
#define PROTO(ARGS) ARGS
#else
#define PROTO(ARGS) ()
#endif
#endif
extern void link_function PROTO((int));
extern char *string PROTO((char *));
static int load_flag=0;
/*
* Loads intrinsic C functions into the hash table.
*/
int
load (x)
struct remote_tab **x;
{
int i = 0;
struct remote_tab *arch=NULL;
if (!load_flag)
{
if (SIZE_REM > 0)
{
*x = (struct remote_tab *)
allocate (sizeof(struct remote_tab), PERM);
(*x)->name = intr_name[i].name;
(*x)->adr = (INTRINSIC_FUNCTION)intr_name[i].adr;
(*x)->next = NULL;
arch = *x;
for (i = 1; i < SIZE_REM; i++)
{
arch->next = (struct remote_tab *)
allocate (sizeof(struct remote_tab), PERM);
arch = arch->next;
arch->name = intr_name[i].name;
arch->adr = (INTRINSIC_FUNCTION)intr_name[i].adr;
arch->next = NULL;
}
load_flag = 1;
return (0);
}
else
{
error_message (1008);
return (-1);
}
}
else
{
return (1);
}
}
static int load_flag_new=0;
int
load_new ()
{
int i;
if(!load_flag_new)
{
for(i = 0; i < SIZE_REM; i++)
{
text = string (intr_name[i].name);
link_function (i);
}
load_flag_new = 1;
return (0);
}
else
return (load_flag_new);
}
int
unload ()
{
load_flag_new = 0;
return (0);
}
|