Imported Upstream version 034 upstream upstream/034
authorgregor herrmann <gregoa@debian.org>
Wed, 15 Jan 2014 17:13:27 +0000 (18:13 +0100)
committergregor herrmann <gregoa@debian.org>
Wed, 15 Jan 2014 17:13:27 +0000 (18:13 +0100)
.gitignore
ChangeLog
RELEASE-NOTES
bti.1
bti.c
bti.h
bti.xml
config.c
configure.ac

index 6b1050f..105a7a8 100644 (file)
@@ -4,24 +4,25 @@ bti
 *.swp
 *.gz
 *.bz2
+INSTALL
 Makefile
 Makefile.in
+TAGS
 aclocal.m4
 autom4te.cache
+check-news.in
+compile
+config.guess
 config.h
 config.h.in
 config.log
 config.status
-config.guess
 config.sub
+configure
+depcomp
+install-sh
 libtool
 ltmain.sh
-install-sh
 missing
-configure
 stamp-h1
-depcomp
-INSTALL
-check-news.in
 tags
-TAGS
index 280888c..5feb05e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+Summary of changes from v033 to v034
+============================================
+
+Colin Guthrie (1):
+      Build against the new JSON-C library name.
+
+Dirk Eddelbuettel (1):
+      change remaining http:// to https://
+
+Greg Kroah-Hartman (5):
+      use -EIO instead of -EREMOTEIO
+      dry-run shouldn't error out.
+      remove identi.ca support.
+      Remove unused xml parsing function
+      Merge pull request #32 from eddelbuettel/master
+
+
 Summary of changes from v032 to v033
 ============================================
 
index 8e1ba09..458f10e 100644 (file)
@@ -1,3 +1,10 @@
+bti 033
+=============
+- fixes due to Twitter turning off http support (everything is https now.)
+  thanks to Dirk Eddelbuettel
+- BSD build fixes
+- JSON-C build fixes thanks to Colin Guthrie
+
 bti 033
 =============
 - fixes due to Twitter turning off old XML interface thanks to Paul Salanitri
diff --git a/bti.1 b/bti.1
index b4b9198..a019929 100644 (file)
--- a/bti.1
+++ b/bti.1
@@ -1,7 +1,7 @@
 '\" t
 .\"     Title: bti
 .\"    Author: [see the "AUTHOR" section]
-.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
+.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
 .\"      Date: May 2008
 .\"    Manual: bti
 .\"    Source: bti
 .\" * MAIN CONTENT STARTS HERE *
 .\" -----------------------------------------------------------------
 .SH "NAME"
-bti \- send a tweet to twitter\&.com or identi\&.ca from the command line
+bti \- send a tweet to twitter\&.com from the command line
 .SH "SYNOPSIS"
 .HP \w'\fBbti\fR\ 'u
 \fBbti\fR [\fB\-\-account\ account\fR] [\fB\-\-password\ password\fR] [\fB\-\-action\ action\fR] [\fB\-\-user\ screenname\fR] [\fB\-\-host\ HOST_NAME\fR] [\fB\-\-proxy\ PROXY:PORT\fR] [\fB\-\-logfile\ LOGFILE\fR] [\fB\-\-config\ CONFIGFILE\fR] [\fB\-\-replyto\ ID\fR] [\fB\-\-retweet\ ID\fR] [\fB\-\-page\ PAGENUMBER\fR] [\fB\-\-bash\fR] [\fB\-\-shrink\-urls\fR] [\fB\-\-debug\fR] [\fB\-\-dry\-run\fR] [\fB\-\-verbose\fR] [\fB\-\-version\fR] [\fB\-\-help\fR]
 .SH "DESCRIPTION"
 .PP
-bti sends a tweet message to twitter\&.com or identi\&.ca\&.
+bti sends a tweet message to twitter\&.com\&.
 .SH "OPTIONS"
 .PP
 \fB\-\-account account\fR
 .RS 4
-Specify the twitter\&.com or identi\&.ca account name\&.
+Specify the twitter\&.com account name\&.
 .RE
 .PP
 \fB\-\-password password\fR
 .RS 4
-Specify the password of your twitter\&.com or identi\&.ca account\&.
+Specify the password of your twitter\&.com account\&.
 .RE
 .PP
 \fB\-\-action action\fR
@@ -59,7 +59,7 @@ Specify the user whose messages you want to see when the action is "user", and t
 .PP
 \fB\-\-host HOST_NAME\fR
 .RS 4
