Artsize still not quite right in CURRENT

Fabien Tassin fta at sofaraway.org
Mon Apr 16 14:29:49 UTC 2001


According to Fabien Tassin:
> 
> -- Binary/unsupported file stripped by Listar --
> -- Type: text/x-csrc

grrr.. I hate Listar.

====
/* Open a cycbuf, seek to a position given an offset and
   print the given amount of data */
/* Fabien Tassin <fta at sofaraway.org> - Apr 16 2001 */

/* Must be compiled with the appropriate define(s) for large files.
   Ex for Linux: -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 */

#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>

void usage(char *name) {
  fprintf(stderr, "Usage: %s file offset len\n", name);
  exit(1);
}

int main(int argc, char *argv[]) {
   int fd;
   long long offset;
   long len;
   char *buf, *file;

   if (argc != 4)
     usage(argv[0]);
   file = argv[1];
   offset = atoll(argv[2]);
   offset <<= 9;
   len = atol(argv[3]);
   buf = (char *) malloc(len + 1);
   
   fd = open(file, O_RDONLY);
   lseek(fd, offset,  SEEK_SET);
   read(fd, buf, len);
   write(1, buf, len);
   free(buf);
   close(fd);
   return(0);
}
====
-- 
Fabien Tassin -+- fta at sofaraway.org


More information about the inn-workers mailing list