Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
5234b73c
Commit
5234b73c
authored
Sep 08, 2015
by
Marko Mikulicic
Committed by
Sergey Lyubka
Sep 09, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add simple core dumper for ESP
PUBLISHED_FROM=ec98516ce6aa1c841344adc7aae20b044b3d349b
parent
c566e2eb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
20 deletions
+75
-20
mongoose.c
mongoose.c
+68
-20
mongoose.h
mongoose.h
+7
-0
No files found.
mongoose.c
View file @
5234b73c
...
...
@@ -674,31 +674,79 @@ void MD5_Final(unsigned char digest[16], MD5_CTX *ctx) {
/* Amalgamated: #include "base64.h" */
#define BASE64_ENCODE_BODY \
static const char *b64 = \
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; \
int i, j, a, b, c; \
\
for (i = j = 0; i < src_len; i += 3) { \
a = src[i]; \
b = i + 1 >= src_len ? 0 : src[i + 1]; \
c = i + 2 >= src_len ? 0 : src[i + 2]; \
\
BASE64_OUT(b64[a >> 2]); \
BASE64_OUT(b64[((a & 3) << 4) | (b >> 4)]); \
if (i + 1 < src_len) { \
BASE64_OUT(b64[(b & 15) << 2 | (c >> 6)]); \
} \
if (i + 2 < src_len) { \
BASE64_OUT(b64[c & 63]); \
} \
} \
\
while (j % 4 != 0) { \
BASE64_OUT('='); \
} \
BASE64_FLUSH()
#define BASE64_OUT(ch) \
do { \
dst[j++] = (ch); \
} while (0)
#define BASE64_FLUSH() \
do { \
dst[j++] = '\0'; \
} while (0)
void
cs_base64_encode
(
const
unsigned
char
*
src
,
int
src_len
,
char
*
dst
)
{
static
const
char
*
b64
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
int
i
,
j
,
a
,
b
,
c
;
BASE64_ENCODE_BODY
;
}
for
(
i
=
j
=
0
;
i
<
src_len
;
i
+=
3
)
{
a
=
src
[
i
];
b
=
i
+
1
>=
src_len
?
0
:
src
[
i
+
1
];
c
=
i
+
2
>=
src_len
?
0
:
src
[
i
+
2
];
#undef BASE64_OUT
#undef BASE64_FLUSH
dst
[
j
++
]
=
b64
[
a
>>
2
];
dst
[
j
++
]
=
b64
[((
a
&
3
)
<<
4
)
|
(
b
>>
4
)];
if
(
i
+
1
<
src_len
)
{
dst
[
j
++
]
=
b64
[(
b
&
15
)
<<
2
|
(
c
>>
6
)];
}
if
(
i
+
2
<
src_len
)
{
dst
[
j
++
]
=
b64
[
c
&
63
];
}
}
while
(
j
%
4
!=
0
)
{
dst
[
j
++
]
=
'='
;
}
dst
[
j
++
]
=
'\0'
;
#define BASE64_OUT(ch) \
do { \
cb((ch)); \
j++; \
} while (0)
#define BASE64_FLUSH()
void
cs_base64_encode2
(
const
unsigned
char
*
src
,
int
src_len
,
cs_base64_cb_t
cb
)
{
BASE64_ENCODE_BODY
;
}
#undef BASE64_OUT
#undef BASE64_FLUSH
#define BASE64_OUT(ch) \
do { \
fprintf(f, "%c", (ch)); \
j++; \
} while (0)
#define BASE64_FLUSH()
void
cs_fprint_base64
(
FILE
*
f
,
const
unsigned
char
*
src
,
int
src_len
)
{
BASE64_ENCODE_BODY
;
}
#undef BASE64_OUT
#undef BASE64_FLUSH
/* Convert one byte of encoded base64 input stream to 6-bit chunk */
static
unsigned
char
from_b64
(
unsigned
char
ch
)
{
/* Inverse lookup map */
...
...
mongoose.h
View file @
5234b73c
...
...
@@ -402,11 +402,18 @@ void MD5_Final(unsigned char *md, MD5_CTX *c);
#if !defined(BASE64_H_INCLUDED) && !defined(DISABLE_BASE64)
#define BASE64_H_INCLUDED
#include <stdio.h>
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
void
(
*
cs_base64_cb_t
)(
char
ch
);
void
cs_base64_encode
(
const
unsigned
char
*
src
,
int
src_len
,
char
*
dst
);
void
cs_base64_encode2
(
const
unsigned
char
*
src
,
int
src_len
,
cs_base64_cb_t
cb
);
void
cs_fprint_base64
(
FILE
*
f
,
const
unsigned
char
*
src
,
int
src_len
);
int
cs_base64_decode
(
const
unsigned
char
*
s
,
int
len
,
char
*
dst
);
#ifdef __cplusplus
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment