-
-
Notifications
You must be signed in to change notification settings - Fork 914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functionality to write to a temp file through url arguments #747
Open
vaishalikumanan
wants to merge
10
commits into
tsl0922:main
Choose a base branch
from
vaishalikumanan:add-tmp-file
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ed9511a
Add functionality to write to a temp file through url arguments
vaishalikumanan cde0982
close file
vaishalikumanan 25f91ea
Add argument for temp file path/prefix
vaishalikumanan 53565c7
Concat temp file suffix without strcat
vaishalikumanan 5a3ad2f
use snprintf instead of sprintf
vaishalikumanan 4be5009
Reformat code
vaishalikumanan a487955
Merge branch 'main' into add-tmp-file
kahing 092dc3d
fix build and error check
kahing b9b962b
fix a merge problem and addressed feedback
kahing c01676c
add a note to -f
kahing File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,9 +102,30 @@ static bool spawn_process(struct pss_tty *pss, uint16_t columns, uint16_t rows) | |
for (i = 0; i < server->argc; i++) { | ||
argv[n++] = server->argv[i]; | ||
} | ||
for (i = 0; i < pss->argc; i++) { | ||
argv[n++] = pss->args[i]; | ||
if (server->url_arg) { | ||
for (i = 0; i < pss->argc; i++) { | ||
argv[n++] = pss->args[i]; | ||
} | ||
} | ||
else if (server->arg_file) { | ||
int fd = -1; | ||
char filePath[] = "/tmp/XXXXXX"; | ||
|
||
if ((fd = mkstemp(filePath)) == -1) { | ||
lwsl_err("Creation of temp file failed with error: %d (%s)\n", errno, strerror(errno)); | ||
return false; | ||
} | ||
|
||
for (i = 0; i < pss->argc; i++) { | ||
if (dprintf(fd, "%s\n", pss->args[i]) < 0) { | ||
lwsl_err("Write to temp file failed with error: %d (%s)\n", errno, strerror(errno)); | ||
return false; | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to close the file |
||
argv[n++] = filePath; | ||
} | ||
|
||
argv[n] = NULL; | ||
|
||
pty_process *process = process_init((void *) pss, server->loop, argv); | ||
|
@@ -178,7 +199,7 @@ int callback_tty(struct lws *wsi, enum lws_callback_reasons reason, void *user, | |
pss->wsi = wsi; | ||
pss->lws_close_status = LWS_CLOSE_STATUS_NOSTATUS; | ||
|
||
if (server->url_arg) { | ||
if (server->url_arg || server->arg_file) { | ||
while (lws_hdr_copy_fragment(wsi, buf, sizeof(buf), WSI_TOKEN_HTTP_URI_ARGS, n++) > 0) { | ||
if (strncmp(buf, "arg=", 4) == 0) { | ||
pss->args = xrealloc(pss->args, (pss->argc + 1) * sizeof(char *)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will leak fd too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filePath
is not freed too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed