cvs commit
| From: | steinm | Date: | Wed, 07 Jul 1999 11:31:16 +0000 |
| Subject: | cvs commit | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-8163@lists.php.net to get a copy of this message | ||
From: steinm
Date: Wed Jul 7 11:31:16 1999
Modified files:
php3/functions/hg_comm.c
php3/functions/hg_comm.h
php3/functions/hw.c
Log message:
new parameter for hw_gettext()
Index: php3/functions/hg_comm.c
diff -u php3/functions/hg_comm.c:1.25 php3/functions/hg_comm.c:1.26
--- php3/functions/hg_comm.c:1.25 Tue Jul 6 14:29:18 1999
+++ php3/functions/hg_comm.c Wed Jul 7 11:31:16 1999
@@ -23,7 +23,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: hg_comm.c,v 1.25 1999/07/06 18:29:18 steinm Exp $ */
+/* $Id: hg_comm.c,v 1.26 1999/07/07 15:31:16 steinm Exp $ */
/* #define HW_DEBUG */
@@ -458,7 +458,7 @@
* Return: Text with anchors *
***********************************************************************/
#define BUFFERLEN 200
-char *fnInsAnchorsIntoText(char *text, DLIST *pAnchorList, char **bodytag) {
+char *fnInsAnchorsIntoText(char *text, DLIST *pAnchorList, char **bodytag, char *urlprefix) {
ANCHOR *cur_ptr;
char bgstr[BUFFERLEN], istr[BUFFERLEN];
char *scriptname;
@@ -466,21 +466,30 @@
int offset = 0;
int laststart=0;
+/* The following is very tricky and depends on how rewriting is setup on your webserver.
+ If you skip the scriptname in the url you will have to map each hyperwave name to http://<hwname>.
+ This may not always be a good idea. The best solution is probably to provide a prefix for such
+ a case which is an optional parameter to hw_gettext hw_pipedocument.
+*/
+ if(urlprefix) {
+ scriptname = urlprefix;
+ } else {
#if APACHE
- {
- int j;
- array_header *arr = table_elts(GLOBAL(php3_rqst)->subprocess_env);
- table_entry *elts = (table_entry *)arr->elts;
-
- for (j=0; j < arr->nelts; j++) {
- if(0 == strcmp(elts[j].key, "SCRIPT_NAME"))
- break;
- }
- scriptname = elts[j].val;
- }
+ {
+ int j;
+ array_header *arr = table_elts(GLOBAL(php3_rqst)->subprocess_env);
+ table_entry *elts = (table_entry *)arr->elts;
+
+ for (j=0; j < arr->nelts; j++) {
+ if(0 == strcmp(elts[j].key, "SCRIPT_NAME"))
+ break;
+ }
+ scriptname = elts[j].val;
+ }
#else
- scriptname = getenv("SCRIPT_FILENAME");
+ scriptname = getenv("SCRIPT_FILENAME");
#endif
+ }
newtext = text;
bgstr[0] = '\0';
@@ -526,7 +535,7 @@
/* snprintf(istr, BUFFERLEN, " %s='%s/%s#%s'", cur_ptr->tagattr,
scriptname == NULL ? "." : scriptname, cur_ptr->destdocname, cur_ptr->fragment);*/
snprintf(istr, BUFFERLEN, " %s='#%s'", cur_ptr->tagattr,
cur_ptr->fragment);
else
- snprintf(istr, BUFFERLEN, " %s='%s/%s'", cur_ptr->tagattr, scriptname
== NULL ? "." : scriptname, cur_ptr->destdocname);
+ snprintf(istr, BUFFERLEN, " %s='%s/%s'", cur_ptr->tagattr, scriptname
== NULL ? "." : scriptname, cur_ptr->destdocname);
offset -= 4; /* because there is no closing tag </A> */
/* laststart = cur_ptr->start; */
break;
@@ -1778,7 +1787,7 @@
int send_getdestforanchorsobj(int sockfd, char **anchorrec, char ***destrec, int count);
int send_getreldestforanchorsobj(int sockfd, char **anchorrec, char ***reldestrec, int count, int
rootID, int thisID);
-int send_gettext(int sockfd, hw_objectID objectID, int mode, int rootid, char **objattr, char
**bodytag, char **text, int *count)
+int send_gettext(int sockfd, hw_objectID objectID, int mode, int rootid, char **objattr, char
**bodytag, char **text, int *count, char *urlprefix)
{
hg_msg msg, *retmsg;
int length, *ptr, ancount, error;
@@ -1889,7 +1898,7 @@
char *newtext;
char *body;
- newtext = fnInsAnchorsIntoText(*text, pAnchorList, &body);
+ newtext = fnInsAnchorsIntoText(*text, pAnchorList, &body, urlprefix);
dlst_kill(pAnchorList, fnDeleteAnchor);
*bodytag = strdup(body);
efree(body);
@@ -4064,7 +4073,7 @@
return(0);
}
-int send_pipedocument(int sockfd, char *host, hw_objectID objectID, int mode, int rootid, char
**objattr, char **bodytag, char **text, int *count)
+int send_pipedocument(int sockfd, char *host, hw_objectID objectID, int mode, int rootid, char
**objattr, char **bodytag, char **text, int *count, char *urlprefix)
{
hg_msg msg, *retmsg;
int length, len;
@@ -4226,7 +4235,7 @@
char *newtext;
char *body;
- newtext = fnInsAnchorsIntoText(*text, pAnchorList, &body);
+ newtext = fnInsAnchorsIntoText(*text, pAnchorList, &body, urlprefix);
dlst_kill(pAnchorList, fnDeleteAnchor);
*bodytag = strdup(body);
efree(body);
Index: php3/functions/hg_comm.h
diff -u php3/functions/hg_comm.h:1.9 php3/functions/hg_comm.h:1.10
--- php3/functions/hg_comm.h:1.9 Tue Jul 6 14:29:18 1999
+++ php3/functions/hg_comm.h Wed Jul 7 11:31:16 1999
@@ -23,7 +23,7 @@
*/
-/* $Id: hg_comm.h,v 1.9 1999/07/06 18:29:18 steinm Exp $ */
+/* $Id: hg_comm.h,v 1.10 1999/07/07 15:31:16 steinm Exp $ */
#ifndef _HG_COMM_H
#define _HG_COMM_H
@@ -168,7 +168,7 @@
extern int send_getandlock(int sockfd, hw_objectID objectID, char **attributes);
extern int send_lock(int sockfd, hw_objectID objectID);
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_gettext(int sockfd, hw_objectID objectID, int mode, int rootid, char **objattr,
char **bodytag, char **text, int *count, char *urlprefix);
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);
@@ -192,7 +192,7 @@
extern int send_getparents(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count);
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_pipedocument(int sockfd, char *hostname, hw_objectID objectID, int mode, int
rootid, char** objattr, char **bodytag, char **text, int *count, char *urlprefix);
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 parentID, char *objectRec, char
*text, int count, hw_objectID *objectID);
extern int send_inscoll(int sockfd, hw_objectID objectID, char *objrec, hw_objectID *new_objectID);
Index: php3/functions/hw.c
diff -u php3/functions/hw.c:1.43 php3/functions/hw.c:1.44
--- php3/functions/hw.c:1.43 Tue Jul 6 14:29:18 1999
+++ php3/functions/hw.c Wed Jul 7 11:31:16 1999
@@ -23,7 +23,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: hw.c,v 1.43 1999/07/06 18:29:18 steinm Exp $ */
+/* $Id: hw.c,v 1.44 1999/07/07 15:31:16 steinm Exp $ */
#if COMPILE_DL
#include "dl/phpdl.h"
@@ -1786,6 +1786,7 @@
pval *argv[3];
int argc, link, id, type, mode;
int rootid = 0;
+ char *urlprefix;
hw_document *doc;
hw_connection *ptr;
HW_TLS_VARS;
@@ -1799,12 +1800,21 @@
convert_to_long(argv[0]);
convert_to_long(argv[1]);
+ mode = 0;
+ urlprefix = NULL;
if(argc == 3) {
- convert_to_long(argv[2]);
- rootid = argv[2]->value.lval;
- mode = 1;
- } else
- mode = 0;
+ switch(argv[2]->type) {
+ case IS_LONG:
+ convert_to_long(argv[2]);
+ rootid = argv[2]->value.lval;
+ mode = 1;
+ break;
+ case IS_STRING:
+ convert_to_string(argv[2]);
+ urlprefix = argv[2]->value.str.val;
+ break;
+ }
+ }
link=argv[0]->value.lval;
id=argv[1]->value.lval;
ptr = php3_list_find(link,&type);
@@ -1820,7 +1830,7 @@
char *bodytag = NULL;
int count;
/* !!!! memory for object and attributes is allocated with malloc !!!! */
- if (0 != (ptr->lasterror = send_gettext(ptr->socket, id, mode, rootid, &attributes,
&bodytag, &object, &count)))
+ if (0 != (ptr->lasterror = send_gettext(ptr->socket, id, mode, rootid, &attributes,
&bodytag, &object, &count, urlprefix)))
RETURN_FALSE;
doc = malloc(sizeof(hw_document));
doc->data = object;
@@ -2164,7 +2174,7 @@
#else
getenv("HOSTNAME"),
#endif
- id, mode, rootid, &attributes, &bodytag, &object, &count)))
+ id, mode, rootid, &attributes, &bodytag, &object, &count, NULL)))
RETURN_FALSE;
doc = malloc(sizeof(hw_document));