3 * Revision 1.2 2000-03-14 14:06:04 ian
4 * Minor change to order of debugging output for send_apdu,
5 * fixed encoding of admin request.
7 * Revision 1.1 2000/03/14 09:27:07 ian
8 * Added code to enable sending of admin extended service requests
17 #include <yaz/yaz-util.h>
19 #include <yaz/tcpip.h>
21 #include <yaz/xmosi.h>
24 #include <yaz/proto.h>
25 #include <yaz/marcdisp.h>
26 #include <yaz/diagbib1.h>
28 #include <yaz/pquery.h>
31 /* #include <yaz/esadmin.h> */
35 /* Helper functions to get to various statics in the client */
36 ODR getODROutputStream();
37 void send_apdu(Z_APDU *a);
41 int sendAdminES(int type, char* dbname)
43 ODR out = getODROutputStream();
45 /* Type: 1=reindex, 2=truncate, 3=delete, 4=create, 5=import, 6=refresh, 7=commit */
46 Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest );
47 Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
50 Z_ESAdminOriginPartToKeep *toKeep;
51 Z_ESAdminOriginPartNotToKeep *notToKeep;
53 printf ("Admin request\n");
56 /* Set up the OID for the external */
57 update_oid.proto = PROTO_Z3950;
58 update_oid.oclass = CLASS_EXTSERV;
59 update_oid.value = VAL_ADMINSERVICE;
61 oid_ent_to_oid (&update_oid, oid);
62 req->packageType = odr_oiddup(out,oid);
63 req->packageName = "1.Extendedserveq";
65 /* Allocate the external */
66 r = req->taskSpecificParameters = (Z_External *) odr_malloc (out, sizeof(*r));
67 r->direct_reference = odr_oiddup(out,oid);
68 r->indirect_reference = 0;
70 r->which = Z_External_ESAdmin;
71 r->u.adminService = (Z_Admin *) odr_malloc(out, sizeof(*r->u.adminService));
72 r->u.adminService->which = Z_Admin_esRequest;
73 r->u.adminService->u.esRequest = (Z_AdminEsRequest *) odr_malloc(out, sizeof(*r->u.adminService->u.esRequest));
75 toKeep = r->u.adminService->u.esRequest->toKeep = (Z_ESAdminOriginPartToKeep *)
76 odr_malloc(out, sizeof(*r->u.adminService->u.esRequest->toKeep));
81 toKeep->which=Z_ESAdminOriginPartToKeep_reIndex;
82 toKeep->u.reIndex=odr_nullval();
85 toKeep->which=Z_ESAdminOriginPartToKeep_truncate;
86 toKeep->u.truncate=odr_nullval();
89 toKeep->which=Z_ESAdminOriginPartToKeep_delete;
90 toKeep->u.delete=odr_nullval();
93 toKeep->which=Z_ESAdminOriginPartToKeep_create;
94 toKeep->u.create=odr_nullval();
97 toKeep->which=Z_ESAdminOriginPartToKeep_import;
98 toKeep->u.import=odr_nullval();
101 toKeep->which=Z_ESAdminOriginPartToKeep_refresh;
102 toKeep->u.refresh=odr_nullval();
105 toKeep->which=Z_ESAdminOriginPartToKeep_commit;
106 toKeep->u.commit=odr_nullval();
110 toKeep->databaseName = dbname;
113 notToKeep = r->u.adminService->u.esRequest->notToKeep = (Z_ESAdminOriginPartNotToKeep *)
114 odr_malloc(out, sizeof(*r->u.adminService->u.esRequest->notToKeep));
115 notToKeep->which=Z_ESAdminOriginPartNotToKeep_recordsWillFollow;
116 notToKeep->u.recordsWillFollow=odr_nullval();
123 /* cmd_adm_reindex <dbname>
124 Ask the specified database to fully reindex itself */
125 int cmd_adm_reindex(char* arg)
130 /* cmd_adm_truncate <dbname>
131 Truncate the specified database, removing all records and index entries, but leaving
132 the database & it's explain information intact ready for new records */
133 int cmd_adm_truncate(char* arg)
138 /* cmd_adm_create <dbname>
139 Create a new database */
140 int cmd_adm_create(char* arg)
145 /* cmd_adm_delete <dbname>
147 int cmd_adm_delete(char* arg)
152 /* cmd_adm_import <dbname> <rectype> <sourcefile>
153 Import the specified updated into the database
154 N.B. That in this case, the import may contain instructions to delete records as well as new or updates
155 to existing records */
156 int cmd_adm_import(char* arg)
161 /* "Freshen" the specified database, by checking metadata records against the sources from which they were
162 generated, and creating a new record if the source has been touched since the last extraction */
163 int cmd_adm_refresh(char* arg)
169 Make imported records a permenant & visible to the live system */
170 int cmd_adm_commit(char* arg)