CVS update: php3/functions
| From: | steinm | Date: | Fri, 28 Aug 1998 11:15:13 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-638@lists.php.net to get a copy of this message | ||
Date: Friday August 28, 1998 @ 7:15
Author: steinm
Update of /repository/php3/functions
In directory asf:/u2/tmp/cvs-serv8324/functions
Modified Files:
hg_comm.c hg_comm.h hw.c
Log Message:
fixed bug in hw_getcgi(), hw_pipecgi() but still needs polishing
Index: php3/functions/hg_comm.c
diff -c php3/functions/hg_comm.c:1.4 php3/functions/hg_comm.c:1.5
*** php3/functions/hg_comm.c:1.4 Mon Aug 24 08:51:01 1998
--- php3/functions/hg_comm.c Fri Aug 28 07:15:12 1998
***************
*** 23,29 ****
+----------------------------------------------------------------------+
*/
! /* $Id: hg_comm.c,v 1.4 1998/08/24 12:51:01 steinm Exp $ */
/* #define HW_DEBUG */
--- 23,29 ----
+----------------------------------------------------------------------+
*/
! /* $Id: hg_comm.c,v 1.5 1998/08/28 11:15:12 steinm Exp $ */
/* #define HW_DEBUG */
***************
*** 1841,1847 ****
tmp = build_msg_int(msg.buf, objectID);
tmp = build_msg_str(tmp, path);
tmp = build_msg_str(tmp, "");
! tmp = build_msg_str(tmp, *text);
if(path) efree(path);
if(objid) efree(objid);
--- 1841,1847 ----
tmp = build_msg_int(msg.buf, objectID);
tmp = build_msg_str(tmp, path);
tmp = build_msg_str(tmp, "");
! tmp = build_msg_str(tmp, text);
if(path) efree(path);
if(objid) efree(objid);
***************
*** 1865,1875 ****
return(error);
}
! int send_getcgi(int sockfd, hw_objectID objectID, char **objattr, char **text, int *count)
{
hg_msg msg, *retmsg;
! int length, *ptr, error;
! char *tmp, *attributes;
length = HEADER_LENGTH + sizeof(hw_objectID);
--- 1865,1875 ----
return(error);
}
! int send_getcgi(int sockfd, hw_objectID objectID, char *cgi_env_str, char **objattr, char **text,
int *count)
{
hg_msg msg, *retmsg;
! int length, *ptr, error, new_attr_len;
! char *tmp, *attributes, *new_attr;
length = HEADER_LENGTH + sizeof(hw_objectID);
***************
*** 1908,1914 ****
return error;
}
! length = HEADER_LENGTH + strlen(attributes) + 1 + sizeof(int);
build_msg_header(&msg, length, msgid++, GETCGI_MESSAGE);
if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
--- 1908,1918 ----
return error;
}
! new_attr_len = strlen(attributes) + strlen(cgi_env_str) + 2;
! new_attr = malloc(new_attr_len);
! strcpy(new_attr, attributes);
! strcat(new_attr, cgi_env_str);
! length = HEADER_LENGTH + strlen(new_attr) + 1 + sizeof(int);
build_msg_header(&msg, length, msgid++, GETCGI_MESSAGE);
if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
***************
*** 1917,1927 ****
return(-1);
}
! tmp = build_msg_str(msg.buf, attributes);
tmp = build_msg_int(tmp, 0);
*objattr = strdup(attributes);
efree(attributes);
if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
efree(msg.buf);
--- 1921,1932 ----
return(-1);
}
! tmp = build_msg_str(msg.buf, new_attr);
tmp = build_msg_int(tmp, 0);
*objattr = strdup(attributes);
efree(attributes);
+ free(new_attr);
if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
efree(msg.buf);
***************
*** 4054,4069 ****
return(0);
}
! int send_pipecgi(int sockfd, char *host, hw_objectID objectID, char **objattr, char **text, int
*count)
{
hg_msg msg, *retmsg;
! int length, len;
char *tmp, header[80], *head_ptr, *sizestr;
struct sockaddr_in serv_addr;
struct hostent *hostptr;
char *hostip = NULL;
char *attributes = NULL;
! char *documenttype;
int newfd, fd, port, size, error;
int *ptr;
--- 4059,4074 ----
return(0);
}
! int send_pipecgi(int sockfd, char *host, hw_objectID objectID, char *cgi_env_str, char **objattr,
char **text, int *count)
{
hg_msg msg, *retmsg;
! int length, len, new_attr_len;
char *tmp, header[80], *head_ptr, *sizestr;
struct sockaddr_in serv_addr;
struct hostent *hostptr;
char *hostip = NULL;
char *attributes = NULL;
! char *documenttype, *new_attr;
int newfd, fd, port, size, error;
int *ptr;
***************
*** 4111,4117 ****
return error;
}
! length = HEADER_LENGTH + strlen(attributes) + 1 + sizeof(int) + strlen(hostip) + 1 + sizeof(int)
+ sizeof(int);
build_msg_header(&msg, length, msgid++, PIPECGI_MESSAGE);
if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
--- 4116,4126 ----
return error;
}
! new_attr_len = strlen(attributes) + strlen(cgi_env_str) + 2;
! new_attr = malloc(new_attr_len);
! strcpy(new_attr, attributes);
! strcat(new_attr, cgi_env_str);
! length = HEADER_LENGTH + strlen(new_attr) + 1 + sizeof(int) + strlen(hostip) + 1 + sizeof(int) +
sizeof(int);
build_msg_header(&msg, length, msgid++, PIPECGI_MESSAGE);
if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
***************
*** 4122,4130 ****
tmp = build_msg_str(msg.buf, hostip);
tmp = build_msg_int(tmp, port);
! tmp = build_msg_str(tmp, attributes);
tmp = build_msg_int(tmp, 1);
tmp = build_msg_int(tmp, 0x12345678);
if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
if(attributes) efree(attributes);
--- 4131,4140 ----
tmp = build_msg_str(msg.buf, hostip);
tmp = build_msg_int(tmp, port);
! tmp = build_msg_str(tmp, new_attr);
tmp = build_msg_int(tmp, 1);
tmp = build_msg_int(tmp, 0x12345678);
+ free(new_attr);
if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
if(attributes) efree(attributes);
Index: php3/functions/hg_comm.h
diff -c php3/functions/hg_comm.h:1.1 php3/functions/hg_comm.h:1.2
*** php3/functions/hg_comm.h:1.1 Wed Aug 12 05:29:17 1998
--- php3/functions/hg_comm.h Fri Aug 28 07:15:12 1998
***************
*** 23,29 ****
*/
! /* $Id: hg_comm.h,v 1.1 1998/08/12 09:29:17 steinm Exp $ */
#ifndef _HG_COMM_H
#define _HG_COMM_H
--- 23,29 ----
*/
! /* $Id: hg_comm.h,v 1.2 1998/08/28 11:15:12 steinm Exp $ */
#ifndef _HG_COMM_H
#define _HG_COMM_H
***************
*** 155,161 ****
extern int send_unlock(int sockfd, hw_objectID objectID);
extern int send_gettext(int sockfd, hw_objectID objectID, int mode, int rootid, char **objattr,
char **bodytag, char **text, int *count);
extern int send_edittext(int sockfd, char *objattr, char *text);
! extern int send_getcgi(int sockfd, hw_objectID objectID, char **objattr, char **text, int *count);
extern int send_getremote(int sockfd, hw_objectID objectID, char **objattr, char **text, int
*count);
extern int send_getremotechildren(int sockfd, char *attributes, char **text, int **childIDs, int
*count);
extern int send_docbyanchor(int sockfd, hw_objectID objectID, hw_objectID *anchorID);
--- 155,161 ----
extern int send_unlock(int sockfd, hw_objectID objectID);
extern int send_gettext(int sockfd, hw_objectID objectID, int mode, int rootid, char **objattr,
char **bodytag, char **text, int *count);
extern int send_edittext(int sockfd, char *objattr, char *text);
! extern int send_getcgi(int sockfd, hw_objectID objectID, char *cgi_env_str, char **objattr, char
**text, int *count);
extern int send_getremote(int sockfd, hw_objectID objectID, char **objattr, char **text, int
*count);
extern int send_getremotechildren(int sockfd, char *attributes, char **text, int **childIDs, int
*count);
extern int send_docbyanchor(int sockfd, hw_objectID objectID, hw_objectID *anchorID);
***************
*** 177,183 ****
extern int send_children(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count);
extern int send_getparentsobj(int sockfd, hw_objectID objectID, char ***childrec, int *count);
extern int send_pipedocument(int sockfd, char *hostname, hw_objectID objectID, int mode, int
rootid, char** objattr, char **bodytag, char **text, int *count);
! extern int send_pipecgi(int sockfd, char *host, hw_objectID objectID, char **objattr, char **text,
int *count);
extern int send_putdocument(int sockfd, char *hostname, hw_objectID objectID, char *objectRec,
char *text, int count);
extern int send_inscoll(int sockfd, hw_objectID objectID, char *objrec, hw_objectID
*new_objectID);
extern int send_insertobject(int sockfd, char *objrec, char *parms, hw_objectID *objectID);
--- 177,183 ----
extern int send_children(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count);
extern int send_getparentsobj(int sockfd, hw_objectID objectID, char ***childrec, int *count);
extern int send_pipedocument(int sockfd, char *hostname, hw_objectID objectID, int mode, int
rootid, char** objattr, char **bodytag, char **text, int *count);
! extern int send_pipecgi(int sockfd, char *host, hw_objectID objectID, char *cgi_env_str, char
**objattr, char **text, int *count);
extern int send_putdocument(int sockfd, char *hostname, hw_objectID objectID, char *objectRec,
char *text, int count);
extern int send_inscoll(int sockfd, hw_objectID objectID, char *objrec, hw_objectID
*new_objectID);
extern int send_insertobject(int sockfd, char *objrec, char *parms, hw_objectID *objectID);
Index: php3/functions/hw.c
diff -c php3/functions/hw.c:1.5 php3/functions/hw.c:1.6
*** php3/functions/hw.c:1.5 Fri Aug 21 05:05:28 1998
--- php3/functions/hw.c Fri Aug 28 07:15:13 1998
***************
*** 23,29 ****
+----------------------------------------------------------------------+
*/
! /* $Id: hw.c,v 1.5 1998/08/21 09:05:28 steinm Exp $ */
#if COMPILE_DL
#include "dl/phpdl.h"
#endif
--- 23,29 ----
+----------------------------------------------------------------------+
*/
! /* $Id: hw.c,v 1.6 1998/08/28 11:15:13 steinm Exp $ */
#if COMPILE_DL
#include "dl/phpdl.h"
#endif
***************
*** 222,231 ****
return 0;
}
! // creates an array return value from object record
int make_return_array_from_objrec(YYSTYPE **return_value, char *objrec) {
YYSTYPE title_arr, desc_arr;
! char *attrname, *str, *temp, *language, *title;
int iTitle, iDesc;
int hasTitle = 0;
int hasDescription = 0;
--- 222,233 ----
return 0;
}
! /*
! ** creates an array return value from object record
! */
int make_return_array_from_objrec(YYSTYPE **return_value, char *objrec) {
YYSTYPE title_arr, desc_arr;
! char *attrname, *str, *temp, language[3], *title;
int iTitle, iDesc;
int hasTitle = 0;
int hasDescription = 0;
***************
*** 268,284 ****
iDesc = 1;
}
if(iTitle || iDesc) { /* Poor error check if end of string */
! language = str;
! while((*str != ':') && (*str != '\0'))
! str++;
! *str = '\0';
! str++;
title = str;
! while((*str != '=') && (*str != '\0'))
str++;
*str = '\0';
! if(iTitle)
add_assoc_string(&title_arr, language, title, 1);
else
add_assoc_string(&desc_arr, language, title, 1);
--- 270,287 ----
iDesc = 1;
}
if(iTitle || iDesc) { /* Poor error check if end of string */
! if(str[2] == ':') {
! str[2] = '\0';
! strcpy(language, str);
! str += 3;
! } else
! strcpy(language, "xx");
title = str;
! /* while((*str != '=') && (*str != '\0'))
str++;
*str = '\0';
! */ if(iTitle)
add_assoc_string(&title_arr, language, title, 1);
else
add_assoc_string(&desc_arr, language, title, 1);
***************
*** 1226,1260 ****
for(i=0; i<_php3_hash_num_elements(newobjarr); i++) {
char *key, *str, *str1, newattribute[200];
YYSTYPE *data;
! int j, ind;
_php3_hash_get_current_key(newobjarr, &key, &ind);
_php3_hash_get_current_data(newobjarr, (void *) &data);
switch(data->type) {
case IS_STRING:
! sprintf(newattribute, "%s=%s", key, data->value.str.val);
break;
default:
sprintf(newattribute, "%s", "");
}
! modification = fnInsStr(modification, 0, "\\");
! modification = fnInsStr(modification, 0, newattribute);
! modification = fnInsStr(modification, 0, "add ");
!
! /* Retrieve the old attribute from object record */
! if(NULL != (str = strstr(oldobjrec, key))) {
! str1 = str;
! j = 0;
! while((str1 != NULL) && (*str1 != '\n')) {
! buf[j++] = *str1++;
! }
! buf[j] = '\0';
modification = fnInsStr(modification, 0, "\\");
! modification = fnInsStr(modification, 0, buf);
! modification = fnInsStr(modification, 0, "rem ");
! }
!
efree(key);
_php3_hash_move_forward(newobjarr);
}
--- 1229,1267 ----
for(i=0; i<_php3_hash_num_elements(newobjarr); i++) {
char *key, *str, *str1, newattribute[200];
YYSTYPE *data;
! int j, ind, noinsert=1;
_php3_hash_get_current_key(newobjarr, &key, &ind);
_php3_hash_get_current_data(newobjarr, (void *) &data);
switch(data->type) {
case IS_STRING:
! if(strlen(data->value.str.val) == 0)
! noinsert = 0;
! else
! sprintf(newattribute, "%s=%s", key, data->value.str.val);
break;
default:
sprintf(newattribute, "%s", "");
}
! if(!noinsert) {
modification = fnInsStr(modification, 0, "\\");
! modification = fnInsStr(modification, 0, newattribute);
! modification = fnInsStr(modification, 0, "add ");
!
! /* Retrieve the old attribute from object record */
! if(NULL != (str = strstr(oldobjrec, key))) {
! str1 = str;
! j = 0;
! while((str1 != NULL) && (*str1 != '\n')) {
! buf[j++] = *str1++;
! }
! buf[j] = '\0';
! modification = fnInsStr(modification, 0, "\\");
! modification = fnInsStr(modification, 0, buf);
! modification = fnInsStr(modification, 0, "rem ");
! }
! }
efree(key);
_php3_hash_move_forward(newobjarr);
}
***************
*** 1262,1268 ****
set_swap(ptr->swap_on);
modification[strlen(modification)-1] = '\0';
! // php3_printf("%0x%X, %s", id, modification);
if (0 != (ptr->lasterror = send_changeobject(ptr->socket, id, modification)))
RETURN_FALSE;
free(modification);
--- 1269,1275 ----
set_swap(ptr->swap_on);
modification[strlen(modification)-1] = '\0';
! /* php3_printf("0x%X, %s", id, modification); */
if (0 != (ptr->lasterror = send_changeobject(ptr->socket, id, modification)))
RETURN_FALSE;
free(modification);
***************
*** 1465,1470 ****
--- 1472,1478 ----
int link, id, type;
hw_document *doc;
hw_connection *ptr;
+ char cgi_env_str[1000];
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
***************
*** 1485,1492 ****
char *object = NULL;
char *attributes = NULL;
int count;
/* !!!! memory for object and attributes is allocated with malloc !!!! */
! if (0 != (ptr->lasterror = send_getcgi(ptr->socket, id, &attributes, &object,
&count)))
RETURN_FALSE;
doc = malloc(sizeof(hw_document));
doc->data = object;
--- 1493,1513 ----
char *object = NULL;
char *attributes = NULL;
int count;
+
+ /* Here is another undocument function of Hyperwave.
+ If you call a cgi script with getcgi-message, you will
+ have to provide the complete cgi enviroment, since it is
+ only known to the webserver (or wavemaster). This is done
+ by extending the object record with the following incomplete
+ string. It should contain any enviroment variable a cgi script
+ requires.
+ */
+ sprintf(cgi_env_str, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s",
+ GLOBAL(request_info).request_method,
+ GLOBAL(request_info).path_info,
+ GLOBAL(request_info).query_string);
/* !!!! memory for object and attributes is allocated with malloc !!!! */
! if (0 != (ptr->lasterror = send_getcgi(ptr->socket, id, cgi_env_str, &attributes,
&object, &count)))
RETURN_FALSE;
doc = malloc(sizeof(hw_document));
doc->data = object;
***************
*** 1621,1626 ****
--- 1642,1648 ----
int rootid = 0;
hw_connection *ptr;
hw_document *doc;
+ server_rec *serv = GLOBAL(php3_rqst)->server;
TLS_VARS;
argc = ARG_COUNT(ht);
***************
*** 1658,1664 ****
char *bodytag = NULL;
int count;
/* !!!! memory for object, bodytag and attributes is allocated with malloc !!!! */
! if (0 != (ptr->lasterror = send_pipedocument(ptr->socket,
"gehtnix.fernuni-hagen.de", id, mode, rootid, &attributes, &bodytag, &object,
&count)))
RETURN_FALSE;
doc = malloc(sizeof(hw_document));
--- 1680,1686 ----
char *bodytag = NULL;
int count;
/* !!!! memory for object, bodytag and attributes is allocated with malloc !!!! */
! if (0 != (ptr->lasterror = send_pipedocument(ptr->socket, serv->server_hostname, id,
mode, rootid, &attributes, &bodytag, &object, &count)))
RETURN_FALSE;
doc = malloc(sizeof(hw_document));
***************
*** 1677,1682 ****
--- 1699,1706 ----
int link, id, type;
hw_connection *ptr;
hw_document *doc;
+ char cgi_env_str[1000];
+ server_rec *serv = GLOBAL(php3_rqst)->server;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
***************
*** 1697,1704 ****
char *object = NULL;
char *attributes = NULL;
int count;
/* !!!! memory for object, bodytag and attributes is allocated with malloc !!!! */
! if (0 != (ptr->lasterror = send_pipecgi(ptr->socket, "gehtnix.fernuni-hagen.de",
id, &attributes, &object, &count)))
RETURN_FALSE;
doc = malloc(sizeof(hw_document));
--- 1721,1733 ----
char *object = NULL;
char *attributes = NULL;
int count;
+
+ sprintf(cgi_env_str, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s",
+ GLOBAL(request_info).request_method,
+ GLOBAL(request_info).path_info,
+ GLOBAL(request_info).query_string);
/* !!!! memory for object, bodytag and attributes is allocated with malloc !!!! */
! if (0 != (ptr->lasterror = send_pipecgi(ptr->socket, serv->server_hostname, id,
cgi_env_str, &attributes, &object, &count)))
RETURN_FALSE;
doc = malloc(sizeof(hw_document));
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net