File: load.h

package info (click to toggle)
netrik 1.16.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, stretch
  • size: 3,272 kB
  • ctags: 729
  • sloc: ansic: 6,657; sh: 994; makefile: 114
file content (65 lines) | stat: -rw-r--r-- 1,536 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
   netrik -- The ANTRIK Internet Viewer
   Copyright (C) Olaf D. Buddenhagen AKA antrik, et al (see AUTHORS)
   Published under the GNU GPL; see LICENSE for details.
*/
/*
 * load.h -- data structures and extern function declarations for load.c
 *
 * (C) 2001, 2002 antrik
 *     2001, 2002 Patrice Neff
 */

#ifndef __LOAD_H
#define __LOAD_H

#include <stdio.h>

#include "items.h"
#include "url.h"

struct Http_headers {
   int			count;
   struct Header {
      char	*name;
      char	*value;
   }			*header;
};

/* Patrice --> */
struct Http_handle {
   int	socket;
   struct Http_headers	headers;
};
/* <-- Patrice */

enum Res_type {
   RES_FAIL,    /* failed to open resource */
   RES_STDIN,
   RES_FILE,
   RES_HTTP,
   RES_PIPE
};

/* all data for an input resource (file etc.) */
struct Resource {
   struct Url		*url;    /* effective URL */
   enum Res_type	type;
   union {    /* specific for every ressource type */
      FILE	*stream;
      struct Http_handle
		*http;
   } 			handle;

   char			*buf;    /* input buffer */
   char			*buf_end;    /* end of data in input buffer */
   char			*buf_ptr;    /* current read position in buffer */

   int			user_break;    /* SIGINT recieved while loading resource */
};

struct Resource *init_load(const struct Url *base, const char *url, const struct Item *form_data);    /* build new URL, and prepare for reading */
void load(struct Resource *res);    /* read data block into buffer */
void uninit_load(struct Resource *res);    /* tidy up after reading a file */

#endif