OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [uIP_Demo_IAR_ARM7/] [uip/] [fs.c] - Blame information for rev 583

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 583 jeremybenn
/**
2
 * \addtogroup httpd
3
 * @{
4
 */
5
 
6
/**
7
 * \file
8
 * HTTP server read-only file system code.
9
 * \author Adam Dunkels <adam@dunkels.com>
10
 *
11
 * A simple read-only filesystem.
12
 */
13
 
14
/*
15
 * Copyright (c) 2001, Swedish Institute of Computer Science.
16
 * All rights reserved.
17
 *
18
 * Redistribution and use in source and binary forms, with or without
19
 * modification, are permitted provided that the following conditions
20
 * are met:
21
 * 1. Redistributions of source code must retain the above copyright
22
 *    notice, this list of conditions and the following disclaimer.
23
 * 2. Redistributions in binary form must reproduce the above copyright
24
 *    notice, this list of conditions and the following disclaimer in the
25
 *    documentation and/or other materials provided with the distribution.
26
 * 3. Neither the name of the Institute nor the names of its contributors
27
 *    may be used to endorse or promote products derived from this software
28
 *    without specific prior written permission.
29
 *
30
 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
31
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
34
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40
 * SUCH DAMAGE.
41
 *
42
 * This file is part of the lwIP TCP/IP stack.
43
 *
44
 * Author: Adam Dunkels <adam@sics.se>
45
 *
46
 * $Id: fs.c 2 2011-07-17 20:13:17Z filepang@gmail.com $
47
 */
48
 
49
#include "uip.h"
50
#include "httpd.h"
51
#include "fs.h"
52
#include "fsdata.h"
53
 
54
#define NULL (void *)0
55
#include "fsdata.c"
56
 
57
#ifdef FS_STATISTICS
58
#if FS_STATISTICS == 1
59
static u16_t count[FS_NUMFILES];
60
#endif /* FS_STATISTICS */
61
#endif /* FS_STATISTICS */
62
 
63
/*-----------------------------------------------------------------------------------*/
64
static u8_t
65
fs_strcmp(const char *str1, const char *str2)
66
{
67
  u8_t i;
68
  i = 0;
69
 loop:
70
 
71
  if(str2[i] == 0 ||
72
     str1[i] == '\r' ||
73
     str1[i] == '\n') {
74
    return 0;
75
  }
76
 
77
  if(str1[i] != str2[i]) {
78
    return 1;
79
  }
80
 
81
 
82
  ++i;
83
  goto loop;
84
}
85
/*-----------------------------------------------------------------------------------*/
86
int
87
fs_open(const char *name, struct fs_file *file)
88
{
89
#ifdef FS_STATISTICS
90
#if FS_STATISTICS == 1
91
  u16_t i = 0;
92
#endif /* FS_STATISTICS */
93
#endif /* FS_STATISTICS */
94
  struct fsdata_file_noconst *f;
95
 
96
  for(f = (struct fsdata_file_noconst *)FS_ROOT;
97
      f != NULL;
98
      f = (struct fsdata_file_noconst *)f->next) {
99
 
100
    if(fs_strcmp(name, f->name) == 0) {
101
      file->data = f->data;
102
      file->len = f->len;
103
#ifdef FS_STATISTICS
104
#if FS_STATISTICS == 1
105
      ++count[i];
106
#endif /* FS_STATISTICS */
107
#endif /* FS_STATISTICS */
108
 
109
      return 1;
110
    }
111
#ifdef FS_STATISTICS
112
#if FS_STATISTICS == 1
113
    ++i;
114
#endif /* FS_STATISTICS */
115
#endif /* FS_STATISTICS */
116
 
117
  }
118
  return 0;
119
}
120
/*-----------------------------------------------------------------------------------*/
121
void
122
fs_init(void)
123
{
124
#ifdef FS_STATISTICS
125
#if FS_STATISTICS == 1
126
  u16_t i;
127
  for(i = 0; i < FS_NUMFILES; i++) {
128
    count[i] = 0;
129
  }
130
#endif /* FS_STATISTICS */
131
#endif /* FS_STATISTICS */
132
}
133
/*-----------------------------------------------------------------------------------*/
134
#ifdef FS_STATISTICS
135
#if FS_STATISTICS == 1
136
u16_t fs_count
137
(char *name)
138
{
139
  struct fsdata_file_noconst *f;
140
  u16_t i;
141
 
142
  i = 0;
143
  for(f = (struct fsdata_file_noconst *)FS_ROOT;
144
      f != NULL;
145
      f = (struct fsdata_file_noconst *)f->next) {
146
 
147
    if(fs_strcmp(name, f->name) == 0) {
148
      return count[i];
149
    }
150
    ++i;
151
  }
152
  return 0;
153
}
154
#endif /* FS_STATISTICS */
155
#endif /* FS_STATISTICS */
156
/*-----------------------------------------------------------------------------------*/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.