Revision: 75727
          http://sourceforge.net/p/brlcad/code/75727
Author:   starseeker
Date:     2020-05-07 15:11:51 +0000 (Thu, 07 May 2020)
Log Message:
-----------
Put back the libbu wrappers - looking like whether the define trick succeeds is 
sensitive to header ordering and compile language, which is Not Good...

Modified Paths:
--------------
    brlcad/branches/bioh/include/bu/file.h
    brlcad/branches/bioh/include/common.h
    brlcad/branches/bioh/src/conv/asc/asc2g.c
    brlcad/branches/bioh/src/conv/conv-vg2g.c
    brlcad/branches/bioh/src/conv/dxf/dxf-g.c
    brlcad/branches/bioh/src/conv/fast4-g.c
    brlcad/branches/bioh/src/conv/g-acad.c
    brlcad/branches/bioh/src/conv/iges/findp.c
    brlcad/branches/bioh/src/conv/iges/g-iges.c
    brlcad/branches/bioh/src/conv/iges/n_iges.cpp
    brlcad/branches/bioh/src/conv/iges/n_iges.hpp
    brlcad/branches/bioh/src/conv/iges/readrec.c
    brlcad/branches/bioh/src/conv/iges/recsize.c
    brlcad/branches/bioh/src/conv/nastran-g.c
    brlcad/branches/bioh/src/conv/shp/shapelib/shpopen.c
    brlcad/branches/bioh/src/conv/stl/g-stl.c
    brlcad/branches/bioh/src/conv/vdeck/vdeck.c
    brlcad/branches/bioh/src/fb/bw-fb.c
    brlcad/branches/bioh/src/fb/pix-fb.c
    brlcad/branches/bioh/src/libbu/file.c
    brlcad/branches/bioh/src/libbu/vfont.c
    brlcad/branches/bioh/src/libdm/fontstash/fontstash.h
    brlcad/branches/bioh/src/libfb/fb_generic.c
    brlcad/branches/bioh/src/libfb/if_X24.c
    brlcad/branches/bioh/src/libfb/if_disk.c
    brlcad/branches/bioh/src/libgcv/plugins/fastgen4/fastgen4_read.c
    brlcad/branches/bioh/src/libgcv/plugins/stl/stl_write.c
    brlcad/branches/bioh/src/libged/bot_dump.c
    brlcad/branches/bioh/src/libged/tables.c
    brlcad/branches/bioh/src/libicv/rot.c
    brlcad/branches/bioh/src/librt/db5_scan.c
    brlcad/branches/bioh/src/librt/db_corrupt.c
    brlcad/branches/bioh/src/librt/db_io.c
    brlcad/branches/bioh/src/librt/db_scan.c
    brlcad/branches/bioh/src/librt/primitives/primitive_util.c
    brlcad/branches/bioh/src/remrt/remrt.c
    brlcad/branches/bioh/src/rt/do.c
    brlcad/branches/bioh/src/rt/view.c
    brlcad/branches/bioh/src/util/ap-pix.c
    brlcad/branches/bioh/src/util/bwcrop.c
    brlcad/branches/bioh/src/util/bwhisteq.c
    brlcad/branches/bioh/src/util/bwrot.c
    brlcad/branches/bioh/src/util/bwscale.c
    brlcad/branches/bioh/src/util/dpix-pix.c
    brlcad/branches/bioh/src/util/pixbustup.c
    brlcad/branches/bioh/src/util/pixcrop.c
    brlcad/branches/bioh/src/util/pixrot.c
    brlcad/branches/bioh/src/util/pixscale.c
    brlcad/branches/bioh/src/util/plot3rot.c

Modified: brlcad/branches/bioh/include/bu/file.h
===================================================================
--- brlcad/branches/bioh/include/bu/file.h      2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/include/bu/file.h      2020-05-07 15:11:51 UTC (rev 
75727)
@@ -164,6 +164,16 @@
  */
 BU_EXPORT extern char *bu_file_realpath(const char *path, char *resolved_path);
 
+/**
+ * Windows corecrt_io.h defines an lseek and an _lseeki64, with different 
function
+ * signatures, that cause trouble when we try to simply #define lseek 
_lseeki64.
+ *
+ * Similarly, _ftelli64 has a problematic signature.
+ */
+BU_EXPORT int bu_fseek(FILE *stream, b_off_t offset, int origin);
+BU_EXPORT b_off_t bu_lseek(int fd, b_off_t offset, int whence);
+BU_EXPORT b_off_t bu_ftell(FILE *stream);
+
 /** @} */
 
 __END_DECLS

Modified: brlcad/branches/bioh/include/common.h
===================================================================
--- brlcad/branches/bioh/include/common.h       2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/include/common.h       2020-05-07 15:11:51 UTC (rev 
75727)
@@ -211,16 +211,12 @@
 #if defined(_WIN64)
 #  include <sys/stat.h>
 #  define b_off_t __int64
-#  define fseek _fseeki64
-#  define ftell _ftelli64
 #  define fstat _fstati64
-#  define lseek _lseeki64
 #  define stat  _stati64
 #elif defined (_WIN32)
 #  include <sys/stat.h>
 #  define b_off_t _off_t
 #  define fstat _fstat
-#  define lseek _lseek
 #  define stat  _stat
 #else
 #  define b_off_t off_t

Modified: brlcad/branches/bioh/src/conv/asc/asc2g.c
===================================================================
--- brlcad/branches/bioh/src/conv/asc/asc2g.c   2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/conv/asc/asc2g.c   2020-05-07 15:11:51 UTC (rev 
75727)
@@ -1049,7 +1049,7 @@
     name = bu_strdup(cp);
 
     /* Count up the number of poly data lines which follow */
-    startpos = ftell(ifp);
+    startpos = bu_ftell(ifp);
     for (nlines = 0;; nlines++) {
        if (bu_fgets(buf, BUFSIZE, ifp) == NULL) break;
        if (buf[0] != ID_P_DATA) break; /* 'Q' */
@@ -1065,7 +1065,7 @@
     pg->max_npts = 0;
 
     /* Return to first 'Q' record */
-    fseek(ifp, startpos, 0);
+    bu_fseek(ifp, startpos, 0);
 
     for (nlines = 0; nlines < pg->npoly; nlines++) {
        struct rt_pg_face_internal *fp = &pg->poly[nlines];

Modified: brlcad/branches/bioh/src/conv/conv-vg2g.c
===================================================================
--- brlcad/branches/bioh/src/conv/conv-vg2g.c   2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/conv/conv-vg2g.c   2020-05-07 15:11:51 UTC (rev 
75727)
@@ -107,7 +107,7 @@
            bu_strlcpy(rec.i.i_version, ID_VERSION, sizeof(rec.i.i_version));
        }
     } else {
-       lseek(ifd, 0, 0);
+       bu_lseek(ifd, 0, 0);
        /* have an old vged file to convert */
 
        /* units are important now because:
@@ -206,7 +206,7 @@
            case ID_ARS_A:
                if (rec.a.a_name[0] == '\0') {
                    /* Skip deleted junk */
-                   lseek(ifd, (b_off_t)(rec.a.a_totlen * sizeof(rec)), 1);
+                   bu_lseek(ifd, (b_off_t)(rec.a.a_totlen * sizeof(rec)), 1);
                    goto top;
                }
                rec.a.a_xmin *= factor;

Modified: brlcad/branches/bioh/src/conv/dxf/dxf-g.c
===================================================================
--- brlcad/branches/bioh/src/conv/dxf/dxf-g.c   2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/conv/dxf/dxf-g.c   2020-05-07 15:11:51 UTC (rev 
75727)
@@ -629,7 +629,7 @@
            } else if (!bu_strncmp(line, "BLOCK", 5)) {
                /* start of a new block */
                BU_ALLOC(curr_block, struct block_list);
-               curr_block->offset = ftell(dxf);
+               curr_block->offset = bu_ftell(dxf);
                BU_LIST_INSERT(&(block_head), &(curr_block->l));
                break;
            }
@@ -1109,7 +1109,7 @@
                    break;
                }
                bu_free((char *)tmp_state, "curr_state");
-               fseek(dxf, curr_state->file_offset, SEEK_SET);
+               bu_fseek(dxf, curr_state->file_offset, SEEK_SET);
                curr_state->sub_state = UNKNOWN_ENTITY_STATE;
                if (verbose) {
                    bu_log("Popped state at end of inserted block (seeked to 
%jd)\n", (intmax_t)curr_state->file_offset);
@@ -1223,7 +1223,7 @@
                BU_LIST_PUSH(&state_stack, &(curr_state->l));
                curr_state = new_state;
                new_state = NULL;
-               fseek(dxf, curr_state->curr_block->offset, SEEK_SET);
+               bu_fseek(dxf, curr_state->curr_block->offset, SEEK_SET);
                curr_state->state = ENTITIES_SECTION;
                curr_state->sub_state = UNKNOWN_ENTITY_STATE;
                if (verbose) {
@@ -2504,7 +2504,7 @@
                    BU_LIST_PUSH(&state_stack, &(curr_state->l));
                    curr_state = new_state;
                    new_state = NULL;
-                   fseek(dxf, curr_state->curr_block->offset, SEEK_SET);
+                   bu_fseek(dxf, curr_state->curr_block->offset, SEEK_SET);
                    curr_state->state = ENTITIES_SECTION;
                    curr_state->sub_state = UNKNOWN_ENTITY_STATE;
                    if (verbose) {
@@ -3083,7 +3083,7 @@
     size_t line_len;
     static int line_num = 0;
 
-    curr_state->file_offset = ftell(dxf);
+    curr_state->file_offset = bu_ftell(dxf);
 
     if (bu_fgets(line, MAX_LINE_SIZE, dxf) == NULL) {
        return ERROR_FLAG;

Modified: brlcad/branches/bioh/src/conv/fast4-g.c
===================================================================
--- brlcad/branches/bioh/src/conv/fast4-g.c     2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/conv/fast4-g.c     2020-05-07 15:11:51 UTC (rev 
75727)
@@ -2065,7 +2065,7 @@
     b_off_t section_start;
 
     /* skip to start of next section */
-    section_start = ftell(fpin);
+    section_start = bu_ftell(fpin);
     if (section_start < 0) {
        bu_exit(1, "Error: couldn't get input file's current file position.\n");
     }
@@ -2076,7 +2076,7 @@
               bu_strncmp(line, "WALL", 4) &&
               bu_strncmp(line, "VEHICLE", 7))
        {
-           section_start = ftell(fpin);
+           section_start = bu_ftell(fpin);
            if (section_start < 0) {
                bu_exit(1, "Error: couldn't get input file's current file 
position.\n");
            }
@@ -2085,7 +2085,7 @@
        }
     }
     /* seek to start of the section */
-    fseek(fpin, section_start, SEEK_SET);
+    bu_fseek(fpin, section_start, SEEK_SET);
 }
 
 

Modified: brlcad/branches/bioh/src/conv/g-acad.c
===================================================================
--- brlcad/branches/bioh/src/conv/g-acad.c      2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/conv/g-acad.c      2020-05-07 15:11:51 UTC (rev 
75727)
@@ -649,7 +649,7 @@
     /* Write out number of facet entities to .facet file */
 
     rewind(fp);
-    fseek(fp, 46, 0); /* Re-position pointer to 2nd line */
+    bu_fseek(fp, 46, 0); /* Re-position pointer to 2nd line */
     fprintf(fp, "%d\n", regions_written); /* Write out number of regions */
     fclose(fp);
 

Modified: brlcad/branches/bioh/src/conv/iges/findp.c
===================================================================
--- brlcad/branches/bioh/src/conv/iges/findp.c  2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/conv/iges/findp.c  2020-05-07 15:11:51 UTC (rev 
75727)
@@ -44,13 +44,13 @@
 
     saverec = currec;  /* save current record number */
 
-    if (fseek(fd, 0, 2)) {
+    if (bu_fseek(fd, 0, 2)) {
        /* go to end of file */
        bu_log("Cannot seek to end of file\n");
        perror("Findp");
        bu_exit(1, NULL);
     }
-    offset = ftell(fd);        /* get file length */
+    offset = bu_ftell(fd);     /* get file length */
     rec2 = offset/reclen;      /* calculate record number for last record */
     Readrec(rec2);     /* read last record into "card" buffer */
     dstart = 0;

Modified: brlcad/branches/bioh/src/conv/iges/g-iges.c
===================================================================
--- brlcad/branches/bioh/src/conv/iges/g-iges.c 2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/conv/iges/g-iges.c 2020-05-07 15:11:51 UTC (rev 
75727)
@@ -402,7 +402,7 @@
 
     if (!multi_file) {
        /* Copy the parameter section from the temporary file to the output 
file */
-       if ((fseek(fp_param, 0, 0))) {
+       if ((bu_fseek(fp_param, 0, 0))) {
            perror("g-iges");
            bu_exit(1, "Cannot seek to start of temporary file\n");
        }
@@ -619,7 +619,7 @@
            char copy_buffer[CP_BUF_SIZE] = {0};
 
            /* Copy the parameter section from the temporary file to the output 
file */
-           if ((fseek(fp_param, 0, 0))) {
+           if ((bu_fseek(fp_param, 0, 0))) {
                perror("g-iges");
                bu_exit(1, "Cannot seek to start of temporary file\n");
            }

Modified: brlcad/branches/bioh/src/conv/iges/n_iges.cpp
===================================================================
--- brlcad/branches/bioh/src/conv/iges/n_iges.cpp       2020-05-07 14:40:30 UTC 
(rev 75726)
+++ brlcad/branches/bioh/src/conv/iges/n_iges.cpp       2020-05-07 15:11:51 UTC 
(rev 75727)
@@ -206,7 +206,7 @@
     if (k == (-1))     /* We didn't encounter an early EOF */
        k = NRECS;
 
-    if (fseek(in, 0, SEEK_SET)) {
+    if (bu_fseek(in, 0, SEEK_SET)) {
        /* rewind file */
        perror("Recsize");
        bu_exit(-1, "Cannot rewind file\n");
@@ -228,7 +228,7 @@
 
 Record::Record(FILE* in) : _fp(in) {
     if (_reclen < 0) calcRecsize(in); // FIXME: ...
-    _start = ftell(in);
+    _start = bu_ftell(in);
     _read();
 }
 
@@ -235,9 +235,9 @@
 
 Record::Record(FILE* in, int paramStart, int record) : _fp(in) {
     if (_reclen < 0) calcRecsize(in);
-    _start = ftell(in);
+    _start = bu_ftell(in);
     int pos = (record-1)*_reclen;
-    fseek(_fp, paramStart + pos, SEEK_SET);
+    bu_fseek(_fp, paramStart + pos, SEEK_SET);
     _read();
 }
 
@@ -262,7 +262,7 @@
 
 void
 Record::_undoRead(int numLines) {
-    fseek(_fp, -(numLines * _reclen), SEEK_CUR);
+    bu_fseek(_fp, -(numLines * _reclen), SEEK_CUR);
 }
 
 

Modified: brlcad/branches/bioh/src/conv/iges/n_iges.hpp
===================================================================
--- brlcad/branches/bioh/src/conv/iges/n_iges.hpp       2020-05-07 14:40:30 UTC 
(rev 75726)
+++ brlcad/branches/bioh/src/conv/iges/n_iges.hpp       2020-05-07 15:11:51 UTC 
(rev 75727)
@@ -359,8 +359,8 @@
     bool isParameter() { return _type == 'P'; }
     bool isTerminal() { return _type == 'T'; }
     // reset the stream to the start of this record
-    void reset() { fseek(_fp, _start, SEEK_SET); }
-    long where() { return ftell(_fp); }
+    void reset() { bu_fseek(_fp, _start, SEEK_SET); }
+    long where() { return bu_ftell(_fp); }
 
     GlobalSection* createGlobalSection();
     void createDirectory(vector<DirectoryEntry*>& dir);

Modified: brlcad/branches/bioh/src/conv/iges/readrec.c
===================================================================
--- brlcad/branches/bioh/src/conv/iges/readrec.c        2020-05-07 14:40:30 UTC 
(rev 75726)
+++ brlcad/branches/bioh/src/conv/iges/readrec.c        2020-05-07 15:11:51 UTC 
(rev 75727)
@@ -44,7 +44,7 @@
 
     currec = recno;
     offset = (recno - 1) * reclen;
-    if (fseek(fd, offset, 0)) {
+    if (bu_fseek(fd, offset, 0)) {
        bu_log("Error in seek\n");
        perror("Readrec");
        bu_exit(1, NULL);

Modified: brlcad/branches/bioh/src/conv/iges/recsize.c
===================================================================
--- brlcad/branches/bioh/src/conv/iges/recsize.c        2020-05-07 14:40:30 UTC 
(rev 75726)
+++ brlcad/branches/bioh/src/conv/iges/recsize.c        2020-05-07 15:11:51 UTC 
(rev 75727)
@@ -68,7 +68,7 @@
     if (k == (-1))     /* We didn't encounter an early EOF */
        k = NRECS;
 
-    if (fseek(fd, 0, 0)) {
+    if (bu_fseek(fd, 0, 0)) {
        /* rewind file */
        bu_log("Cannot rewind file\n");
        perror("Recsize");

Modified: brlcad/branches/bioh/src/conv/nastran-g.c
===================================================================
--- brlcad/branches/bioh/src/conv/nastran-g.c   2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/conv/nastran-g.c   2020-05-07 15:11:51 UTC (rev 
75727)
@@ -161,7 +161,7 @@
     for (i=0; i < 20; i++)
        prev_rec[i][0] = '\0';
 
-    fseek(fpin, start_off, SEEK_SET);
+    bu_fseek(fpin, start_off, SEEK_SET);
     line_count = bulk_data_start_line;
 
     tmp = bu_fgets(next_line, MAX_LINE_SIZE, fpin);
@@ -1193,7 +1193,7 @@
        if (bu_strncmp(line, "BEGIN BULK", 10))
            continue;
 
-       start_off = ftell(fpin);
+       start_off = bu_ftell(fpin);
        break;
     }
 
@@ -1219,7 +1219,7 @@
     nmg_model = (struct model *)NULL;
 
     /* count grid points */
-    fseek(fptmp, 0, SEEK_SET);
+    bu_fseek(fptmp, 0, SEEK_SET);
     while (bu_fgets(line, MAX_LINE_SIZE, fptmp)) {
        if (!bu_strncmp(line, "GRID", 4))
            grid_count++;
@@ -1229,7 +1229,7 @@
     }
 
     /* get default values and properties */
-    fseek(fptmp, 0, SEEK_SET);
+    bu_fseek(fptmp, 0, SEEK_SET);
     while (get_next_record(fptmp, 1, 0)) {
        if (!bu_strncmp(curr_rec[0], "BAROR", 5)) {
            /* get BAR defaults */
@@ -1262,7 +1262,7 @@
     g_pts = (struct grid_point *)bu_calloc(grid_count, sizeof(struct 
grid_point), "grid points");
 
     /* get all grid points */
-    fseek(fptmp, 0, SEEK_SET);
+    bu_fseek(fptmp, 0, SEEK_SET);
     while (get_next_record(fptmp, 1, 0)) {
        int gid;
        int cid;
@@ -1287,7 +1287,7 @@
 
 
     /* find coordinate systems */
-    fseek(fptmp, 0, SEEK_SET);
+    bu_fseek(fptmp, 0, SEEK_SET);
     while (get_next_record(fptmp, 1, 0)) {
        if (bu_strncmp(curr_rec[0], "CORD", 4))
            continue;
@@ -1306,7 +1306,7 @@
     mk_id(fpout, nastran_file);
 
     /* get elements */
-    fseek(fptmp, 0, SEEK_SET);
+    bu_fseek(fptmp, 0, SEEK_SET);
     while (get_next_record(fptmp, 1, 0)) {
        if (!bu_strncmp(curr_rec[0], "CBAR", 4))
            get_cbar();

Modified: brlcad/branches/bioh/src/conv/shp/shapelib/shpopen.c
===================================================================
--- brlcad/branches/bioh/src/conv/shp/shapelib/shpopen.c        2020-05-07 
14:40:30 UTC (rev 75726)
+++ brlcad/branches/bioh/src/conv/shp/shapelib/shpopen.c        2020-05-07 
15:11:51 UTC (rev 75727)
@@ -1596,7 +1596,7 @@
         */
        char str[128];
        sprintf( str,
-                "Error in fseek() reading object from .shp file at offset %u",
+                "Error in bu_fseek() reading object from .shp file at offset 
%u",
                 psSHP->panRecOffset[hEntity]);
 
        psSHP->sHooks.Error( str );

Modified: brlcad/branches/bioh/src/conv/stl/g-stl.c
===================================================================
--- brlcad/branches/bioh/src/conv/stl/g-stl.c   2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/conv/stl/g-stl.c   2020-05-07 15:11:51 UTC (rev 
75727)
@@ -283,7 +283,7 @@
            unsigned char tot_buffer[4];
 
            /* Re-position pointer to 80th byte */
-           lseek(bfd, 80, SEEK_SET);
+           bu_lseek(bfd, 80, SEEK_SET);
 
            /* Write out number of triangles */
            *(uint32_t *)tot_buffer = htonl((unsigned long)region_polys);
@@ -499,7 +499,7 @@
            unsigned char tot_buffer[4];
 
            /* Re-position pointer to 80th byte */
-           lseek(bfd, 80, SEEK_SET);
+           bu_lseek(bfd, 80, SEEK_SET);
 
            /* Write out number of triangles */
            *(uint32_t *)tot_buffer = htonl((unsigned long)tot_polygons);

Modified: brlcad/branches/bioh/src/conv/vdeck/vdeck.c
===================================================================
--- brlcad/branches/bioh/src/conv/vdeck/vdeck.c 2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/conv/vdeck/vdeck.c 2020-05-07 15:11:51 UTC (rev 
75727)
@@ -1218,7 +1218,7 @@
     ewrite(solfp, LF, 1);
 
     /* Save space for number of solids and regions.                    */
-    savsol = ftell(solfp);
+    savsol = bu_ftell(solfp);
     if (savsol < 0) {
        perror("ftell");
     }
@@ -1272,7 +1272,7 @@
 
     /* Go back, and add number of solids and regions on second card. */
     if (savsol >= 0)
-       fseek(solfp, savsol, 0);
+       bu_fseek(solfp, savsol, 0);
 
     vdeck_itoa(nns, buff, 5);
     ewrite(solfp, buff, 5);

Modified: brlcad/branches/bioh/src/fb/bw-fb.c
===================================================================
--- brlcad/branches/bioh/src/fb/bw-fb.c 2020-05-07 14:40:30 UTC (rev 75726)
+++ brlcad/branches/bioh/src/fb/bw-fb.c 2020-05-07 15:11:51 UTC (rev 75727)
@@ -342,7 +342,7 @@
     int n, tries;
 
     if (fileinput) {
-       (void)lseek(fd, num, 1);
+       (void)bu_lseek(fd, num, 1);
        return 0;
     }
 

Modified: brlcad/branches/bioh/src/fb/pix-fb.c
===================================================================
--- brlcad/branches/bioh/src/fb/pix-fb.c        2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/fb/pix-fb.c        2020-05-07 15:11:51 UTC (rev 
75727)
@@ -193,7 +193,7 @@
     int n, tries;
 
     if (fileinput) {
-       (void)lseek(fd, num, 1);
+       (void)bu_lseek(fd, num, 1);
        return 0;
     }
 

Modified: brlcad/branches/bioh/src/libbu/file.c
===================================================================
--- brlcad/branches/bioh/src/libbu/file.c       2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/libbu/file.c       2020-05-07 15:11:51 UTC (rev 
75727)
@@ -490,6 +490,49 @@
     return 1;
 }
 
+int
+bu_fseek(FILE *stream, b_off_t offset, int origin)
+{
+    int ret;
+
+#if defined(HAVE__FSEEKI64) && defined(SIZEOF_VOID_P) && SIZEOF_VOID_P == 8^M
+    ret = _fseeki64(stream, offset, origin);
+#else
+    ret = fseek(stream, offset, origin);
+#endif
+
+    return ret;
+}
+
+b_off_t
+bu_lseek(int fd, b_off_t offset, int whence)
+{
+    b_off_t ret;
+
+#if defined(HAVE__LSEEKI64) && defined(SIZEOF_VOID_P) && SIZEOF_VOID_P == 8
+    ret = _lseeki64(fd, offset, whence);
+#else
+    ret = lseek(fd, offset, whence);
+#endif
+
+    return ret;
+}
+
+b_off_t
+bu_ftell(FILE *stream)
+{
+    b_off_t ret;
+
+#if defined(HAVE__FTELLI64) && defined(SIZEOF_VOID_P) && SIZEOF_VOID_P == 8
+    /* windows 64bit */
+    ret = _ftelli64(stream);
+#else
+    ret = ftell(stream);
+#endif
+
+    return ret;
+}
+
 /*
  * Local Variables:
  * mode: C

Modified: brlcad/branches/bioh/src/libbu/vfont.c
===================================================================
--- brlcad/branches/bioh/src/libbu/vfont.c      2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/libbu/vfont.c      2020-05-07 15:11:51 UTC (rev 
75727)
@@ -99,7 +99,7 @@
     /* Addresses of characters in the file are relative to point in
      * the file after the directory, so grab the current position.
      */
-    font.offset = ftell(font.ffdes);
+    font.offset = bu_ftell(font.ffdes);
 
     return font;
 }

Modified: brlcad/branches/bioh/src/libdm/fontstash/fontstash.h
===================================================================
--- brlcad/branches/bioh/src/libdm/fontstash/fontstash.h        2020-05-07 
14:40:30 UTC (rev 75726)
+++ brlcad/branches/bioh/src/libdm/fontstash/fontstash.h        2020-05-07 
15:11:51 UTC (rev 75727)
@@ -884,9 +884,9 @@
        // Read in the font data.
        fp = fopen(path, "rb");
        if (fp == NULL) goto error;
-       fseek(fp,0,SEEK_END);
-       dataSize = (int)ftell(fp);
-       fseek(fp,0,SEEK_SET);
+       bu_fseek(fp,0,SEEK_END);
+       dataSize = (int)bu_ftell(fp);
+       bu_fseek(fp,0,SEEK_SET);
        data = (unsigned char*)malloc(dataSize);
        if (data == NULL) goto error;
        if (!fread(data, 1, dataSize, fp)) goto error;

Modified: brlcad/branches/bioh/src/libfb/fb_generic.c
===================================================================
--- brlcad/branches/bioh/src/libfb/fb_generic.c 2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/libfb/fb_generic.c 2020-05-07 15:11:51 UTC (rev 
75727)
@@ -43,6 +43,7 @@
 #include "bio.h"
 
 #include "bu/color.h"
+#include "bu/file.h"
 #include "bu/malloc.h"
 #include "bu/str.h"
 #include "bu/log.h"
@@ -675,7 +676,7 @@
     int n, tries;
 
     if (fileinput) {
-       (void)lseek(fd, num, 1);
+       (void)bu_lseek(fd, num, 1);
        return 0;
     }
 

Modified: brlcad/branches/bioh/src/libfb/if_X24.c
===================================================================
--- brlcad/branches/bioh/src/libfb/if_X24.c     2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/libfb/if_X24.c     2020-05-07 15:11:51 UTC (rev 
75727)
@@ -2011,11 +2011,11 @@
                fd = open(BS_NAME, O_RDWR | O_CREAT | O_BINARY, 0666);
                if (fd < 0)
                    fb_log("X24_getmem: can't create fb file, using private 
memory instead, errno %d\n", errno);
-               else if (lseek(fd, (b_off_t)size, SEEK_SET) < 0)
+               else if (bu_lseek(fd, (b_off_t)size, SEEK_SET) < 0)
                    fb_log("X24_getmem: can't seek fb file, using private 
memory instead, errno %d\n", errno);
                else if (write(fd, &isnew, 1) < 0)
                    fb_log("X24_getmem: can't zero fb file, using private 
memory instead, errno %d\n", errno);
-               else if (lseek(fd, 0, SEEK_SET) < 0)
+               else if (bu_lseek(fd, 0, SEEK_SET) < 0)
                    fb_log("X24_getmem: can't seek fb file, using private 
memory instead, errno %d\n", errno);
                else if ((mem = (char *)mmap(NULL, size, PROT_READ | 
PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED)
                    fb_log("X24_getmem: can't mmap fb file, using private 
memory instead, errno %d\n", errno);

Modified: brlcad/branches/bioh/src/libfb/if_disk.c
===================================================================
--- brlcad/branches/bioh/src/libfb/if_disk.c    2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/libfb/if_disk.c    2020-05-07 15:11:51 UTC (rev 
75727)
@@ -76,7 +76,7 @@
        && (ifp->if_fd = open(file, O_RDONLY | O_BINARY, 0)) == -1) {
        if ((ifp->if_fd = open(file, O_RDWR | O_CREAT | O_BINARY, 0664)) > 0) {
            /* New file, write byte at end */
-           if (lseek(ifp->if_fd, (height*width*sizeof(RGBpixel)-1), 0) == -1) {
+           if (bu_lseek(ifp->if_fd, (height*width*sizeof(RGBpixel)-1), 0) == 
-1) {
                fb_log("disk_device_open : can not seek to end of new file.\n");
                return -1;
            }
@@ -92,7 +92,7 @@
 
     ifp->if_width = width;
     ifp->if_height = height;
-    if (lseek(ifp->if_fd, 0, 0) == -1) {
+    if (bu_lseek(ifp->if_fd, 0, 0) == -1) {
        fb_log("disk_device_open : can not seek to beginning.\n");
        return -1;
     }
@@ -176,7 +176,7 @@
 
     /* Set start of framebuffer */
     fd = ifp->if_fd;
-    if (ifp->if_seekpos != 0 && lseek(fd, 0, 0) == -1) {
+    if (ifp->if_seekpos != 0 && bu_lseek(fd, 0, 0) == -1) {
        fb_log("disk_color_clear : seek failed.\n");
        return -1;
     }
@@ -221,7 +221,7 @@
     if (fd == 1) fd = 0;
 
     dest = ((y * ifp->if_width) + x) * sizeof(RGBpixel);
-    if (ifp->if_seekpos != dest && lseek(fd, dest, 0) == -1) {
+    if (ifp->if_seekpos != dest && bu_lseek(fd, dest, 0) == -1) {
        fb_log("disk_buffer_read : seek to %ld failed.\n", dest);
        return -1;
     }
@@ -264,7 +264,7 @@
 
     dest = (y * ifp->if_width + x) * sizeof(RGBpixel);
     if (dest != ifp->if_seekpos) {
-       if (lseek(ifp->if_fd, (b_off_t)dest, 0) == -1) {
+       if (bu_lseek(ifp->if_fd, (b_off_t)dest, 0) == -1) {
            fb_log("disk_buffer_write : seek to %zd failed.\n", dest);
            return -1;
        }
@@ -295,7 +295,7 @@
     if (fd == 1) fd = 0;
 
     if (ifp->if_seekpos != FILE_CMAP_SIZE &&
-       lseek(fd, (b_off_t)FILE_CMAP_SIZE, 0) == -1) {
+       bu_lseek(fd, (b_off_t)FILE_CMAP_SIZE, 0) == -1) {
        fb_log("disk_colormap_read : seek to %zd failed.\n", FILE_CMAP_SIZE);
        return -1;
     }
@@ -318,7 +318,7 @@
        return 0;
     if (fb_is_linear_cmap(cmap))
        return 0;
-    if (lseek(ifp->if_fd, (b_off_t)FILE_CMAP_SIZE, 0) == -1) {
+    if (bu_lseek(ifp->if_fd, (b_off_t)FILE_CMAP_SIZE, 0) == -1) {
        fb_log("disk_colormap_write : seek to %zd failed.\n", FILE_CMAP_SIZE);
        return -1;
     }

Modified: brlcad/branches/bioh/src/libgcv/plugins/fastgen4/fastgen4_read.c
===================================================================
--- brlcad/branches/bioh/src/libgcv/plugins/fastgen4/fastgen4_read.c    
2020-05-07 14:40:30 UTC (rev 75726)
+++ brlcad/branches/bioh/src/libgcv/plugins/fastgen4/fastgen4_read.c    
2020-05-07 15:11:51 UTC (rev 75727)
@@ -2161,7 +2161,7 @@
     b_off_t section_start;
 
     /* skip to start of next section */
-    section_start = ftell(pstate->fpin);
+    section_start = bu_ftell(pstate->fpin);
     if (section_start < 0) {
        bu_bomb("Error: couldn't get input file's current file position.");
     }
@@ -2172,7 +2172,7 @@
               bu_strncmp(pstate->line, "WALL", 4) &&
               bu_strncmp(pstate->line, "vehicle", 7))
        {
-           section_start = ftell(pstate->fpin);
+           section_start = bu_ftell(pstate->fpin);
            if (section_start < 0) {
                bu_bomb("Error: couldn't get input file's current file 
position.");
            }
@@ -2181,7 +2181,7 @@
        }
     }
     /* seek to start of the section */
-    fseek(pstate->fpin, section_start, SEEK_SET);
+    bu_fseek(pstate->fpin, section_start, SEEK_SET);
 }
 
 

Modified: brlcad/branches/bioh/src/libgcv/plugins/stl/stl_write.c
===================================================================
--- brlcad/branches/bioh/src/libgcv/plugins/stl/stl_write.c     2020-05-07 
14:40:30 UTC (rev 75726)
+++ brlcad/branches/bioh/src/libgcv/plugins/stl/stl_write.c     2020-05-07 
15:11:51 UTC (rev 75727)
@@ -298,7 +298,7 @@
            unsigned char tot_buffer[4];
 
            /* Re-position pointer to 80th byte */
-           lseek(pstate->bfd, 80, SEEK_SET);
+           bu_lseek(pstate->bfd, 80, SEEK_SET);
 
            /* Write out number of triangles */
            *(uint32_t *)tot_buffer = htonl((unsigned long)region_polys);
@@ -441,7 +441,7 @@
            unsigned char tot_buffer[4];
 
            /* Re-position pointer to 80th byte */
-           lseek(state.bfd, 80, SEEK_SET);
+           bu_lseek(state.bfd, 80, SEEK_SET);
 
            /* Write out number of triangles */
            *(uint32_t *)tot_buffer = htonl((unsigned long)state.tot_polygons);

Modified: brlcad/branches/bioh/src/libged/bot_dump.c
===================================================================
--- brlcad/branches/bioh/src/libged/bot_dump.c  2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/libged/bot_dump.c  2020-05-07 15:11:51 UTC (rev 
75727)
@@ -645,7 +645,7 @@
            stl_write_bot_binary(bot, fd, dp->d_namep);
 
            /* Re-position pointer to 80th byte */
-           lseek(fd, 80, SEEK_SET);
+           bu_lseek(fd, 80, SEEK_SET);
 
            /* Write out number of triangles */
            *(uint32_t *)tot_buffer = htonl((unsigned long)total_faces);
@@ -1037,7 +1037,7 @@
            unsigned char tot_buffer[4];
 
            /* Re-position pointer to 80th byte */
-           lseek(fd, 80, SEEK_SET);
+           bu_lseek(fd, 80, SEEK_SET);
 
            /* Write out number of triangles */
            *(uint32_t *)tot_buffer = htonl((unsigned long)total_faces);
@@ -1517,7 +1517,7 @@
            unsigned char tot_buffer[4];
 
            /* Re-position pointer to 80th byte */
-           lseek(fd, 80, SEEK_SET);
+           bu_lseek(fd, 80, SEEK_SET);
 
            /* Write out number of triangles */
            *(uint32_t *)tot_buffer = htonl((unsigned long)total_faces);

Modified: brlcad/branches/bioh/src/libged/tables.c
===================================================================
--- brlcad/branches/bioh/src/libged/tables.c    2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/libged/tables.c    2020-05-07 15:11:51 UTC (rev 
75727)
@@ -113,7 +113,7 @@
     MAT_COPY(idbuf1.i_mat, matrix);
 
     for (i = 0; i < (ssize_t)*numsol; i++) {
-       (void)lseek(rd_idfd, i*sizeof(identt), 0);
+       (void)bu_lseek(rd_idfd, i*sizeof(identt), 0);
        readval = read(rd_idfd, &idbuf2, sizeof identt);
 
        if (readval < 0) {
@@ -130,7 +130,7 @@
     (*numsol)++;
     idbuf1.i_index = *numsol;
 
-    (void)lseek(idfd, 0, 2);
+    (void)bu_lseek(idfd, 0, 2);
     i = write(idfd, &idbuf1, sizeof identt);
     if (i < 0)
        perror("write");

Modified: brlcad/branches/bioh/src/libicv/rot.c
===================================================================
--- brlcad/branches/bioh/src/libicv/rot.c       2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/libicv/rot.c       2020-05-07 15:11:51 UTC (rev 
75727)
@@ -326,7 +326,7 @@
 
     /*
      * Clear our "file pointer."  We need to maintain this
-     * In order to tell if seeking is required.  ftell() always
+     * In order to tell if seeking is required.  bu_ftell() always
      * fails on pipes, so we can't use it.
      */
     outplace = 0;
@@ -353,7 +353,7 @@
                xout = (nyin - 1) - lasty;
                outbyte = ((yout * nyin) + xout) * pixbytes;
                if (outplace != outbyte) {
-                   if (fseek(ofp, outbyte, SEEK_SET) < 0) {
+                   if (bu_fseek(ofp, outbyte, SEEK_SET) < 0) {
                        ret = 3;
                        perror("fseek");
                        bu_log("ERROR: %s can't seek on output (ofp=%p, 
outbyte=%jd)\n", argv[0], (void *)ofp, (intmax_t)outbyte);
@@ -383,7 +383,7 @@
                xout = yin;
                outbyte = ((yout * nyin) + xout) * pixbytes;
                if (outplace != outbyte) {
-                   if (fseek(ofp, outbyte, SEEK_SET) < 0) {
+                   if (bu_fseek(ofp, outbyte, SEEK_SET) < 0) {
                        ret = 3;
                        perror("fseek");
                        bu_log("ERROR: %s can't seek on output (ofp=%p, 
outbyte=%jd)\n", argv[0], (void *)ofp, (intmax_t)outbyte);
@@ -405,7 +405,7 @@
                yout = (nyin - 1) - y + 1;
                outbyte = yout * scanbytes;
                if (outplace != outbyte) {
-                   if (fseek(ofp, outbyte, SEEK_SET) < 0) {
+                   if (bu_fseek(ofp, outbyte, SEEK_SET) < 0) {
                        ret = 3;
                        perror("fseek");
                        bu_log("ERROR: %s can't seek on output (ofp=%p, 
outbyte=%jd)\n", argv[0], (void *)ofp, (intmax_t)outbyte);

Modified: brlcad/branches/bioh/src/librt/db5_scan.c
===================================================================
--- brlcad/branches/bioh/src/librt/db5_scan.c   2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/librt/db5_scan.c   2020-05-07 15:11:51 UTC (rev 
75727)
@@ -85,7 +85,7 @@
            goto fatal;
        }
        for (;;) {
-           addr = ftell(dbip->dbi_fp);
+           addr = bu_ftell(dbip->dbi_fp);
            if ((got = db5_get_raw_internal_fp(&raw, dbip->dbi_fp)) < 0) {
                if (got == -1) break;           /* EOF */
                goto fatal;
@@ -97,7 +97,7 @@
                raw.buf = NULL;
            }
        }
-       dbip->dbi_eof = ftell(dbip->dbi_fp);
+       dbip->dbi_eof = bu_ftell(dbip->dbi_fp);
        rewind(dbip->dbi_fp);
     }
 

Modified: brlcad/branches/bioh/src/librt/db_corrupt.c
===================================================================
--- brlcad/branches/bioh/src/librt/db_corrupt.c 2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/librt/db_corrupt.c 2020-05-07 15:11:51 UTC (rev 
75727)
@@ -54,7 +54,7 @@
     RT_CK_DBI(dbip);
 
     /* get into position */
-    ret = fseek(dbip->dbi_fp, offset, 0);
+    ret = bu_fseek(dbip->dbi_fp, offset, 0);
     if (ret) {
        bu_log("Database seek failure, unable to seek [%s]\n", name);
        return 0;

Modified: brlcad/branches/bioh/src/librt/db_io.c
===================================================================
--- brlcad/branches/bioh/src/librt/db_io.c      2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/librt/db_io.c      2020-05-07 15:11:51 UTC (rev 
75727)
@@ -80,7 +80,7 @@
     }
     bu_semaphore_acquire(BU_SEM_SYSCALL);
 
-    ret = fseek(dbip->dbi_fp, offset, 0);
+    ret = bu_fseek(dbip->dbi_fp, offset, 0);
     if (ret)
        bu_bomb("db_read: fseek error\n");
     got = (size_t)fread(addr, 1, count, dbip->dbi_fp);
@@ -198,7 +198,7 @@
     bu_semaphore_acquire(BU_SEM_SYSCALL);
     bu_interrupt_suspend();
 
-    (void)fseek(dbip->dbi_fp, offset, 0);
+    (void)bu_fseek(dbip->dbi_fp, offset, 0);
     got = fwrite(addr, 1, count, dbip->dbi_fp);
     fflush(dbip->dbi_fp);
 

Modified: brlcad/branches/bioh/src/librt/db_scan.c
===================================================================
--- brlcad/branches/bioh/src/librt/db_scan.c    2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/librt/db_scan.c    2020-05-07 15:11:51 UTC (rev 
75727)
@@ -99,7 +99,7 @@
        return -1;
     }
     rewind(dbip->dbi_fp);
-    next = ftell(dbip->dbi_fp);
+    next = bu_ftell(dbip->dbi_fp);
     if (next < 0) {
        perror("ftell");
        next = 0;
@@ -111,8 +111,8 @@
     totrec = 0;
     while (1) {
        nrec = 0;
-       if (fseek(dbip->dbi_fp, next, 0) != 0) {
-           bu_log("db_scan:  fseek(offset=%jd) failure\n", (intmax_t)next);
+       if (bu_fseek(dbip->dbi_fp, next, 0) != 0) {
+           bu_log("db_scan:  bu_fseek(offset=%jd) failure\n", (intmax_t)next);
            return -1;
        }
        addr = next;
@@ -120,7 +120,7 @@
        if (fread((char *)&record, sizeof record, 1, dbip->dbi_fp) != 1
            || feof(dbip->dbi_fp))
            break;
-       next = ftell(dbip->dbi_fp);
+       next = bu_ftell(dbip->dbi_fp);
        if (next < 0) {
            perror("db_scan:  ftell:  ");
            return -1;
@@ -146,18 +146,18 @@
                break;
            case ID_ARS_A:
                while (1) {
-                   here = ftell(dbip->dbi_fp);
+                   here = bu_ftell(dbip->dbi_fp);
                    if (fread((char *)&rec2, sizeof(rec2),
                              1, dbip->dbi_fp) != 1)
                        break;
                    RT_DEBUG_PR(here, rec2);
                    if (rec2.u_id != ID_ARS_B) {
-                       fseek(dbip->dbi_fp, here, 0);
+                       bu_fseek(dbip->dbi_fp, here, 0);
                        break;
                    }
                    nrec++;
                }
-               next = ftell(dbip->dbi_fp);
+               next = bu_ftell(dbip->dbi_fp);
                handler(dbip, record.a.a_name, addr, nrec, RT_DIR_SOLID, 
client_data);
                break;
            case ID_ARS_B:
@@ -171,7 +171,7 @@
                    if (fread((char *)&rec2, sizeof(rec2), 1, dbip->dbi_fp) != 
1)
                        break;
                }
-               next = ftell(dbip->dbi_fp);
+               next = bu_ftell(dbip->dbi_fp);
                handler(dbip, record.ss.ss_name, addr, nrec, RT_DIR_SOLID, 
client_data);
                break;
            case ID_MATERIAL:
@@ -192,17 +192,17 @@
                break;
            case ID_P_HEAD:
                while (1) {
-                   here = ftell(dbip->dbi_fp);
+                   here = bu_ftell(dbip->dbi_fp);
                    if (fread((char *)&rec2, sizeof(rec2), 1, dbip->dbi_fp) != 
1)
                        break;
                    RT_DEBUG_PR(here, rec2);
                    if (rec2.u_id != ID_P_DATA) {
-                       fseek(dbip->dbi_fp, here, 0);
+                       bu_fseek(dbip->dbi_fp, here, 0);
                        break;
                    }
                    nrec++;
                }
-               next = ftell(dbip->dbi_fp);
+               next = bu_ftell(dbip->dbi_fp);
                handler(dbip, record.p.p_name, addr, nrec, RT_DIR_SOLID, 
client_data);
                break;
            case ID_P_DATA:
@@ -211,12 +211,12 @@
            case ID_BSOLID:
                while (1) {
                    /* Find and skip subsequent BSURFs */
-                   here = ftell(dbip->dbi_fp);
+                   here = bu_ftell(dbip->dbi_fp);
                    if (fread((char *)&rec2, sizeof(rec2), 1, dbip->dbi_fp) != 
1)
                        break;
                    RT_DEBUG_PR(here, rec2);
                    if (rec2.u_id != ID_BSURF) {
-                       fseek(dbip->dbi_fp, here, 0);
+                       bu_fseek(dbip->dbi_fp, here, 0);
                        break;
                    }
 
@@ -227,7 +227,7 @@
                        if (fread((char *)&rec2, sizeof(rec2), 1, dbip->dbi_fp) 
!= 1)
                            break;
                    }
-                   next = ftell(dbip->dbi_fp);
+                   next = bu_ftell(dbip->dbi_fp);
                }
                handler(dbip, record.B.B_name, addr, nrec, RT_DIR_SOLID, 
client_data);
                break;
@@ -249,7 +249,7 @@
                    if (fread((char *)&rec2, sizeof(rec2), 1, dbip->dbi_fp) != 
1)
                        break;
                }
-               next = ftell(dbip->dbi_fp);
+               next = bu_ftell(dbip->dbi_fp);
                handler(dbip, record.n.n_name, addr, nrec, RT_DIR_SOLID, 
client_data);
                break;
            case DBID_PARTICLE:
@@ -262,7 +262,7 @@
                    if (fread((char *)&rec2, sizeof(rec2), 1, dbip->dbi_fp) != 
1)
                        break;
                }
-               next = ftell(dbip->dbi_fp);
+               next = bu_ftell(dbip->dbi_fp);
                handler(dbip, record.pwr.pwr_name, addr, nrec, RT_DIR_SOLID, 
client_data);
                break;
            case DBID_NMG:
@@ -272,7 +272,7 @@
                    if (fread((char *)&rec2, sizeof(rec2), 1, dbip->dbi_fp) != 
1)
                        break;
                }
-               next = ftell(dbip->dbi_fp);
+               next = bu_ftell(dbip->dbi_fp);
                handler(dbip, record.nmg.N_name, addr, nrec, RT_DIR_SOLID, 
client_data);
                break;
            case DBID_SKETCH:
@@ -282,7 +282,7 @@
                    if (fread((char *)&rec2, sizeof(rec2), 1, dbip->dbi_fp) != 
1)
                        break;
                }
-               next = ftell(dbip->dbi_fp);
+               next = bu_ftell(dbip->dbi_fp);
                handler(dbip, record.skt.skt_name, addr, nrec, RT_DIR_SOLID, 
client_data);
                break;
            case DBID_EXTR:
@@ -292,7 +292,7 @@
                    if (fread((char *)&rec2, sizeof(rec2), 1, dbip->dbi_fp) != 
1)
                        break;
                }
-               next = ftell(dbip->dbi_fp);
+               next = bu_ftell(dbip->dbi_fp);
                handler(dbip, record.extr.ex_name, addr, nrec, RT_DIR_SOLID, 
client_data);
                break;
            case DBID_CLINE:
@@ -305,7 +305,7 @@
                    if (fread((char *)&rec2, sizeof(rec2), 1, dbip->dbi_fp) != 
1)
                        break;
                }
-               next = ftell(dbip->dbi_fp);
+               next = bu_ftell(dbip->dbi_fp);
                handler(dbip, record.s.s_name, addr, nrec, RT_DIR_SOLID, 
client_data);
                break;
            case ID_MEMB:
@@ -313,17 +313,17 @@
                break;
            case ID_COMB:
                while (1) {
-                   here = ftell(dbip->dbi_fp);
+                   here = bu_ftell(dbip->dbi_fp);
                    if (fread((char *)&rec2, sizeof(rec2), 1, dbip->dbi_fp) != 
1)
                        break;
                    RT_DEBUG_PR(here, rec2);
                    if (rec2.u_id != ID_MEMB) {
-                       fseek(dbip->dbi_fp, here, 0);
+                       bu_fseek(dbip->dbi_fp, here, 0);
                        break;
                    }
                    nrec++;
                }
-               next = ftell(dbip->dbi_fp);
+               next = bu_ftell(dbip->dbi_fp);
                switch (record.c.c_flags) {
                    default:
                    case DBV4_NON_REGION:
@@ -346,7 +346,7 @@
        totrec += nrec;
     }
     dbip->dbi_nrec = totrec;
-    next = ftell(dbip->dbi_fp);
+    next = bu_ftell(dbip->dbi_fp);
     if (next < 0)
        dbip->dbi_eof = -1;
     else

Modified: brlcad/branches/bioh/src/librt/primitives/primitive_util.c
===================================================================
--- brlcad/branches/bioh/src/librt/primitives/primitive_util.c  2020-05-07 
14:40:30 UTC (rev 75726)
+++ brlcad/branches/bioh/src/librt/primitives/primitive_util.c  2020-05-07 
15:11:51 UTC (rev 75727)
@@ -528,8 +528,8 @@
     fp = fopen(filename , "r");
     if (!fp) bu_exit(-1, "failed to read OpenCL code file (%s)\n", filename);
 
-    fseek(fp, 0, SEEK_END);
-    *length = ftell(fp);
+    bu_fseek(fp, 0, SEEK_END);
+    *length = bu_ftell(fp);
     rewind(fp);
 
     data = (char*)bu_malloc((*length+1)*sizeof(char), "failed bu_malloc() in 
clt_read_code()");

Modified: brlcad/branches/bioh/src/remrt/remrt.c
===================================================================
--- brlcad/branches/bioh/src/remrt/remrt.c      2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/remrt/remrt.c      2020-05-07 15:11:51 UTC (rev 
75727)
@@ -3233,7 +3233,7 @@
     if ((fd = open(fr->fr_filename, 2)) < 0) {
        /* open failed */
        perror(fr->fr_filename);
-    } else if (lseek(fd, info.li_startpix*3, 0) < 0) {
+    } else if (bu_lseek(fd, info.li_startpix*3, 0) < 0) {
        /* seek failed */
        perror(fr->fr_filename);
        (void)close(fd);

Modified: brlcad/branches/bioh/src/rt/do.c
===================================================================
--- brlcad/branches/bioh/src/rt/do.c    2020-05-07 14:40:30 UTC (rev 75726)
+++ brlcad/branches/bioh/src/rt/do.c    2020-05-07 15:11:51 UTC (rev 75727)
@@ -692,7 +692,7 @@
     }
     if (outfp) {
         bu_semaphore_acquire(BU_SEM_SYSCALL);
-        if (fseek(outfp, cur_pixel*clt_o[1], 0) != 0)
+        if (bu_fseek(outfp, cur_pixel*clt_o[1], 0) != 0)
             fprintf(stderr, "fseek error\n");
         if (fwrite(pixelp, size, 1, outfp) != 1)
             bu_exit(EXIT_FAILURE, "pixel fwrite error");
@@ -919,7 +919,7 @@
        /*
         * This code allows the computation of a particular frame to a
         * disk file to be resumed automatically.  This is worthwhile
-        * crash protection.  This use of stat() and fseek() is
+        * crash protection.  This use of stat() and bu_fseek() is
         * UNIX-specific.
         *
         * It is not appropriate for the RT "top part" to assume

Modified: brlcad/branches/bioh/src/rt/view.c
===================================================================
--- brlcad/branches/bioh/src/rt/view.c  2020-05-07 14:40:30 UTC (rev 75726)
+++ brlcad/branches/bioh/src/rt/view.c  2020-05-07 15:11:51 UTC (rev 75727)
@@ -306,7 +306,7 @@
                    icv_writepixel(bif, ap->a_x, ap->a_y, ap->a_color);
                } else if (outfp != NULL) {
                    bu_semaphore_acquire(BU_SEM_SYSCALL);
-                   if (fseek(outfp, (ap->a_y*width*pwidth) + (ap->a_x*pwidth), 
0) != 0)
+                   if (bu_fseek(outfp, (ap->a_y*width*pwidth) + 
(ap->a_x*pwidth), 0) != 0)
                        fprintf(stderr, "fseek error\n");
                    if (fwrite(p, 3, 1, outfp) != 1)
                        bu_exit(EXIT_FAILURE, "pixel fwrite error");
@@ -512,7 +512,7 @@
                size_t count;
 
                bu_semaphore_acquire(BU_SEM_SYSCALL);
-               if (fseek(outfp, ap->a_y*width*pwidth, 0) != 0)
+               if (bu_fseek(outfp, ap->a_y*width*pwidth, 0) != 0)
                    fprintf(stderr, "fseek error\n");
                count = fwrite(scanline[ap->a_y].sl_buf,
                               sizeof(char), width*pwidth, outfp);

Modified: brlcad/branches/bioh/src/util/ap-pix.c
===================================================================
--- brlcad/branches/bioh/src/util/ap-pix.c      2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/util/ap-pix.c      2020-05-07 15:11:51 UTC (rev 
75727)
@@ -80,9 +80,9 @@
        bu_exit(2, "%s: can't open \"%s\"\n", argv0, argv[1]);
     }
     yelfp = fopen(argv[1], "r");
-    fseek(yelfp, 50*sizeof(yelline), 0);
+    bu_fseek(yelfp, 50*sizeof(yelline), 0);
     cyafp = fopen(argv[1], "r");
-    fseek(cyafp, 100*sizeof(cyaline), 0);
+    bu_fseek(cyafp, 100*sizeof(cyaline), 0);
 
     line = 0;
     while ((int)fread(&cyaline, sizeof(cyaline), 1, cyafp) > 0) {

Modified: brlcad/branches/bioh/src/util/bwcrop.c
===================================================================
--- brlcad/branches/bioh/src/util/bwcrop.c      2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/util/bwcrop.c      2020-05-07 15:11:51 UTC (rev 
75727)
@@ -104,7 +104,7 @@
     if (buf_start < 0)
        buf_start = 0;
 
-    fseek(ifp, buf_start * scanlen, 0);
+    bu_fseek(ifp, buf_start * scanlen, 0);
     ret = fread(buffer, scanlen, buflines, ifp);
     if (ret == 0)
        perror("fread");

Modified: brlcad/branches/bioh/src/util/bwhisteq.c
===================================================================
--- brlcad/branches/bioh/src/util/bwhisteq.c    2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/util/bwhisteq.c    2020-05-07 15:11:51 UTC (rev 
75727)
@@ -105,7 +105,7 @@
            fprintf(stderr, "result[%d] = %d\n", i, result[i]);
     }
 
-    fseek(fp, 0, 0);
+    bu_fseek(fp, 0, 0);
     while ((n = fread(buf, 1, BUFSIZE, fp)) > 0) {
        for (i = 0; i < n; i++) {
            long idx = buf[i];

Modified: brlcad/branches/bioh/src/util/bwrot.c
===================================================================
--- brlcad/branches/bioh/src/util/bwrot.c       2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/util/bwrot.c       2020-05-07 15:11:51 UTC (rev 
75727)
@@ -331,7 +331,7 @@
 
     /*
      * Clear our "file pointer."  We need to maintain this
-     * In order to tell if seeking is required.  ftell() always
+     * In order to tell if seeking is required.  bu_ftell() always
      * fails on pipes, so we can't use it.
      */
     outplace = 0;
@@ -358,7 +358,7 @@
                xout = (nyin - 1) - lasty;
                outbyte = ((yout * nyin) + xout) * pixbytes;
                if (outplace != outbyte) {
-                   if (fseek(ofp, outbyte, SEEK_SET) < 0) {
+                   if (bu_fseek(ofp, outbyte, SEEK_SET) < 0) {
                        ret = 3;
                        perror("fseek");
                        bu_log("ERROR: %s can't seek on output (ofp=%p, 
outbyte=%zd)\n", bu_getprogname(), (void *)ofp, outbyte);
@@ -384,7 +384,7 @@
                xout = yin;
                outbyte = ((yout * nyin) + xout) * pixbytes;
                if (outplace != outbyte) {
-                   if (fseek(ofp, outbyte, SEEK_SET) < 0) {
+                   if (bu_fseek(ofp, outbyte, SEEK_SET) < 0) {
                        ret = 3;
                        perror("fseek");
                        bu_log("ERROR: %s can't seek on output (ofp=%p, 
outbyte=%zd)\n", bu_getprogname(), (void *)ofp, outbyte);
@@ -402,7 +402,7 @@
                yout = (nyin - 1) - y + 1;
                outbyte = yout * scanbytes;
                if (outplace != outbyte) {
-                   if (fseek(ofp, outbyte, SEEK_SET) < 0) {
+                   if (bu_fseek(ofp, outbyte, SEEK_SET) < 0) {
                        ret = 3;
                        perror("fseek");
                        bu_log("ERROR: %s can't seek on output (ofp=%p, 
outbyte=%zd)\n", bu_getprogname(), (void *)ofp, outbyte);

Modified: brlcad/branches/bioh/src/util/bwscale.c
===================================================================
--- brlcad/branches/bioh/src/util/bwscale.c     2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/util/bwscale.c     2020-05-07 15:11:51 UTC (rev 
75727)
@@ -87,7 +87,7 @@
     buf_start = y - buflines/2;
     if (buf_start < 0) buf_start = 0;
 
-    if (fseek(buffp, buf_start * scanlen, 0) < 0) {
+    if (bu_fseek(buffp, buf_start * scanlen, 0) < 0) {
        fprintf(stderr, "bwscale: Can't seek to input pixel!\n");
        /* bu_exit (3, NULL); */
     }

Modified: brlcad/branches/bioh/src/util/dpix-pix.c
===================================================================
--- brlcad/branches/bioh/src/util/dpix-pix.c    2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/util/dpix-pix.c    2020-05-07 15:11:51 UTC (rev 
75727)
@@ -97,7 +97,7 @@
        }
     }
 
-    lseek(fd, 0, 0);           /* rewind(fp); */
+    bu_lseek(fd, 0, 0);                /* rewind(fp); */
 
     /* This section uses the maximum and the minimum values found to
      * compute the m and the b of the line as specified by the

Modified: brlcad/branches/bioh/src/util/pixbustup.c
===================================================================
--- brlcad/branches/bioh/src/util/pixbustup.c   2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/util/pixbustup.c   2020-05-07 15:11:51 UTC (rev 
75727)
@@ -81,7 +81,7 @@
 
     if (argc == 4) {
        image_offset = atoi(argv[3]);
-       lseek(0, image_offset*scanbytes, 0);
+       bu_lseek(0, image_offset*scanbytes, 0);
     }
     if (argc == 5)
        framenumber = atoi(argv[4]);

Modified: brlcad/branches/bioh/src/util/pixcrop.c
===================================================================
--- brlcad/branches/bioh/src/util/pixcrop.c     2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/util/pixcrop.c     2020-05-07 15:11:51 UTC (rev 
75727)
@@ -103,7 +103,7 @@
     buf_start = y - buflines/2;
     if (buf_start < 0) buf_start = 0;
 
-    fseek(ifp, 0, 0);
+    bu_fseek(ifp, 0, 0);
     ret = fread(buffer, scanlen, 3*buflines, ifp);
     if (ret == 0)
        perror("fread");

Modified: brlcad/branches/bioh/src/util/pixrot.c
===================================================================
--- brlcad/branches/bioh/src/util/pixrot.c      2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/util/pixrot.c      2020-05-07 15:11:51 UTC (rev 
75727)
@@ -165,7 +165,7 @@
 
     /*
      * Clear our "file pointer." We need to maintain this
-     * In order to tell if seeking is required.  ftell() always
+     * In order to tell if seeking is required.  bu_ftell() always
      * fails on pipes, so we can't use it.
      */
     outplace = 0;
@@ -190,7 +190,7 @@
                xout = (nyin - 1) - lasty;
                outbyte = ((yout * nyin) + xout) * pixbytes;
                if (outplace != outbyte) {
-                   if (fseek(ofp, outbyte, 0) < 0) {
+                   if (bu_fseek(ofp, outbyte, 0) < 0) {
                        bu_exit(3, "pixrot: Can't seek on output, yet I need 
to!\n");
                    }
                    outplace = outbyte;
@@ -215,7 +215,7 @@
                xout = yin;
                outbyte = ((yout * nyin) + xout) * pixbytes;
                if (outplace != outbyte) {
-                   if (fseek(ofp, outbyte, 0) < 0) {
+                   if (bu_fseek(ofp, outbyte, 0) < 0) {
                        bu_exit(3, "pixrot: Can't seek on output, yet I need 
to!\n");
                    }
                    outplace = outbyte;
@@ -232,7 +232,7 @@
                yout = (nyin - 1) - y;
                outbyte = yout * scanbytes;
                if (outplace != outbyte) {
-                   if (fseek(ofp, outbyte, 0) < 0) {
+                   if (bu_fseek(ofp, outbyte, 0) < 0) {
                        bu_exit(3, "pixrot: Can't seek on output, yet I need 
to!\n");
                    }
                    outplace = outbyte;

Modified: brlcad/branches/bioh/src/util/pixscale.c
===================================================================
--- brlcad/branches/bioh/src/util/pixscale.c    2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/util/pixscale.c    2020-05-07 15:11:51 UTC (rev 
75727)
@@ -90,7 +90,7 @@
     if (buf_start < 0) buf_start = 0;
 
     if (file_pos != buf_start * scanlen) {
-       if (fseek(buffp, buf_start * scanlen, 0) < 0) {
+       if (bu_fseek(buffp, buf_start * scanlen, 0) < 0) {
            bu_exit(3, "pixscale: Can't seek to input pixel! y=%d\n", y);
        }
        file_pos = buf_start * scanlen;

Modified: brlcad/branches/bioh/src/util/plot3rot.c
===================================================================
--- brlcad/branches/bioh/src/util/plot3rot.c    2020-05-07 14:40:30 UTC (rev 
75726)
+++ brlcad/branches/bioh/src/util/plot3rot.c    2020-05-07 15:11:51 UTC (rev 
75727)
@@ -525,7 +525,7 @@
                bu_log("plot3rot: unrecognized command '%c' (0x%x)\n",
                       (isprint(c)) ? c : '?',
                       c);
-               bu_log("plot3rot: ftell = %jd\n", (intmax_t)ftell(fp));
+               bu_log("plot3rot: ftell = %jd\n", (intmax_t)bu_ftell(fp));
                putchar(c);
                break;
        }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to