2 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
5 The code for storing information of functions present in the module
8 #include "functionhead.h"
10 struct functionhead
*newfunctionhead(const char *name
, enum libcall libcall
)
12 struct functionhead
*funchead
= malloc(sizeof(struct functionhead
));
16 funchead
->next
= NULL
;
17 funchead
->name
= strdup(name
);
18 funchead
->type
= NULL
;
19 funchead
->libcall
= libcall
;
21 funchead
->argcount
= 0;
22 funchead
->arguments
= NULL
;
23 funchead
->aliases
= NULL
;
27 puts("Out of memory !");
34 struct functionarg
*funcaddarg
36 struct functionhead
*funchead
,
37 const char *arg
, const char *reg
40 struct functionarg
**argptr
= &funchead
->arguments
;
42 while ((*argptr
) != NULL
) argptr
= &(*argptr
)->next
;
44 *argptr
= malloc(sizeof(struct functionarg
));
47 (*argptr
)->next
= NULL
;
48 (*argptr
)->arg
= (arg
== NULL
) ? NULL
: strdup(arg
);
49 (*argptr
)->reg
= (reg
== NULL
) ? NULL
: strdup(reg
);
55 puts("Out of memory !");
62 struct stringlist
*funcaddalias(struct functionhead
*funchead
, const char *alias
)
64 return slist_append(&funchead
->aliases
, alias
);
67 char *getargtype(const struct functionarg
*funcarg
)
69 char *s
, *begin
, *end
;
70 unsigned int brackets
= 0, i
;
72 begin
= s
= strdup(funcarg
->arg
);
74 /* Count the [] at the end of the argument */
75 end
= begin
+strlen(begin
);
76 while (isspace(*(end
-1))) end
--;
81 while (isspace(*(end
-1))) end
--;
88 while (isspace(*(end
-1))) end
--;
91 /* Skip over the argument name */
92 while (!isspace(*(end
-1)) && *(end
-1)!='*') end
--;
94 /* Add * for the brackets */
95 while (isspace(*(end
-1))) end
--;
96 for (i
=0; i
<brackets
; i
++)
106 char *getargname(const struct functionarg
*funcarg
)
108 char *s
, *begin
, *end
;
111 /* Count the [] at the end of the argument */
112 end
= funcarg
->arg
+strlen(funcarg
->arg
);
113 while (isspace(*(end
-1))) end
--;
114 while (*(end
-1)==']')
117 while (isspace(*(end
-1))) end
--;
121 while (isspace(*(end
-1))) end
--;
124 /* Go to the beginning of the argument name */
126 while (!isspace(*(begin
-1)) && *(begin
-1)!='*') begin
--;
131 strncpy(s
, begin
, len
);