summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-01-09 16:57:25 +0100
committerFlorian Pritz <bluewind@xinu.at>2013-01-09 16:59:05 +0100
commit18f85cc73adf723b8bf1aad9a2c3e9a5898648fb (patch)
tree76f586cac208d4e6bc404626024d67a3556ed5e4
parent1aa1cbf8e5bc134b620ed153534b4891195d4b55 (diff)
Add debugging support
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--fb-helper.c9
-rw-r--r--fb.12
-rw-r--r--fb.in13
3 files changed, 22 insertions, 2 deletions
diff --git a/fb-helper.c b/fb-helper.c
index 56f9429..11d115e 100644
--- a/fb-helper.c
+++ b/fb-helper.c
@@ -48,6 +48,7 @@ struct progressData {
};
struct options {
+ int debug;
char *url;
char *file;
};
@@ -238,12 +239,14 @@ int main(int argc, char *argv[])
int opt;
struct options options = {
+ .debug = 0,
.file = NULL,
.url = NULL
};
- while ((opt = getopt(argc, argv, "u:f:m:")) != -1) {
+ while ((opt = getopt(argc, argv, "Du:f:m:")) != -1) {
switch (opt) {
+ case 'D': options.debug = 1; break;
case 'u': options.url = optarg; break;
@@ -268,6 +271,10 @@ int main(int argc, char *argv[])
goto cleanup;
}
+ if (options.debug > 0) {
+ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+ }
+
/* if we have a file to upload, add it as a POST request */
if (options.file) {
struct stat statbuf;
diff --git a/fb.1 b/fb.1
index a68aa79..3ffac8e 100644
--- a/fb.1
+++ b/fb.1
@@ -83,6 +83,8 @@ Upload a tar file containing all files and directories specified on the
command line.
.It Fl v
Display the client version.
+.It Fl D
+Display debugging information.
.El
.Sh CONFIGURATION FILES
.Bl -tag
diff --git a/fb.in b/fb.in
index ce56a6d..d96146b 100644
--- a/fb.in
+++ b/fb.in
@@ -46,6 +46,7 @@ compress=0
display_history=
clipboard=""
exitcode=0
+debug=
base64_encode() {
if type base64 2>&1 >/dev/null; then
@@ -68,6 +69,10 @@ request_helper() {
if [ -x "$libdir/fb-helper" ]; then
helperopts=""
+ if [ "$debug" ]; then
+ helperopts="$helperopts -D"
+ fi
+
if [ "$mode" = "d" ]; then
$libdir/fb-helper $helperopts -u "$url"
fi
@@ -79,6 +84,10 @@ request_helper() {
useragent="fb-client/shell-$version"
curlopts="-# -n -L -A $useragent --speed-time 30 --speed-limit 1 --connect-timeout 10"
+ if [ "$debug" ]; then
+ curlopts="$curlopts -v"
+ fi
+
if [ "$mode" = "d" ]; then
curlopts="$curlopts -s"
fi
@@ -222,6 +231,7 @@ usage: [cat |] `basename "$0"` [switches] [options] [<file(s)|ID(s)|folder(s)>]
-t upload a tar file containing all files (and directories)
-c compress the file being uploaded with gz or xz if used 2 times
When used in conjunction with -g this decompresses the download
+ -D show debugging information
!
}
@@ -230,7 +240,7 @@ if ! type getopts >/dev/null 2>&1; then
exit 1
fi
-while getopts "e:gdhHtcv" option; do
+while getopts "e:gdhHtcvD" option; do
case $option in
e) extension="$OPTARG";;
g) get=1;;
@@ -239,6 +249,7 @@ while getopts "e:gdhHtcv" option; do
d) delete=1;;
H) display_history=1;;
v) printf "%s\n" "$version"; exit 0;;
+ D) debug=1;;
h|\?) help; exit 0;;
esac
done