char *user;
int bash;
int shrink_urls;
+ int dry_run;
enum host host;
enum action action;
};
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf);
- res = curl_easy_perform(curl);
- if (res && !session->bash) {
- fprintf(stderr, "error(%d) trying to perform operation\n", res);
- return -EINVAL;
+ if (!session->dry_run) {
+ res = curl_easy_perform(curl);
+ if (res && !session->bash) {
+ fprintf(stderr, "error(%d) trying to perform operation\n", res);
+ return -EINVAL;
+ }
}
curl_easy_cleanup(curl);
* execution it can then write to element 0 (stdin of exe), and read from
* element 1 (stdout) and 2 (stderr).
*/
-static int popenRW(int *rwepipe, const char *exe, const char *const argv[])
+static int popenRWE(int *rwepipe, const char *exe, const char *const argv[])
{
int in[2];
int out[2];
return -1;
}
-static int pcloseRW(int pid, int *rwepipe)
+static int pcloseRWE(int pid, int *rwepipe)
{
int rc, status;
close(rwepipe[0]);
NULL
};
int shrink_pid;
- int shrink_pipe[2];
+ int shrink_pipe[3];
int inlen = strlen(text);
dbg("before len=%u\n", inlen);
- shrink_pid = popenRW(shrink_pipe, shrink_args[0], shrink_args);
+ shrink_pid = popenRWE(shrink_pipe, shrink_args[0], shrink_args);
if (shrink_pid < 0)
return text;
free(ranges);
- (void)pcloseRW(shrink_pid, shrink_pipe);
+ (void)pcloseRWE(shrink_pid, shrink_pipe);
text[outofs] = 0;
dbg("after len=%u\n", outofs);
{ "shrink-urls", 0, NULL, 's' },
{ "help", 0, NULL, 'h' },
{ "bash", 0, NULL, 'b' },
+ { "dry-run", 0, NULL, 'n' },
{ "version", 0, NULL, 'v' },
{ }
};
case 'h':
display_help();
goto exit;
+ case 'n':
+ session->dry_run = 1;
+ break;
case 'v':
display_version();
goto exit;