[Refdb-cvs] CVS: refdb/src risxhandler.c,1.20,1.21
Status: Beta
Brought to you by:
mhoenicka
|
From: Markus H. <mho...@us...> - 2004-01-07 19:43:06
|
Update of /cvsroot/refdb/refdb/src
In directory sc8-pr-cvs1:/tmp/cvs-serv29508
Modified Files:
risxhandler.c
Log Message:
check get_attr() for NULL; skip adding PATH to availability data that erroneously carries this prefix
Index: risxhandler.c
===================================================================
RCS file: /cvsroot/refdb/refdb/src/risxhandler.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -U2 -r1.20 -r1.21
--- risxhandler.c 3 Jan 2004 20:11:44 -0000 1.20
+++ risxhandler.c 7 Jan 2004 19:43:03 -0000 1.21
@@ -739,5 +739,5 @@
/* else: corporate name is in ptr_ainfo->name anyway */
- /* role attribute */
+ /* role attribute, function checks for NULL value */
set_authorinfo_role(ptr_ardata->ptr_ainfo, get_attr(ptr_ardata->ptr_first, "role"));
@@ -1135,34 +1135,36 @@
type = get_attr(ptr_ardata->ptr_first, "type");
- if (!strcmp(type, "1")) {
- strcpy(tofield, "user1");
- }
- else if (!strcmp(type, "2")) {
- strcpy(tofield, "user2");
- }
- else if (!strcmp(type, "3")) {
- strcpy(tofield, "user3");
- }
- else if (!strcmp(type, "4")) {
- strcpy(tofield, "user4");
- }
- else if (!strcmp(type, "5")) {
- strcpy(tofield, "user5");
- }
+ if (type) {
+ if (!strcmp(type, "1")) {
+ strcpy(tofield, "user1");
+ }
+ else if (!strcmp(type, "2")) {
+ strcpy(tofield, "user2");
+ }
+ else if (!strcmp(type, "3")) {
+ strcpy(tofield, "user3");
+ }
+ else if (!strcmp(type, "4")) {
+ strcpy(tofield, "user4");
+ }
+ else if (!strcmp(type, "5")) {
+ strcpy(tofield, "user5");
+ }
- result = set_risdata_field(ptr_ardata->ptr_risdata, tofield, (ptr_ardata->ptr_first)->ptr_elvalue, ptr_ardata->driver);
- if (result == 1) {
- LOG_PRINT(LOG_WARNING, outomem.text);
- if ((new_msgpool = mstrcat(ptr_ardata->msgpool, outomem_n.text, &(ptr_ardata->msgpool_len), 0)) == NULL) {
- (ptr_ardata->nmem_error)++;
+ result = set_risdata_field(ptr_ardata->ptr_risdata, tofield, (ptr_ardata->ptr_first)->ptr_elvalue, ptr_ardata->driver);
+ if (result == 1) {
+ LOG_PRINT(LOG_WARNING, outomem.text);
+ if ((new_msgpool = mstrcat(ptr_ardata->msgpool, outomem_n.text, &(ptr_ardata->msgpool_len), 0)) == NULL) {
+ (ptr_ardata->nmem_error)++;
+ return;
+ }
+ else {
+ ptr_ardata->msgpool = new_msgpool;
+ }
+ (ptr_ardata->ndb_error)++;
return;
}
- else {
- ptr_ardata->msgpool = new_msgpool;
- }
- (ptr_ardata->ndb_error)++;
- return;
+ /* else: all fine */
}
- /* else: all fine */
}
/* ------------------------------------------------------------ */
@@ -1173,28 +1175,30 @@
type = get_attr(ptr_ardata->ptr_first, "type");
- if (!strcmp(type, "1")) {
- strcpy(tofield, "misc1");
- }
- else if (!strcmp(type, "2")) {
- strcpy(tofield, "misc2");
- }
- else if (!strcmp(type, "3")) {
- strcpy(tofield, "misc3");
- }
+ if (type) {
+ if (!strcmp(type, "1")) {
+ strcpy(tofield, "misc1");
+ }
+ else if (!strcmp(type, "2")) {
+ strcpy(tofield, "misc2");
+ }
+ else if (!strcmp(type, "3")) {
+ strcpy(tofield, "misc3");
+ }
- result = set_risdata_field(ptr_ardata->ptr_risdata, tofield, (ptr_ardata->ptr_first)->ptr_elvalue, ptr_ardata->driver);
- if (result == 1) {
- LOG_PRINT(LOG_WARNING, outomem.text);
- if ((new_msgpool = mstrcat(ptr_ardata->msgpool, outomem_n.text, &(ptr_ardata->msgpool_len), 0)) == NULL) {
- (ptr_ardata->nmem_error)++;
+ result = set_risdata_field(ptr_ardata->ptr_risdata, tofield, (ptr_ardata->ptr_first)->ptr_elvalue, ptr_ardata->driver);
+ if (result == 1) {
+ LOG_PRINT(LOG_WARNING, outomem.text);
+ if ((new_msgpool = mstrcat(ptr_ardata->msgpool, outomem_n.text, &(ptr_ardata->msgpool_len), 0)) == NULL) {
+ (ptr_ardata->nmem_error)++;
+ return;
+ }
+ else {
+ ptr_ardata->msgpool = new_msgpool;
+ }
+ (ptr_ardata->ndb_error)++;
return;
}
- else {
- ptr_ardata->msgpool = new_msgpool;
- }
- (ptr_ardata->ndb_error)++;
- return;
+ /* else: all fine */
}
- /* else: all fine */
}
/* ------------------------------------------------------------ */
@@ -1205,31 +1209,33 @@
type = get_attr(ptr_ardata->ptr_first, "type");
- if (!strcmp(type, "pdf")) {
- strcpy(tofield, "linkpdf");
- }
- else if (!strcmp(type, "fulltext")) {
- strcpy(tofield, "linkfull");
- }
- else if (!strcmp(type, "related")) {
- strcpy(tofield, "linkrel");
- }
- else /* if (!strcmp(type, "image")) */ {
- strcpy(tofield, "linkimg");
- }
+ if (type) {
+ if (!strcmp(type, "pdf")) {
+ strcpy(tofield, "linkpdf");
+ }
+ else if (!strcmp(type, "fulltext")) {
+ strcpy(tofield, "linkfull");
+ }
+ else if (!strcmp(type, "related")) {
+ strcpy(tofield, "linkrel");
+ }
+ else /* if (!strcmp(type, "image")) */ {
+ strcpy(tofield, "linkimg");
+ }
- result = set_risdata_field(ptr_ardata->ptr_risdata, tofield, (ptr_ardata->ptr_first)->ptr_elvalue, ptr_ardata->driver);
- if (result == 1) {
- LOG_PRINT(LOG_WARNING, outomem.text);
- if ((new_msgpool = mstrcat(ptr_ardata->msgpool, outomem_n.text, &(ptr_ardata->msgpool_len), 0)) == NULL) {
- (ptr_ardata->nmem_error)++;
+ result = set_risdata_field(ptr_ardata->ptr_risdata, tofield, (ptr_ardata->ptr_first)->ptr_elvalue, ptr_ardata->driver);
+ if (result == 1) {
+ LOG_PRINT(LOG_WARNING, outomem.text);
+ if ((new_msgpool = mstrcat(ptr_ardata->msgpool, outomem_n.text, &(ptr_ardata->msgpool_len), 0)) == NULL) {
+ (ptr_ardata->nmem_error)++;
+ return;
+ }
+ else {
+ ptr_ardata->msgpool = new_msgpool;
+ }
+ (ptr_ardata->ndb_error)++;
return;
}
- else {
- ptr_ardata->msgpool = new_msgpool;
- }
- (ptr_ardata->ndb_error)++;
- return;
+ /* else: all fine */
}
- /* else: all fine */
}
/* ------------------------------------------------------------ */
@@ -1270,15 +1276,26 @@
type = get_attr(ptr_ardata->ptr_first, "type");
- if (!strcmp(type, "useroot")) {
+ if (type && !strcmp(type, "useroot")) {
if ((temp_avail = malloc(strlen((ptr_ardata->ptr_first)->ptr_elvalue)+6)) == NULL) {
(ptr_ardata->nmem_error)++;
return;
}
- strcpy(temp_avail, "PATH:");
+
+ /* skip adding PATH: to data that already contain this prefix
+ this was added erroneously by some previous versions */
+ if (strncmp((ptr_ardata->ptr_first)->ptr_elvalue, "PATH:", 5)) {
+ strcpy(temp_avail, "PATH:");
+ }
+ else {
+ *temp_avail = '\0';
+ }
strcat(temp_avail, (ptr_ardata->ptr_first)->ptr_elvalue);
result = update_avail(temp_avail, ptr_ardata->n_refdb_id, ptr_ardata->n_user_id, ptr_ardata->conn, ptr_ardata->driver);
+
+ free(temp_avail);
}
else {
+ /* full string, not a path */
result = update_avail((ptr_ardata->ptr_first)->ptr_elvalue, ptr_ardata->n_refdb_id, ptr_ardata->n_user_id, ptr_ardata->conn, ptr_ardata->driver);
}
|