3 * Revision 1.3 2000-03-14 15:23:17 ian
4 * Removed unwanted ifdef and include of zes-admin.h
6 * Revision 1.2 2000/03/14 14:06:04 ian
7 * Minor change to order of debugging output for send_apdu,
8 * fixed encoding of admin request.
10 * Revision 1.1 2000/03/14 09:27:07 ian
11 * Added code to enable sending of admin extended service requests
20 #include <yaz/yaz-util.h>
22 #include <yaz/tcpip.h>
24 #include <yaz/xmosi.h>
27 #include <yaz/proto.h>
28 #include <yaz/marcdisp.h>
29 #include <yaz/diagbib1.h>
31 #include <yaz/pquery.h>
33 /* Helper functions to get to various statics in the client */
34 ODR getODROutputStream();
35 void send_apdu(Z_APDU *a);
39 int sendAdminES(int type, char* dbname)
41 ODR out = getODROutputStream();
43 /* Type: 1=reindex, 2=truncate, 3=delete, 4=create, 5=import, 6=refresh, 7=commit */
44 Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest );
45 Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
48 Z_ESAdminOriginPartToKeep *toKeep;
49 Z_ESAdminOriginPartNotToKeep *notToKeep;
51 printf ("Admin request\n");
54 /* Set up the OID for the external */
55 update_oid.proto = PROTO_Z3950;
56 update_oid.oclass = CLASS_EXTSERV;
57 update_oid.value = VAL_ADMINSERVICE;
59 oid_ent_to_oid (&update_oid, oid);
60 req->packageType = odr_oiddup(out,oid);
61 req->packageName = "1.Extendedserveq";
63 /* Allocate the external */
64 r = req->taskSpecificParameters = (Z_External *) odr_malloc (out, sizeof(*r));
65 r->direct_reference = odr_oiddup(out,oid);
66 r->indirect_reference = 0;
68 r->which = Z_External_ESAdmin;
69 r->u.adminService = (Z_Admin *) odr_malloc(out, sizeof(*r->u.adminService));
70 r->u.adminService->which = Z_Admin_esRequest;
71 r->u.adminService->u.esRequest = (Z_AdminEsRequest *) odr_malloc(out, sizeof(*r->u.adminService->u.esRequest));
73 toKeep = r->u.adminService->u.esRequest->toKeep = (Z_ESAdminOriginPartToKeep *)
74 odr_malloc(out, sizeof(*r->u.adminService->u.esRequest->toKeep));
79 toKeep->which=Z_ESAdminOriginPartToKeep_reIndex;
80 toKeep->u.reIndex=odr_nullval();
83 toKeep->which=Z_ESAdminOriginPartToKeep_truncate;
84 toKeep->u.truncate=odr_nullval();
87 toKeep->which=Z_ESAdminOriginPartToKeep_delete;
88 toKeep->u.delete=odr_nullval();
91 toKeep->which=Z_ESAdminOriginPartToKeep_create;
92 toKeep->u.create=odr_nullval();
95 toKeep->which=Z_ESAdminOriginPartToKeep_import;
96 toKeep->u.import=odr_nullval();
99 toKeep->which=Z_ESAdminOriginPartToKeep_refresh;
100 toKeep->u.refresh=odr_nullval();
103 toKeep->which=Z_ESAdminOriginPartToKeep_commit;
104 toKeep->u.commit=odr_nullval();
108 toKeep->databaseName = dbname;
111 notToKeep = r->u.adminService->u.esRequest->notToKeep = (Z_ESAdminOriginPartNotToKeep *)
112 odr_malloc(out, sizeof(*r->u.adminService->u.esRequest->notToKeep));
113 notToKeep->which=Z_ESAdminOriginPartNotToKeep_recordsWillFollow;
114 notToKeep->u.recordsWillFollow=odr_nullval();
121 /* cmd_adm_reindex <dbname>
122 Ask the specified database to fully reindex itself */
123 int cmd_adm_reindex(char* arg)
128 /* cmd_adm_truncate <dbname>
129 Truncate the specified database, removing all records and index entries, but leaving
130 the database & it's explain information intact ready for new records */
131 int cmd_adm_truncate(char* arg)
136 /* cmd_adm_create <dbname>
137 Create a new database */
138 int cmd_adm_create(char* arg)
143 /* cmd_adm_delete <dbname>
145 int cmd_adm_delete(char* arg)
150 /* cmd_adm_import <dbname> <rectype> <sourcefile>
151 Import the specified updated into the database
152 N.B. That in this case, the import may contain instructions to delete records as well as new or updates
153 to existing records */
154 int cmd_adm_import(char* arg)
159 /* "Freshen" the specified database, by checking metadata records against the sources from which they were
160 generated, and creating a new record if the source has been touched since the last extraction */
161 int cmd_adm_refresh(char* arg)
167 Make imported records a permenant & visible to the live system */
168 int cmd_adm_commit(char* arg)