Commit 7125b13c 7125b13cdb23c4504180949ebdadcb5e0efa2e6d by Sergey Poznyakoff

Move declarations of strobj functions to mh_format.h

1 parent e7269ace
...@@ -20,46 +20,13 @@ ...@@ -20,46 +20,13 @@
20 /* This module implements execution of MH format strings. */ 20 /* This module implements execution of MH format strings. */
21 21
22 #include <mh.h> 22 #include <mh.h>
23 #include <mh_format.h>
23 #include <mailutils/mime.h> 24 #include <mailutils/mime.h>
24 25
25 #ifdef HAVE_STRINGS_H 26 #ifdef HAVE_STRINGS_H
26 # include <strings.h> 27 # include <strings.h>
27 #endif 28 #endif
28 29
29 #define obstack_chunk_alloc malloc
30 #define obstack_chunk_free free
31 #include <obstack.h>
32
33 typedef struct /* A string object type */
34 {
35 int size; /* Allocated size or 0 for static storage */
36 char *ptr; /* Actual data */
37 } strobj_t;
38
39 struct mh_machine
40 {
41 strobj_t reg_str; /* String register */
42 int reg_num; /* Numeric register */
43
44 strobj_t arg_str; /* String argument */
45 long arg_num; /* Numeric argument */
46
47 size_t pc; /* Program counter */
48 size_t progsize; /* Size of allocated program*/
49 mh_instr_t *prog; /* Program itself */
50 int stop; /* Stop execution immediately */
51
52 struct obstack stk; /* Output buffer */
53 size_t width; /* Output buffer width */
54 size_t ind; /* Output buffer index */
55
56 mu_list_t addrlist; /* The list of email addresses output this far */
57 int fmtflags; /* Current formatting flags */
58
59 mu_message_t message; /* Current message */
60 size_t msgno; /* Its number */
61 };
62
63 static char *_get_builtin_name (mh_builtin_fp ptr); 30 static char *_get_builtin_name (mh_builtin_fp ptr);
64 31
65 /* Functions for handling string objects. */ 32 /* Functions for handling string objects. */
...@@ -73,12 +40,7 @@ strobj_free (strobj_t *obj) ...@@ -73,12 +40,7 @@ strobj_free (strobj_t *obj)
73 obj->ptr = NULL; 40 obj->ptr = NULL;
74 } 41 }
75 42
76 #define strobj_ptr(p) ((p)->ptr ? (p)->ptr : "") 43 void
77 #define strobj_len(p) (strobj_is_null(p) ? 0 : strlen((p)->ptr))
78 #define strobj_is_null(p) ((p)->ptr == NULL)
79 #define strobj_is_static(p) ((p)->size == 0)
80
81 static void
82 strobj_create (strobj_t *lvalue, char *str) 44 strobj_create (strobj_t *lvalue, char *str)
83 { 45 {
84 if (!str) 46 if (!str)
...@@ -94,14 +56,14 @@ strobj_create (strobj_t *lvalue, char *str) ...@@ -94,14 +56,14 @@ strobj_create (strobj_t *lvalue, char *str)
94 } 56 }
95 } 57 }
96 58
97 static void 59 void
98 strobj_set (strobj_t *lvalue, char *str) 60 strobj_set (strobj_t *lvalue, char *str)
99 { 61 {
100 lvalue->size = 0; 62 lvalue->size = 0;
101 lvalue->ptr = str; 63 lvalue->ptr = str;
102 } 64 }
103 65
104 static void 66 void
105 strobj_assign (strobj_t *lvalue, strobj_t *rvalue) 67 strobj_assign (strobj_t *lvalue, strobj_t *rvalue)
106 { 68 {
107 strobj_free (lvalue); 69 strobj_free (lvalue);
...@@ -110,7 +72,7 @@ strobj_assign (strobj_t *lvalue, strobj_t *rvalue) ...@@ -110,7 +72,7 @@ strobj_assign (strobj_t *lvalue, strobj_t *rvalue)
110 rvalue->ptr = NULL; 72 rvalue->ptr = NULL;
111 } 73 }
112 74
113 static void 75 void
114 strobj_copy (strobj_t *lvalue, strobj_t *rvalue) 76 strobj_copy (strobj_t *lvalue, strobj_t *rvalue)
115 { 77 {
116 if (strobj_is_null (rvalue)) 78 if (strobj_is_null (rvalue))
...@@ -125,7 +87,7 @@ strobj_copy (strobj_t *lvalue, strobj_t *rvalue) ...@@ -125,7 +87,7 @@ strobj_copy (strobj_t *lvalue, strobj_t *rvalue)
125 } 87 }
126 } 88 }
127 89
128 static void 90 void
129 strobj_realloc (strobj_t *obj, size_t length) 91 strobj_realloc (strobj_t *obj, size_t length)
130 { 92 {
131 if (strobj_is_static (obj)) 93 if (strobj_is_static (obj))
......