- /* 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];
-
- 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)
- {
- printf("Must specify database-name, record-type and filename for import\n");
- return 0;
- }
-
- /* Attempt to open the file */
-
- pImportFile = fopen(filename_buff,"r");
-
- /* This chunk of code should move into client.c sometime soon for sending files via the update es */
- /* This function will then refer to the standard client.c one for uploading a file using es update */
- if ( pImportFile )
- {
- int iTotalWritten = 0;
-
- /* 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);
-
- while ( ! feof(pImportFile ) )
- {
- /* Read buffer_size bytes from the file */
- size_t num_items = fread((void*)chunk_buffer, 1, sizeof(chunk_buffer), pImportFile);
-
- /* Write num_bytes of data to */
-
- if ( feof(pImportFile ) )
- {
- /* This is the last chunk... Write it as the last fragment */
- printf("Last segment of %d bytes\n", num_items);
- }
- else if ( iTotalWritten == 0 )
- {
- printf("First segment of %d bytes\n",num_items);
- }
- else
- {
- printf("Writing %d bytes\n", num_items);
- }
-
- iTotalWritten += num_items;
- }
- }
- return 2;
- }