- if (!zh->m_group || !*zh->m_group)
- *gprefix = '\0';
- else
- sprintf (gprefix, "%s.", zh->m_group);
-
- yaz_log (YLOG_DEBUG, "fileExtract %s", fname);
-
- /* determine file extension */
- *ext = '\0';
- for (i = strlen(fname); --i >= 0; )
- if (fname[i] == '/')
- break;
- else if (fname[i] == '.')
- {
- strcpy (ext, fname+i+1);
- break;
- }
- /* determine file type - depending on extension */
- original_record_type = zh->m_record_type;
- if (!zh->m_record_type)
- {
- sprintf (ext_res, "%srecordType.%s", gprefix, ext);
- zh->m_record_type = res_get (zh->res, ext_res);
- }
- if (!zh->m_record_type)
- {
- if (zh->records_processed < zh->m_file_verbose_limit)
- yaz_log (YLOG_LOG, "? %s", fname);
- return 0;
- }
- /* determine match criteria */
- if (!zh->m_record_id)
- {
- sprintf (ext_res, "%srecordId.%s", gprefix, ext);
- zh->m_record_id = res_get (zh->res, ext_res);
- }
-
- if (sysno && deleteFlag)
- fd = -1;
- else
- {
- char full_rep[1024];
-
- if (zh->path_reg && !yaz_is_abspath (fname))
- {
- strcpy (full_rep, zh->path_reg);
- strcat (full_rep, "/");
- strcat (full_rep, fname);
- }
- else
- strcpy (full_rep, fname);
-
-
- if ((fd = open (full_rep, O_BINARY|O_RDONLY)) == -1)
- {
- yaz_log (YLOG_WARN|YLOG_ERRNO, "open %s", full_rep);
- zh->m_record_type = original_record_type;
- return 0;
- }
- }
- fi = file_read_start (fd);
- do
- {
- file_begin (fi);
- r = file_extract_record (zh, sysno, fname, deleteFlag, fi, 1);
- } while (r && !sysno && fi->file_more);
- file_read_stop (fi);
- if (fd != -1)
- close (fd);
- zh->m_record_type = original_record_type;
- return r;
-}
-
-/*
- If sysno is provided, then it's used to identify the reocord.
- If not, and match_criteria is provided, then sysno is guessed
- If not, and a record is provided, then sysno is got from there
-
- */
-ZEBRA_RES buffer_extract_record (ZebraHandle zh,
- const char *buf, size_t buf_size,
- int delete_flag,
- int test_mode,
- const char *recordType,
- SYSNO *sysno,
- const char *match_criteria,
- const char *fname,
- int force_update,
- int allow_update)