stoken: Implement new auth form to gather soft token information
[platform/upstream/openconnect.git] / http.c
diff --git a/http.c b/http.c
index 0fb661e..38fc9a5 100644 (file)
--- a/http.c
+++ b/http.c
@@ -526,28 +526,6 @@ static int run_csd_script(struct openconnect_info *vpninfo, char *buf, int bufle
        return 0;
 }
 
-#ifndef HAVE_STRCASESTR
-static char *openconnect__strcasestr(const char *haystack, const char *needle)
-{
-       int hlen = strlen(haystack);
-       int nlen = strlen(needle);
-       int i, j;
-
-       for (i = 0; i < hlen - nlen + 1; i++) {
-               for (j = 0; j < nlen; j++) {
-                       if (tolower(haystack[i + j]) != 
-                           tolower(needle[j]))
-                               break;
-               }
-               if (j == nlen)
-                       return (char *)haystack + i;
-       }
-       return NULL;
-}
-#define strcasestr openconnect__strcasestr
-#endif
-
-
 int internal_parse_url(char *url, char **res_proto, char **res_host,
                       int *res_port, char **res_path, int default_port)
 {
@@ -615,8 +593,8 @@ int internal_parse_url(char *url, char **res_proto, char **res_host,
 
 /* Return value:
  *  < 0, on error
- *  = 0, no cookie (user cancel)
- *  = 1, obtained cookie
+ *  > 0, no cookie (user cancel)
+ *  = 0, obtained cookie
  */
 int openconnect_obtain_cookie(struct openconnect_info *vpninfo)
 {
@@ -628,6 +606,12 @@ int openconnect_obtain_cookie(struct openconnect_info *vpninfo)
        const char *request_body_type = NULL;
        const char *method = "GET";
 
+       if (vpninfo->use_stoken) {
+               result = prepare_stoken(vpninfo);
+               if (result)
+                       return result;
+       }
+
  retry:
        if (form_buf) {
                free(form_buf);