Refactoring netutils strings
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@351 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
7bc52e9ea1
commit
24dc336781
@ -1,40 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
|
||||
sub stringify {
|
||||
my $name = shift(@_);
|
||||
open(OUTPUTC, "> $name.c");
|
||||
open(OUTPUTH, "> $name.h");
|
||||
|
||||
open(FILE, "$name");
|
||||
|
||||
while(<FILE>) {
|
||||
if(/(.+) "(.+)"/) {
|
||||
$var = $1;
|
||||
$data = $2;
|
||||
|
||||
$datan = $data;
|
||||
$datan =~ s/\\r/\r/g;
|
||||
$datan =~ s/\\n/\n/g;
|
||||
$datan =~ s/\\01/\01/g;
|
||||
$datan =~ s/\\0/\0/g;
|
||||
|
||||
printf(OUTPUTC "const char $var\[%d] = \n", length($datan) + 1);
|
||||
printf(OUTPUTC "/* \"$data\" */\n");
|
||||
printf(OUTPUTC "{");
|
||||
for($j = 0; $j < length($datan); $j++) {
|
||||
printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1)));
|
||||
}
|
||||
printf(OUTPUTC "};\n");
|
||||
|
||||
printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1);
|
||||
|
||||
}
|
||||
}
|
||||
close(OUTPUTC);
|
||||
close(OUTPUTH);
|
||||
}
|
||||
stringify("smtp-strings");
|
||||
|
||||
exit 0;
|
||||
|
@ -1,11 +0,0 @@
|
||||
smtp_220 "220"
|
||||
smtp_helo "HELO "
|
||||
smtp_mail_from "MAIL FROM: "
|
||||
smtp_rcpt_to "RCPT TO: "
|
||||
smtp_data "DATA\r\n"
|
||||
smtp_to "To: "
|
||||
smtp_from "From: "
|
||||
smtp_subject "Subject: "
|
||||
smtp_quit "QUIT\r\n"
|
||||
smtp_crnl "\r\n"
|
||||
smtp_crnlperiodcrnl "\r\n.\r\n"
|
@ -1,33 +0,0 @@
|
||||
const char smtp_220[4] =
|
||||
/* "220" */
|
||||
{0x32, 0x32, 0x30, };
|
||||
const char smtp_helo[6] =
|
||||
/* "HELO " */
|
||||
{0x48, 0x45, 0x4c, 0x4f, 0x20, };
|
||||
const char smtp_mail_from[12] =
|
||||
/* "MAIL FROM: " */
|
||||
{0x4d, 0x41, 0x49, 0x4c, 0x20, 0x46, 0x52, 0x4f, 0x4d, 0x3a, 0x20, };
|
||||
const char smtp_rcpt_to[10] =
|
||||
/* "RCPT TO: " */
|
||||
{0x52, 0x43, 0x50, 0x54, 0x20, 0x54, 0x4f, 0x3a, 0x20, };
|
||||
const char smtp_data[7] =
|
||||
/* "DATA\r\n" */
|
||||
{0x44, 0x41, 0x54, 0x41, 0xd, 0xa, };
|
||||
const char smtp_to[5] =
|
||||
/* "To: " */
|
||||
{0x54, 0x6f, 0x3a, 0x20, };
|
||||
const char smtp_from[7] =
|
||||
/* "From: " */
|
||||
{0x46, 0x72, 0x6f, 0x6d, 0x3a, 0x20, };
|
||||
const char smtp_subject[10] =
|
||||
/* "Subject: " */
|
||||
{0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x3a, 0x20, };
|
||||
const char smtp_quit[7] =
|
||||
/* "QUIT\r\n" */
|
||||
{0x51, 0x55, 0x49, 0x54, 0xd, 0xa, };
|
||||
const char smtp_crnl[3] =
|
||||
/* "\r\n" */
|
||||
{0xd, 0xa, };
|
||||
const char smtp_crnlperiodcrnl[6] =
|
||||
/* "\r\n.\r\n" */
|
||||
{0xd, 0xa, 0x2e, 0xd, 0xa, };
|
@ -1,11 +0,0 @@
|
||||
extern const char smtp_220[4];
|
||||
extern const char smtp_helo[6];
|
||||
extern const char smtp_mail_from[12];
|
||||
extern const char smtp_rcpt_to[10];
|
||||
extern const char smtp_data[7];
|
||||
extern const char smtp_to[5];
|
||||
extern const char smtp_from[7];
|
||||
extern const char smtp_subject[10];
|
||||
extern const char smtp_quit[7];
|
||||
extern const char smtp_crnl[3];
|
||||
extern const char smtp_crnlperiodcrnl[6];
|
372
netutils/uiplib/makestrings.c
Executable file
372
netutils/uiplib/makestrings.c
Executable file
@ -0,0 +1,372 @@
|
||||
/****************************************************************************
|
||||
* net/recv.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Based loosely on a uIP perl script by Adam Dunkels
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <errno.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
enum eaction { GENSRC=0, SRCLIST=1 };
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const char *g_progname;
|
||||
static const char *g_stringfile;
|
||||
static enum eaction g_action;
|
||||
|
||||
static char g_line[1024];
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: parse_stringfile_line
|
||||
****************************************************************************/
|
||||
|
||||
void unescape_value(char *pvalue)
|
||||
{
|
||||
const char *pin;
|
||||
char *pout;
|
||||
|
||||
pin = pvalue;
|
||||
pout = pvalue;
|
||||
while (*pin)
|
||||
{
|
||||
if (*pin == '\\')
|
||||
{
|
||||
pin++;
|
||||
if ( *pin >= 0 && *pin <= 0)
|
||||
{
|
||||
char *pend;
|
||||
unsigned long val = strtoul(pin, &pend, 0);
|
||||
if (pend != pin)
|
||||
{
|
||||
*pout++ = (char)val;
|
||||
pin = pend;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pout++ = '\\';
|
||||
*pout++ = *pin++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (*pin)
|
||||
{
|
||||
case 'a':
|
||||
*pout++ = 0x07;
|
||||
break;
|
||||
case 'b':
|
||||
*pout++ = 0x08;
|
||||
break;
|
||||
case 't':
|
||||
*pout++ = 0x09;
|
||||
break;
|
||||
case 'n':
|
||||
*pout++ = 0x0a;
|
||||
break;
|
||||
case 'v':
|
||||
*pout++ = 0x0b;
|
||||
case 'f':
|
||||
*pout++ = 0x0c;
|
||||
break;
|
||||
case 'r':
|
||||
*pout++ = 0x0d;
|
||||
break;
|
||||
default:
|
||||
*pout++ = *pin;
|
||||
break;
|
||||
}
|
||||
pin++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*pout++ = *pin++;
|
||||
}
|
||||
}
|
||||
*pout = '\0';
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: parse_stringfile_line
|
||||
****************************************************************************/
|
||||
|
||||
int parse_stringfile_line(const char **ppname, const char **ppvalue)
|
||||
{
|
||||
char *ptmp;
|
||||
char *pname;
|
||||
char *pvalue;
|
||||
|
||||
pname = g_line;
|
||||
ptmp = strchr(g_line, ' ');
|
||||
if (ptmp)
|
||||
{
|
||||
*ptmp++ = '\0';
|
||||
pvalue = strchr(ptmp, '"');
|
||||
if (pvalue)
|
||||
{
|
||||
pvalue++;
|
||||
ptmp = strchr(pvalue, '"');
|
||||
if (ptmp)
|
||||
{
|
||||
*ptmp = '\0';
|
||||
unescape_value(pvalue);
|
||||
if (ppname)
|
||||
{
|
||||
*ppname = pname;
|
||||
}
|
||||
if (ppvalue)
|
||||
{
|
||||
*ppvalue = pvalue;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: open_stringfile
|
||||
****************************************************************************/
|
||||
|
||||
FILE *open_stringfile(void)
|
||||
{
|
||||
FILE *stream = fopen(g_stringfile, "r");
|
||||
if (!stream)
|
||||
{
|
||||
fprintf(stderr, "Failed to open %s for reading: %s\n", g_stringfile, strerror(errno));
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: open_outfile
|
||||
****************************************************************************/
|
||||
|
||||
FILE *open_outfile(const char *filename)
|
||||
{
|
||||
FILE *stream = fopen(filename, "w");
|
||||
if (!stream)
|
||||
{
|
||||
fprintf(stderr, "Failed to open %s for writing: %s\n", filename, strerror(errno));
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: generate_sourcefile_list
|
||||
****************************************************************************/
|
||||
|
||||
int generate_sourcefile_list(void)
|
||||
{
|
||||
int ret = 1;
|
||||
FILE *stream;
|
||||
|
||||
if (( stream = open_stringfile()))
|
||||
{
|
||||
ret = 0;
|
||||
while (fgets(g_line, 1024, stream) && !ret)
|
||||
{
|
||||
const char *pname;
|
||||
ret = parse_stringfile_line(&pname, NULL);
|
||||
if (!ret)
|
||||
{
|
||||
printf("%s.c ", pname);
|
||||
}
|
||||
}
|
||||
fclose(stream);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: generate_sourcefiles
|
||||
****************************************************************************/
|
||||
|
||||
int generate_sourcefiles(void)
|
||||
{
|
||||
FILE *instream;
|
||||
FILE *hstream;
|
||||
FILE *cstream;
|
||||
const char *pname;
|
||||
const char *pvalue;
|
||||
char buffer[512];
|
||||
int len;
|
||||
int ndx;
|
||||
int ret = 1;
|
||||
|
||||
if (( instream = open_stringfile()))
|
||||
{
|
||||
snprintf(buffer, 512, "%s.h", g_stringfile);
|
||||
hstream = open_outfile(buffer);
|
||||
if (hstream)
|
||||
{
|
||||
fprintf(hstream, "#ifndef __NETUTIL_STRINGS\n#define __NETUTIL_STRINGS\n\n");
|
||||
|
||||
ret = 0;
|
||||
while (fgets(g_line, 1024, instream) && !ret)
|
||||
{
|
||||
ret = parse_stringfile_line(&pname, &pvalue);
|
||||
if (!ret)
|
||||
{
|
||||
snprintf(buffer, 512, "%s.c", pname);
|
||||
cstream = open_outfile(buffer);
|
||||
if (cstream)
|
||||
{
|
||||
len = strlen(pvalue);
|
||||
fprintf(cstream, "const char %s[%d] = {", pname, len);
|
||||
for (ndx = 0; ndx < len; ndx++)
|
||||
{
|
||||
if (ndx > 0)
|
||||
{
|
||||
fprintf(cstream, ", ");
|
||||
}
|
||||
fprintf(cstream, "0x%02x", pvalue[ndx]);
|
||||
}
|
||||
fprintf(cstream, "}\n");
|
||||
fclose(cstream);
|
||||
}
|
||||
fprintf(hstream, "extern const char %s[%d];\n", pname, len);
|
||||
}
|
||||
}
|
||||
fprintf(hstream, "\n#endif /* __NETUTIL_STRINGS */\n");
|
||||
fclose(hstream);
|
||||
}
|
||||
fclose(instream);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: show_usage
|
||||
****************************************************************************/
|
||||
|
||||
static void show_usage( void )
|
||||
{
|
||||
fprintf(stderr, "USAGE: %s [OPTIONS] <string-file>\n\n", g_progname );
|
||||
fprintf(stderr, "Where [OPTIONS] include:\n");
|
||||
fprintf(stderr, "\t-s: Output string source file list on stdout");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: show_usage
|
||||
****************************************************************************/
|
||||
|
||||
static void parse_commandline( int argc, char **argv )
|
||||
{
|
||||
int option;
|
||||
g_progname = argv[0];
|
||||
while ((option = getopt(argc, argv, ":s")) >= 0)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
case 's':
|
||||
g_action = SRCLIST;
|
||||
break;
|
||||
|
||||
case ':':
|
||||
fprintf(stderr, "Missing command argument\n");
|
||||
show_usage();
|
||||
break;
|
||||
|
||||
case '?':
|
||||
option = optopt;
|
||||
default:
|
||||
fprintf(stderr, "Unrecognized option: %c\n", option);
|
||||
show_usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
g_stringfile = argv[optind];
|
||||
optind++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Missing <string-file> path\n");
|
||||
show_usage();
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
fprintf(stderr, "Garbage on command line after <string-file>\n");
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: main
|
||||
****************************************************************************/
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
int ret = 0;
|
||||
parse_commandline(argc, argv);
|
||||
switch (g_action)
|
||||
{
|
||||
case GENSRC:
|
||||
ret = generate_sourcefiles();
|
||||
break;
|
||||
case SRCLIST:
|
||||
ret = generate_sourcefile_list();
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,35 +1,46 @@
|
||||
http_http "http://"
|
||||
http_10 "HTTP/1.0"
|
||||
http_11 "HTTP/1.1"
|
||||
http_200 "200 "
|
||||
http_301 "301 "
|
||||
http_302 "302 "
|
||||
http_get "GET "
|
||||
http_10 "HTTP/1.0"
|
||||
http_11 "HTTP/1.1"
|
||||
http_content_type "content-type: "
|
||||
http_texthtml "text/html"
|
||||
http_location "location: "
|
||||
http_host "host: "
|
||||
http_crnl "\r\n"
|
||||
http_index_html "/index.html"
|
||||
http_404_html "/404.html"
|
||||
http_referer "Referer:"
|
||||
http_content_type "content-type: "
|
||||
http_content_type_binary "Content-type: application/octet-stream\r\n\r\n"
|
||||
http_content_type_css "Content-type: text/css\r\n\r\n"
|
||||
http_content_type_gif "Content-type: image/gif\r\n\r\n"
|
||||
http_content_type_html "Content-type: text/html\r\n\r\n"
|
||||
http_content_type_jpg "Content-type: image/jpeg\r\n\r\n"
|
||||
http_content_type_plain "Content-type: text/plain\r\n\r\n"
|
||||
http_content_type_png "Content-type: image/png\r\n\r\n"
|
||||
http_content_type_text "Content-type: text/text\r\n\r\n"
|
||||
http_crnl "\r\n"
|
||||
http_css ".css"
|
||||
http_get "GET "
|
||||
http_gif ".gif"
|
||||
http_header_200 "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n"
|
||||
http_header_404 "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n"
|
||||
http_content_type_plain "Content-type: text/plain\r\n\r\n"
|
||||
http_content_type_html "Content-type: text/html\r\n\r\n"
|
||||
http_content_type_css "Content-type: text/css\r\n\r\n"
|
||||
http_content_type_text "Content-type: text/text\r\n\r\n"
|
||||
http_content_type_png "Content-type: image/png\r\n\r\n"
|
||||
http_content_type_gif "Content-type: image/gif\r\n\r\n"
|
||||
http_content_type_jpg "Content-type: image/jpeg\r\n\r\n"
|
||||
http_content_type_binary "Content-type: application/octet-stream\r\n\r\n"
|
||||
http_html ".html"
|
||||
http_shtml ".shtml"
|
||||
http_host "host: "
|
||||
http_htm ".htm"
|
||||
http_css ".css"
|
||||
http_png ".png"
|
||||
http_gif ".gif"
|
||||
http_html ".html"
|
||||
http_http "http://"
|
||||
http_index_html "/index.html"
|
||||
http_jpg ".jpg"
|
||||
http_text ".txt"
|
||||
http_location "location: "
|
||||
http_png ".png"
|
||||
http_referer "Referer:"
|
||||
http_shtml ".shtml"
|
||||
http_text ".text"
|
||||
http_texthtml "text/html"
|
||||
http_txt ".txt"
|
||||
|
||||
http_user_agent_fields "Connection: close\r\nUser-Agent: uIP/1.0 (; http://www.sics.se/~adam/uip/)\r\n\r\n"
|
||||
smtp_220 "220"
|
||||
smtp_crnl "\r\n"
|
||||
smtp_crnlperiodcrnl "\r\n.\r\n"http_http "http://"
|
||||
smtp_data "DATA\r\n"
|
||||
smtp_from "From: "
|
||||
smtp_helo "HELO "
|
||||
smtp_mail_from "MAIL FROM: "
|
||||
smtp_quit "QUIT\r\n"
|
||||
smtp_rcpt_to "RCPT TO: "
|
||||
smtp_subject "Subject: "
|
||||
smtp_to "To: "
|
@ -1,40 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
|
||||
sub stringify {
|
||||
my $name = shift(@_);
|
||||
open(OUTPUTC, "> $name.c");
|
||||
open(OUTPUTH, "> $name.h");
|
||||
|
||||
open(FILE, "$name");
|
||||
|
||||
while(<FILE>) {
|
||||
if(/(.+) "(.+)"/) {
|
||||
$var = $1;
|
||||
$data = $2;
|
||||
|
||||
$datan = $data;
|
||||
$datan =~ s/\\r/\r/g;
|
||||
$datan =~ s/\\n/\n/g;
|
||||
$datan =~ s/\\01/\01/g;
|
||||
$datan =~ s/\\0/\0/g;
|
||||
|
||||
printf(OUTPUTC "const char $var\[%d] = \n", length($datan) + 1);
|
||||
printf(OUTPUTC "/* \"$data\" */\n");
|
||||
printf(OUTPUTC "{");
|
||||
for($j = 0; $j < length($datan); $j++) {
|
||||
printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1)));
|
||||
}
|
||||
printf(OUTPUTC "0 };\n");
|
||||
|
||||
printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1);
|
||||
|
||||
}
|
||||
}
|
||||
close(OUTPUTC);
|
||||
close(OUTPUTH);
|
||||
}
|
||||
stringify("webclient-strings");
|
||||
|
||||
exit 0;
|
||||
|
@ -1,31 +0,0 @@
|
||||
http_http "http://"
|
||||
http_200 "200 "
|
||||
http_301 "301 "
|
||||
http_302 "302 "
|
||||
http_get "GET "
|
||||
http_10 "HTTP/1.0"
|
||||
http_11 "HTTP/1.1"
|
||||
http_content_type "content-type: "
|
||||
http_texthtml "text/html"
|
||||
http_location "location: "
|
||||
http_host "host: "
|
||||
http_crnl "\r\n"
|
||||
http_index_html "/index.html"
|
||||
http_404_html "/404.html"
|
||||
http_content_type_html "Content-type: text/html\r\n\r\n"
|
||||
http_content_type_css "Content-type: text/css\r\n\r\n"
|
||||
http_content_type_text "Content-type: text/text\r\n\r\n"
|
||||
http_content_type_png "Content-type: image/png\r\n\r\n"
|
||||
http_content_type_gif "Content-type: image/gif\r\n\r\n"
|
||||
http_content_type_jpg "Content-type: image/jpeg\r\n\r\n"
|
||||
http_content_type_binary "Content-type: application/octet-stream\r\n\r\n"
|
||||
http_html ".html"
|
||||
http_shtml ".shtml"
|
||||
http_htm ".htm"
|
||||
http_css ".css"
|
||||
http_png ".png"
|
||||
http_gif ".gif"
|
||||
http_jpg ".jpg"
|
||||
http_text ".text"
|
||||
http_txt ".txt"
|
||||
http_user_agent_fields "Connection: close\r\nUser-Agent: uIP/1.0 (; http://www.sics.se/~adam/uip/)\r\n\r\n"
|
@ -1,93 +0,0 @@
|
||||
const char http_http[8] =
|
||||
/* "http://" */
|
||||
{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0 };
|
||||
const char http_200[5] =
|
||||
/* "200 " */
|
||||
{0x32, 0x30, 0x30, 0x20, 0 };
|
||||
const char http_301[5] =
|
||||
/* "301 " */
|
||||
{0x33, 0x30, 0x31, 0x20, 0 };
|
||||
const char http_302[5] =
|
||||
/* "302 " */
|
||||
{0x33, 0x30, 0x32, 0x20, 0 };
|
||||
const char http_get[5] =
|
||||
/* "GET " */
|
||||
{0x47, 0x45, 0x54, 0x20, 0 };
|
||||
const char http_10[9] =
|
||||
/* "HTTP/1.0" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0 };
|
||||
const char http_11[9] =
|
||||
/* "HTTP/1.1" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0 };
|
||||
const char http_content_type[15] =
|
||||
/* "content-type: " */
|
||||
{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0 };
|
||||
const char http_texthtml[10] =
|
||||
/* "text/html" */
|
||||
{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0 };
|
||||
const char http_location[11] =
|
||||
/* "location: " */
|
||||
{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0 };
|
||||
const char http_host[7] =
|
||||
/* "host: " */
|
||||
{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, 0 };
|
||||
const char http_crnl[3] =
|
||||
/* "\r\n" */
|
||||
{0xd, 0xa, 0 };
|
||||
const char http_index_html[12] =
|
||||
/* "/index.html" */
|
||||
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0 };
|
||||
const char http_404_html[10] =
|
||||
/* "/404.html" */
|
||||
{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0 };
|
||||
const char http_content_type_html[28] =
|
||||
/* "Content-type: text/html\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, 0 };
|
||||
const char http_content_type_css [27] =
|
||||
/* "Content-type: text/css\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, 0 };
|
||||
const char http_content_type_text[28] =
|
||||
/* "Content-type: text/text\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, 0 };
|
||||
const char http_content_type_png [28] =
|
||||
/* "Content-type: image/png\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, 0 };
|
||||
const char http_content_type_gif [28] =
|
||||
/* "Content-type: image/gif\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, 0 };
|
||||
const char http_content_type_jpg [29] =
|
||||
/* "Content-type: image/jpeg\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, 0 };
|
||||
const char http_content_type_binary[43] =
|
||||
/* "Content-type: application/octet-stream\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, 0 };
|
||||
const char http_html[6] =
|
||||
/* ".html" */
|
||||
{0x2e, 0x68, 0x74, 0x6d, 0x6c, 0 };
|
||||
const char http_shtml[7] =
|
||||
/* ".shtml" */
|
||||
{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0 };
|
||||
const char http_htm[5] =
|
||||
/* ".htm" */
|
||||
{0x2e, 0x68, 0x74, 0x6d, 0 };
|
||||
const char http_css[5] =
|
||||
/* ".css" */
|
||||
{0x2e, 0x63, 0x73, 0x73, 0 };
|
||||
const char http_png[5] =
|
||||
/* ".png" */
|
||||
{0x2e, 0x70, 0x6e, 0x67, 0 };
|
||||
const char http_gif[5] =
|
||||
/* ".gif" */
|
||||
{0x2e, 0x67, 0x69, 0x66, 0 };
|
||||
const char http_jpg[5] =
|
||||
/* ".jpg" */
|
||||
{0x2e, 0x6a, 0x70, 0x67, 0 };
|
||||
const char http_text[6] =
|
||||
/* ".text" */
|
||||
{0x2e, 0x74, 0x65, 0x78, 0x74, 0 };
|
||||
const char http_txt[5] =
|
||||
/* ".txt" */
|
||||
{0x2e, 0x74, 0x78, 0x74, 0 };
|
||||
const char http_user_agent_fields[77] =
|
||||
/* "Connection: close\r\nUser-Agent: uIP/1.0 (; http://www.sics.se/~adam/uip/)\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x28, 0x3b, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0x29, 0xd, 0xa, 0xd, 0xa, 0 };
|
@ -1,31 +0,0 @@
|
||||
extern const char http_http[8];
|
||||
extern const char http_200[5];
|
||||
extern const char http_301[5];
|
||||
extern const char http_302[5];
|
||||
extern const char http_get[5];
|
||||
extern const char http_10[9];
|
||||
extern const char http_11[9];
|
||||
extern const char http_content_type[15];
|
||||
extern const char http_texthtml[10];
|
||||
extern const char http_location[11];
|
||||
extern const char http_host[7];
|
||||
extern const char http_crnl[3];
|
||||
extern const char http_index_html[12];
|
||||
extern const char http_404_html[10];
|
||||
extern const char http_content_type_html[28];
|
||||
extern const char http_content_type_css [27];
|
||||
extern const char http_content_type_text[28];
|
||||
extern const char http_content_type_png [28];
|
||||
extern const char http_content_type_gif [28];
|
||||
extern const char http_content_type_jpg [29];
|
||||
extern const char http_content_type_binary[43];
|
||||
extern const char http_html[6];
|
||||
extern const char http_shtml[7];
|
||||
extern const char http_htm[5];
|
||||
extern const char http_css[5];
|
||||
extern const char http_png[5];
|
||||
extern const char http_gif[5];
|
||||
extern const char http_jpg[5];
|
||||
extern const char http_text[6];
|
||||
extern const char http_txt[5];
|
||||
extern const char http_user_agent_fields[77];
|
@ -1,102 +0,0 @@
|
||||
const char http_http[8] =
|
||||
/* "http://" */
|
||||
{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, };
|
||||
const char http_200[5] =
|
||||
/* "200 " */
|
||||
{0x32, 0x30, 0x30, 0x20, };
|
||||
const char http_301[5] =
|
||||
/* "301 " */
|
||||
{0x33, 0x30, 0x31, 0x20, };
|
||||
const char http_302[5] =
|
||||
/* "302 " */
|
||||
{0x33, 0x30, 0x32, 0x20, };
|
||||
const char http_get[5] =
|
||||
/* "GET " */
|
||||
{0x47, 0x45, 0x54, 0x20, };
|
||||
const char http_10[9] =
|
||||
/* "HTTP/1.0" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, };
|
||||
const char http_11[9] =
|
||||
/* "HTTP/1.1" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, };
|
||||
const char http_content_type[15] =
|
||||
/* "content-type: " */
|
||||
{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, };
|
||||
const char http_texthtml[10] =
|
||||
/* "text/html" */
|
||||
{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_location[11] =
|
||||
/* "location: " */
|
||||
{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, };
|
||||
const char http_host[7] =
|
||||
/* "host: " */
|
||||
{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, };
|
||||
const char http_crnl[3] =
|
||||
/* "\r\n" */
|
||||
{0xd, 0xa, };
|
||||
const char http_index_html[12] =
|
||||
/* "/index.html" */
|
||||
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_404_html[10] =
|
||||
/* "/404.html" */
|
||||
{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_referer[9] =
|
||||
/* "Referer:" */
|
||||
{0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, 0x3a, };
|
||||
const char http_header_200[84] =
|
||||
/* "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
|
||||
const char http_header_404[91] =
|
||||
/* "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34, 0x30, 0x34, 0x20, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
|
||||
const char http_content_type_plain[29] =
|
||||
/* "Content-type: text/plain\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_html[28] =
|
||||
/* "Content-type: text/html\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_css [27] =
|
||||
/* "Content-type: text/css\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_text[28] =
|
||||
/* "Content-type: text/text\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_png [28] =
|
||||
/* "Content-type: image/png\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_gif [28] =
|
||||
/* "Content-type: image/gif\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_jpg [29] =
|
||||
/* "Content-type: image/jpeg\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_binary[43] =
|
||||
/* "Content-type: application/octet-stream\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_html[6] =
|
||||
/* ".html" */
|
||||
{0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_shtml[7] =
|
||||
/* ".shtml" */
|
||||
{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_htm[5] =
|
||||
/* ".htm" */
|
||||
{0x2e, 0x68, 0x74, 0x6d, };
|
||||
const char http_css[5] =
|
||||
/* ".css" */
|
||||
{0x2e, 0x63, 0x73, 0x73, };
|
||||
const char http_png[5] =
|
||||
/* ".png" */
|
||||
{0x2e, 0x70, 0x6e, 0x67, };
|
||||
const char http_gif[5] =
|
||||
/* ".gif" */
|
||||
{0x2e, 0x67, 0x69, 0x66, };
|
||||
const char http_jpg[5] =
|
||||
/* ".jpg" */
|
||||
{0x2e, 0x6a, 0x70, 0x67, };
|
||||
const char http_text[5] =
|
||||
/* ".txt" */
|
||||
{0x2e, 0x74, 0x78, 0x74, };
|
||||
const char http_txt[5] =
|
||||
/* ".txt" */
|
||||
{0x2e, 0x74, 0x78, 0x74, };
|
@ -1,34 +0,0 @@
|
||||
extern const char http_http[8];
|
||||
extern const char http_200[5];
|
||||
extern const char http_301[5];
|
||||
extern const char http_302[5];
|
||||
extern const char http_get[5];
|
||||
extern const char http_10[9];
|
||||
extern const char http_11[9];
|
||||
extern const char http_content_type[15];
|
||||
extern const char http_texthtml[10];
|
||||
extern const char http_location[11];
|
||||
extern const char http_host[7];
|
||||
extern const char http_crnl[3];
|
||||
extern const char http_index_html[12];
|
||||
extern const char http_404_html[10];
|
||||
extern const char http_referer[9];
|
||||
extern const char http_header_200[84];
|
||||
extern const char http_header_404[91];
|
||||
extern const char http_content_type_plain[29];
|
||||
extern const char http_content_type_html[28];
|
||||
extern const char http_content_type_css [27];
|
||||
extern const char http_content_type_text[28];
|
||||
extern const char http_content_type_png [28];
|
||||
extern const char http_content_type_gif [28];
|
||||
extern const char http_content_type_jpg [29];
|
||||
extern const char http_content_type_binary[43];
|
||||
extern const char http_html[6];
|
||||
extern const char http_shtml[7];
|
||||
extern const char http_htm[5];
|
||||
extern const char http_css[5];
|
||||
extern const char http_png[5];
|
||||
extern const char http_gif[5];
|
||||
extern const char http_jpg[5];
|
||||
extern const char http_text[5];
|
||||
extern const char http_txt[5];
|
@ -1,40 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
|
||||
sub stringify {
|
||||
my $name = shift(@_);
|
||||
open(OUTPUTC, "> $name.c");
|
||||
open(OUTPUTH, "> $name.h");
|
||||
|
||||
open(FILE, "$name");
|
||||
|
||||
while(<FILE>) {
|
||||
if(/(.+) "(.+)"/) {
|
||||
$var = $1;
|
||||
$data = $2;
|
||||
|
||||
$datan = $data;
|
||||
$datan =~ s/\\r/\r/g;
|
||||
$datan =~ s/\\n/\n/g;
|
||||
$datan =~ s/\\01/\01/g;
|
||||
$datan =~ s/\\0/\0/g;
|
||||
|
||||
printf(OUTPUTC "const char $var\[%d] = \n", length($datan) + 1);
|
||||
printf(OUTPUTC "/* \"$data\" */\n");
|
||||
printf(OUTPUTC "{");
|
||||
for($j = 0; $j < length($datan); $j++) {
|
||||
printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1)));
|
||||
}
|
||||
printf(OUTPUTC "};\n");
|
||||
|
||||
printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1);
|
||||
|
||||
}
|
||||
}
|
||||
close(OUTPUTC);
|
||||
close(OUTPUTH);
|
||||
}
|
||||
stringify("http-strings");
|
||||
|
||||
exit 0;
|
||||
|
Loading…
Reference in New Issue
Block a user