source: rtems/cpukit/httpd/webpage.c @ ee75aad

4.104.115
Last change on this file since ee75aad was 73b5bd5d, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/15/04 at 13:33:58

Remove stray white spaces.

  • 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 * $Id$
9 */
10
11/******************************** Description *********************************/
12
13/*
14 *      This module provides page retrieval handling. It provides support for
15 *      reading web pages from file systems and has expansion for ROMed web
16 *      pages.
17 */
18
19/********************************* Includes ***********************************/
20
21#include        "wsIntrn.h"
22
23/*********************************** Code *************************************/
24/*
25 *      Open a web page. lpath is the local filename. path is the URL path name.
26 */
27
28int websPageOpen(webs_t wp, char_t *lpath, char_t *path, int mode, int perm)
29{
30        a_assert(websValid(wp));
31
32#ifdef WEBS_PAGE_ROM
33        return websRomPageOpen(wp, path, mode, perm);
34#else
35        return (wp->docfd = gopen(lpath, mode, perm));
36#endif /* WEBS_PAGE_ROM */
37}
38
39/******************************************************************************/
40/*
41 *      Close a web page
42 */
43
44void websPageClose(webs_t wp)
45{
46        a_assert(websValid(wp));
47
48#ifdef WEBS_PAGE_ROM
49        websRomPageClose(wp->docfd);
50#else
51        if (wp->docfd >= 0) {
52                close(wp->docfd);
53                wp->docfd = -1;
54        }
55#endif
56}
57
58/******************************************************************************/
59/*
60 *      Stat a web page lpath is the local filename. path is the URL path name.
61 */
62
63int websPageStat(webs_t wp, char_t *lpath, char_t *path, websStatType* sbuf)
64{
65#ifdef WEBS_PAGE_ROM
66        return websRomPageStat(path, sbuf);
67#else
68        gstat_t s;
69
70        if (gstat(lpath, &s) < 0) {
71                return -1;
72        }
73        sbuf->size = s.st_size;
74        sbuf->mtime = s.st_mtime;
75        sbuf->isDir = s.st_mode & S_IFDIR;
76        return 0;
77#endif
78}
79
80/******************************************************************************/
81/*
82 *      Is this file a directory?
83 */
84
85int websPageIsDirectory(char_t *lpath)
86{
87#ifdef WEBS_PAGE_ROM
88        websStatType    sbuf;
89
90        if (websRomPageStat(lpath, &sbuf) >= 0) {
91                return(sbuf.isDir);
92        } else {
93                return 0;
94        }
95#else
96        gstat_t sbuf;
97
98        if (gstat(lpath, &sbuf) >= 0) {
99                return(sbuf.st_mode & S_IFDIR);
100        } else {
101                return 0;
102        }
103#endif
104}
105
106
107/******************************************************************************/
108/*
109 *      Read a web page. Returns the number of _bytes_ read.
110 *      len is the size of buf, in bytes.
111 */
112
113int websPageReadData(webs_t wp, char *buf, int nBytes)
114{
115
116#ifdef WEBS_PAGE_ROM
117        a_assert(websValid(wp));
118        return websRomPageReadData(wp, buf, nBytes);
119#else
120        a_assert(websValid(wp));
121        return read(wp->docfd, buf, nBytes);
122#endif
123}
124
125/******************************************************************************/
126/*
127 *      Move file pointer offset bytes.
128 */
129
130void websPageSeek(webs_t wp, long offset)
131{
132        a_assert(websValid(wp));
133
134#ifdef WEBS_PAGE_ROM
135        websRomPageSeek(wp, offset, SEEK_CUR);
136#else
137        lseek(wp->docfd, offset, SEEK_CUR);
138#endif
139}
140
141/******************************************************************************/
Note: See TracBrowser for help on using the repository browser.