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
c19f7657
Commit
c19f7657
authored
11 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Add -strip command-line option to strip all Ctrl-A codes which do not have ANSI
equivalents (e.g. pause, delay).
parent
1ae90fd5
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/asc2ans.c
+38
-24
38 additions, 24 deletions
src/sbbs3/asc2ans.c
with
38 additions
and
24 deletions
src/sbbs3/asc2ans.c
+
38
−
24
View file @
c19f7657
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* *
* Copyright 20
09
Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 20
14
Rob Swindell - http://www.synchro.net/copyright.html *
* *
* *
* This program is free software; you can redistribute it and/or *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* modify it under the terms of the GNU General Public License *
...
@@ -42,38 +42,51 @@
...
@@ -42,38 +42,51 @@
#define CTRL_A '\1'
#define CTRL_A '\1'
#define ANSI fprintf(out,"\x1b[")
#define ANSI fprintf(out,"\x1b[")
int
main
(
int
argc
,
char
**
argv
)
static
void
print_usage
(
const
char
*
prog
)
{
{
char
revision
[
16
];
char
revision
[
16
];
int
ch
;
FILE
*
in
;
FILE
*
out
;
sscanf
(
"$Revision$"
,
"%*s %s"
,
revision
);
sscanf
(
"$Revision$"
,
"%*s %s"
,
revision
);
fprintf
(
stderr
,
"
\n
Synchronet Ctrl-A-Code to ANSI-Terminal-Sequence Conversion Utility v%s
\n
"
,
revision
);
fprintf
(
stderr
,
"
\n
usage: %s infile.asc [outfile.ans] [[option] [...]]
\n
"
,
prog
);
fprintf
(
stderr
,
"
\n
options:
\n\n
"
);
fprintf
(
stderr
,
"-strip strip Ctrl-A codes without ANSI equivalent, e.g. pause, delay
\n
"
);
}
int
main
(
int
argc
,
char
**
argv
)
{
int
ch
;
int
i
;
int
strip
=
0
;
FILE
*
in
=
stdin
;
FILE
*
out
=
stdout
;
if
(
argc
<
2
)
{
if
(
argc
<
2
)
{
fprintf
(
stderr
,
"
\n
asc2ans %s
\n
"
,
revision
);
print_usage
(
argv
[
0
]);
fprintf
(
stderr
,
"
\n
usage: %s infile.asc [outfile.ans]
\n
"
,
argv
[
0
]);
return
(
0
);
return
(
0
);
}
}
if
(
strcmp
(
argv
[
1
],
"-"
))
{
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
if
((
in
=
fopen
(
argv
[
1
],
"rb"
))
==
NULL
)
{
if
(
argv
[
i
][
0
]
==
'-'
)
{
perror
(
argv
[
1
]);
if
(
strcmp
(
argv
[
i
],
"-strip"
)
==
0
)
return
(
1
);
strip
=
1
;
}
else
{
}
print_usage
(
argv
[
0
]);
else
return
0
;
in
=
stdin
;
}
}
else
if
(
in
==
stdin
)
{
if
(
argc
>
2
&&
(
strcmp
(
argv
[
2
],
"-"
)))
{
if
((
in
=
fopen
(
argv
[
i
],
"rb"
))
==
NULL
)
{
if
((
out
=
fopen
(
argv
[
2
],
"wb"
))
==
NULL
)
{
perror
(
argv
[
i
]);
perror
(
argv
[
2
]);
return
(
1
);
return
(
1
);
}
}
else
if
(
out
==
stdout
)
{
if
((
out
=
fopen
(
argv
[
i
],
"wb"
))
==
NULL
)
{
perror
(
argv
[
i
]);
return
(
1
);
}
}
}
}
}
else
out
=
stdout
;
while
((
ch
=
fgetc
(
in
))
!=
EOF
)
{
while
((
ch
=
fgetc
(
in
))
!=
EOF
)
{
if
(
ch
==
CTRL_A
)
{
/* ctrl-a */
if
(
ch
==
CTRL_A
)
{
/* ctrl-a */
...
@@ -190,7 +203,8 @@ int main(int argc, char **argv)
...
@@ -190,7 +203,8 @@ int main(int argc, char **argv)
fprintf
(
out
,
"47m"
);
fprintf
(
out
,
"47m"
);
break
;
break
;
default:
default:
fprintf
(
out
,
"
\1
%c"
,
ch
);
if
(
!
strip
)
fprintf
(
out
,
"
\1
%c"
,
ch
);
break
;
break
;
}
}
}
}
...
...
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