Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hammer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
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
Sven M. Hallberg
hammer
Commits
bd41f059
Commit
bd41f059
authored
12 years ago
by
Meredith L. Patterson
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://github.com/abiggerhammer/hammer
parents
ef6af551
a68b93c6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
examples/Makefile
+11
-3
11 additions, 3 deletions
examples/Makefile
examples/base64.c
+54
-0
54 additions, 0 deletions
examples/base64.c
with
66 additions
and
3 deletions
.gitignore
+
1
−
0
View file @
bd41f059
...
...
@@ -4,6 +4,7 @@
src/test_suite
lib/hush
examples/dns
examples/base64
TAGS
*.swp
*.swo
This diff is collapsed.
Click to expand it.
examples/Makefile
+
11
−
3
View file @
bd41f059
OUTPUTS
:=
dns.o
\
dns
dns
\
base64.o
\
base64
TOPLEVEL
:=
../
include
../common.mk
all
:
dns
all
:
dns
base64
dns
:
LDFLAGS:=-L../src -lhammer $(LDFLAGS)
dns
:
dns.o rr.o dns_common.o
...
...
@@ -17,4 +19,10 @@ dns.o: ../src/hammer.h dns_common.h
rr.o
:
../src/hammer.h rr.h dns_common.h
dns_common.o
:
../src/hammer.h dns_common.h
\ No newline at end of file
dns_common.o
:
../src/hammer.h dns_common.h
base64
:
LDFLAGS:=-L../src -lhammer $(LDFLAGS)
base64
:
base64.o
$(
call hush,
"Linking
$@
"
)
$(
CC
)
-o
$@
$^
$(
LDFLAGS
)
base64.o
:
../src/hammer.h
This diff is collapsed.
Click to expand it.
examples/base64.c
0 → 100644
+
54
−
0
View file @
bd41f059
#include
"../src/hammer.h"
const
HParser
*
document
=
NULL
;
void
init_parser
(
void
)
{
// CORE
const
HParser
*
digit
=
h_ch_range
(
0x30
,
0x39
);
const
HParser
*
alpha
=
h_choice
(
h_ch_range
(
0x41
,
0x5a
),
h_ch_range
(
0x61
,
0x7a
),
NULL
);
// AUX.
const
HParser
*
plus
=
h_ch
(
'+'
);
const
HParser
*
slash
=
h_ch
(
'/'
);
const
HParser
*
equals
=
h_ch
(
'='
);
const
HParser
*
bsfdig
=
h_choice
(
alpha
,
digit
,
plus
,
slash
,
NULL
);
const
HParser
*
bsfdig_4bit
=
h_choice
(
h_ch
(
'A'
),
h_ch
(
'E'
),
h_ch
(
'I'
),
h_ch
(
'M'
),
h_ch
(
'Q'
),
h_ch
(
'U'
),
h_ch
(
'Y'
),
h_ch
(
'c'
),
h_ch
(
'g'
),
h_ch
(
'k'
),
h_ch
(
'o'
),
h_ch
(
's'
),
h_ch
(
'w'
),
h_ch
(
'0'
),
h_ch
(
'4'
),
h_ch
(
'8'
),
NULL
);
const
HParser
*
bsfdig_2bit
=
h_choice
(
h_ch
(
'A'
),
h_ch
(
'Q'
),
h_ch
(
'g'
),
h_ch
(
'w'
),
NULL
);
const
HParser
*
base64_2
=
h_sequence
(
bsfdig
,
bsfdig
,
bsfdig_4bit
,
equals
,
NULL
);
const
HParser
*
base64_1
=
h_sequence
(
bsfdig
,
bsfdig_2bit
,
equals
,
equals
,
NULL
);
const
HParser
*
base64
=
h_choice
(
base64_2
,
base64_1
,
NULL
);
// why does this parse "A=="?!
// why does this parse "aaA=" but not "aA=="?!
document
=
base64
;
}
#include
<stdio.h>
int
main
(
int
argc
,
char
**
argv
)
{
uint8_t
input
[
102400
];
size_t
inputsize
;
const
HParseResult
*
result
;
init_parser
();
inputsize
=
fread
(
input
,
1
,
sizeof
(
input
),
stdin
);
fprintf
(
stderr
,
"inputsize=%lu
\n
input="
,
inputsize
);
fwrite
(
input
,
1
,
inputsize
,
stderr
);
result
=
h_parse
(
document
,
input
,
inputsize
);
if
(
result
)
{
fprintf
(
stderr
,
"parsed=%lld bytes
\n
"
,
result
->
bit_length
/
8
);
h_pprint
(
stdout
,
result
->
ast
,
0
,
0
);
return
0
;
}
else
{
return
1
;
}
}
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