-Specify the host which you want to send your message to\&. Valid options are "twitter" to send to twitter\&.com and "identica" to send to identi\&.ca\&. If you want to send the message to a custom StatusNet installation, you should specify the API URI\&. For example identi\&.ca\*(Aqs URI is: https://identi\&.ca/api/statuses
+Specify the host which you want to send your message to\&. Valid options are "twitter" to send to twitter\&.com\&.
 .sp
 If no host is specified, the default is to send to twitter\&.com\&.
 .RE
@@ -154,7 +154,6 @@ Its primary focus is to allow you to log everything that you type into a bash sh
 .PP
 To hook bti up to your bash shell, export the following variable:
 .PP
-
 PROMPT_COMMAND=\*(Aqhistory 1 | sed \-e "s/^\es*[0\-9]*\es*//" | bti \-\-bash\*(Aq
 .PP
 This example assumes that you have the
@@ -167,12 +166,12 @@ The account and password can be stored in a configuration file in the users home
 .PP
 \fBaccount\fR
 .RS 4
-The twitter\&.com or identi\&.ca account name you wish to use to send this message with\&.
+The twitter\&.com account name you wish to use to send this message with\&.
 .RE
 .PP
 \fBpassword\fR
 .RS 4
-The twitter\&.com or identi\&.ca password for the account you wish to use to send this message with\&.
+The twitter\&.com password for the account you wish to use to send this message with\&.
 .RE
 .PP
 \fB\-\-action action\fR
@@ -187,7 +186,7 @@ Specify the user you want to see his/her messages while the action is "user"\&.
 .PP
 \fBhost\fR
 .RS 4
-The host you want to use to send the message to\&. Valid options are either "twitter" or "identica" to send to twitter\&.com or identi\&.ca respectively\&. If you want to send the message to a custom StatusNet installation, you should specify the API URI\&. For example identi\&.ca\*(Aqs URI is: https://identi\&.ca/api/statuses\&.
+The host you want to use to send the message to\&. Valid options is "twitter" or "custom" to specify your own server\&.
 .RE
 .PP
 \fBproxy\fR
@@ -238,4 +237,4 @@ environment variables
 For example, command line options always override any config file option, or any environment variables\&. Unless a config file is specified by the command line\&. At that point, the new config file is read, and any previous options set by a command line option, would be overridden\&.
 .SH "AUTHOR"
 .PP
-Written by Greg Kroah\-Hartman <greg@kroah\&.com> and Amir Mohammad Saied <amirsaied@gmail\&.com>\&.
+Written by Greg Kroah\-Hartman <<greg@kroah\&.com>> and Amir Mohammad Saied <<amirsaied@gmail\&.com>>\&.
diff --git a/bti.c b/bti.c
index 3138e02..f4b2c4d 100644 (file)
--- a/bti.c
+++ b/bti.c
@@ -32,7 +32,7 @@
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
 #include <libxml/tree.h>
-#include <json/json.h>
+#include <json-c/json.h>
 #include <pcre.h>
 #include <termios.h>
 #include <dlfcn.h>
@@ -258,19 +258,14 @@ static void bti_curl_buffer_free(struct bti_curl_buffer *buffer)
        free(buffer);
 }
 
-const char twitter_host[]  = "http://api.twitter.com/1.1/statuses";
+const char twitter_host[]  = "https://api.twitter.com/1.1/statuses";
 const char twitter_host_stream[]  = "https://stream.twitter.com/1.1/statuses"; /*this is not reset, and doesnt work */
-const char twitter_host_simple[]  = "http://api.twitter.com/1.1";
-const char identica_host[] = "https://identi.ca/api/statuses";
+const char twitter_host_simple[]  = "https://api.twitter.com/1.1";
 const char twitter_name[]  = "twitter";
-const char identica_name[] = "identi.ca";
 
 static const char twitter_request_token_uri[]  = "https://twitter.com/oauth/request_token";
 static const char twitter_access_token_uri[]   = "https://twitter.com/oauth/access_token";
 static const char twitter_authorize_uri[]      = "https://twitter.com/oauth/authorize?oauth_token=";
-static const char identica_request_token_uri[] = "https://identi.ca/api/oauth/request_token?oauth_callback=oob";
-static const char identica_access_token_uri[]  = "https://identi.ca/api/oauth/access_token";
-static const char identica_authorize_uri[]     = "https://identi.ca/api/oauth/authorize?oauth_token=";
 static const char custom_request_token_uri[]   = "/../oauth/request_token?oauth_callback=oob";
 static const char custom_access_token_uri[]    = "/../oauth/access_token";
 static const char custom_authorize_uri[]       = "/../oauth/authorize?oauth_token=";
@@ -685,7 +680,7 @@ static int parse_response_json(char *document, struct session *session)
                                results.code, results.message);
                fprintf(stderr, "error condition detected: %d = %s\n",
                        results.code, results.message);
-               return -EREMOTEIO;
+               return -EIO;
        }
        return 0;
 }
@@ -717,64 +712,6 @@ static void parse_timeline_json(char *document, struct session *session)
        }
 }
 
-#ifdef OLDXML
-static int parse_response_xml(char *document, struct session *session)
-{
-       xmlDocPtr doc;
-       xmlNodePtr current;
-
-       doc = xmlReadMemory(document, strlen(document),
-                               "response.xml", NULL,
-                               XML_PARSE_NOERROR);
-       if (doc == NULL)
-               return -EREMOTEIO;
-
-       current = xmlDocGetRootElement(doc);
-       if (current == NULL) {
-               fprintf(stderr, "empty document\n");
-               xmlFreeDoc(doc);
-               return -EREMOTEIO;
-       }
-
-       if (xmlStrcmp(current->name, (const xmlChar *) "status")) {
-               if (xmlStrcmp(current->name, (const xmlChar *) "direct_message")) {
-                       if (xmlStrcmp(current->name, (const xmlChar *) "hash")
-                               && xmlStrcmp(current->name, (const xmlChar *) "errors")) {
-                               fprintf(stderr, "unexpected document type\n");
-                               xmlFreeDoc(doc);
-                               return -EREMOTEIO;
-                       } else {
-                               xmlChar *text=NULL;
-                               while (current != NULL) {
-                                       if (current->type == XML_ELEMENT_NODE)
-                                               if (!xmlStrcmp(current->name, (const xmlChar *)"error")) {
-                                                       text = xmlNodeListGetString(doc, current->xmlChildrenNode, 1);
-                                                       break;
-                                               }
-                                       if (current->children)
-                                               current = current->children;
-                                       else
-                                               current = current->next;
-                               }
-
-                               if (text) {
-                                       fprintf(stderr, "error condition detected = %s\n", text);
-                                       xmlFree(text);
-                               } else
-                                       fprintf(stderr, "unknown error condition\n");
-
-                               xmlFreeDoc(doc);
-                               return -EREMOTEIO;
-                       }
-               }
-       }
-
-       xmlFreeDoc(doc);
-
-       return 0;
-}
-#endif
-
 static size_t curl_callback(void *buffer, size_t size, size_t nmemb,
                            void *userp)
 {
@@ -860,11 +797,6 @@ static int request_access_token(struct session *session)
                                twitter_request_token_uri, NULL,
                                OA_HMAC, NULL, session->consumer_key,
                                session->consumer_secret, NULL, NULL);
-       else if (session->host == HOST_IDENTICA)
-               request_url = oauth_sign_url2(
-                               identica_request_token_uri, NULL,
-                               OA_HMAC, NULL, session->consumer_key,
-                               session->consumer_secret, NULL, NULL);
        else {
                sprintf(token_uri, "%s%s",
                        session->hosturl, custom_request_token_uri);
@@ -898,11 +830,6 @@ static int request_access_token(struct session *session)
                verifier = session->readline(NULL);
                sprintf(at_uri, "%s?oauth_verifier=%s",
                        twitter_access_token_uri, verifier);
-       } else if (session->host == HOST_IDENTICA) {
-               fprintf(stdout, "%s%s\nPIN: ", identica_authorize_uri, at_key);
-               verifier = session->readline(NULL);
-               sprintf(at_uri, "%s?oauth_verifier=%s",
-                       identica_access_token_uri, verifier);
        } else {
                fprintf(stdout, "%s%s%s\nPIN: ",
                        session->hosturl, custom_authorize_uri, at_key);
@@ -1205,14 +1132,12 @@ static int send_request(struct session *session)
                        dbg("reply:%s\n", reply);
                        if (req_url)
                                free(req_url);
-               }
 
-               if (!reply) {
-                       fprintf(stderr, "Error retrieving from URL (%s)\n", endpoint);
-                       return -EIO;
-               }
+                       if (!reply) {
+                               fprintf(stderr, "Error retrieving from URL (%s)\n", endpoint);
+                               return -EIO;
+                       }
 
-               if (!session->dry_run) {
                        if ((session->action != ACTION_UPDATE) &&
                                        (session->action != ACTION_RETWEET) &&
                                        (session->action != ACTION_DIRECT))
@@ -1770,10 +1695,6 @@ int main(int argc, char *argv[], char *envp[])
                                session->host = HOST_TWITTER;
                                session->hosturl = strdup(twitter_host);
                                session->hostname = strdup(twitter_name);
-                       } else if (strcasecmp(optarg, "identica") == 0) {
-                               session->host = HOST_IDENTICA;
-                               session->hosturl = strdup(identica_host);
-                               session->hostname = strdup(identica_name);
                        } else {
                                session->host = HOST_CUSTOM;
                                session->hosturl = strdup(optarg);
diff --git a/bti.h b/bti.h
index 62ab23f..3d5ed9c 100644 (file)
--- a/bti.h
+++ b/bti.h
@@ -18,7 +18,6 @@
 
 enum host {
        HOST_TWITTER  = 0,
-       HOST_IDENTICA = 1,
        HOST_CUSTOM   = 2
 };
 
@@ -77,9 +76,7 @@ struct bti_curl_buffer {
 };
 
 extern const char twitter_host[];
-extern const char identica_host[];
 extern const char twitter_name[];
-extern const char identica_name[];
 extern int debug;
 
 extern void bti_parse_configfile(struct session *session);
diff --git a/bti.xml b/bti.xml
index a2efd60..c0b89ee 100644 (file)
--- a/bti.xml
+++ b/bti.xml
@@ -21,7 +21,7 @@
 
       <refnamediv>
         <refname>bti</refname>
-        <refpurpose>send a tweet to twitter.com or identi.ca from the command line</refpurpose>
+        <refpurpose>send a tweet to twitter.com from the command line</refpurpose>
       </refnamediv>
 
       <refsynopsisdiv>
@@ -49,7 +49,7 @@
       </refsynopsisdiv>
 
       <refsect1><title>DESCRIPTION</title>
-        <para>bti sends a tweet message to twitter.com or identi.ca.
+        <para>bti sends a tweet message to twitter.com.
         </para>
       </refsect1>
 
@@ -59,7 +59,7 @@
             <term><option>--account account</option></term>
             <listitem>
               <para>
-               Specify the twitter.com or identi.ca account name.
+               Specify the twitter.com account name.
              </para>
             </listitem>
           </varlistentry>
@@ -67,7 +67,7 @@
             <term><option>--password password</option></term>
             <listitem>
               <para>
-                Specify the password of your twitter.com or identi.ca account.
+                Specify the password of your twitter.com account.
               </para>
             </listitem>
           </varlistentry>
             <listitem>
               <para>
                Specify the host which you want to send your message to.  Valid
-               options are "twitter" to send to twitter.com and "identica" to
-        send to identi.ca.
-
-        If you want to send the message to a custom StatusNet installation,
-        you should specify the API URI. For example identi.ca's URI is:
-        https://identi.ca/api/statuses
+               options are "twitter" to send to twitter.com.
               </para>
               <para>
                If no host is specified, the default is to send to twitter.com.
              <term><option>account</option></term>
              <listitem>
                <para>
-                 The twitter.com or identi.ca account name you wish to use to send this
+                 The twitter.com account name you wish to use to send this
                  message with.
                </para>
              </listitem>
              <term><option>password</option></term>
              <listitem>
                <para>
-                 The twitter.com or identi.ca password for the account you wish to use
+                 The twitter.com password for the account you wish to use
                  to send this message with.
                </para>
              </listitem>
              <listitem>
                <para>
                 The host you want to use to send the message to.  Valid
-                options are either "twitter" or "identica" to send to
-                twitter.com or identi.ca respectively.
+                options is "twitter" or "custom" to specify your own server.
 
-         If you want to send the message to a custom StatusNet installation,
-         you should specify the API URI. For example identi.ca's URI is:
-         https://identi.ca/api/statuses.
                </para>
              </listitem>
            </varlistentry>
index dd1b38f..e6fecc1 100644 (file)
--- a/config.c
+++ b/config.c
@@ -223,10 +223,6 @@ static int host_callback(struct session *session, char *value)
                session->host = HOST_TWITTER;
                session->hosturl = strdup(twitter_host);
                session->hostname = strdup(twitter_name);
-       } else if (strcasecmp(value, "identica") == 0) {
-               session->host = HOST_IDENTICA;
-               session->hosturl = strdup(identica_host);
-               session->hostname = strdup(identica_name);
        } else {
                session->host = HOST_CUSTOM;
                session->hosturl = strdup(value);
index 4923480..0cadef9 100644 (file)
@@ -1,7 +1,7 @@
-AC_INIT([bti], [033], [greg@kroah.com])
+AC_INIT([bti], [034], [greg@kroah.com])
 AC_PREREQ(2.60)
 
-AM_INIT_AUTOMAKE(bti, 033)
+AM_INIT_AUTOMAKE(bti, 034)
 
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
@@ -18,7 +18,7 @@ PKG_CHECK_MODULES(LIBOAUTH, oauth)
 PKG_CHECK_MODULES(LIBPCRE, libpcre)
 PKG_CHECK_MODULES([LIBCURL], [libcurl])
 PKG_CHECK_MODULES([XML], [libxml-2.0])
-PKG_CHECK_MODULES([JSON], [json])
+PKG_CHECK_MODULES([JSON], [json-c])
 
 AC_SEARCH_LIBS([dlopen], [dl])