Cookies 2.67 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* Copyright 1997 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
15 16 17 18 19 20 21 22 23
/***************************************************/
/* File   : Cookies.c                              */
/*                                                 */
/* Purpose: Browser-end HTTP Cookie support.       */
/*                                                 */
/* Author : A.D.Hodgkinson                         */
/*                                                 */
/* History: 28-Jul-96: Created.                    */
/***************************************************/
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "swis.h"

#include "wimp.h"
#include "wimplib.h"
#include "event.h"

#include "svcprint.h"
#include "Global.h"
#include "Utils.h"

#include "MiscDefs.h"

#include "Cookies.h"

/*************************************************/
/* cookies_process_cookie()                      */
/*                                               */
/* If a call to URL_ReadData flags (through bit  */
/* 16 of the returned status word being set)     */
/* that a cookie / some cookies have arrived,    */
/* this function deals with sending that cookie  */
/* on or getting rid of it. This may or may not  */
/* involve user level interaction.               */
/*                                               */
/* Parameters: Pointer to a browser_data struct  */
/*             relevant to the fetch.            */
/*************************************************/

_kernel_oserror * cookies_process_cookie(browser_data * b)
{
  _kernel_oserror * e;
  int               handle = 0;
61
  int               unread = 1;
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
  int               flags;
  int               ncookies;
  char            * domain;
  char            * name;
  char            * value;
  char            * path;

  while (unread)
  {
    e = _swix(HTTP_EnumerateCookies,
              _INR(0,1) | _OUTR(0,7),

              0,
              handle,

              &flags,
              &handle,
              &ncookies,
              &unread,
              &domain,
              &name,
              &value,
              &path);

    /* Exit conditions */

    if (e) return e;
    if (!handle) break;
  }

  return NULL;
}