source: rtems/c/src/libnetworking/rtems_webserver/webpage.c @ d0d73ec

4.104.114.84.95
Last change on this file since d0d73ec was a6b4c0df, checked in by Joel Sherrill <joel.sherrill@…>, on 09/01/00 at 10:57:21

2000-08-30 Joel Sherrill <joel@…>

  • Merged version 2.1 of GoAhead? webserver. This update was submitted by Antti P Miettinen <antti.p.miettinen@…>.
  • NOTES, base64.c, ejIntrn.h, emfdb.c, emfdb.h, md5.h, md5c.c, um.c, um.h: New files.
  • wbase64.c: Removed.
  • Makefile.am, asp.c, balloc.c, default.c, ej.h, ejlex.c, ejparse.c, form.c, h.c, handler.c, mime.c, misc.c, ringq.c, rom.c, security.c, socket.c, sym.c, uemf.c, uemf.h, url.c, value.c, webcomp.c, webmain.c, webpage.c, webrom.c, webs.c, webs.h, websuemf.c, wsIntrn.h: Modified.
  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 * Page.c -- Support for page retrieval.
3 *
4 * Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
5 *
6 * See the file "license.txt" for usage and redistribution license requirements
7 */
8
9/******************************** Description *********************************/
10
11/*
12 *      This module provides page retrieval handling. It provides support for
13 *      reading web pages from file systems and has expansion for ROMed web
14 *      pages.
15 */
16
17/********************************* Includes ***********************************/
18
19#include        "wsIntrn.h"
20
21/*********************************** Code *************************************/
22/*
23 *      Open a web page. lpath is the local filename. path is the URL path name.
24 */
25
26int websPageOpen(webs_t wp, char_t *lpath, char_t *path, int mode, int perm)
27{
28        a_assert(websValid(wp));
29
30#if WEBS_PAGE_ROM
31        return websRomPageOpen(wp, path, mode, perm);
32#else
33        return (wp->docfd = gopen(lpath, mode, perm));
34#endif /* WEBS_PAGE_ROM */
35}
36
37/******************************************************************************/
38/*
39 *      Close a web page
40 */
41
42void websPageClose(webs_t wp)
43{
44        a_assert(websValid(wp));
45
46#if WEBS_PAGE_ROM
47        websRomPageClose(wp->docfd);
48#else
49        if (wp->docfd >= 0) {
50                close(wp->docfd);
51                wp->docfd = -1;
52        }
53#endif
54}
55
56/******************************************************************************/
57/*
58 *      Stat a web page lpath is the local filename. path is the URL path name.
59 */
60
61int websPageStat(webs_t wp, char_t *lpath, char_t *path, websStatType* sbuf)
62{
63#if WEBS_PAGE_ROM
64        return websRomPageStat(path, sbuf);
65#else
66        gstat_t s;
67
68        if (gstat(lpath, &s) < 0) {
69                return -1;
70        }
71        sbuf->size = s.st_size;
72        sbuf->mtime = s.st_mtime;
73        sbuf->isDir = s.st_mode & S_IFDIR;
74        return 0;
75#endif
76}
77
78/******************************************************************************/
79/*
80 *      Is this file a directory?
81 */
82
83int websPageIsDirectory(char_t *lpath)
84{
85#if WEBS_PAGE_ROM
86        websStatType    sbuf;
87
88        if (websRomPageStat(lpath, &sbuf) >= 0) {
89                return(sbuf.isDir);
90        } else {
91                return 0;
92        }
93#else
94        gstat_t sbuf;
95
96        if (gstat(lpath, &sbuf) >= 0) {
97                return(sbuf.st_mode & S_IFDIR);
98        } else {
99                return 0;
100        }
101#endif
102}
103
104
105/******************************************************************************/
106/*
107 *      Read a web page. Returns the number of _bytes_ read.
108 *      len is the size of buf, in bytes.
109 */
110
111int websPageReadData(webs_t wp, char *buf, int nBytes)
112{
113
114#if WEBS_PAGE_ROM
115        a_assert(websValid(wp));
116        return websRomPageReadData(wp, buf, nBytes);
117#else
118        a_assert(websValid(wp));
119        return read(wp->docfd, buf, nBytes);
120#endif
121}
122
123/******************************************************************************/
124/*
125 *      Move file pointer offset bytes.
126 */
127
128void websPageSeek(webs_t wp, long offset)
129{
130        a_assert(websValid(wp));
131
132#if WEBS_PAGE_ROM
133        websRomPageSeek(wp, offset, SEEK_CUR);
134#else
135        lseek(wp->docfd, offset, SEEK_CUR);
136#endif
137}
138
139/******************************************************************************/
140
Note: See TracBrowser for help on using the repository browser.