Ejemplo n.º 1
0
Archivo: auth.c Proyecto: epitron/dillo
/*
 * Given authentication challenge(s), prepare authorization.
 * Return: 0 on failure
 *         nonzero on success. A new query will be sent to the server.
 */
int a_Auth_do_auth(Dlist *challenges, const DilloUrl *url)
{
   int i;
   char *chal;

   for (i = 0; (chal = dList_nth_data(challenges, i)); ++i)
      if (!dStrnAsciiCasecmp(chal, "Digest ", 7))
         if (Auth_do_auth(chal, DIGEST, url))
            return 1;
   for (i = 0; (chal = dList_nth_data(challenges, i)); ++i)
      if (!dStrnAsciiCasecmp(chal, "Basic ", 6))
         if (Auth_do_auth(chal, BASIC, url))
            return 1;

   return 0;
}
Ejemplo n.º 2
0
/*
 * Search the list of major MIME viewers, for a Method that matches 'Key'
 * 'Key' is the content-type string that identifies the MIME type
 */
static Viewer_t Mime_major_type_fetch(const char *Key, uint_t Size)
{
   int i;

   if (Size) {
      for ( i = 0; i < MimeMajItemsSize; ++i )
         if (dStrnAsciiCasecmp(Key, MimeMajItems[i].Name, Size) == 0)
            return MimeMajItems[i].Data;
   }
   return NULL;
}
Ejemplo n.º 3
0
Archivo: dpid.c Proyecto: epitron/dillo
/*
 * Compare a struct service pointer and a service name
 * This function is used for searching services by name
 */
int service_match(const struct service *A, const char *B)
{
   int A_len, B_len, len;

   A_len = strlen(A->name);
   B_len = strlen(B);
   len = MAX (A_len, B_len);

   if (A->name[A_len - 1] == '*')
      len = A_len - 1;

   return(dStrnAsciiCasecmp(A->name, B, len));
}
Ejemplo n.º 4
0
/*
 * Change Content-Type for cache entry found by url.
 * from = { "http" | "meta" }
 * Return new content type.
 */
const char *a_Cache_set_content_type(const DilloUrl *url, const char *ctype,
                                     const char *from)
{
   const char *curr;
   char *major, *minor, *charset;
   CacheEntry_t *entry = Cache_entry_search(url);

   dReturn_val_if_fail (entry != NULL, NULL);

   _MSG("a_Cache_set_content_type {%s} {%s}\n", ctype, URL_STR(url));

   curr = Cache_current_content_type(entry);
   if  (entry->TypeMeta || (*from == 'h' && entry->TypeHdr) ) {
      /* Type is already been set. Do nothing.
       * BTW, META overrides TypeHdr */
   } else {
      if (*from == 'h') {
         /* Content-Type from HTTP header */
         entry->TypeHdr = dStrdup(ctype);
      } else {
         /* Content-Type from META */
         entry->TypeMeta = dStrdup(ctype);
      }
      if (a_Misc_content_type_cmp(curr, ctype)) {
         /* ctype gives one different from current */
         a_Misc_parse_content_type(ctype, &major, &minor, &charset);
         if (*from == 'm' && charset &&
             ((!major || !*major) && (!minor || !*minor))) {
            /* META only gives charset; use detected MIME type too */
            entry->TypeNorm = dStrconcat(entry->TypeDet, ctype, NULL);
         } else if (*from == 'm' &&
                    !dStrnAsciiCasecmp(ctype, "text/xhtml", 10)) {
            /* WORKAROUND: doxygen uses "text/xhtml" in META */
            entry->TypeNorm = dStrdup(entry->TypeDet);
         }
         if (charset) {
            if (entry->CharsetDecoder)
               a_Decode_free(entry->CharsetDecoder);
            entry->CharsetDecoder = a_Decode_charset_init(charset);
            curr = Cache_current_content_type(entry);

            /* Invalidate UTF8Data */
            dStr_free(entry->UTF8Data, 1);
            entry->UTF8Data = NULL;
         }
         dFree(major); dFree(minor); dFree(charset);
      }
   }
   return curr;
}
Ejemplo n.º 5
0
/*
 * Take a month's name and return a number between 0-11.
 * E.g. 'April' -> 3
 */
static int Cookies_get_month(const char *month_name)
{
   static const char *const months[] =
   { "Jan", "Feb", "Mar",
     "Apr", "May", "Jun",
     "Jul", "Aug", "Sep",
     "Oct", "Nov", "Dec"
   };
   int i;

   for (i = 0; i < 12; i++) {
      if (!dStrnAsciiCasecmp(months[i], month_name, 3))
         return i;
   }
   return -1;
}