FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
extractor.cpp/main.cpp at master · algorithm-visualizer/extractor.cpp · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
algorithm-visualizer
/
extractor.cpp
Public
Notifications
You must be signed in to change notification settings
Fork
4
Star
7
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
extractor.cpp
/
main.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (36 loc) · 1.12 KB
Breadcrumbs
extractor.cpp
/
main.cpp
Copy path
File metadata and controls
42 lines (36 loc) · 1.12 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#
include
<
aws/lambda-runtime/runtime.h
>
#
include
<
cstdio
>
#
include
<
iostream
>
#
include
<
memory
>
#
include
<
stdexcept
>
#
include
<
string
>
#
include
<
array
>
using
namespace
aws
::lambda_runtime
;
std::string
exec
(
const
char
* cmd) {
std::array<
char
,
128
> buffer;
std::string result;
std::unique_ptr<
FILE
,
decltype
(&pclose)>
pipe
(
popen
(cmd,
"
r
"
), pclose);
if
(!pipe) {
throw
std::runtime_error
(
"
popen() failed!
"
);
}
while
(
fgets
(buffer.
data
(), buffer.
size
(), pipe.
get
()) !=
nullptr
) {
result += buffer.
data
();
}
return
result;
}
static
invocation_response
handle_request
(invocation_request
const
& req)
{
std::cout <<
exec
(
"
whereis g++
"
);
std::cout <<
exec
(
"
echo
\"
blahkhgfd
\"
"
);
if
(req.
payload
.
length
() >
42
) {
return
invocation_response::failure
(
"
error message here
"
/*
error_message
*/
,
"
error type here
"
/*
error_type
*/
);
}
return
invocation_response::success
(
"
json payload here
"
/*
payload
*/
,
"
application/json
"
/*
MIME type
*/
);
}
int
main
()
{
run_handler
(handle_request);
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL