]> diplodocus.org Git - nmh/blobdiff - sbr/oauth.c
showfile.c: Move interface to own file.
[nmh] / sbr / oauth.c
index aac6b43a693a6e53d4cfc40e0db431c511a79ef4..195b9b8fe77e8724cae524a971112b0850123943 100755 (executable)
@@ -5,7 +5,10 @@
  * complete copyright information.
  */
 
  * complete copyright information.
  */
 
-#include <h/mh.h>
+#include "h/mh.h"
+#include "trimcpy.h"
+#include "getcpy.h"
+#include "error.h"
 
 #ifdef OAUTH_SUPPORT
 
 
 #ifdef OAUTH_SUPPORT
 
 #include <unistd.h>
 
 #include <curl/curl.h>
 #include <unistd.h>
 
 #include <curl/curl.h>
-#include <thirdparty/jsmn/jsmn.h>
+#include "thirdparty/jsmn/jsmn.h"
 
 
-#include <h/oauth.h>
-#include <h/utils.h>
+#include "h/oauth.h"
+#include "h/utils.h"
 #include "lock_file.h"
 
 #define JSON_TYPE "application/json"
 #include "lock_file.h"
 
 #define JSON_TYPE "application/json"
@@ -141,7 +144,7 @@ mh_oauth_do_xoauth(const char *user, const char *svc, unsigned char **oauth_res,
     char *client_res;
 
     if (!mh_oauth_new (&ctx, svc))
     char *client_res;
 
     if (!mh_oauth_new (&ctx, svc))
-        adios(NULL, "%s", mh_oauth_get_err_string(ctx));
+        die("%s", mh_oauth_get_err_string(ctx));
 
     if (log != NULL) mh_oauth_log_to(stderr, ctx);
 
 
     if (log != NULL) mh_oauth_log_to(stderr, ctx);
 
@@ -149,7 +152,7 @@ mh_oauth_do_xoauth(const char *user, const char *svc, unsigned char **oauth_res,
     fp = lkfopendata(fn, "r+", &failed_to_lock);
     if (fp == NULL) {
         if (errno == ENOENT) {
     fp = lkfopendata(fn, "r+", &failed_to_lock);
     if (fp == NULL) {
         if (errno == ENOENT) {
-            adios(NULL, "no credentials -- run mhlogin -saslmech xoauth2 -authservice %s", svc);
+            die("no credentials -- run mhlogin -saslmech xoauth2 -authservice %s", svc);
         }
         adios(fn, "failed to open");
     }
         }
         adios(fn, "failed to open");
     }
@@ -158,24 +161,24 @@ mh_oauth_do_xoauth(const char *user, const char *svc, unsigned char **oauth_res,
     }
 
     if ((cred = mh_oauth_cred_load(fp, ctx, user)) == NULL) {
     }
 
     if ((cred = mh_oauth_cred_load(fp, ctx, user)) == NULL) {
-        adios(NULL, "%s", mh_oauth_get_err_string(ctx));
+        die("%s", mh_oauth_get_err_string(ctx));
     }
 
     if (!mh_oauth_access_token_valid(time(NULL), cred)) {
         if (!mh_oauth_refresh(cred)) {
             if (mh_oauth_get_err_code(ctx) == MH_OAUTH_NO_REFRESH) {
     }
 
     if (!mh_oauth_access_token_valid(time(NULL), cred)) {
         if (!mh_oauth_refresh(cred)) {
             if (mh_oauth_get_err_code(ctx) == MH_OAUTH_NO_REFRESH) {
-                adios(NULL, "no valid credentials -- run mhlogin -saslmech xoauth2 -authservice %s", svc);
+                die("no valid credentials -- run mhlogin -saslmech xoauth2 -authservice %s", svc);
             }
             if (mh_oauth_get_err_code(ctx) == MH_OAUTH_BAD_GRANT) {
             }
             if (mh_oauth_get_err_code(ctx) == MH_OAUTH_BAD_GRANT) {
-                adios(NULL, "credentials rejected -- run mhlogin -saslmech xoauth2 -authservice %s", svc);
+                die("credentials rejected -- run mhlogin -saslmech xoauth2 -authservice %s", svc);
             }
             inform("error refreshing OAuth2 token");
             }
             inform("error refreshing OAuth2 token");
-            adios(NULL, "%s", mh_oauth_get_err_string(ctx));
+            die("%s", mh_oauth_get_err_string(ctx));
         }
 
         fseek(fp, 0, SEEK_SET);
         if (!mh_oauth_cred_save(fp, cred, user)) {
         }
 
         fseek(fp, 0, SEEK_SET);
         if (!mh_oauth_cred_save(fp, cred, user)) {
-            adios(NULL, "%s", mh_oauth_get_err_string(ctx));
+            die("%s", mh_oauth_get_err_string(ctx));
         }
     }
 
         }
     }