home *** CD-ROM | disk | FTP | other *** search
- /*
- l_proto.h
- */
- /* Copyright (c) 1994 Christian F. Tschudin. All rights reserved.
-
- Distributed under the terms of the GNU General Public License
- version 2 of june 1991 as published by the Free Software
- Foundation, Inc.
-
- This file is part of M0.
-
- M0 is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY. No author or distributor accepts responsibility to anyone for
- the consequences of using it or for whether it serves any particular
- purpose or works at all, unless he says so in writing. Refer to the GNU
- General Public License for full details.
-
- Everyone is granted permission to copy, modify and redistribute M0, but
- only under the conditions described in the GNU General Public License.
- A copy of this license is supposed to have been given to you along with
- M0 so you can know your rights and responsibilities. It should be in a
- file named LICENSE. Among other things, the copyright notice and this
- notice must be preserved on all copies. */
-
-
- #ifndef L_PROTO_H
- #define L_PROTO_H
-
- #include "element.h"
- #include "error.h"
- #include "proc.h"
-
- #ifdef DEBUG
- # define TRACE(lev,stmt) if (trace > lev) stmt;
- #else
- # define TRACE(lev,stmt)
- #endif
-
- /* interp.h */
- extern retcode init_interpreter(char *bin, char *lib);
- extern int runable(void);
- extern retcode run(void);
-
-
- /* l_array.c */
- extern eindex new_array(mproc p, uint len);
- extern eindex array_get(mproc p, eindex a, uint offs);
- extern retcode array_put(mproc p, eindex a, uint offs, eindex e);
- extern eindex make_array(mproc p, eindex *ip, uint len);
- extern void array_free(mproc p, eindex ei);
- extern retcode array_copy(mproc p, eindex f, eptr from, eptr to);
-
-
- /* l_compat.c */
- extern void fillin_hostid(byteptr hid);
- extern void get_utc(uint *sec, uint *usec);
-
-
- /* l_dict.c */
- extern eindex systemdict;
- extern eindex new_dict(mproc p);
- extern retcode dict_def(mproc p, eindex d, eindex key, eindex val);
- extern eindex dict_get(mproc p, eindex d, eindex key);
- extern retcode dict_undef(mproc p, eindex d, eindex key);
- extern void dict_free(mproc p, eindex d);
- #define DICT_DELETED (~(1<<(8*sizeof(eindex)-2)))
- extern retcode dict_copy(mproc p, eindex f, eptr from, eptr to);
-
-
- /* l_dump.c */
- #ifdef DEBUG
- extern int trace;
- extern void dump_element(FILE *f, mproc p, eindex ei);
- extern void dump_elements(FILE *f, mproc p);
- extern void dump_stack(FILE *f, eindex *s, ushort lim);
- extern void dump_elements_to_file(char *fn, mproc p);
- extern void dump_process_to_file(char *fn, mproc p);
- extern void dump_process(FILE *f, mproc p);
- #endif
- extern void terminate(int s);
-
- /* l_elemnt.c */
- extern char* type_names[];
- extern eindex new_element(mproc p, byte t);
- extern void free_element(mproc p, eindex ei);
- extern void decref(mproc p, eindex ei);
- extern eindex element_copy(mproc p, eindex ei); /* make a local copy */
- extern eindex make_sub(mproc p, eindex ei, uint offset);
- extern eindex make_global(mproc p, eindex ei);
- extern eindex desub(mproc p, eindex ei);
- extern void remove_refcycles(void);
- extern int element_equal(mproc p, eindex e1, eindex e2);
-
-
- /* l_format.c */
- extern byteptr make_msgr(byteptr q, byteptr c, uint clen,
- byteptr d, uint dlen, uint *len);
- extern eindex make_msgr_str(mproc p, eindex q, eindex c, eindex d);
- extern retcode decomp_msgr(mproc p, eindex m, eindex *q, eindex *c, eindex *d);
-
-
- /* l_incom.c */
- extern void add_incoming(int fd, receivefct fct, eindex cname, sint cno);
- extern int incoming_wouldblock(void);
- extern int serve_incoming(long usec);
-
-
- /* l_init.h */
- extern eptr global;
- extern eindex systemdict;
- extern eindex queuedict;
- extern eindex channeldict;
- extern eindex errorhandler_name;
- extern eindex null_val;
- extern eindex null_key;
- extern eindex null_name;
- extern eindex msgr_name;
- extern eindex msgrO_name;
- extern eindex code_name;
- extern eindex data_name;
- extern eindex orig_name;
- extern eindex ext_name;
- extern eindex msgr_start; /* init code (string) of each msgr */
- extern eindex host_id; /* key */
- extern eindex mark; /* used on the operand stack */
- extern eindex err_name_array; /* array with all error names */
- extern eindex type_name_array; /* array with all type names */
- extern retcode low_level_init(void);
-
-
- /* interp.c */
- extern retcode init_interpreter(char *bin, char *lib);
- extern int runable(void);
- extern retcode run(void);
-
-
- /* l_misc.c */
- extern char* error_names[];
- extern char* unique_filename(char *pref);
- extern void random64(byte *b); /* fills in 64 random bits */
- extern byteptr load_m0(char *binpath, char *libpath, char *filename);
- extern retcode new_channel(eindex key, void *data, submitfct fct);
-
-
- /* l_name.c */
- extern eindex name_add(byteptr n, uint len, byte attr);
- extern int name_eq(eindex n1, eindex n2);
- extern eindex key_add(byteptr k);
- extern int key_eq(eindex k1, eindex k2);
- extern void free_name(eindex ei);
-
-
- /* l_proc.c */
- extern mproc current, time_queue;
- extern retcode new_proc(eindex msgr, eindex orig);
- extern void remove_proc(mproc p);
- extern retcode enqueue(mproc p, eindex qkey, eindex t);
- extern void dequeue(mproc p);
- extern void timeout(mproc p);
- extern void queue_state(eindex qk, sint i);
-
-
- /* l_str.c */
- extern retcode import_str_from_file(char *fn, eindex *str);
- extern eindex str_import(mproc p, byteptr s, uint len, uint alen);
- extern retcode str_export(mproc p, byteptr dest, eindex str, uint offs, uint len);
- extern eindex new_string(mproc p, uint len);
- extern int str_get(mproc p, eindex str, uint pos);
- extern void str_put(mproc p, eindex str, uint pos, byte c);
- extern int str_gt(mproc p, eindex s1, eindex s2);
- extern retcode str_gettoken(mproc p, eindex str, uint *lp, eindex *e);
- extern void free_string(mproc p,eindex ei);
- extern retcode str_copy(mproc p, eindex f, eptr from, eptr to);
-
-
- /* l_time.c */
- extern eindex time_now(mproc p);
- extern eindex time_addint(mproc p, eindex t1, sint usec);
- extern eindex time_diff(mproc p, eindex t1, eindex t2);
- extern int time_eq(struct time_s *t1, struct time_s *t2);
- extern int time_gt(struct time_s *t1, struct time_s *t2);
- extern long next_timeout(void); /* consults the time_queue, result in usecs */
-
- #endif
-