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
bbd5e52a
Commit
bbd5e52a
authored
4 years ago
by
Deucе
Browse files
Options
Downloads
Patches
Plain Diff
Implement upload/download support and use cache dir
parent
17607549
No related branches found
No related tags found
1 merge request
!463
MRC mods by Codefenix (2024-10-20)
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/syncterm/ripper.c
+128
-11
128 additions, 11 deletions
src/syncterm/ripper.c
src/syncterm/term.c
+2
-7
2 additions, 7 deletions
src/syncterm/term.c
src/syncterm/term.h
+7
-0
7 additions, 0 deletions
src/syncterm/term.h
with
137 additions
and
18 deletions
src/syncterm/ripper.c
+
128
−
11
View file @
bbd5e52a
...
@@ -32,6 +32,8 @@
...
@@ -32,6 +32,8 @@
#include "term.h"
#include "term.h"
#include "window.h"
#include "window.h"
#include "amigafont.h"
#include "amigafont.h"
#include "ripper.h"
#include "sexyz.h"
// TODO: Output parsing... (yech)
// TODO: Output parsing... (yech)
// TODO: Actually make the graphics viewport work properly
// TODO: Actually make the graphics viewport work properly
...
@@ -272,6 +274,7 @@ static struct {
...
@@ -272,6 +274,7 @@ static struct {
struct {
struct {
int sx, sy, ex, ey, xpos, ypos;
int sx, sy, ex, ey, xpos, ypos;
} text_region;
} text_region;
struct bbslist *bbs;
} rip = {
} rip = {
RIP_STATE_BOL,
RIP_STATE_BOL,
RIP_STATE_FLUSHING,
RIP_STATE_FLUSHING,
...
@@ -307,6 +310,7 @@ static struct {
...
@@ -307,6 +310,7 @@ static struct {
0, 0,
0, 0,
NULL,
NULL,
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
NULL,
};
};
static const uint16_t rip_line_patterns[4] = {
static const uint16_t rip_line_patterns[4] = {
...
@@ -12487,25 +12491,28 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
...
@@ -12487,25 +12491,28 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
break;
break;
if (strchr(&args[6], '\\'))
if (strchr(&args[6], '\\'))
break;
break;
if (!get_cache_fn_base(rip.bbs, cache_path, sizeof(cache_path)))
break;
strcat(cache_path, &args[6]);
struct stat st;
struct stat st;
char str[1024];
char str[1024];
char dstr[64];
char dstr[64];
struct tm tm;
struct tm tm;
switch(arg1) {
switch(arg1) {
case 0:
case 0:
if (access(
&args[6]
, R_OK))
if (access(
cache_path
, R_OK))
conn_send("0", 1, 1000);
conn_send("0", 1, 1000);
else
else
conn_send("1", 1, 1000);
conn_send("1", 1, 1000);
break;
break;
case 1:
case 1:
if (access(
&args[6]
, R_OK))
if (access(
cache_path
, R_OK))
conn_send("0\r", 2, 1000);
conn_send("0\r", 2, 1000);
else
else
conn_send("1\r", 2, 1000);
conn_send("1\r", 2, 1000);
break;
break;
case 2:
case 2:
if (stat(
&args[6]
, &st))
if (stat(
cache_path
, &st))
conn_send("0\r", 2, 1000);
conn_send("0\r", 2, 1000);
else {
else {
sprintf(str, "1.%" PRIdOFF "\n", st.st_size);
sprintf(str, "1.%" PRIdOFF "\n", st.st_size);
...
@@ -12513,7 +12520,7 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
...
@@ -12513,7 +12520,7 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
}
}
break;
break;
case 3:
case 3:
if (stat(
&args[6]
, &st))
if (stat(
cache_path
, &st))
conn_send("0\r", 2, 1000);
conn_send("0\r", 2, 1000);
else {
else {
localtime_r(&st.st_atime, &tm);
localtime_r(&st.st_atime, &tm);
...
@@ -12523,7 +12530,7 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
...
@@ -12523,7 +12530,7 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
}
}
break;
break;
case 4:
case 4:
if (stat(
&args[6]
, &st))
if (stat(
cache_path
, &st))
conn_send("0\r", 2, 1000);
conn_send("0\r", 2, 1000);
else {
else {
localtime_r(&st.st_atime, &tm);
localtime_r(&st.st_atime, &tm);
...
@@ -12604,7 +12611,8 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
...
@@ -12604,7 +12611,8 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
* parameters, should be set to "10".
* parameters, should be set to "10".
*/
*/
handled = true;
handled = true;
cache_path[0] = 0;
if (!get_cache_fn_base(rip.bbs, cache_path, sizeof(cache_path)))
break;
GET_XY();
GET_XY();
arg1 = parse_mega(&args[4], 2);
arg1 = parse_mega(&args[4], 2);
arg2 = parse_mega(&args[6], 1);
arg2 = parse_mega(&args[6], 1);
...
@@ -13148,7 +13156,8 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
...
@@ -13148,7 +13156,8 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
handled = true;
handled = true;
if (rip.clipboard == NULL)
if (rip.clipboard == NULL)
break;
break;
cache_path[0] = 0;
if (!get_cache_fn_base(rip.bbs, cache_path, sizeof(cache_path)))
break;
strcat(cache_path, &args[1]);
strcat(cache_path, &args[1]);
icn = fopen(cache_path, "wb");
icn = fopen(cache_path, "wb");
if (icn != NULL) {
if (icn != NULL) {
...
@@ -13274,6 +13283,113 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
...
@@ -13274,6 +13283,113 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
* command on a line of text. The protocol must begin on
* command on a line of text. The protocol must begin on
* the very next line.
* the very next line.
*/
*/
arg1 = parse_mega(&args[0], 1);
arg2 = parse_mega(&args[1], 1);
arg3 = parse_mega(&args[2], 2);
arg4 = parse_mega(&args[4], 4);
handled = true;
if (arg1 < 0 || arg1 > 1)
break;
if (arg2 < 0 || arg2 == 4 || arg2 > 7)
break;
if (arg3 < 0 || arg3 == 0 || arg3 == 5)
break;
if (!get_cache_fn_base(rip.bbs, cache_path, sizeof(cache_path)))
break;
size_t cpln = strlen(cache_path);
if (arg1 == 0) { // Download (from BBS)
char *dldir = strdup(rip.bbs->dldir);
strcpy(rip.bbs->dldir, cache_path);
char *p = strstr(&args[8], "<>");
if (p == NULL) {
strcpy(rip.bbs->dldir, dldir);
free(dldir);
break;
}
size_t fnln = p - &args[8];
if (cpln + fnln >= cpln) {
strcpy(rip.bbs->dldir, dldir);
free(dldir);
break;
}
strncpy(&cache_path[cpln], &args[8], sizeof(cache_path) - cpln);
suspend_rip(true);
switch(arg2) {
case 0:
xmodem_download(rip.bbs, XMODEM|RECV, cache_path);
break;
case 1:
xmodem_download(rip.bbs, XMODEM|CRC|RECV, cache_path);
break;
case 2:
xmodem_download(rip.bbs, XMODEM|CRC|RECV, cache_path);
break;
case 3:
xmodem_download(rip.bbs, XMODEM|GMODE|CRC|RECV, cache_path);
break;
case 5:
xmodem_download(rip.bbs, YMODEM|CRC|RECV, cache_path);
break;
case 6:
xmodem_download(rip.bbs, YMODEM|GMODE|CRC|RECV, cache_path);
break;
case 7:
zmodem_download(rip.bbs);
break;
}
strcpy(rip.bbs->dldir, dldir);
free(dldir);
suspend_rip(false);
}
else { // Upload (to BBS)
char *uldir = strdup(rip.bbs->uldir);
strcpy(rip.bbs->uldir, cache_path);
char *p = strstr(&args[8], "<>");
if (p == NULL) {
strcpy(rip.bbs->uldir, uldir);
free(uldir);
break;
}
size_t fnln = p - &args[8];
if (cpln + fnln >= cpln) {
strcpy(rip.bbs->uldir, uldir);
free(uldir);
break;
}
strncpy(&cache_path[cpln], &args[8], sizeof(cache_path) - cpln);
FILE* fp = fopen(cache_path, "rb");
if (fp == NULL) {
strcpy(rip.bbs->uldir, uldir);
free(uldir);
break;
}
setvbuf(fp, NULL, _IOFBF, 0x10000);
suspend_rip(true);
switch(arg2) {
case 0:
xmodem_upload(rip.bbs, fp, cache_path, XMODEM_128B|XMODEM|SEND, 0);
break;
case 1:
xmodem_upload(rip.bbs, fp, cache_path, XMODEM_128B|XMODEM|CRC|SEND, 0);
break;
case 2:
xmodem_upload(rip.bbs, fp, cache_path, XMODEM|CRC|SEND, 0);
break;
case 3:
xmodem_upload(rip.bbs, fp, cache_path, XMODEM|GMODE|CRC|SEND, 0);
break;
case 5:
xmodem_upload(rip.bbs, fp, cache_path, YMODEM|CRC|SEND, 0);
break;
case 6:
xmodem_upload(rip.bbs, fp, cache_path, YMODEM|GMODE|CRC|SEND, 0);
break;
case 7:
zmodem_upload(rip.bbs, fp, cache_path);
break;
}
suspend_rip(false);
}
break;
break;
}
}
break;
break;
...
@@ -14307,7 +14423,7 @@ parse_rip(BYTE *origbuf, unsigned blen, unsigned maxlen)
...
@@ -14307,7 +14423,7 @@ parse_rip(BYTE *origbuf, unsigned blen, unsigned maxlen)
}
}
void
void
init_rip(
int version
)
init_rip(
struct bbslist *bbs
)
{
{
FREE_AND_NULL(rip.xmap);
FREE_AND_NULL(rip.xmap);
FREE_AND_NULL(rip.ymap);
FREE_AND_NULL(rip.ymap);
...
@@ -14316,8 +14432,8 @@ init_rip(int version)
...
@@ -14316,8 +14432,8 @@ init_rip(int version)
memset(&rip, 0, sizeof(rip));
memset(&rip, 0, sizeof(rip));
rip.state = RIP_STATE_BOL;
rip.state = RIP_STATE_BOL;
rip.newstate = RIP_STATE_FLUSHING;
rip.newstate = RIP_STATE_FLUSHING;
rip.enabled =
version
!= RIP_VERSION_NONE;
rip.enabled =
bbs->rip
!= RIP_VERSION_NONE;
rip.version =
version
;
rip.version =
bbs->rip
;
rip.x = 0;
rip.x = 0;
rip.y = 0;
rip.y = 0;
rip.viewport.sx = 0;
rip.viewport.sx = 0;
...
@@ -14343,6 +14459,7 @@ init_rip(int version)
...
@@ -14343,6 +14459,7 @@ init_rip(int version)
pthread_mutex_unlock(&vstatlock);
pthread_mutex_unlock(&vstatlock);
rip.viewport.ex = rip.x_dim - 1;
rip.viewport.ex = rip.x_dim - 1;
rip.viewport.ey = rip.y_dim - 1;
rip.viewport.ey = rip.y_dim - 1;
rip.bbs = bbs;
pending_len = 0;
pending_len = 0;
if (pending)
if (pending)
...
@@ -14350,7 +14467,7 @@ init_rip(int version)
...
@@ -14350,7 +14467,7 @@ init_rip(int version)
moredata_len = 0;
moredata_len = 0;
if (moredata)
if (moredata)
moredata[0] = 0;
moredata[0] = 0;
if (
version
) {
if (
bbs->rip
) {
shadow_palette();
shadow_palette();
memcpy(&curr_ega_palette, &default_ega_palette, sizeof(curr_ega_palette));
memcpy(&curr_ega_palette, &default_ega_palette, sizeof(curr_ega_palette));
set_ega_palette();
set_ega_palette();
...
...
This diff is collapsed.
Click to expand it.
src/syncterm/term.c
+
2
−
7
View file @
bbd5e52a
...
@@ -802,11 +802,6 @@ void erase_transfer_window(void) {
...
@@ -802,11 +802,6 @@ void erase_transfer_window(void) {
void
ascii_upload
(
FILE
*
fp
);
void
ascii_upload
(
FILE
*
fp
);
void
raw_upload
(
FILE
*
fp
);
void
raw_upload
(
FILE
*
fp
);
#define XMODEM_128B (1<<10)
/* Use 128 byte block size (ick!) */
void
zmodem_upload
(
struct
bbslist
*
bbs
,
FILE
*
fp
,
char
*
path
);
void
xmodem_upload
(
struct
bbslist
*
bbs
,
FILE
*
fp
,
char
*
path
,
long
mode
,
int
lastch
);
void
xmodem_download
(
struct
bbslist
*
bbs
,
long
mode
,
char
*
path
);
void
zmodem_download
(
struct
bbslist
*
bbs
);
void
begin_upload
(
struct
bbslist
*
bbs
,
BOOL
autozm
,
int
lastch
)
void
begin_upload
(
struct
bbslist
*
bbs
,
BOOL
autozm
,
int
lastch
)
{
{
...
@@ -2126,7 +2121,7 @@ void capture_control(struct bbslist *bbs)
...
@@ -2126,7 +2121,7 @@ void capture_control(struct bbslist *bbs)
updated=TRUE; \
updated=TRUE; \
}
}
static
int
get_cache_fn_base
(
struct
bbslist
*
bbs
,
char
*
fn
,
size_t
fnsz
)
int
get_cache_fn_base
(
struct
bbslist
*
bbs
,
char
*
fn
,
size_t
fnsz
)
{
{
get_syncterm_filename
(
fn
,
fnsz
,
SYNCTERM_PATH_CACHE
,
FALSE
);
get_syncterm_filename
(
fn
,
fnsz
,
SYNCTERM_PATH_CACHE
,
FALSE
);
backslash
(
fn
);
backslash
(
fn
);
...
@@ -2532,7 +2527,7 @@ BOOL doterm(struct bbslist *bbs)
...
@@ -2532,7 +2527,7 @@ BOOL doterm(struct bbslist *bbs)
/* Main input loop */
/* Main input loop */
oldmc
=
hold_update
;
oldmc
=
hold_update
;
showmouse
();
showmouse
();
init_rip
(
bbs
->
rip
);
init_rip
(
bbs
);
if
(
bbs
->
rip
)
if
(
bbs
->
rip
)
ms
.
mode
=
MM_RIP
;
ms
.
mode
=
MM_RIP
;
setup_mouse_events
(
&
ms
);
setup_mouse_events
(
&
ms
);
...
...
This diff is collapsed.
Click to expand it.
src/syncterm/term.h
+
7
−
0
View file @
bbd5e52a
...
@@ -16,12 +16,19 @@ struct terminal {
...
@@ -16,12 +16,19 @@ struct terminal {
int
nostatus
;
int
nostatus
;
};
};
#define XMODEM_128B (1<<10)
/* Use 128 byte block size (ick!) */
extern
struct
terminal
term
;
extern
struct
terminal
term
;
extern
struct
cterminal
*
cterm
;
extern
struct
cterminal
*
cterm
;
extern
int
log_level
;
extern
int
log_level
;
void
zmodem_upload
(
struct
bbslist
*
bbs
,
FILE
*
fp
,
char
*
path
);
void
xmodem_upload
(
struct
bbslist
*
bbs
,
FILE
*
fp
,
char
*
path
,
long
mode
,
int
lastch
);
void
xmodem_download
(
struct
bbslist
*
bbs
,
long
mode
,
char
*
path
);
void
zmodem_download
(
struct
bbslist
*
bbs
);
BOOL
doterm
(
struct
bbslist
*
);
BOOL
doterm
(
struct
bbslist
*
);
void
mousedrag
(
struct
vmem_cell
*
scrollback
);
void
mousedrag
(
struct
vmem_cell
*
scrollback
);
void
get_cterm_size
(
int
*
cols
,
int
*
rows
,
int
ns
);
void
get_cterm_size
(
int
*
cols
,
int
*
rows
,
int
ns
);
int
get_cache_fn_base
(
struct
bbslist
*
bbs
,
char
*
fn
,
size_t
fnsz
);
#endif
#endif
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