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

Subversion Repositories openrisc

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

Go to most recent revision | 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
      return 1;
109
    }
110
#ifdef FS_STATISTICS
111
#if FS_STATISTICS == 1
112
    ++i;
113
#endif /* FS_STATISTICS */
114
#endif /* FS_STATISTICS */
115
 
116
  }
117
  return 0;
118
}
119
/*-----------------------------------------------------------------------------------*/
120
void
121
fs_init(void)
122
{
123
#ifdef FS_STATISTICS
124
#if FS_STATISTICS == 1
125
  u16_t i;
126
  for(i = 0; i < FS_NUMFILES; i++) {
127
    count[i] = 0;
128
  }
129
#endif /* FS_STATISTICS */
130
#endif /* FS_STATISTICS */
131
}
132
/*-----------------------------------------------------------------------------------*/
133
#ifdef FS_STATISTICS
134
#if FS_STATISTICS == 1  
135
u16_t fs_count
136
(char *name)
137
{
138
  struct fsdata_file_noconst *f;
139
  u16_t i;
140
 
141
  i = 0;
142
  for(f = (struct fsdata_file_noconst *)FS_ROOT;
143
      f != NULL;
144
      f = (struct fsdata_file_noconst *)f->next) {
145
 
146
    if(fs_strcmp(name, f->name) == 0) {
147
      return count[i];
148
    }
149
    ++i;
150
  }
151
  return 0;
152
}
153
#endif /* FS_STATISTICS */
154
#endif /* FS_STATISTICS */
155
/*-----------------------------------------------------------------------------------*/

powered by: WebSVN 2.1.0

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