source: network-demos/http/init.c @ fb8fed5

network-demos-4-9-branch
Last change on this file since fb8fed5 was fb8fed5, checked in by Joel Sherrill <joel.sherrill@…>, on 09/26/08 at 19:24:40

2008-09-26 Joel Sherrill <joel.sherrill@…>

  • init.c: Eliminate boolean for bool.
  • Property mode set to 100644
File size: 4.7 KB
Line 
1/*  Init
2 *
3 *  This routine is the initialization task for this test program.
4 *
5 *  Don't forget to change the IP addresses
6 */
7
8#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
9#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
10#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
11#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS        20
12#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
13
14#define CONFIGURE_EXECUTIVE_RAM_SIZE    (512*1024)
15#define CONFIGURE_MAXIMUM_SEMAPHORES    20
16#define CONFIGURE_MAXIMUM_TASKS         20
17
18#define CONFIGURE_MICROSECONDS_PER_TICK 10000
19
20#define CONFIGURE_INIT_TASK_STACK_SIZE  (10*1024)
21#define CONFIGURE_INIT_TASK_PRIORITY    120
22#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
23                                           RTEMS_NO_TIMESLICE | \
24                                           RTEMS_NO_ASR | \
25                                           RTEMS_INTERRUPT_LEVEL(0))
26
27#define STACK_CHECKER_ON
28#define CONFIGURE_INIT
29
30#include "system.h"
31#include <bsp.h>
32
33#include <errno.h>
34#include <time.h>
35
36#include <rtems/confdefs.h>
37#include <stdio.h>
38#include <rtems/rtems_bsdnet.h>
39#include <rtems/ftpd.h>
40#include <rtems/untar.h>
41
42     
43#include <rtems/error.h>
44#include <rpc/rpc.h>
45#include <netinet/in.h>
46#include <time.h>
47
48#include <arpa/inet.h>
49#include <sys/socket.h>
50#include "../networkconfig.h"
51
52#include <rtems_webserver.h>
53
54#define ARGUMENT 0
55
56/*
57 *  The tarfile image is built automatically externally.
58 */
59#include "FilesystemImage.h"
60
61#if defined(USE_FTPD)
62  bool FTPD_enabled = true;
63  struct rtems_ftpd_configuration rtems_ftpd_configuration = {
64    10,                     /* FTPD task priority            */
65    1024,                   /* Maximum buffersize for hooks  */
66    21,                     /* Well-known port     */
67    NULL,                   /* List of hooks       */
68    NULL,                   /* Root for FTPD or 0 for / */
69    0,                      /* Max. connections    */
70    0,                      /* Idle timeout in seoconds
71                               or 0 for no (inf) timeout */
72    0,                      /* 0 - r/w, 1 - read-only,
73                               2 - write-only,
74                               3 - browse-only */
75 };
76
77#else
78 bool FTPD_enabled = false;
79#endif
80
81#if defined(USE_GOAHEAD_HTTPD) && !defined(RTEMS_POSIX_API)
82  #warning "GoAhead server requires POSIX API - switching to SHTTPD"
83  #undef USE_GOAHEAD_HTTPD
84  #undef USE_SIMPLE_HTTPD
85#endif
86
87#if defined(USE_GOAHEAD_HTTPD)
88  bool GoAhead_HTTPD_enabled = true;
89
90  /* GoAhead Trace Handler */
91  #include <goahead/uemf.h>
92  void quietTraceHandler(int level, char *buf)
93  {
94    /* do nothing */
95  }
96#else
97  bool GoAhead_HTTPD_enabled = false;
98#endif
99
100#if defined(USE_SIMPLE_HTTPD)
101  bool Simple_HTTPD_enabled = true;
102
103  #include <shttpd/shttpd.h>
104#else
105  bool Simple_HTTPD_enabled = false;
106#endif
107
108#define bool2string(_b) ((_b) ? "true" : "false")
109
110#if defined(USE_SIMPLE_HTTPD)
111extern void example_shttpd_addpages(struct shttpd_ctx *ctx);
112#endif
113
114rtems_task Init(
115  rtems_task_argument argument
116)
117{
118  rtems_status_code status;
119
120  printf("\n\n*** HTTP TEST ***\n\r" );
121  printf("GoAhead HTTPD Enabled: %s\n", bool2string(GoAhead_HTTPD_enabled) );
122  printf("Simple HTTPD Enabled: %s\n", bool2string(Simple_HTTPD_enabled) );
123  printf("FTPD Enabled: %s\n", bool2string(FTPD_enabled) );
124  printf("\n");
125
126  /*
127   * Load filesystem image
128   */
129  printf("Loading filesystem image\n");
130  status = Untar_FromMemory( (char *)FilesystemImage, FilesystemImage_size );
131   
132  printf("Initializing Network\n");
133  rtems_bsdnet_initialize_network ();
134
135  #if defined(USE_FTPD)
136    printf( "Initializing FTPD\n" );
137    rtems_initialize_ftpd();
138  #endif
139
140  #if defined(USE_GOAHEAD_HTTPD)
141    printf( "Initializing GoAhead HTTPD\n" );
142    status = rtems_initialize_webserver();
143    if ( status )
144      printf( "ERROR -- failed to initialize webserver\n" );
145
146    traceSetHandler( quietTraceHandler );
147  #endif
148
149  #if defined(USE_SIMPLE_HTTPD)
150    /*
151     *  SHTTPD uses about 37K of stack even in this test on a PowerPC.
152     *  There is no point in doing math for the stack size.  Bump it
153     *  until there isn't a problem.
154     */
155    printf( "Initializing Simple HTTPD\n" );
156    status = rtems_initialize_webserver(
157      100,                             /* initial priority */
158      (48 * 1024),                     /* stack size */
159      RTEMS_DEFAULT_MODES,             /* initial modes */
160      RTEMS_DEFAULT_ATTRIBUTES,        /* attributes */
161      NULL,                            /* init_callback */
162      example_shttpd_addpages,         /* addpages_callback */
163      "/",                             /* initial priority */
164      80                               /* port to listen on */
165    );
166    if ( status )
167      printf( "ERROR -- failed to initialize webserver\n" );
168
169  #endif
170
171  status = rtems_task_delete( RTEMS_SELF );
172}
173
174
175
176
Note: See TracBrowser for help on using the repository browser.