cvs: /php4/ext/hyperwave hw.c hg_comm.c

From: Date: Wed, 01 Sep 1999 06:15:45 +0000
Subject: cvs: /php4/ext/hyperwave hw.c hg_comm.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-3943@lists.php.net to get a copy of this message
steinm Wed Sep 1 02:15:45 1999 EDT Modified files: /php4/ext/hyperwave hw.c hg_comm.c Log: - Group-attribute may now appear multiple times in objrec record. Index: php4/ext/hyperwave/hw.c diff -u php4/ext/hyperwave/hw.c:1.17 php4/ext/hyperwave/hw.c:1.18 --- php4/ext/hyperwave/hw.c:1.17 Thu Aug 19 11:03:14 1999 +++ php4/ext/hyperwave/hw.c Wed Sep 1 02:15:45 1999 @@ -16,12 +16,13 @@ +----------------------------------------------------------------------+ */ -/* $Id: hw.c,v 1.17 1999/08/19 15:03:14 steinm Exp $ */ +/* $Id: hw.c,v 1.18 1999/09/01 06:15:45 steinm Exp $ */ #if COMPILE_DL #include "dl/phpdl.h" #endif #include <stdlib.h> +#include <errno.h> #include "php.h" #include "php_globals.h" @@ -274,17 +275,20 @@ */ int make_return_array_from_objrec(pval **return_value, char *objrec) { char *attrname, *str, *temp, language[3], *title; - int iTitle, iDesc, iKeyword; + int iTitle, iDesc, iKeyword, iGroup; zval *title_arr; zval *desc_arr; zval *keyword_arr; + zval *group_arr; int hasTitle = 0; int hasDescription = 0; int hasKeyword = 0; + int hasGroup = 0; MAKE_STD_ZVAL(title_arr); MAKE_STD_ZVAL(desc_arr); MAKE_STD_ZVAL(keyword_arr); + MAKE_STD_ZVAL(group_arr); if (array_init(*return_value) == FAILURE) { (*return_value)->type = IS_STRING; @@ -301,6 +305,7 @@ iTitle = 0; iDesc = 0; iKeyword = 0; + iGroup = 0; if(0 == strncmp(attrname, "Title=", 6)) { if ((hasTitle == 0) && (array_init(title_arr) == FAILURE)) { return -1; @@ -322,6 +327,13 @@ hasKeyword = 1; str += 8; iKeyword = 1; + } else if(0 == strncmp(attrname, "Group=", 6)) { + if ((hasGroup == 0) && (array_init(group_arr) == FAILURE)) { + return -1; + } + hasGroup = 1; + str += 6; + iGroup = 1; } if(iTitle || iDesc || iKeyword) { /* Poor error check if end of string */ if(str[2] == ':') { @@ -338,6 +350,9 @@ add_assoc_string(desc_arr, language, title, 1); else if(iKeyword) add_assoc_string(keyword_arr, language, title, 1); + } else if(iGroup) { + if(iGroup) + add_next_index_string(group_arr, str, 1); } attrname = strtok(NULL, "\n"); } @@ -368,6 +383,14 @@ efree(keyword_arr); } + if(hasGroup) { + /* Add the Group array, if we have one */ + zend_hash_update((*return_value)->value.ht, "Group", 6, &group_arr, sizeof(zval *), NULL); + + } else { + efree(group_arr); + } + /* All other attributes. Make a another copy first */ temp = estrdup(objrec); attrname = strtok(temp, "\n"); @@ -376,6 +399,7 @@ /* We don't want to insert titles, descr., keywords a second time */ if((0 != strncmp(attrname, "Title=", 6)) && (0 != strncmp(attrname, "Description=", 12)) && + (0 != strncmp(attrname, "Group=", 6)) && (0 != strncmp(attrname, "Keyword=", 8))) { while((*str != '=') && (*str != '\0')) str++; @@ -408,15 +432,21 @@ *objrec = '\0'; for(i=0; i<count; i++) { keytype = zend_hash_get_current_key(lht, &key, &length); - if(HASH_KEY_IS_STRING == keytype) { +// if(HASH_KEY_IS_STRING == keytype) { zend_hash_get_current_data(lht, (void **) &keydataptr); keydata = *keydataptr; switch(keydata->type) { case IS_STRING: - snprintf(str, BUFFERLEN, "%s=%s\n", key, keydata->value.str.val); + if(HASH_KEY_IS_STRING == keytype) + snprintf(str, BUFFERLEN, "%s=%s\n", key, keydata->value.str.val); + else + snprintf(str, BUFFERLEN, "%s\n", keydata->value.str.val); break; case IS_LONG: - snprintf(str, BUFFERLEN, "%s=0x%lX\n", key, keydata->value.lval); + if(HASH_KEY_IS_STRING == keytype) + snprintf(str, BUFFERLEN, "%s=0x%lX\n", key, keydata->value.lval); + else + snprintf(str, BUFFERLEN, "0x%lX\n", keydata->value.lval); break; case IS_ARRAY: { int i, len, keylen, count; @@ -451,10 +481,10 @@ break; } } - efree(key); + if(HASH_KEY_IS_STRING == keytype) efree(key); objrec = realloc(objrec, strlen(objrec)+strlen(str)+1); strcat(objrec, str); - } +// } zend_hash_move_forward(lht); } return objrec; @@ -576,7 +606,7 @@ } if ( (sockfd = open_hg_connection(host, port)) < 0 ) { - php_error(E_ERROR, "Could not open connection to %s, Port: %d (retval=%d)", host, port, sockfd); + php_error(E_ERROR, "Could not open connection to %s, Port: %d (retval=%d, errno=%d)", host, port, sockfd, errno); if(host) efree(host); if(username) efree(username); if(password) efree(password); @@ -1624,7 +1654,7 @@ free(modification); RETURN_TRUE; } -/* fprintf(stderr, "modifyobject: %s\n", modification);*/ +/* fprintf(stderr, "modifyobject: %s\n", modification); */ switch(mode) { case 0: if (0 == (ptr->lasterror = send_lock(ptr->socket, id))) { Index: php4/ext/hyperwave/hg_comm.c diff -u php4/ext/hyperwave/hg_comm.c:1.10 php4/ext/hyperwave/hg_comm.c:1.11 --- php4/ext/hyperwave/hg_comm.c:1.10 Tue Aug 17 05:59:18 1999 +++ php4/ext/hyperwave/hg_comm.c Wed Sep 1 02:15:45 1999 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: hg_comm.c,v 1.10 1999/08/17 09:59:18 steinm Exp $ */ +/* $Id: hg_comm.c,v 1.11 1999/09/01 06:15:45 steinm Exp $ */ /* #define HW_DEBUG */ @@ -950,7 +950,7 @@ setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option)); #endif /* SUN */ - if (connect(sockfd, (struct sockaddr *) &server_addr, sizeof(server_addr)) != 0) { + if (connect(sockfd, (struct sockaddr *) &server_addr, sizeof(server_addr)) < 0) { HWSOCK_FCLOSE(sockfd); return(-3); } @@ -1377,6 +1377,8 @@ } error = *((int *) retmsg->buf); + efree(retmsg->buf); + efree(retmsg); return(error); } @@ -1720,6 +1722,8 @@ ptr++; *new_objectID = *ptr; + efree(retmsg->buf); + efree(retmsg); return 0; } @@ -1769,6 +1773,8 @@ ptr++; *new_objectID = *ptr; + efree(retmsg->buf); + efree(retmsg); return 0; } @@ -4124,6 +4130,7 @@ build_msg_header(&msg, length, msgid++, PIPEDOCUMENT_MESSAGE); if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) { + if(attributes) efree(attributes); lowerror = LE_MALLOC; return(-5); } @@ -4615,6 +4622,7 @@ if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) { /* perror("send_command"); */ + efree(childIDs); lowerror = LE_MALLOC; return(-1); } @@ -4622,12 +4630,14 @@ tmp = build_msg_int(msg.buf, childIDs[i]); if ( send_hg_msg(sockfd, &msg, length) == -1 ) { + efree(childIDs); efree(msg.buf); return(-1); } efree(msg.buf); } + efree(childIDs); if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) { /* if emalloc fails, get at least all remaining messages from server */

« previous php.version4 (#3943) next »