1ff2e18ba5e50dd2d1becd3cd6a25343578c10b8 markd Tue Apr 21 14:09:04 2026 -0700 rework of htslib/UDC integration to use htslib hfile driver mechanism diff --git src/lib/knetUdc.c src/lib/knetUdc.c index a6482168006..a31efe5a33f 100644 --- src/lib/knetUdc.c +++ src/lib/knetUdc.c @@ -1,83 +1,18 @@ -/* knetUdc -- install udc i/o functions in knetfile interface in samtools. */ -/* As of 2/23/10, the KNETFILE_HOOKS extension is a UCSC-local modification of samtools. */ +/* knetUdc -- legacy shim, now delegates to hfile UDC backend. + * The old knetfile hook mechanism is no longer supported by htslib. + * This stub keeps existing callers of knetUdcInstall() compiling + * while UDC I/O is handled by the hfile scheme handler in hfileUdc.c. */ /* Copyright (C) 2014 The Regents of the University of California * See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */ - #include "common.h" -#include "udc.h" #include "knetUdc.h" -#include "htslib/knetfile.h" - -static char *udcCacheDir = NULL; - -static knetFile *kuOpen(const char *filename, const char *mode) -/* Open the given filename with mode which must be "r". */ -{ -if (!(sameOk((char *)mode, "r") || sameOk((char *)mode, "rb"))) - errAbort("mode passed to kuOpen must be 'r' or 'rb' not '%s'", mode); -struct udcFile *udcf = udcFileMayOpen((char *)filename, udcCacheDir); -if (udcf == NULL) - return NULL; -knetFile *kf = NULL; -AllocVar(kf); -kf->udcf = udcf; -verbose(2, "kuOpen: returning %lu\n", (unsigned long)(kf->udcf)); -return kf; -} - -static knetFile *kuDopen(int fd, const char *mode) -/* Open from a file descriptor -- not necessary for our use of samtools. */ -{ -errAbort("kuDopen not implemented"); -return NULL; -} - -static off_t kuRead(knetFile *fp, void *buf, off_t len) -/* Read len bytes into buf, return amount actually read. */ -{ -verbose(2, "udcRead(%lu, buf, %lld)\n", (unsigned long)(fp->udcf), (long long)len); -return (off_t)udcRead(fp->udcf, buf, (int)len); -} - -static off_t kuSeek(knetFile *fp, int64_t off, int whence) -/* Seek to off according to whence (but don't waste time with samtools' SEEK_END to - * check empty record at end of file. Don't be fooled by the off_t return type -- - * it's 0 for OK, non-0 for fail. */ -{ -bits64 offset; -if (whence == SEEK_SET) - offset = off; -else if (whence == SEEK_CUR) - offset = off+ udcTell(fp->udcf); -else - return -1; -verbose(2, "udcSeek(%lu, %lld)\n", (unsigned long)(fp->udcf), offset); -udcSeek(fp->udcf, offset); -return 0; -} - -static off_t kuTell(knetFile *fp) -/* Tell current offset in file. */ -{ -verbose(2, "udcTell(%lu)\n", (unsigned long)(fp->udcf)); -return udcTell(fp->udcf); -} - -static int kuClose(knetFile *fp) -/* Close and free fp->udcf. */ -{ -verbose(2, "udcClose(%lu)\n", (unsigned long)(fp->udcf)); -udcFileClose(&(fp->udcf)); -return 0; -} +#include "hfileUdc.h" void knetUdcInstall() -/* install udc i/o functions in knetfile interface in Heng Li's samtools lib. */ +/* Install UDC I/O via hfile backend. Legacy wrapper — new code should + * call hfileUdcInstall() directly. */ { -// maybe init udcCacheDir from hg.conf? -knet_init_alt(kuOpen, kuDopen, kuRead, kuSeek, kuTell, kuClose); +hfileUdcInstall(); } \ No newline at end of file - -