"SfR Fresh" - the SfR Freeware/Shareware Archive

Member "odt2txt-0.4/kunzip/fileio.c" of archive odt2txt-0.4.tar.gz:


As a special service "SfR Fresh" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
    1 #include <stdio.h>
    2 #include <stdlib.h>
    3 
    4 /*
    5 
    6 This code is Copyright 2005-2006 by Michael Kohn
    7 
    8 This program is free software; you can redistribute it and/or
    9 modify it under the terms of the GNU General Public License,
   10 version 2 as published by the Free Software Foundation
   11 
   12 */
   13 
   14 int read_int(FILE *in)
   15 {
   16 	int c;
   17 
   18 	c = getc(in);
   19 	c = c | (getc(in) << 8);
   20 	c = c | (getc(in) << 16);
   21 	c = c | (getc(in) << 24);
   22 
   23 	return c;
   24 }
   25 
   26 int read_word(FILE *in)
   27 {
   28 	int c;
   29 
   30 	c = getc(in);
   31 	c = c | (getc(in) << 8);
   32 
   33 	return c;
   34 }
   35 
   36 int read_chars(FILE *in, char *s, int count)
   37 {
   38 	int t;
   39 
   40 	for (t = 0; t < count; t++) {
   41 		s[t] = getc(in);
   42 	}
   43 
   44 	s[t] = 0;
   45 
   46 	return 0;
   47 }
   48 
   49 int read_int_b(FILE *in)
   50 {
   51 	int c;
   52 
   53 	c = getc(in);
   54 	c = (c << 8) + getc(in);
   55 	c = (c << 8) + getc(in);
   56 	c = (c << 8) + getc(in);
   57 
   58 	return c;
   59 }
   60 
   61 int read_word_b(FILE *in)
   62 {
   63 	int c;
   64 
   65 	c = getc(in);
   66 	c = (c << 8) + getc(in);
   67 
   68 	return c;
   69 }
   70 
   71 int read_buffer(FILE *in, unsigned char *buffer, int len)
   72 {
   73 	int t;
   74 
   75 	t = 0;
   76 	while (t < len) {
   77 		t = t + fread(buffer + t, 1, len - t, in);
   78 	}
   79 
   80 	return t;
   81 }