static void parse_cookie(const char *cookies, char *value, const char *key);

 

사용하기

parse_cookie(cookies, value, "GOOGLE-LOGIN");

 

다음은 코드..

 

 

 

#include <stdio.h>

  

static void parse_cookie(const char *cookies, char *value, const char *key)

{

  register const char *p;

  int key_len;

 

  if (!cookies) return;

 

  p = cookies;

  key_len = strlen(key);

 

  while (*p) {

    const char *name;

    while (*p == ' ' || *p == ';') p++;

    name = p;

    do {

      if (*p == '\0') break;

      p++;

    } while (*p != '=');

    if (p - name == key_len && !strncmp(key, name, key_len)) {

      register char *c = value;

      p++;

      do {

        if (*p == '\0' || *p == ' ' || *p == ';') break;

        *c++ = *p++;

      } while (*p != ' ' && *p != ';');

      *c = '\0';

      return;

    }

    else {

      do {

        if (*p == '\0' || *p == ' ' || *p == ';') break;

        p++;

      } while (*p != ' ' && *p != ';');

    }

  }

}

 

 

 

Posted by '김용환'
,