1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-29 01:45:34 +00:00

formfd -> fd, formfile -> fp, formfilename -> filename. Idea by Alexey

Tourbin.
This commit is contained in:
Laurent MONIN 2007-03-05 21:17:09 +01:00 committed by Laurent MONIN
parent 31865ef953
commit 0a8b52282c

View File

@ -217,21 +217,21 @@ static unsigned char *
save_form_data_to_file(struct uri *uri)
{
unsigned char *filename = get_tempdir_filename("elinks-XXXXXX");
int formfd;
FILE *formfile;
int fd;
FILE *fp;
if (!filename) return NULL;
formfd = safe_mkstemp(filename);
if (formfd < 0) {
fd = safe_mkstemp(filename);
if (fd < 0) {
mem_free(filename);
return NULL;
}
formfile = fdopen(formfd, "w");
if (!formfile) {
fp = fdopen(fd, "w");
if (!fp) {
mem_free(filename);
close(formfd);
close(fd);
return NULL;
}
@ -240,9 +240,9 @@ save_form_data_to_file(struct uri *uri)
unsigned char *formdata = strchr(uri->post, '\n');
formdata = formdata ? formdata + 1 : uri->post;
fwrite(formdata, strlen(formdata), 1, formfile);
fwrite(formdata, strlen(formdata), 1, fp);
}
fclose(formfile);
fclose(fp);
return filename;
}
@ -251,7 +251,7 @@ void
user_protocol_handler(struct session *ses, struct uri *uri)
{
unsigned char *subj = NULL, *prog;
unsigned char *formfilename;
unsigned char *filename;
prog = get_user_program(ses->tab->term, struri(uri), uri->protocollen);
if (!prog || !*prog) {
@ -280,19 +280,19 @@ user_protocol_handler(struct session *ses, struct uri *uri)
}
}
formfilename = save_form_data_to_file(uri);
filename = save_form_data_to_file(uri);
prog = subst_cmd(prog, uri, subj, formfilename);
prog = subst_cmd(prog, uri, subj, filename);
mem_free_if(subj);
if (prog) {
unsigned char *delete = empty_string_or_(formfilename);
unsigned char *delete = empty_string_or_(filename);
exec_on_terminal(ses->tab->term, prog, delete, 1);
mem_free(prog);
} else if (formfilename) {
unlink(formfilename);
} else if (filename) {
unlink(filename);
}
mem_free_if(formfilename);
mem_free_if(filename);
}