OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
-#include "php_psi_stdinc.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#else
+# include "php_config.h"
+#endif
+#include "php_psi.h"
#include "data.h"
#include "php_globals.h"
-#include "php_network.h"
+#include "zend_types.h"
#include <dlfcn.h>
#include <ctype.h>
+#if PSI_THREADED_PARSER
+# include <pthread.h>
+
+static pthread_mutex_t psi_string_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+zend_string *psi_string_init_interned(const char *buf, size_t len, int p)
+{
+ zend_string *str;
+
+ pthread_mutex_lock(&psi_string_mutex);
+ str = zend_string_init_interned(buf, len, p);
+ pthread_mutex_unlock(&psi_string_mutex);
+
+ return str;
+}
+
+zend_string *psi_new_interned_string(zend_string *str)
+{
+ zend_string *new_str;
+
+ pthread_mutex_lock(&psi_string_mutex);
+ new_str = zend_new_interned_string(str);
+ pthread_mutex_unlock(&psi_string_mutex);
+
+ return new_str;
+}
+
+#endif
+
static void psi_data_ctor_internal(struct psi_data *data,
psi_error_cb error, unsigned flags)
{
data->flags = flags;
if (data->flags & PSI_DEBUG) {
- char *debug = getenv("PSI_DEBUG");
-
- if (debug) {
- int fd = -1;
- char *addr = strstr(debug, "://");
-
- if (addr) {
- addr += 3;
- }
- if (addr && *addr) {
- struct sockaddr_storage sa = {0};
- socklen_t ss = 0;
- int rc = php_network_parse_network_address_with_port(addr,
- strlen(addr), (struct sockaddr *) &sa, &ss);
-
- if (SUCCESS == rc) {
- int styp = strncmp(debug, "udp:", 4)
- ? SOCK_STREAM
- : SOCK_DGRAM;
- int sfam = sa.ss_family == AF_INET6
- ? ((struct sockaddr_in6 *) &sa)->sin6_family
- : ((struct sockaddr_in *) &sa)->sin_family;
-
- fd = socket(sfam, styp, 0);
-
- if (fd > 0 && 0 != connect(fd, (struct sockaddr *) &sa, ss)) {
- perror(debug);
- close(fd);
- fd = -1;
- }
- }
- } else if (!strcmp(debug, "stdout")) {
- fd = STDOUT_FILENO;
- } else if (!strcmp(debug, "stderr")) {
- fd = STDERR_FILENO;
- } else if (!(fd = atoi(debug))) {
- fd = open(debug, O_WRONLY|O_APPEND|O_CREAT|O_CLOEXEC, 0664);
- }
+ int fd = psi_fdopen(getenv("PSI_DEBUG"));
- if (fd > 0) {
- data->debug_fd = fd;
- } else {
- data->debug_fd = STDERR_FILENO;
- }
+ if (fd > 0) {
+ data->debug_fd = fd;
+ } else {
+ data->debug_fd = STDERR_FILENO;
}
}
}
while (psi_plist_get(D->unions, i++, &unn)) {
if (!psi_decl_type_is_anon(unn->name, "union")) {
- psi_decl_union_dump(fd, unn);
+ psi_decl_union_dump(dump, unn);
PSI_DUMP(dump, "\n");
}
}
struct psi_decl_enum *enm;
while (psi_plist_get(D->enums, i++, &enm)) {
- if (!psi_decl_type_is_anon(enm->name, "enum")) {
+ if (true || !psi_decl_type_is_anon(enm->name, "enum")) {
psi_decl_enum_dump(dump, enm, 0);
PSI_DUMP(dump, "\n");
}
while (psi_plist_get(D->decls, i++, &decl)) {
if (decl->extvar) {
- PSI_DUMP(dump, "/* extvar accessor\n");
+ PSI_DUMP(dump, "/* extvar accessor \n");
}
psi_decl_dump(dump, decl);
- PSI_DUMP(dump, "\n");
if (decl->extvar) {
- PSI_DUMP(dump, " extvar accessor */\n");
+ PSI_DUMP(dump, " */");
}
+ PSI_DUMP(dump, "\n");
}
PSI_DUMP(dump, "\n");
}