3 * Revision 1.1 2000-03-14 09:27:07 ian
4 * Added code to enable sending of admin extended service requests
13 #include <yaz/yaz-util.h>
15 #include <yaz/tcpip.h>
17 #include <yaz/xmosi.h>
20 #include <yaz/proto.h>
21 #include <yaz/marcdisp.h>
22 #include <yaz/diagbib1.h>
24 #include <yaz/pquery.h>
27 /* #include <yaz/esadmin.h> */
31 /* Helper functions to get to various statics in the client */
32 ODR getODROutputStream();
33 void send_apdu(Z_APDU *a);
37 int sendAdminES(int type, char* dbname)
39 ODR out = getODROutputStream();
41 /* Type: 1=reindex, 2=truncate, 3=delete, 4=create, 5=import, 6=refresh, 7=commit */
42 Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest );
43 Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
46 Z_ESAdminOriginPartToKeep *toKeep;
47 Z_ESAdminOriginPartNotToKeep *notToKeep;
49 printf ("Admin request\n");
52 update_oid.proto = PROTO_Z3950;
53 update_oid.oclass = CLASS_EXTSERV;
54 update_oid.value = VAL_ADMINSERVICE;
56 oid_ent_to_oid (&update_oid, oid);
57 req->packageType = odr_oiddup(out,oid);
58 req->packageName = "1.Extendedserveq";
60 r = req->taskSpecificParameters = (Z_External *)
61 odr_malloc (out, sizeof(*r));
62 r->direct_reference = odr_oiddup(out,oid);
63 r->indirect_reference = 0;
65 r->which = Z_External_ESAdmin;
66 r->u.adminService = (Z_Admin *) odr_malloc(out, sizeof(*r->u.adminService));
67 r->u.adminService->which = Z_Admin_esRequest;
68 r->u.adminService->u.esRequest = (Z_AdminEsRequest *) odr_malloc(out, sizeof(*r->u.adminService->u.esRequest));
70 toKeep = r->u.adminService->u.esRequest->toKeep = (Z_ESAdminOriginPartToKeep *)
71 odr_malloc(out, sizeof(*r->u.adminService->u.esRequest->toKeep));
76 toKeep->which=Z_ESAdminOriginPartToKeep_reIndex;
77 toKeep->u.reIndex=NULL;
80 toKeep->which=Z_ESAdminOriginPartToKeep_truncate;
81 toKeep->u.truncate=NULL;
84 toKeep->which=Z_ESAdminOriginPartToKeep_delete;
85 toKeep->u.delete=NULL;
88 toKeep->which=Z_ESAdminOriginPartToKeep_create;
89 toKeep->u.create=NULL;
92 toKeep->which=Z_ESAdminOriginPartToKeep_import;
93 toKeep->u.import=NULL;
96 toKeep->which=Z_ESAdminOriginPartToKeep_refresh;
97 toKeep->u.refresh=NULL;
100 toKeep->which=Z_ESAdminOriginPartToKeep_commit;
101 toKeep->u.commit=NULL;
106 notToKeep = r->u.adminService->u.esRequest->notToKeep = (Z_ESAdminOriginPartNotToKeep *)
107 odr_malloc(out, sizeof(*r->u.adminService->u.esRequest->notToKeep));
108 notToKeep->which=Z_ESAdminOriginPartNotToKeep_recordsWillFollow;
109 notToKeep->u.recordsWillFollow=NULL;
116 /* cmd_adm_reindex <dbname>
117 Ask the specified database to fully reindex itself */
118 int cmd_adm_reindex(char* arg)
123 /* cmd_adm_truncate <dbname>
124 Truncate the specified database, removing all records and index entries, but leaving
125 the database & it's explain information intact ready for new records */
126 int cmd_adm_truncate(char* arg)
131 /* cmd_adm_create <dbname>
132 Create a new database */
133 int cmd_adm_create(char* arg)
138 /* cmd_adm_delete <dbname>
140 int cmd_adm_delete(char* arg)
145 /* cmd_adm_import <dbname> <rectype> <sourcefile>
146 Import the specified updated into the database
147 N.B. That in this case, the import may contain instructions to delete records as well as new or updates
148 to existing records */
149 int cmd_adm_import(char* arg)
154 /* "Freshen" the specified database, by checking metadata records against the sources from which they were
155 generated, and creating a new record if the source has been touched since the last extraction */
156 int cmd_adm_refresh(char* arg)
162 Make imported records a permenant & visible to the live system */
163 int cmd_adm_commit(char* arg)