Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Main
Synchronet
Commits
5291dc24
Commit
5291dc24
authored
21 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Eliminated silly strcpy/strcat code.
Changed mime blurb.
parent
2fcd5122
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/mime.c
+21
-47
21 additions, 47 deletions
src/sbbs3/mime.c
with
21 additions
and
47 deletions
src/sbbs3/mime.c
+
21
−
47
View file @
5291dc24
...
...
@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 200
0
Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 200
3
Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
...
...
@@ -47,10 +47,10 @@
#define SIZEOF_MIMEBOUNDARY 36
char
*
mimegetboundary
()
char
*
mimegetboundary
()
{
int
i
,
num
;
char
*
boundaryString
=
(
char
*
)
malloc
(
SIZEOF_MIMEBOUNDARY
+
1
);
int
i
,
num
;
char
*
boundaryString
=
(
char
*
)
malloc
(
SIZEOF_MIMEBOUNDARY
+
1
);
srand
(
time
(
NULL
));
if
(
boundaryString
==
NULL
)
...
...
@@ -69,36 +69,28 @@ char * mimegetboundary()
return
boundaryString
;
}
void
mimeheaders
(
SOCKET
socket
,
char
*
boundary
)
void
mimeheaders
(
SOCKET
socket
,
char
*
boundary
)
{
char
bndline
[
50
];
sockprintf
(
socket
,
"MIME-Version: 1.0"
);
sockprintf
(
socket
,
"Content-Type: multipart/mixed;"
);
strcpy
(
bndline
,
" boundary=
\"
"
);
strcat
(
bndline
,
boundary
);
strcat
(
bndline
,
"
\"
"
);
sockprintf
(
socket
,
bndline
);
sockprintf
(
socket
,
" boundary=
\"
%s
\"
"
,
boundary
);
}
void
mimeblurb
(
SOCKET
socket
,
char
*
boundary
)
void
mimeblurb
(
SOCKET
socket
,
char
*
boundary
)
{
sockprintf
(
socket
,
"This is a
MIME blurb. You shouldn't be seeing this!
"
);
sockprintf
(
socket
,
"This is a
multi-part message in MIME format.
"
);
sockprintf
(
socket
,
""
);
}
void
mimetextpartheader
(
SOCKET
socket
,
char
*
boundary
)
void
mimetextpartheader
(
SOCKET
socket
,
char
*
boundary
)
{
char
bndline
[
50
];
strcpy
(
bndline
,
"--"
);
strcat
(
bndline
,
boundary
);
sockprintf
(
socket
,
bndline
);
sockprintf
(
socket
,
"--%s"
,
boundary
);
sockprintf
(
socket
,
"Content-Type: text/plain;"
);
sockprintf
(
socket
,
" charset=
\"
iso-8859-1
\"
"
);
sockprintf
(
socket
,
"Content-Transfer-Encoding: 7bit"
);
}
BOOL
base64out
(
SOCKET
socket
,
char
*
pathfile
)
BOOL
base64out
(
SOCKET
socket
,
char
*
pathfile
)
{
FILE
*
fp
;
char
in
[
57
];
...
...
@@ -108,13 +100,13 @@ BOOL base64out(SOCKET socket, char * pathfile)
if
((
fp
=
fopen
(
pathfile
,
"rb"
))
==
NULL
)
return
(
FALSE
);
while
(
1
)
{
bytesread
=
fread
(
in
,
1
,
57
,
fp
);
bytesread
=
fread
(
in
,
1
,
sizeof
(
in
)
,
fp
);
if
((
b64_encode
(
out
,
sizeof
(
out
),
in
,
bytesread
)
==-
1
)
||
!
sockprintf
(
socket
,
out
))
{
fclose
(
fp
);
return
(
FALSE
);
}
if
(
bytesread
!=
57
||
feof
(
fp
))
if
(
bytesread
!=
sizeof
(
in
)
||
feof
(
fp
))
break
;
}
fclose
(
fp
);
...
...
@@ -122,44 +114,26 @@ BOOL base64out(SOCKET socket, char * pathfile)
return
(
TRUE
);
}
BOOL
mimeattach
(
SOCKET
socket
,
char
*
boundary
,
char
*
pathfile
)
BOOL
mimeattach
(
SOCKET
socket
,
char
*
boundary
,
char
*
pathfile
)
{
char
bndline
[
41
];
char
*
fname
=
getfname
(
pathfile
);
char
*
line
=
(
char
*
)
MALLOC
(
strlen
(
fname
)
+
20
);
if
(
line
==
NULL
)
return
(
FALSE
);
char
*
fname
=
getfname
(
pathfile
);
strcpy
(
bndline
,
"--"
);
strcat
(
bndline
,
boundary
);
sockprintf
(
socket
,
bndline
);
sockprintf
(
socket
,
"--%s"
,
boundary
);
sockprintf
(
socket
,
"Content-Type: application/octet-stream;"
);
strcpy
(
line
,
" name=
\"
"
);
strcat
(
line
,
fname
);
strcat
(
line
,
"
\"
"
);
sockprintf
(
socket
,
line
);
sockprintf
(
socket
,
" name=
\"
%s
\"
"
,
fname
);
sockprintf
(
socket
,
"Content-Transfer-Encoding: base64"
);
sockprintf
(
socket
,
"Content-Disposition: attachment;"
);
strcpy
(
line
,
" filename=
\"
"
);
strcat
(
line
,
fname
);
strcat
(
line
,
"
\"
"
);
sockprintf
(
socket
,
line
);
sockprintf
(
socket
,
" filename=
\"
%s
\"
"
,
fname
);
sockprintf
(
socket
,
""
);
if
(
!
base64out
(
socket
,
pathfile
))
return
(
FALSE
);
sockprintf
(
socket
,
""
);
FREE
(
line
);
return
(
TRUE
);
}
void
endmime
(
SOCKET
socket
,
char
*
boundary
)
void
endmime
(
SOCKET
socket
,
char
*
boundary
)
{
char
bndline
[
128
];
strcpy
(
bndline
,
"--"
);
strcat
(
bndline
,
boundary
);
strcat
(
bndline
,
"--"
);
/* last boundary */
sockprintf
(
socket
,
bndline
);
/* last boundary */
sockprintf
(
socket
,
"--%s--"
,
boundary
);
sockprintf
(
socket
,
""
);
}
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