New upstream release.
authorgregor herrmann <gregoa@debian.org>
Sat, 24 Jan 2009 16:36:56 +0000 (16:36 -0000)
committergregor herrmann <gregoa@debian.org>
Sat, 24 Jan 2009 16:36:56 +0000 (16:36 -0000)
ChangeLog
Makefile
RELEASE-NOTES
bti-bashcompletion [new file with mode: 0644]
bti.c
bti.example
bti.xml
debian/changelog

index 9460863979e678b6dc97f39d2b7d7b777818d830..a9f28305df2684e482091cc714233fc10fad3186 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+Summary of changes from v011 to v012
+============================================
+
+Amir Mohammad Saied (2):
+      Source parameter added
+      Add bash completion script
+
+Greg Kroah-Hartman (2):
+      add --logfile option
+      document the logfile option
+
+SanjayKumar J (1):
+      bti: incorrect version fix
+
+
 Summary of changes from v010 to v011
 ============================================
 Amir Mohammad Saied (1):
index 233782e5ad9ff617136b940e3a012df87a2f6210..1d67ca8c4734566043c892dcb93b6b01c17cf923 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@
 #
 #
 
-VERSION = 011
+VERSION = 012
 
 PROGRAM = bti
 
@@ -75,7 +75,7 @@ bti: %: $(HEADERS) $(GEN_HEADERS) $(CORE_OBJS)
        $(Q) $(CC) -c $(CFLAGS) $< -o $@
 
 
-bti_version.h:
+bti_version.h: Makefile
        $(E) "  GENHDR  " $@
        $(Q) echo "/* Generated by make. */" > $@
        $(Q) echo \#define BTI_VERSION  \"$(VERSION)\" >> $@
index 28c252141474d9f2a4836a79292a5ced0f73ccd0..463005e42e98fa1eae17718cc3c1ebb5c3395443 100644 (file)
@@ -1,3 +1,9 @@
+bti 012
+=============
+Logfile support added to track status of tweets
+bash completion script added thanks to Amir Saied
+proper "application name" added thanks to Amir Saied
+
 bti 011
 =============
 Readline support thanks to Amir Saied
diff --git a/bti-bashcompletion b/bti-bashcompletion
new file mode 100644 (file)
index 0000000..fa155bc
--- /dev/null
@@ -0,0 +1,20 @@
+_bti()
+{
+       local cur prev
+       COMPREPLY=()
+       cur="${COMP_WORDS[COMP_CWORD]}"
+       prev="${COMP_WORDS[COMP_CWORD-1]}"
+       if [[ "${cur}" == -* ]] ; then
+               COMPREPLY=( $(compgen -W "-a -p -P -H -b -d -v -h --account \
+                       --password --proxy --host --bash --debug --version \
+                       --help" -- ${cur}) )
+       fi
+
+       if [[ "${prev}" == "--host" ]] ; then
+               COMPREPLY=( $(compgen -W "twitter identica" -- ${cur} ) )
+       fi
+
+       return 0
+}
+
+complete -F _bti bti
diff --git a/bti.c b/bti.c
index 8370b2eb91cc2975920fe07342276cfbc1dff56e..0ae103d893ababc70f0c26ba655d5729e23156c3 100644 (file)
--- a/bti.c
+++ b/bti.c
@@ -54,6 +54,7 @@ struct session {
        char *proxy;
        char *time;
        char *homedir;
+       char *logfile;
        int bash;
        enum host host;
 };
@@ -74,6 +75,7 @@ static void display_help(void)
        fprintf(stdout, "  --password password\n");
        fprintf(stdout, "  --proxy PROXY:PORT\n");
        fprintf(stdout, "  --host HOST\n");
+       fprintf(stdout, "  --logfile logfile\n");
        fprintf(stdout, "  --bash\n");
        fprintf(stdout, "  --debug\n");
        fprintf(stdout, "  --version\n");
@@ -222,6 +224,11 @@ static int send_tweet(struct session *session)
                     CURLFORM_COPYCONTENTS, session->tweet,
                     CURLFORM_END);
 
+       curl_formadd(&formpost, &lastptr,
+                    CURLFORM_COPYNAME, "source",
+                    CURLFORM_COPYCONTENTS, "bti",
+                    CURLFORM_END);
+
        curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
 
        switch (session->host) {
@@ -273,6 +280,7 @@ static void parse_configfile(struct session *session)
        char *password = NULL;
        char *host = NULL;
        char *proxy = NULL;
+       char *logfile = NULL;
        char *file;
 
        /* config file is ~/.bti  */
@@ -324,6 +332,11 @@ static void parse_configfile(struct session *session)
                        c += 6;
                        if (c[0] != '\0')
                                proxy = strdup(c);
+               } else if (!strncasecmp(c, "logfile", 7) &&
+                          (c[7] == '=')) {
+                       c += 8;
+                       if (c[0] != '\0')
+                               logfile = strdup(c);
                }
        } while (!feof(config_file));
 
@@ -343,6 +356,8 @@ static void parse_configfile(struct session *session)
                        free(session->proxy);
                session->proxy = proxy;
        }
+       if (logfile)
+               session->logfile = logfile;
 
        /* Free buffer and close file.  */
        free(line);
@@ -355,10 +370,14 @@ static void log_session(struct session *session, int retval)
        char *filename;
        char *host;
 
-       /* logfile is ~/.bti.log  */
-       filename = alloca(strlen(session->homedir) + 10);
+       /* Only log something if we have a log file set */
+       if (!session->logfile)
+               return;
+
+       filename = alloca(strlen(session->homedir) +
+                         strlen(session->logfile) + 3);
 
-       sprintf(filename, "%s/.bti.log", session->homedir);
+       sprintf(filename, "%s/%s", session->homedir, session->logfile);
 
        log_file = fopen(filename, "a+");
        if (log_file == NULL)
@@ -391,6 +410,7 @@ int main(int argc, char *argv[], char *envp[])
                { "password", 1, NULL, 'p' },
                { "host", 1, NULL, 'H' },
                { "proxy", 1, NULL, 'P' },
+               { "logfile", 1, NULL, 'L' },
                { "help", 0, NULL, 'h' },
                { "bash", 0, NULL, 'b' },
                { "version", 0, NULL, 'v' },
@@ -463,6 +483,12 @@ int main(int argc, char *argv[], char *envp[])
                        session->proxy = strdup(optarg);
                        dbg("proxy = %s\n", session->proxy);
                        break;
+               case 'L':
+                       if (session->logfile)
+                               free(session->logfile);
+                       session->logfile = strdup(optarg);
+                       dbg("logfile = %s\n", session->logfile);
+                       break;
                case 'H':
                        if (strcasecmp(optarg, "twitter") == 0)
                                session->host = HOST_TWITTER;
@@ -544,7 +570,7 @@ int main(int argc, char *argv[], char *envp[])
        if (retval && !session->bash)
                fprintf(stderr, "tweet failed\n");
 
-//     log_session(session, retval);
+       log_session(session, retval);
 exit:
        session_free(session);
        return retval;;
index 580a9f4cb1a107a81c1172e8591a7bbae7416920..bc973292a5c5cd8d81b0ec1f53099733e724f538 100644 (file)
@@ -6,4 +6,5 @@
 account=twitmaster
 password=icanhascheezburger
 host=identica
+logfile=.bti.log
 #proxy=http://localhost:8080
diff --git a/bti.xml b/bti.xml
index 96f424a67ac80cd358e68b1cc94b73cc956b0240..1b20586ba0bd0bc6c1cf92d6f7c91b6fd4b85a8b 100644 (file)
--- a/bti.xml
+++ b/bti.xml
@@ -30,6 +30,7 @@
           <arg><option>--password password</option></arg>
           <arg><option>--host HOST_NAME</option></arg>
           <arg><option>--proxy PROXY:PORT</option></arg>
+          <arg><option>--logfile LOGFILE</option></arg>
           <arg><option>--bash</option></arg>
           <arg><option>--debug</option></arg>
           <arg><option>--version</option></arg>
               </para>
             </listitem>
           </varlistentry>
+          <varlistentry>
+            <term><option>--logfile LOGFILE</option></term>
+            <listitem>
+              <para>
+               Specify a logfile for bti to write status messages to.  LOGFILE
+               is in relation to the user's home directory, not an absolute
+               path to a file.
+              </para>
+            </listitem>
+          </varlistentry>
           <varlistentry>
             <term><option>--debug</option></term>
             <listitem>
                </para>
              </listitem>
            </varlistentry>
+           <varlistentry>
+             <term><option>logfile</option></term>
+             <listitem>
+               <para>
+                The logfile name for bti to write what happened to.
+                This file is relative to the user's home directory.  If this
+                file is not specified here or on the command line, no logging
+                will be written to the disk.
+               </para>
+             </listitem>
+           </varlistentry>
          </variablelist>
          <para>
            There is an example config file called
index 235972480165af150b99dc5f17032ee1351fef3b..439fc024a4aac1eaad773832faf9da5c8f0cff79 100644 (file)
@@ -1,3 +1,9 @@
+bti (012-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- gregor herrmann <gregoa@debian.org>  Sat, 24 Jan 2009 17:35:19 +0100
+
 bti (011-1) unstable; urgency=low
 
   * New upstream release.