* Sebastian Hammer, Adam Dickmeiss
*
* $Log: seshigh.c,v $
- * Revision 1.1 1995-03-15 16:02:10 quinn
+ * Revision 1.5 1995-03-17 10:44:13 quinn
+ * Added catch of null-string in makediagrec
+ *
+ * Revision 1.4 1995/03/17 10:18:08 quinn
+ * Added memory management.
+ *
+ * Revision 1.3 1995/03/16 17:42:39 quinn
+ * Little changes
+ *
+ * Revision 1.2 1995/03/16 13:29:01 quinn
+ * Partitioned server.
+ *
+ * Revision 1.1 1995/03/15 16:02:10 quinn
* Modded session.c seshigh.c
*
* Revision 1.10 1995/03/15 15:18:51 quinn
odr_destroy(h->decode);
odr_destroy(h->encode);
free(h->encode_buffer);
+ if (h->input_buffer)
+ free(h->input_buffer);
free(h);
}
assoc->input_apdu_len = res;
if (process_apdu(h) < 0)
{
- fprintf(stderr, "Bad data from peer\n");
+ fprintf(stderr, "Operation failed\n");
cs_close(conn);
destroy_association(assoc);
iochan_destroy(h);
fprintf(stderr, "Bad APDU\n");
return -1;
}
+ odr_reset(assoc->decode);
return res;
}
resp.result = &result;
resp.implementationId = "YAZ";
resp.implementationName = "YAZ/Simple asynchronous test server";
- resp.implementationVersion = "$Revision: 1.1 $";
+ resp.implementationVersion = "$Revision: 1.5 $";
resp.userInformationField = 0;
if (!z_APDU(assoc->encode, &apdup, 0))
{
- odr_perror(assoc->encode, "Encode init");
+ odr_perror(assoc->encode, "Encode initres");
return -1;
}
odr_getbuf(assoc->encode, &assoc->encoded_len);
+ odr_reset(assoc->encode);
iochan_setflags(client, EVENT_OUTPUT | EVENT_EXCEPT);
return 0;
}
rec.u.nonSurrogateDiagnostic = &dr;
dr.diagnosticSetId = bib1;
dr.condition = &err;
- dr.addinfo = addinfo;
+ dr.addinfo = addinfo ? addinfo : "";
return &rec;
}
if (!z_APDU(assoc->encode, &apdup, 0))
{
- odr_perror(assoc->encode, "Encode init");
+ odr_perror(assoc->encode, "Encode searchres");
return -1;
}
odr_getbuf(assoc->encode, &assoc->encoded_len);
+ odr_reset(assoc->encode);
iochan_setflags(client, EVENT_OUTPUT | EVENT_EXCEPT);
return 0;
}
-static Z_Records *dummy_database_records (int start, int no_requested,
- int *no_returned,
- int preferredMessageSize)
-{
- static Z_Records rec;
- static int no_records = 0;
- static Z_NamePlusRecordList z_nprl;
- int i, size;
- static Z_NamePlusRecord **records;
-
- rec.which = Z_Records_DBOSD;
- rec.u.databaseOrSurDiagnostics = &z_nprl;
- if (!no_records)
- {
- FILE *inf;
- char *buf;
- Odr_external *oep;
-
- inf = fopen ("dummy-records", "r");
- if (!inf)
- return NULL;
- records = malloc (sizeof(*records) * 50);
- assert (records);
- for (i=0; i<50; i++)
- {
- buf = iso2709_read (inf);
- if (!buf)
- break;
- records[i] = malloc (sizeof(**records));
- assert (records[i]);
- records[i]->databaseName = NULL;
- records[i]->which = Z_NamePlusRecord_databaseRecord;
- oep = records[i]->u.databaseRecord =
- malloc (sizeof(*oep));
- assert (oep);
- oep->direct_reference = NULL;
- oep->indirect_reference = NULL;
- oep->descriptor = NULL;
- oep->which = ODR_EXTERNAL_octet;
- oep->u.octet_aligned = malloc (sizeof(*oep->u.octet_aligned));
- assert (oep->u.octet_aligned);
- oep->u.octet_aligned->size = oep->u.octet_aligned->len
- = strlen(buf);
- oep->u.octet_aligned->buf = buf;
- }
- no_records = i;
- fclose (inf);
- }
- if (no_records < start + no_requested)
- return NULL;
-
- z_nprl.records = records + start -1;
- for (size = 0, i = 0; i<no_requested; i++)
- {
- if (z_nprl.records[i]->which == Z_NamePlusRecord_databaseRecord)
- size += z_nprl.records[i]->u.databaseRecord->u.octet_aligned->size;
- printf ("size=%d\n", size);
- if (size > preferredMessageSize)
- break;
- }
- if (i == 0)
- return NULL;
- z_nprl.num_records = *no_returned = i;
- return &rec;
-}
-
static int process_presentRequest(IOCHAN client, Z_PresentRequest *req)
{
Z_APDU apdu, *apdup;
resp.nextResultSetPosition = &nrr;
resp.presentStatus = &nrr;
-#if 0
- resp.records = diagrec(1, "Waiting for records from Adam. :)");
-#else
- if (!(resp.records = dummy_database_records (*req->resultSetStartPoint,
- *req->numberOfRecordsRequested, &nrr, assoc->preferredMessageSize)))
- resp.records = diagrec (1, "No records from Adam. Sorry");
- printf ("nrr=%d\n", nrr);
-#endif
+ resp.records = diagrec(1, "No records yet.");
if (!z_APDU(assoc->encode, &apdup, 0))
{
- odr_perror(assoc->encode, "Encode init");
+ odr_perror(assoc->encode, "Encode presentres");
return -1;
}
odr_getbuf(assoc->encode, &assoc->encoded_len);
+ odr_reset(assoc->encode);
iochan_setflags(client, EVENT_OUTPUT | EVENT_EXCEPT);
return 0;
}