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

4.11network-demos-4-10-branchnetwork-demos-4-8-branchnetwork-demos-4-9-branch
Last change on this file since d51420e was d51420e, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 12, 2007 at 7:05:08 PM

2007-07-12 Joel Sherrill <joel.sherrill@…>

  • ChangeLog?, Makefile, init.c: No switchable from GoAhead? to SHTTPD but defaults to SHTTPD. The displayed index.html will indicate which httpd implementation is enabled. The user should edit the Makefile to switch settings.
  • index.html.in: New file.
  • rootfs/index.html: Removed.
  • Property mode set to 100644
File size: 4.1 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 CONFIGURE_INIT
28
29#include "system.h"
30#include <bsp.h>
31
32#include <errno.h>
33#include <time.h>
34
35#include <rtems/confdefs.h>
36#include <stdio.h>
37#include <rtems/rtems_bsdnet.h>
38#include <rtems/ftpd.h>
39#include <rtems/untar.h>
40
41     
42#include <rtems/error.h>
43#include <rpc/rpc.h>
44#include <netinet/in.h>
45#include <time.h>
46
47#include <arpa/inet.h>
48#include <sys/socket.h>
49#include "../networkconfig.h"
50
51#include <rtems_webserver.h>
52
53#define ARGUMENT 0
54
55/*
56 *  The tarfile is built automatically externally so we need to account
57 *  for the leading symbol on the names.
58 */
59#if defined(__sh__)
60  #define SYM(_x) _x
61#else
62  #define SYM(_x) _ ## _x
63#endif
64
65extern int SYM(binary_tarfile_start);
66extern int SYM(binary_tarfile_size);
67#define TARFILE_START SYM(binary_tarfile_start)
68#define TARFILE_SIZE SYM(binary_tarfile_size)
69
70#if defined(USE_FTPD)
71  boolean FTPD_enabled = TRUE;
72  struct rtems_ftpd_configuration rtems_ftpd_configuration = {
73    10,                     /* FTPD task priority            */
74    1024,                   /* Maximum buffersize for hooks  */
75    21,                     /* Well-known port     */
76    NULL                    /* List of hooks       */
77 };
78#else
79 boolean FTPD_enabled = FALSE;
80#endif
81
82#if defined(USE_GOAHEAD_HTTPD)
83  boolean GoAhead_HTTPD_enabled = TRUE;
84
85  /* GoAhead Trace Handler */
86  #include <goahead/uemf.h>
87  void quietTraceHandler(int level, char *buf)
88  {
89    /* do nothing */
90  }
91#else
92  boolean GoAhead_HTTPD_enabled = FALSE;
93#endif
94
95#if defined(USE_SIMPLE_HTTPD)
96  boolean Simple_HTTPD_enabled = TRUE;
97
98  #include <shttpd/shttpd.h>
99#else
100  boolean Simple_HTTPD_enabled = FALSE;
101#endif
102
103#define bool2string(_b) ((_b) ? "true" : "false")
104
105rtems_task Init(
106  rtems_task_argument argument
107)
108{
109  rtems_status_code status;
110
111  printf("\n\n*** HTTP TEST ***\n\r" );
112  printf("GoAhead HTTPD Enabled: %s\n", bool2string(GoAhead_HTTPD_enabled) );
113  printf("Simple HTTPD Enabled: %s\n", bool2string(Simple_HTTPD_enabled) );
114  printf("FTPD Enabled: %s\n", bool2string(FTPD_enabled) );
115  printf("\n");
116
117  /*
118   * Load filesystem image
119   */
120  printf("Loading filesystem image");
121  status = Untar_FromMemory((void *)(&TARFILE_START), (size_t)&TARFILE_SIZE);
122   
123  printf("Initializing Network");
124  rtems_bsdnet_initialize_network ();
125
126  #if defined(USE_FTPD)
127    printf( "Initializing FTPD\n" );
128    rtems_initialize_ftpd();
129  #endif
130
131  #if defined(USE_GOAHEAD_HTTPD)
132    printf( "Initializing GoAhead HTTPD\n" );
133    status = rtems_initialize_webserver();
134    if ( status )
135      printf( "ERROR -- failed to initialize webserver\n" );
136
137    traceSetHandler( quietTraceHandler );
138  #endif
139
140  #if defined(USE_SIMPLE_HTTPD)
141    printf( "Initializing Simple HTTPD\n" );
142    status = rtems_initialize_webserver(
143      100,                             /* initial priority */
144      RTEMS_MINIMUM_STACK_SIZE * 2,    /* stack size */
145      RTEMS_DEFAULT_MODES,             /* initial modes */
146      RTEMS_DEFAULT_ATTRIBUTES,        /* attributes */
147      NULL,                            /* init_callback */
148      NULL,                            /* addpages_callback */
149      "/"                              /* initial priority */
150    );
151    if ( status )
152      printf( "ERROR -- failed to initialize webserver\n" );
153
154  #endif
155
156  status = rtems_task_delete( RTEMS_SELF );
157}
158
159
160
161
Note: See TracBrowser for help on using the repository browser.