X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=client%2Fadmin.c;h=1e956dacd0489b7e0b6e9e57bfff4a84ccbe37d4;hp=a2873fac0f96c7326374ef1c06214724fff8e442;hb=e5324215018e129dd19734acd0e683e5af748423;hpb=a6eef2e7073a7295d1a7bf09f538946135a5ebbb diff --git a/client/admin.c b/client/admin.c index a2873fa..1e956da 100644 --- a/client/admin.c +++ b/client/admin.c @@ -1,6 +1,15 @@ /* * $Log: admin.c,v $ - * Revision 1.6 2000-03-20 19:06:25 adam + * Revision 1.9 2001-02-21 13:46:53 adam + * C++ fixes. + * + * Revision 1.8 2000/04/17 14:21:38 adam + * WIN32 update. + * + * Revision 1.7 2000/04/05 07:39:54 adam + * Added shared library support (libtool). + * + * Revision 1.6 2000/03/20 19:06:25 adam * Added Segment request for fronend server. Work on admin for client. * * Revision 1.5 2000/03/17 12:47:02 adam @@ -26,9 +35,15 @@ #include #include #include + +#ifdef WIN32 + +#else #include #include #include +#endif + #include #include @@ -42,15 +57,19 @@ #include +#ifdef ASN_COMPILED + /* Helper functions to get to various statics in the client */ ODR getODROutputStream(); void send_apdu(Z_APDU *a); +extern char *databaseNames[]; +extern int num_databaseNames; - -int sendAdminES(int type, char* dbname, char* param1) +int sendAdminES(int type, char* param1) { ODR out = getODROutputStream(); + char *dbname = odr_strdup (out, databaseNames[0]); /* Type: 1=reindex, 2=truncate, 3=delete, 4=create, 5=import, 6=refresh, 7=commit */ Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest ); @@ -96,8 +115,8 @@ int sendAdminES(int type, char* dbname, char* param1) case Z_ESAdminOriginPartToKeep_truncate: toKeep->u.truncate=odr_nullval(); break; - case Z_ESAdminOriginPartToKeep_delete: - toKeep->u.delete=odr_nullval(); + case Z_ESAdminOriginPartToKeep_drop: + toKeep->u.drop=odr_nullval(); break; case Z_ESAdminOriginPartToKeep_create: toKeep->u.create=odr_nullval(); @@ -105,12 +124,10 @@ int sendAdminES(int type, char* dbname, char* param1) case Z_ESAdminOriginPartToKeep_import: toKeep->u.import = (Z_ImportParameters*)odr_malloc(out, sizeof(*toKeep->u.import)); toKeep->u.import->recordType=param1; - toKeep->databaseName = dbname; /* Need to add additional setup of records here */ break; case Z_ESAdminOriginPartToKeep_refresh: toKeep->u.refresh=odr_nullval(); - toKeep->databaseName = dbname; break; case Z_ESAdminOriginPartToKeep_commit: toKeep->u.commit=odr_nullval(); @@ -137,46 +154,46 @@ int sendAdminES(int type, char* dbname, char* param1) return 0; } -/* cmd_adm_reindex +/* cmd_adm_reindex Ask the specified database to fully reindex itself */ int cmd_adm_reindex(char* arg) { - sendAdminES(Z_ESAdminOriginPartToKeep_reIndex,arg,NULL); + sendAdminES(Z_ESAdminOriginPartToKeep_reIndex, NULL); return 2; } -/* cmd_adm_truncate +/* cmd_adm_truncate Truncate the specified database, removing all records and index entries, but leaving the database & it's explain information intact ready for new records */ int cmd_adm_truncate(char* arg) { if ( arg ) { - sendAdminES(Z_ESAdminOriginPartToKeep_truncate,arg,NULL); + sendAdminES(Z_ESAdminOriginPartToKeep_truncate, NULL); return 2; } return 0; } -/* cmd_adm_create +/* cmd_adm_create Create a new database */ int cmd_adm_create(char* arg) { if ( arg ) { - sendAdminES(Z_ESAdminOriginPartToKeep_create,arg,NULL); + sendAdminES(Z_ESAdminOriginPartToKeep_create, NULL); return 2; } return 0; } -/* cmd_adm_delete - Delete a database */ -int cmd_adm_delete(char* arg) +/* cmd_adm_drop + Drop (Delete) a database */ +int cmd_adm_drop(char* arg) { if ( arg ) { - sendAdminES(Z_ESAdminOriginPartToKeep_delete,arg,NULL); + sendAdminES(Z_ESAdminOriginPartToKeep_drop, NULL); return 2; } return 0; @@ -187,8 +204,14 @@ int cmd_adm_delete(char* arg) N.B. That in this case, the import may contain instructions to delete records as well as new or updates to existing records */ -extern char *databaseNames[]; -extern int num_databaseNames; +#ifdef WIN32 +int cmd_adm_import(char *arg) +{ + printf ("not available on WIN32\n"); + return 0; +} + +#else int cmd_adm_import(char *arg) { @@ -210,8 +233,7 @@ int cmd_adm_import(char *arg) if (!dir) return 0; - sendAdminES(Z_ESAdminOriginPartToKeep_import,*databaseNames, - type_str); + sendAdminES(Z_ESAdminOriginPartToKeep_import, type_str); printf ("sent es request\n"); if ((cp=strrchr(dir_str, '/')) && cp[1] == 0) @@ -232,7 +254,7 @@ int cmd_adm_import(char *arg) { Z_Segment *segment; Z_NamePlusRecord *rec; - Odr_oct *oct = odr_malloc (out, sizeof(*oct)); + Odr_oct *oct = (Odr_oct *) odr_malloc (out, sizeof(*oct)); if (!apdu) { @@ -251,7 +273,7 @@ int cmd_adm_import(char *arg) rec->u.intermediateFragment->u.notExternallyTagged = oct; oct->len = oct->size = status.st_size; - oct->buf = odr_malloc (out, oct->size); + oct->buf = (unsigned char *) odr_malloc (out, oct->size); fread (oct->buf, 1, oct->size, inf); fclose (inf); @@ -266,33 +288,26 @@ int cmd_adm_import(char *arg) } } if (apdu) - { - printf ("sending last packet\n"); send_apdu(apdu); - } apdu = zget_APDU(out, Z_APDU_segmentRequest); - printf ("sending end of sequence packet\n"); send_apdu (apdu); closedir(dir); return 2; } +#endif int cmd_adm_import2(char* arg) { - /* Size of chunks we wish to read from import file */ - size_t chunk_size = 8192; - - /* Buffer for reading chunks of data from import file */ - char chunk_buffer[chunk_size]; + /* Buffer for reading chunks of data from import file */ + char chunk_buffer[8192]; if ( arg ) { - char dbname_buff[32]; char rectype_buff[32]; char filename_buff[32]; FILE* pImportFile = NULL; - if (sscanf (arg, "%s %s %s", dbname_buff, rectype_buff, filename_buff) != 3) + if (sscanf (arg, "%s %s", rectype_buff, filename_buff) != 3) { printf("Must specify database-name, record-type and filename for import\n"); return 0; @@ -310,7 +325,7 @@ int cmd_adm_import2(char* arg) /* We opened the import file without problems... So no we send the es request, ready to start sending fragments of the import file as segment messages */ - sendAdminES(Z_ESAdminOriginPartToKeep_import,arg,rectype_buff); + sendAdminES(Z_ESAdminOriginPartToKeep_import, rectype_buff); while ( ! feof(pImportFile ) ) { @@ -347,7 +362,7 @@ int cmd_adm_refresh(char* arg) { if ( arg ) { - sendAdminES(Z_ESAdminOriginPartToKeep_refresh,arg,NULL); + sendAdminES(Z_ESAdminOriginPartToKeep_refresh, NULL); return 2; } return 0; @@ -357,19 +372,19 @@ int cmd_adm_refresh(char* arg) Make imported records a permenant & visible to the live system */ int cmd_adm_commit(char* arg) { - sendAdminES(Z_ESAdminOriginPartToKeep_commit,NULL,NULL); + sendAdminES(Z_ESAdminOriginPartToKeep_commit, NULL); return 2; } int cmd_adm_shutdown(char* arg) { - sendAdminES(Z_ESAdminOriginPartToKeep_shutdown,NULL,NULL); + sendAdminES(Z_ESAdminOriginPartToKeep_shutdown, NULL); return 2; } int cmd_adm_startup(char* arg) { - sendAdminES(Z_ESAdminOriginPartToKeep_start,NULL,NULL); + sendAdminES(Z_ESAdminOriginPartToKeep_start, NULL); return 2; } - +#endif