CVS update: php3/functions
| From: | steinm | Date: | Tue, 12 Jan 1999 17:36:19 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-3500@lists.php.net to get a copy of this message | ||
Date: Tuesday January 12, 1999 @ 12:36
Author: steinm
Update of /repository/php3/functions
In directory asf:/u/temp/cvs-serv15290/functions
Modified Files:
hw.c hw.h hg_comm.c
Log Message:
- cleanups
- new function hw_modifyobject()
Index: php3/functions/hw.c
diff -c php3/functions/hw.c:1.21 php3/functions/hw.c:1.22
*** php3/functions/hw.c:1.21 Mon Jan 4 09:25:20 1999
--- php3/functions/hw.c Tue Jan 12 12:36:18 1999
***************
*** 23,29 ****
+----------------------------------------------------------------------+
*/
! /* $Id: hw.c,v 1.21 1999/01/04 14:25:20 jah Exp $ */
#if COMPILE_DL
#include "dl/phpdl.h"
#endif
--- 23,29 ----
+----------------------------------------------------------------------+
*/
! /* $Id: hw.c,v 1.22 1999/01/12 17:36:18 steinm Exp $ */
#if COMPILE_DL
#include "dl/phpdl.h"
#endif
***************
*** 81,86 ****
--- 81,87 ----
{"hw_cp", php3_hw_cp, NULL},
{"hw_deleteobject", php3_hw_deleteobject, NULL},
{"hw_changeobject", php3_hw_changeobject, NULL},
+ {"hw_modifyobject", php3_hw_modifyobject, NULL},
{"hw_docbyanchor", php3_hw_docbyanchor, NULL},
{"hw_docbyanchorobj", php3_hw_docbyanchorobj, NULL},
{"hw_getobjectbyquery", php3_hw_getobjectbyquery, NULL},
***************
*** 228,238 ****
** creates an array return value from object record
*/
int make_return_array_from_objrec(pval **return_value, char *objrec) {
- pval title_arr, desc_arr;
char *attrname, *str, *temp, language[3], *title;
! int iTitle, iDesc;
int hasTitle = 0;
int hasDescription = 0;
if (array_init(*return_value) == FAILURE) {
(*return_value)->type = IS_STRING;
--- 229,242 ----
** creates an array return value from object record
*/
int make_return_array_from_objrec(pval **return_value, char *objrec) {
char *attrname, *str, *temp, language[3], *title;
! int iTitle, iDesc, iKeyword;
! pval title_arr;
! pval desc_arr;
! pval keyword_arr;
int hasTitle = 0;
int hasDescription = 0;
+ int hasKeyword = 0;
if (array_init(*return_value) == FAILURE) {
(*return_value)->type = IS_STRING;
***************
*** 241,277 ****
return -1;
}
! /* Array for titles. Only if we have at least one title */
! /* if(0 == strncmp(objrec, "Title=", 6)) { */
! if (array_init(&title_arr) == FAILURE) {
! return -1;
! }
! hasTitle = 1;
! /* } */
!
! /* Array for Descriptions. Only if we have at least one description */
! /* if(0 == strncmp(objrec, "Description=", 12)) { */
! if (array_init(&desc_arr) == FAILURE) {
! return -1;
! }
! hasDescription = 1;
! /* } */
!
! /* Fill Array of titles and descriptions */
temp = estrdup(objrec);
attrname = strtok(temp, "\n");
while(attrname != NULL) {
str = attrname;
iTitle = 0;
iDesc = 0;
if(0 == strncmp(attrname, "Title=", 6)) {
str += 6;
iTitle = 1;
} else if(0 == strncmp(attrname, "Description=", 12)) {
str += 12;
iDesc = 1;
! }
! if(iTitle || iDesc) { /* Poor error check if end of string */
if(str[2] == ':') {
str[2] = '\0';
strcpy(language, str);
--- 245,281 ----
return -1;
}
! /* Fill Array of titles, descriptions and keywords */
temp = estrdup(objrec);
attrname = strtok(temp, "\n");
while(attrname != NULL) {
str = attrname;
iTitle = 0;
iDesc = 0;
+ iKeyword = 0;
if(0 == strncmp(attrname, "Title=", 6)) {
+ if ((hasTitle == 0) && (array_init(&title_arr) == FAILURE)) {
+ return -1;
+ }
+ hasTitle = 1;
str += 6;
iTitle = 1;
} else if(0 == strncmp(attrname, "Description=", 12)) {
+ if ((hasDescription == 0) && (array_init(&desc_arr) == FAILURE)) {
+ return -1;
+ }
+ hasDescription = 1;
str += 12;
iDesc = 1;
! } else if(0 == strncmp(attrname, "Keyword=", 8)) {
! if ((hasKeyword == 0) && (array_init(&keyword_arr) == FAILURE)) {
! return -1;
! }
! hasKeyword = 1;
! str += 8;
! iKeyword = 1;
! }
! if(iTitle || iDesc || iKeyword) { /* Poor error check if end of string */
if(str[2] == ':') {
str[2] = '\0';
strcpy(language, str);
***************
*** 280,292 ****
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);
}
attrname = strtok(NULL, "\n");
}
--- 284,295 ----
strcpy(language, "xx");
title = str;
! if(iTitle)
add_assoc_string(&title_arr, language, title, 1);
! else if(iDesc)
add_assoc_string(&desc_arr, language, title, 1);
+ else if(iKeyword)
+ add_assoc_string(&keyword_arr, language, title, 1);
}
attrname = strtok(NULL, "\n");
}
***************
*** 306,319 ****
/* The description array can now be freed, but I don't know how */
}
/* All other attributes. Make a another copy first */
temp = estrdup(objrec);
attrname = strtok(temp, "\n");
while(attrname != NULL) {
str = attrname;
! /* We don't want to insert titles a second time */
if((0 != strncmp(attrname, "Title=", 6)) &&
! (0 != strncmp(attrname, "Description=", 12))) {
while((*str != '=') && (*str != '\0'))
str++;
*str = '\0';
--- 309,330 ----
/* The description array can now be freed, but I don't know how */
}
+ if(hasKeyword) {
+ /* Add the keyword array, if we have one */
+ _php3_hash_update((*return_value)->value.ht, "Keyword", 8, &keyword_arr,
sizeof(pval), NULL);
+
+ /* The keyword array can now be freed, but I don't know how */
+ }
+
/* All other attributes. Make a another copy first */
temp = estrdup(objrec);
attrname = strtok(temp, "\n");
while(attrname != NULL) {
str = attrname;
! /* 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, "Keyword=", 8))) {
while((*str != '=') && (*str != '\0'))
str++;
*str = '\0';
***************
*** 1262,1279 ****
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))) {
--- 1273,1290 ----
switch(data->type) {
case IS_STRING:
if(strlen(data->value.str.val) == 0)
! sprintf(newattribute, "rem %s", key);
else
! sprintf(newattribute, "add %s=%s", key, data->value.str.val);
! noinsert = 0;
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))) {
***************
*** 1294,1301 ****
efree(oldobjrec);
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);
--- 1305,1399 ----
efree(oldobjrec);
set_swap(ptr->swap_on);
+ modification[strlen(modification)-1] = '\0';
+ if (0 != (ptr->lasterror = send_changeobject(ptr->socket, id, modification)))
+ RETURN_FALSE;
+ free(modification);
+ RETURN_TRUE;
+ }
+ /* }}} */
+
+ /* {{{ proto void hw_modifyobject(int link, int objid, array attributes)
+ Changes attributes of an object */
+ void php3_hw_modifyobject(INTERNAL_FUNCTION_PARAMETERS) {
+ pval *arg1, *arg2, *arg3, *arg4;
+ int link, id, type, i;
+ hw_connection *ptr;
+ char *modification, buf[200];
+ HashTable *remobjarr, *addobjarr;
+ TLS_VARS;
+
+ if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) ==
FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long(arg1); /* Connection */
+ convert_to_long(arg2); /* object ID */
+ convert_to_array(arg3); /* Array with attributes to remove */
+ convert_to_array(arg4); /* Array with attributes to add */
+ link=arg1->value.lval;
+ id=arg2->value.lval;
+ remobjarr=arg3->value.ht;
+ addobjarr=arg4->value.ht;
+ 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",id);
+ RETURN_FALSE;
+ }
+
+ modification = strdup("");
+ if(addobjarr != NULL) {
+ _php3_hash_internal_pointer_reset(addobjarr);
+ for(i=0; i<_php3_hash_num_elements(addobjarr); i++) {
+ char *key, *str, *str1, addattribute[200];
+ pval *data;
+ int j, noinsert=1;
+ ulong ind;
+
+ _php3_hash_get_current_key(addobjarr, &key, &ind);
+ _php3_hash_get_current_data(addobjarr, (void *) &data);
+ switch(data->type) {
+ case IS_STRING:
+ sprintf(addattribute, "add %s=%s", key, data->value.str.val);
+ noinsert = 0;
+ break;
+ }
+ if(!noinsert) {
+ modification = fnInsStr(modification, 0, "\\");
+ modification = fnInsStr(modification, 0, addattribute);
+ }
+ efree(key);
+ _php3_hash_move_forward(addobjarr);
+ }
+ }
+
+ if(remobjarr != NULL) {
+ _php3_hash_internal_pointer_reset(remobjarr);
+ for(i=0; i<_php3_hash_num_elements(remobjarr); i++) {
+ char *key, *str, *str1, remattribute[200];
+ pval *data;
+ int j, noinsert=1;
+ ulong ind;
+
+ _php3_hash_get_current_key(remobjarr, &key, &ind);
+ _php3_hash_get_current_data(remobjarr, (void *) &data);
+ switch(data->type) {
+ case IS_STRING:
+ sprintf(remattribute, "rem %s=%s", key, data->value.str.val);
+ noinsert = 0;
+ break;
+ }
+ if(!noinsert) {
+ modification = fnInsStr(modification, 0, "\\");
+ modification = fnInsStr(modification, 0, remattribute);
+ }
+ efree(key);
+ _php3_hash_move_forward(remobjarr);
+ }
+ }
+
+ set_swap(ptr->swap_on);
modification[strlen(modification)-1] = '\0';
! /* fprintf(stderr, "modifyobject: %s\n", modification); */
if (0 != (ptr->lasterror = send_changeobject(ptr->socket, id, modification)))
RETURN_FALSE;
free(modification);
***************
*** 1760,1766 ****
doc->attributes = attributes;
doc->bodytag = bodytag;
doc->size = count;
! fprintf(stderr, "size = %d\n", count);
return_value->value.lval = php3_list_insert(doc,php3_hw_module.le_document);
return_value->type = IS_LONG;
}
--- 1858,1864 ----
doc->attributes = attributes;
doc->bodytag = bodytag;
doc->size = count;
! /* fprintf(stderr, "size = %d\n", count); */
return_value->value.lval = php3_list_insert(doc,php3_hw_module.le_document);
return_value->type = IS_LONG;
}
Index: php3/functions/hw.h
diff -c php3/functions/hw.h:1.4 php3/functions/hw.h:1.5
*** php3/functions/hw.h:1.4 Fri Jan 1 12:59:11 1999
--- php3/functions/hw.h Tue Jan 12 12:36:18 1999
***************
*** 23,29 ****
*/
! /* $Id: hw.h,v 1.4 1999/01/01 17:59:11 zeev Exp $ */
#ifndef _HW_H
#define _HW_H
--- 23,29 ----
*/
! /* $Id: hw.h,v 1.5 1999/01/12 17:36:18 steinm Exp $ */
#ifndef _HW_H
#define _HW_H
***************
*** 65,70 ****
--- 65,71 ----
extern void php3_hw_cp(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_hw_deleteobject(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_hw_changeobject(INTERNAL_FUNCTION_PARAMETERS);
+ extern void php3_hw_modifyobject(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_hw_getparents(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_hw_getparentsobj(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_hw_children(INTERNAL_FUNCTION_PARAMETERS);
Index: php3/functions/hg_comm.c
diff -c php3/functions/hg_comm.c:1.11 php3/functions/hg_comm.c:1.12
*** php3/functions/hg_comm.c:1.11 Fri Jan 1 12:59:10 1999
--- php3/functions/hg_comm.c Tue Jan 12 12:36:18 1999
***************
*** 23,29 ****
+----------------------------------------------------------------------+
*/
! /* $Id: hg_comm.c,v 1.11 1999/01/01 17:59:10 zeev Exp $ */
/* #define HW_DEBUG */
--- 23,29 ----
+----------------------------------------------------------------------+
*/
! /* $Id: hg_comm.c,v 1.12 1999/01/12 17:36:18 steinm Exp $ */
/* #define HW_DEBUG */
***************
*** 3119,3124 ****
--- 3119,3125 ----
send_incollections(sockfd, 1, 1, &thisID, 1, &rootID, &countthis,
&retthisIDs);
send_incollections(sockfd, 1, 1, &destdocid, 1, &rootID, &countdest,
&retdestIDs);
+ /*
fprintf(stderr, "%d: ", thisID);
for(k=0; k<countthis; k++)
fprintf(stderr,"%d, ", retthisIDs[k]);
***************
*** 3127,3132 ****
--- 3128,3134 ----
for(k=0; k<countdest; k++)
fprintf(stderr,"%d: %d, ", destdocid, retdestIDs[k]);
fprintf(stderr,"\n");
+ */
mincount = (countthis < countdest) ? countthis : countdest;
for(j=0; (j<mincount) && (retthisIDs[j]==retdestIDs[j]); j++)
***************
*** 3154,3163 ****
*strptr = '_';
strptr++;
}
! fprintf(stderr, "Adding '%s' to '%s'\n", temp, anchorstr);
strcat(anchorstr, temp);
strcat(anchorstr, "/");
! fprintf(stderr, "Is now '%s'\n", anchorstr);
efree(temprec);
}
/* if the anchor destination is a collection it may not be added anymore. */
--- 3156,3165 ----
*strptr = '_';
strptr++;
}
! /* fprintf(stderr, "Adding '%s' to '%s'\n", temp, anchorstr); */
strcat(anchorstr, temp);
strcat(anchorstr, "/");
! /* fprintf(stderr, "Is now '%s'\n", anchorstr); */
efree(temprec);
}
/* if the anchor destination is a collection it may not be added anymore. */
***************
*** 3175,3181 ****
strcat(anchorstr, "\n");
sprintf(temp, "ObjectID=0x%x", destdocid);
strcat(anchorstr, temp);
! fprintf(stderr, "%s\n", anchorstr);
efree(retthisIDs);
efree(retdestIDs);
reldestptr[i] = estrdup(anchorstr);
--- 3177,3183 ----
strcat(anchorstr, "\n");
sprintf(temp, "ObjectID=0x%x", destdocid);
strcat(anchorstr, temp);
! /* fprintf(stderr, "%s\n", anchorstr); */
efree(retthisIDs);
efree(retdestIDs);
reldestptr[i] = estrdup(anchorstr);
--
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