Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mongoose
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ganil-acq
GANILinux
linux-service
library
mongoose
Commits
78ea0455
Commit
78ea0455
authored
12 years ago
by
Sergey Lyubka
Browse files
Options
Downloads
Patches
Plain Diff
Windows build for examples added
parent
7fe29444
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/Makefile
+14
-0
14 additions, 0 deletions
examples/Makefile
examples/upload.c
+12
-2
12 additions, 2 deletions
examples/upload.c
with
26 additions
and
2 deletions
examples/Makefile
+
14
−
0
View file @
78ea0455
...
...
@@ -8,3 +8,17 @@ all:
$(
CC
)
$(
CFLAGS
)
post.c ../mongoose.c
$$
LIBS
$(
ADD
)
-o
post
;
$(
CC
)
$(
CFLAGS
)
-DUSE_WEBSOCKET
websocket.c ../mongoose.c
$$
LIBS
$(
ADD
)
-o
websocket
;
$(
CC
)
$(
CFLAGS
)
chat.c ../mongoose.c
$$
LIBS
$(
ADD
)
-o
chat
MSVC
=
e:/vc6
CL
=
$(
MSVC
)
/bin/cl
CLFLAGS
=
/MD /TC /nologo
$(
DBG
)
/W3 /DNO_SSL
\
/I
$(
MSVC
)
/include /I.. /Dsnprintf
=
_snprintf
\
/link /incremental:no /libpath:
$(
MSVC
)
/lib /machine:IX86
windows
:
$(
CL
)
hello.c ../mongoose.c
$(
CLFLAGS
)
$(
CL
)
upload.c ../mongoose.c
$(
CLFLAGS
)
$(
CL
)
post.c ../mongoose.c
$(
CLFLAGS
)
$(
CL
)
post.c ../mongoose.c
$(
CLFLAGS
)
$(
CL
)
/DUSE_WEBSOCKET websocket.c ../mongoose.c
$(
CLFLAGS
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
examples/upload.c
+
12
−
2
View file @
78ea0455
...
...
@@ -5,8 +5,18 @@
#include
<string.h>
#include
<fcntl.h>
#include
<stdlib.h>
#ifdef _WIN32
#include
<windows.h>
#include
<io.h>
#define strtoll strtol
typedef
__int64
int64_t
;
#define O_CLOEXEC 0
#define O_EXLOCK 0
#else
#include
<inttypes.h>
#include
<unistd.h>
#endif // !_WIN32
#include
"mongoose.h"
// Make sure that form has enctype="multipart/form-data" attribute
...
...
@@ -25,7 +35,7 @@ static void handle_file_upload(struct mg_connection *conn) {
char
post_data
[
16
*
1024
],
path
[
999
],
file_name
[
1024
],
mime_type
[
100
],
buf
[
BUFSIZ
],
*
eop
,
*
s
,
*
p
;
FILE
*
fp
;
long
long
in
t
cl
,
written
;
int64_
t
cl
,
written
;
int
fd
,
n
,
post_data_len
;
// Figure out total content length. Return if it is not present or invalid.
...
...
@@ -87,7 +97,7 @@ static void handle_file_upload(struct mg_connection *conn) {
(
void
)
fwrite
(
p
,
1
,
n
,
fp
);
written
=
n
;
while
(
written
<
cl
&&
(
n
=
mg_read
(
conn
,
buf
,
cl
-
written
>
(
long
long
)
sizeof
(
buf
)
?
(
n
=
mg_read
(
conn
,
buf
,
cl
-
written
>
(
int64_t
)
sizeof
(
buf
)
?
sizeof
(
buf
)
:
cl
-
written
))
>
0
)
{
(
void
)
fwrite
(
buf
,
1
,
n
,
fp
);
written
+=
n
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment