Imported Upstream version 0.1beta
[debian/yforth] / block.h
1 /* yForth? - Written by Luca Padovani (C) 1996/97
2  * ------------------------------------------------------------------------
3  * This software is FreeWare as long as it comes with this header in each
4  * source file, anyway you can use it or any part of it whatever
5  * you want. It comes without any warranty, so use it at your own risk.
6  * ------------------------------------------------------------------------
7  * Module name:     block.h
8  * Abstract:        Block word set header file
9  */
10
11 #ifdef DECLARE_WORDS
12 #       ifdef PROTOTYPES
13 #               undef PROTOTYPES
14 #       endif
15 #       undef __BLOCK_H__
16 #else
17 #       ifndef PROTOTYPES
18 #               define PROTOTYPES
19 #       endif
20 #endif
21
22 #ifndef __BLOCK_H__
23 #define __BLOCK_H__
24
25 #include "yforth.h"
26 #include "macro.h"
27
28 /**************************************************************************/
29 /* VARIABLES **************************************************************/
30 /**************************************************************************/
31
32 #ifdef PROTOTYPES
33
34 struct _block_data {                /* Entry in the table of blocks */
35     UCell block_no;                 /* Block number */
36     Cell dirty;                     /* Block updated */
37 };
38
39 struct _block_buffer {              /* Simply an array of Char */
40         Char buffer[BLOCK_SIZE];
41 };
42
43 extern FILE *block_file;
44
45 extern struct _block_data *block_data;
46 extern struct _block_buffer *block_buffer;
47
48 extern UCell current_block;
49
50 #endif
51
52 variable(UCell, b_l_k,                                          "blk")
53
54 /**************************************************************************/
55 /* PROTOTYPES *************************************************************/
56 /**************************************************************************/
57
58 code(block,                                     "block",                                        0)
59 code(buffer,                            "buffer",                                       0)
60 code(flush,                                     "flush",                                        0)
61 code(load,                                      "load",                                         0)
62 code(save_buffers,                      "save-buffers",                         0)
63 code(update,                            "update",                                       0)
64
65 #ifdef PROTOTYPES
66
67 /**************************************************************************/
68 /* AUXILIARY FUNCTIONS PROTOTYPES *****************************************/
69 /**************************************************************************/
70
71 int search_block(UCell block_no);
72 int allocate_block(UCell block_no, int load);
73 void load_block(UCell block_no, int b);
74 void save_block(int b);
75 int open_block_file(char *name);
76 void close_block_file(void);
77
78 #endif
79
80 #endif
81