cvs: /php3/functions hg_comm.c hg_comm.h hw.c hw.h /php3/tests hyperwave.php3
| From: | Uwe Steinmann | Date: | Thu, 21 Oct 1999 15:17:12 +0000 |
| Subject: | cvs: /php3/functions hg_comm.c hg_comm.h hw.c hw.h /php3/tests hyperwave.php3 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-11809@lists.php.net to get a copy of this message | ||
steinm Thu Oct 21 11:17:12 1999 EDT
Modified files:
/php3/functions hg_comm.c hg_comm.h hw.c hw.h
/php3/tests hyperwave.php3
Log:
Added hw_mapid(), read comment in hg_comm.c
Index: php3/functions/hg_comm.c
diff -u php3/functions/hg_comm.c:1.30 php3/functions/hg_comm.c:1.31
--- php3/functions/hg_comm.c:1.30 Thu Aug 26 06:36:05 1999
+++ php3/functions/hg_comm.c Thu Oct 21 11:17:11 1999
@@ -23,7 +23,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: hg_comm.c,v 1.30 1999/08/26 10:36:05 steinm Exp $ */
+/* $Id: hg_comm.c,v 1.31 1999/10/21 15:17:11 steinm Exp $ */
/* #define HW_DEBUG */
@@ -80,8 +80,11 @@
virtual. This means whenever an object is requested a
new id is generated for this session. Wavemaster and
Harmony set this flag. How do I know? tcpdump tells
- a lot if investigate the output.
- int version = VERSION | F_DISTRIBUTED; */
+ a lot if the output is investigated. The bit is also
+ need to allow access on other server through the local
+ server. The hw_mapid() function won't work unless you
+ set F_DISTRIBUTED */
+/* int version = VERSION | F_DISTRIBUTED; */
/* int version = VERSION | F_DISTRIBUTED | F_COMPRESSED; */
static int msgid = 1;
static int sock_flags = -1;
@@ -4682,6 +4685,53 @@
return(0);
}
+int send_mapid(int sockfd, int servid, hw_objectID id, int *virtid)
+{
+ hg_msg msg, *retmsg;
+ int length, i, error;
+ char *tmp;
+ int *ptr, *ptr1;
+
+ length = HEADER_LENGTH + 2 * sizeof(hw_objectID);
+
+ build_msg_header(&msg, length, msgid++, HG_MAPID);
+
+ if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
+ lowerror = LE_MALLOC;
+ return(-1);
+ }
+
+ tmp = build_msg_int(msg.buf, servid);
+ tmp = build_msg_int(tmp, id);
+
+ if (-1 == send_hg_msg(sockfd, &msg, length)) {
+ efree(msg.buf);
+ return(-2);
+ }
+
+ efree(msg.buf);
+ retmsg = recv_hg_msg(sockfd);
+ if ( retmsg == NULL ) {
+ return(-3);
+ }
+
+ ptr = (int *) retmsg->buf;
+ if(ptr == NULL) {
+ if(retmsg) efree(retmsg);
+ return -1;
+ }
+ if(*ptr++ == 0) {
+ *virtid = *ptr;
+ } else {
+ error = *((int *) retmsg->buf);
+ efree(retmsg->buf);
+ efree(retmsg);
+ return error;
+ }
+
+ return(0);
+}
+
#define BUFFERLEN 200
char *get_hw_info(hw_connection *conn) {
char temp[BUFFERLEN];
@@ -4837,7 +4887,6 @@
return(buf+len);
}
-
static int swap(int val)
{
Index: php3/functions/hg_comm.h
diff -u php3/functions/hg_comm.h:1.10 php3/functions/hg_comm.h:1.11
--- php3/functions/hg_comm.h:1.10 Wed Jul 7 11:31:16 1999
+++ php3/functions/hg_comm.h Thu Oct 21 11:17:11 1999
@@ -23,7 +23,7 @@
*/
-/* $Id: hg_comm.h,v 1.10 1999/07/07 15:31:16 steinm Exp $ */
+/* $Id: hg_comm.h,v 1.11 1999/10/21 15:17:11 steinm Exp $ */
#ifndef _HG_COMM_H
#define _HG_COMM_H
@@ -74,6 +74,7 @@
#define PUTDOCUMENT_MESSAGE 38
#define GETREMOTE_MESSAGE 39
#define GETREMOTECHILDREN_MESSAGE 40
+#define HG_MAPID 43
#define CHILDREN_MESSAGE 44
#define GETCGI_MESSAGE 45
#define PIPECGI_MESSAGE 46
@@ -200,6 +201,7 @@
extern int send_insdoc(int sockfd, hw_objectID objectID, char *objrec, char *text, hw_objectID
*new_objectID);
extern int send_incollections(int sockfd, int retcol, int cobjids, hw_objectID *objectIDs, int
ccollids, hw_objectID *collIDs, int *count, hw_objectID **retIDs);
extern int send_getsrcbydest(int sockfd, hw_objectID objid, char ***childrec, int *count);
+extern int send_mapid(int sockfd, int servid, hw_objectID id, int *virtid);
extern int send_dummy(int sockfd, hw_objectID objectID, int msgid, char **attributes);
extern char *get_hw_info(hw_connection *conn);
Index: php3/functions/hw.c
diff -u php3/functions/hw.c:1.49 php3/functions/hw.c:1.50
--- php3/functions/hw.c:1.49 Wed Sep 1 02:15:42 1999
+++ php3/functions/hw.c Thu Oct 21 11:17:11 1999
@@ -23,7 +23,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: hw.c,v 1.49 1999/09/01 06:15:42 steinm Exp $ */
+/* $Id: hw.c,v 1.50 1999/10/21 15:17:11 steinm Exp $ */
#if COMPILE_DL
#include "dl/phpdl.h"
@@ -135,6 +135,7 @@
PHP_FE(hw_getrellink, NULL)
PHP_FE(hw_who, NULL)
PHP_FE(hw_stat, NULL)
+ PHP_FE(hw_mapid, NULL)
PHP_FE(hw_dummy, NULL)
{NULL, NULL, NULL}
};
@@ -3505,6 +3506,38 @@
/* create return value and free all memory */
if( 0 > make_return_objrec(&return_value, childObjRecs, count))
RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto int hw_mapid(int link, int serverid, int destid)
+ Returns virtual object id of document on remote hw server */
+PHP_FUNCTION(hw_mapid) {
+ pval *arg1, *arg2, *arg3;
+ int link, type, servid, id, virtid;
+ hw_connection *ptr;
+ HW_TLS_VARS;
+
+ if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long(arg1);
+ convert_to_long(arg2);
+ convert_to_long(arg3);
+ link=arg1->value.lval;
+ servid=arg2->value.lval;
+ id=arg3->value.lval;
+ ptr = php3_list_find(link,&type);
+ if(!ptr || (type!=php3_hw_module.le_socketp && type!=php3_hw_module.le_psocketp)) {
+ php3_error(E_WARNING,"Unable to find file identifier %d",link);
+ RETURN_FALSE;
+ }
+
+ set_swap(ptr->swap_on);
+ if (0 != (ptr->lasterror = send_mapid(ptr->socket, servid, id, &virtid))) {
+ php3_error(E_WARNING, "send_command (mapid) returned %d\n", ptr->lasterror);
+ RETURN_FALSE;
+ }
+ RETURN_LONG(virtid);
}
/* }}} */
Index: php3/functions/hw.h
diff -u php3/functions/hw.h:1.9 php3/functions/hw.h:1.10
--- php3/functions/hw.h:1.9 Fri Aug 6 02:37:31 1999
+++ php3/functions/hw.h Thu Oct 21 11:17:11 1999
@@ -23,7 +23,7 @@
*/
-/* $Id: hw.h,v 1.9 1999/08/06 06:37:31 steinm Exp $ */
+/* $Id: hw.h,v 1.10 1999/10/21 15:17:11 steinm Exp $ */
#ifndef _HW_H
#define _HW_H
@@ -117,6 +117,7 @@
PHP_FUNCTION(hw_dummy);
PHP_FUNCTION(hw_who);
PHP_FUNCTION(hw_stat);
+PHP_FUNCTION(hw_mapid);
#else
#define hw_module_ptr NULL
#endif /* HYPERWAVE */
Index: php3/tests/hyperwave.php3
diff -u php3/tests/hyperwave.php3:1.2 php3/tests/hyperwave.php3:1.3
--- php3/tests/hyperwave.php3:1.2 Sun Sep 6 09:20:38 1998
+++ php3/tests/hyperwave.php3 Thu Oct 21 11:17:11 1999
@@ -48,6 +48,7 @@
echo "1. Connecting to Hyperwave server\n";
echo "2. output the object record of the Hyperroot\n";
echo "3. output the children of the Hyperroot\n";
+ echo "4. map rootcollection on remote server and list children\n";
echo "\n";
echo "Test 1: Connecting to Hyperwave server ($hwhost).\n";
@@ -75,4 +76,12 @@
list_children($rootchildobjrecs);
echo "Test 3: successful\n";
echo "\n";
+
+ echo "Test 4: Map rootcollection on remote server and list children.\n";
+ $rootid = hw_mapid(hexdec("0x82d85c03"), hexdec("0x00000002"));
+ $rootchildobjrecs = hw_childrenobj($connect, $rootid);
+ list_children($rootchildobjrecs);
+ echo "Test 4: successful\n";
+ echo "\n";
+
?>