#include "php.h"
-#include <stdio.h>
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-# endif
-#endif
-#ifdef HAVE_STRING_H
-# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
-# include <memory.h>
-# endif
-# include <string.h>
-#endif
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#ifdef HAVE_ERRNO_H
-# include <errno.h>
-#endif
-#ifdef HAVE_GLOB_H
-# include <glob.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_NAMESER_H
-# include <arpa/nameser.h>
-#endif
-#ifdef HAVE_NETDB_H
-# include <netdb.h>
-#endif
-#ifdef HAVE_RESOLV_H
-# include <resolv.h>
-#endif
-#ifdef HAVE_SYS_SELECT_H
-# include <sys/select.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#ifdef HAVE_SYS_TIMES_H
-# include <sys/times.h>
-#endif
-#ifdef HAVE_SYS_UIO_H
-# include <sys/uio.h>
-#endif
-#ifdef HAVE_SYS_UTSNAME_H
-# include <sys/utsname.h>
-#endif
-#ifdef HAVE_TIME_H
-# include <time.h>
-#endif
-#ifdef HAVE_SYSLOG_H
-# include <syslog.h>
-#endif
-#ifdef HAVE_WCHAR_H
-# include <wchar.h>
-#endif
+#include "php_psi_stdinc.h"
#ifdef HAVE_DIRENT_H
# include <dirent.h>
} psi_std_types[] = {
{PSI_T_FLOAT, "float"},
{PSI_T_DOUBLE, "double"},
+#ifdef HAVE_LONG_DOUBLE
+ {PSI_T_LONG_DOUBLE, "long double"},
+#endif
{PSI_T_INT8, "int8_t"},
{PSI_T_INT16, "int16_t"},
{PSI_T_INT32, "int32_t"},
{0}
};
-static struct psi_predef_type {
- token_t type_tag;
- const char *type_name;
- const char *alias;
-} psi_predef_types[] = {
- PSI_TYPES
- {0}
-};
-
-static struct psi_predef_const {
- token_t type_tag;
- const char *type_name;
- const char *var_name;
- const char *val_text;
- token_t val_type_tag;
-} psi_predef_consts[] = {
- PSI_CONSTS
- {0}
-};
-
-PSI_MACROS
-
-struct utsname *uname2() {
- struct utsname *u = calloc(1, sizeof(*u));
- uname(u);
- return u;
-}
-
-int psi_glob(const char *pattern, int flags,
- int (*errfunc) (const char *epath, int eerrno),
- glob_t *pglob) {
- size_t offs = flags & GLOB_DOOFFS ? pglob->gl_offs : 0;
- int rv = glob(pattern, flags, errfunc, pglob);
- if (pglob->gl_pathv) {
- while (offs--) {
- pglob->gl_pathv[offs] = NULL;
- }
- }
- return rv;
-}
-
-static struct psi_func_redir {
- const char *name;
- void (*func)(void);
-} psi_func_redirs[] = {
- {"glob", (void (*)(void)) psi_glob},
- {"uname2", (void (*)(void)) uname2},
- PSI_REDIRS
- {0}
-};
-
-static struct psi_predef_decl {
- token_t type_tag;
- const char *type_name;
- const char *var_name;
- size_t pointer_level;
- size_t array_size;
-} psi_predef_decls[] = {
- PSI_DECLS
- {0}
-};
-static struct psi_predef_decl psi_predef_vararg_decls[] = {
- PSI_VA_DECLS
- {0}
-};
-
-static struct psi_predef_struct {
- token_t type_tag;
- const char *type_name;
- const char *var_name;
- size_t offset;
- size_t size;
- size_t pointer_level;
- size_t array_size;
-} psi_predef_structs[] = {
- PSI_STRUCTS
- {0}
-};
+#include "php_psi_types.h"
+#include "php_psi_consts.h"
+#include "php_psi_macros.h"
+#include "php_psi_redirs.h"
+#include "php_psi_decls.h"
+#include "php_psi_va_decls.h"
+#include "php_psi_structs.h"
static int validate_lib(PSI_Data *data, void **dlopened) {
char lib[MAXPATHLEN];
static inline int validate_decl_type(PSI_Data *data, decl_type *type) {
switch (type->type) {
+ case PSI_T_CHAR:
+ case PSI_T_SHORT:
+ case PSI_T_INT:
+ case PSI_T_LONG:
case PSI_T_NAME:
if (!data->defs || !locate_decl_type_alias(data->defs, type)) {
return 0;
dprintf(fd, ", ");
dump_num_exp(fd, set->num);
}
- if (set->inner) {
+ if (set->inner && set->func->type != PSI_T_ELLIPSIS) {
dprintf(fd, ",\n");
for (i = 0; i < set->count; ++i) {
dump_impl_set_value(fd, set->inner[i], level+1);
dprintf(fd, "typedef ");
dump_decl_type(fd, tdef->type);
- dprintf(fd, " %s;\n", tdef->alias);
+ dprintf(fd, " %s%s;\n", tdef->type->type == PSI_T_POINTER ? "*":"",
+ tdef->alias);
}
dprintf(fd, "\n");
}
dprintf(fd, "%s($%s)", let->val->data.func->name,
let->val->data.func->var->name);
break;
+ case PSI_LET_NUMEXP:
+ dump_num_exp(fd, let->val->data.num);
+ break;
EMPTY_SWITCH_DEFAULT_CASE();
}