Пример #1
0
bool getRawCookies(const Document*, const KURL& url, Vector<Cookie>& rawCookies)
{
    rawCookies.clear();
    CFHTTPCookieStorageRef cookieStorage = currentCookieStorage();
    if (!cookieStorage)
        return false;

    RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL());

    bool sendSecureCookies = url.protocolIs("https");
    RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(cookieStorage, urlCF.get(), sendSecureCookies));

    CFIndex count = CFArrayGetCount(cookiesCF.get());
    rawCookies.reserveCapacity(count);

    for (CFIndex i = 0; i < count; i++) {
       CFHTTPCookieRef cookie = (CFHTTPCookieRef)CFArrayGetValueAtIndex(cookiesCF.get(), i);
       String name = CFHTTPCookieGetName(cookie);
       String value = CFHTTPCookieGetValue(cookie);
       String domain = CFHTTPCookieGetDomain(cookie);
       String path = CFHTTPCookieGetPath(cookie);

       double expires = (CFDateGetAbsoluteTime(CFHTTPCookieGetExpiratonDate(cookie)) + kCFAbsoluteTimeIntervalSince1970) * 1000;

       bool httpOnly = CFHTTPCookieIsHTTPOnly(cookie);
       bool secure = CFHTTPCookieIsSecure(cookie);
       bool session = false;    // FIXME: Need API for if a cookie is a session cookie.

       rawCookies.uncheckedAppend(Cookie(name, value, domain, path, expires, httpOnly, secure, session));
    }

    return true;
}
Пример #2
0
bool getRawCookies(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& url, Vector<Cookie>& rawCookies)
{
    rawCookies.clear();

    RetainPtr<CFURLRef> urlCF = adoptCF(url.createCFURL());

    bool sendSecureCookies = url.protocolIs("https");
    RetainPtr<CFArrayRef> cookiesCF = adoptCF(CFHTTPCookieStorageCopyCookiesForURL(session.cookieStorage().get(), urlCF.get(), sendSecureCookies));

    CFIndex count = CFArrayGetCount(cookiesCF.get());
    rawCookies.reserveCapacity(count);

    for (CFIndex i = 0; i < count; i++) {
       CFHTTPCookieRef cookie = (CFHTTPCookieRef)CFArrayGetValueAtIndex(cookiesCF.get(), i);
       String name = cookieName(cookie).get();
       String value = cookieValue(cookie).get();
       String domain = cookieDomain(cookie).get();
       String path = cookiePath(cookie).get();

       double expires = (cookieExpirationTime(cookie) + kCFAbsoluteTimeIntervalSince1970) * 1000;

       bool httpOnly = CFHTTPCookieIsHTTPOnly(cookie);
       bool secure = CFHTTPCookieIsSecure(cookie);
       bool session = false;    // FIXME: Need API for if a cookie is a session cookie.

       rawCookies.uncheckedAppend(Cookie(name, value, domain, path, expires, httpOnly, secure, session));
    }

    return true;
}
Пример #3
0
Response parseResponse(char const* str) {
    // Parse an HTTP response 
    auto version = parseToken(str);
    auto code = parseStatus(version.ch);
    auto message = parseUntil(code.ch, [](char ch) { return ch == '\r'; });
    
    auto response = Response();
    if (version.value != "HTTP/1.1") {
        throw Error("bad HTTP version");
    }
      
    auto ch = parseCrLf(message.ch).ch;
    while (*ch != '\0' && *ch != '\r') {
        auto name = parseUntil(ch, [](char ch) { return ch == ':'; });
        if (*name.ch) {
            name.ch++; // For ":"
        }
        auto ws = parseWhile(name.ch, isspace);
        auto value = parseUntil(ws.ch, [](char ch) { return ch == '\r'; });   
        response.headerIs(name.value, value.value);
        if (name.value == "Set-Cookie") {
            response.cookieIs(Cookie(value.value));
        }
        ch = parseCrLf(value.ch).ch;
    }
    ch = parseCrLf(ch).ch;
    
    response.statusIs(code.value);
    response.dataIs(ch); 
    return response;
}
Пример #4
0
TStr CookieCreate(int i)
{
	time_t cookie1;
	time(&cookie1);
	TStr Cookie(LongToStrHex((long)cookie1));
	while( Cookie.Length() < i )
		Cookie = LongToStrHex(getRnd()) + Cookie;
	return Cookie.CopyBefore(i);
}
Пример #5
0
    bool CookieVisitor::Visit(const CefCookie& cefCookie, int count, int total, bool& deleteCookie)
    {
        auto cookie = gcnew Cookie();
        String^ cookieName = StringUtils::ToClr(cefCookie.name);

        if (!String::IsNullOrEmpty(cookieName))
        {
            cookie->Name = StringUtils::ToClr(cefCookie.name);
            cookie->Value = StringUtils::ToClr(cefCookie.value);
            cookie->Domain = StringUtils::ToClr(cefCookie.domain);
            cookie->Path = StringUtils::ToClr(cefCookie.path);
            cookie->Secure = cefCookie.secure == 1;
            cookie->HttpOnly = cefCookie.httponly == 1;

            if (cefCookie.has_expires)
            {
                cookie->Expires = DateTime(
                    cefCookie.expires.year,
                    cefCookie.expires.month,
                    cefCookie.expires.day_of_month,
                    cefCookie.expires.hour,
                    cefCookie.expires.minute,
                    cefCookie.expires.second,
                    cefCookie.expires.millisecond
                );
            }

            //TODO: There is a method in TypeUtils that's in BrowserSubProcess that convers CefTime, need to make it accessible.
            cookie->Creation = DateTime(
                cefCookie.creation.year,
                cefCookie.creation.month,
                cefCookie.creation.day_of_month,
                cefCookie.creation.hour,
                cefCookie.creation.minute,
                cefCookie.creation.second,
                cefCookie.creation.millisecond
                );

            cookie->LastAccess = DateTime(
                cefCookie.last_access.year,
                cefCookie.last_access.month,
                cefCookie.last_access.day_of_month,
                cefCookie.last_access.hour,
                cefCookie.last_access.minute,
                cefCookie.last_access.second,
                cefCookie.last_access.millisecond
                );
        }

        return _visitor->Visit(cookie, count, total, deleteCookie);
    }
Пример #6
0
void Cookies::parse(const QString & cookiesString)
{
    QStringList parts = cookiesString.split(";");

    for (QString & part : parts)
    {
        if (!part.contains("="))
        {
            continue;
        }
        QStringList nameValue = part.trimmed().split("=");
        set(Cookie(nameValue[0], nameValue[1]));
    }
}
Пример #7
0
std::vector<Cookie> SqliteWrapper::printCookies(const char *filename, int mode)
{
    std::vector<Cookie> c;

    int rc;
	char *error;

	sqlite3 *db;
	rc = sqlite3_open(filename, &db);
	if (rc)
	{
		std::cerr << "Error opening SQLite3 database: " << sqlite3_errmsg(db) << std::endl << std::endl;
		sqlite3_close(db);
		return c;
	}

    const char *sqlSelect;

    if ( mode == 1)
        sqlSelect = "SELECT name, value, expiry FROM moz_cookies;";

    else if ( mode ==2 )
        sqlSelect = "SELECT name, value, expires_utc FROM cookies;";

	char **results = NULL;
	int rows, columns;
	sqlite3_get_table(db, sqlSelect, &results, &rows, &columns, &error);
	if (rc)
	{
		std::cerr << "Error executing SQLite3 query: " << sqlite3_errmsg(db) << std::endl << std::endl;
		sqlite3_free(error);
	}
	else
	{
		for (int rowCtr = 0; rowCtr <= rows; ++rowCtr)
		{
		    std::string a[3];
			for (int colCtr = 0; colCtr < columns; ++colCtr)
			{
				int cellPosition = (rowCtr * columns) + colCtr;
				a[colCtr] = results[cellPosition];
			}

			c.push_back(Cookie(a[0], a[1],a[2]));
		}
	}
	sqlite3_free_table(results);
	sqlite3_close(db);
}
Пример #8
0
    bool CookieVisitor::Visit(const CefCookie& cefCookie, int count, int total, bool& deleteCookie)
    {
        auto cookie = gcnew Cookie();
        String^ cookieName = StringUtils::ToClr(cefCookie.name);

        if (!String::IsNullOrEmpty(cookieName))
        {
            cookie->Name = StringUtils::ToClr(cefCookie.name);
            cookie->Value = StringUtils::ToClr(cefCookie.value);
            cookie->Domain = StringUtils::ToClr(cefCookie.domain);
            cookie->Path = StringUtils::ToClr(cefCookie.path);
            cookie->Secure = cefCookie.secure == 1;
            cookie->HttpOnly = cefCookie.httponly == 1;

            if (cefCookie.has_expires)
            {
                auto expires = cefCookie.expires;
                cookie->Expires = DateTimeUtils::FromCefTime(expires.year,
                    expires.month,
                    expires.day_of_month,
                    expires.hour,
                    expires.minute,
                    expires.second,
                    expires.millisecond);
            }


            auto creation = cefCookie.creation;
            cookie->Creation = DateTimeUtils::FromCefTime(creation.year,
                creation.month,
                creation.day_of_month,
                creation.hour,
                creation.minute,
                creation.second,
                creation.millisecond);

            auto lastAccess = cefCookie.last_access;
            cookie->LastAccess = DateTimeUtils::FromCefTime(lastAccess.year,
                lastAccess.month,
                lastAccess.day_of_month,
                lastAccess.hour,
                lastAccess.minute,
                lastAccess.second,
                lastAccess.millisecond);
        }

        return _visitor->Visit(cookie, count, total, deleteCookie);
    }
Пример #9
0
void ChatStateUpdater::sendState(IcqContact *contact, ChatState state)
{
	MTN type = MtnUnknown;
	if (state == ChatStatePaused)
		type = MtnTyped;
	else if (state == ChatStateComposing)
		type = MtnBegun;
	else if (state == ChatStateGone)
		type = MtnGone;
	else if (state == ChatStateInActive || state == ChatStateActive)
		type = MtnFinished;
	if (type == MtnUnknown)
		return;
	SNAC sn(MessageFamily, MessageMtn);
	sn.append(Cookie(true));
	sn.append<quint16>(1); // channel?
	sn.append<quint8>(contact->id());
	sn.append<quint16>(type);
	contact->account()->connection()->send(sn);
}
Пример #10
0
bool getRawCookies(const NetworkStorageSession& session, const URL& /*firstParty*/, const URL& url, Vector<Cookie>& rawCookies)
{
    rawCookies.clear();
    SoupCookieJar* jar = cookieJarForSession(session);
    if (!jar)
        return false;

    GUniquePtr<SoupURI> uri = url.createSoupURI();
    GUniquePtr<GSList> cookies(soup_cookie_jar_get_cookie_list(jar, uri.get(), TRUE));
    if (!cookies)
        return false;

    for (GSList* iter = cookies.get(); iter; iter = g_slist_next(iter)) {
        SoupCookie* cookie = static_cast<SoupCookie*>(iter->data);
        rawCookies.append(Cookie(String::fromUTF8(cookie->name), String::fromUTF8(cookie->value), String::fromUTF8(cookie->domain),
            String::fromUTF8(cookie->path), cookie->expires ? static_cast<double>(soup_date_to_time_t(cookie->expires)) * 1000 : 0,
            cookie->http_only, cookie->secure, !cookie->expires));
        soup_cookie_free(cookie);
    }

    return true;
}
Пример #11
0
bool getRawCookies(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& url, Vector<Cookie>& rawCookies)
{
    rawCookies.clear();
    SoupCookieJar* jar = context ? cookieJarForContext(context) : soupCookieJar();
    if (!jar)
        return false;

    GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(jar));
    if (!cookies)
        return false;

    GOwnPtr<SoupURI> uri(soup_uri_new(url.string().utf8().data()));
    for (GSList* iter = cookies.get(); iter; iter = g_slist_next(iter)) {
        GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(iter->data));
        if (!soup_cookie_applies_to_uri(cookie.get(), uri.get()))
            continue;
        rawCookies.append(Cookie(String::fromUTF8(cookie->name), String::fromUTF8(cookie->value), String::fromUTF8(cookie->domain),
                                 String::fromUTF8(cookie->path), static_cast<double>(soup_date_to_time_t(cookie->expires)) * 1000,
                                 cookie->http_only, cookie->secure, soup_cookie_jar_is_persistent(jar)));
    }

    return true;
}
Пример #12
0
void ParsedCookie::appendWebCoreCookie(Vector<Cookie>& cookieVector) const
{
    cookieVector.append(Cookie(String(m_name), String(m_value), String(m_domain),
            String(m_path), m_expiry, m_isHttpOnly, m_isSecure, m_isSession));
}
Пример #13
0
am_status_t Http::Response::readAndParse(Log::ModuleId logModule, Connection& conn) {
    am_status_t status = AM_FAILURE;
    bool contentLengthHdrSeen = false;

    int htsts = conn.httpStatusCode();

    Log::log(logModule, Log::LOG_DEBUG,
            "HTTP Status = %d", htsts);

    if (htsts != -1) {
        status = AM_SUCCESS;
        httpStatus = static_cast<Status> (htsts);
    }

    if (htsts != 200) {
        status = AM_HTTP_ERROR;
    }

    if (status == AM_SUCCESS) {
        int contentLength = conn.httpContentLength();

        if (contentLength != -1) {
            contentLengthHdrSeen = true;
        }

        std::string search("set-cookie");
        Connection::ConnHeaderMap::iterator it = conn.begin();
        Connection::ConnHeaderMap::iterator itEnd = conn.end();
        for (; it != itEnd; ++it) {
            std::string k = (*it).first;
            std::string v = (*it).second;
            std::string::iterator fpos = std::search(k.begin(), k.end(), search.begin(), search.end(), http_to_lower);
            if (fpos != k.end()) {
                cookieList.push_back(Cookie(v.c_str()));
                //Log::log(logModule, Log::LOG_MAX_DEBUG, "Set-Cookie: %s", v.c_str());
            } else {
                extraHdrs.set(k, v);
                //Log::log(logModule, Log::LOG_MAX_DEBUG, "Header: %s: %s", k.c_str(), v.c_str());
            }
        }

        if (contentLengthHdrSeen == true) {
            Log::log(logModule, Log::LOG_DEBUG,
                    "Http::Response::readAndParse(): "
                    "Reading body content of length: %d", contentLength);

            const char *body = conn.getBody();
            int body_len = conn.httpContentLength();
            if (!body || body_len <= 0) {
                status = AM_END_OF_FILE;
                bodyPtr = NULL;
                bodyLen = 0;
            } else {
                bodyPtr = new (std::nothrow) char[body_len + 1];
                if (bodyPtr) {
                    bodyLen = body_len;
                    memcpy(bodyPtr, body, body_len);
                    bodyPtr[bodyLen] = 0;
                } else {
                    bodyPtr = NULL;
                    bodyLen = 0;
                    status = AM_NO_MEMORY;
                }
            }

        } else {
            Log::log(logModule, Log::LOG_DEBUG,
                    "Http::Response::readAndParse(): "
                    "No content length in response.");
        }
    }

    Log::log(logModule, Log::LOG_MAX_DEBUG, "Http::Response::readAndParse(): "
            "Completed processing the response with status: %s",
            am_status_to_string(status));

    return status;
}
Пример #14
0
int main(void)
{
	TCGI cgi;
	cgi.makeHeader(
			"text/html; charset=Windows-1251"
			"\nExpires: Mon, 26 Jul 1997 05:00:00 GMT"
			"\nX-Accel-Expires: 0"
//			"\nPragma: no-cache"
			"\nCache-Control: none");

	cgi.init();

	TStr Link(cgi.getParamValueByName("Link"));
	TStr Referrer(cgi.getParamValueByName("Referrer"));
	TStr Lang(cgi.getEnvironment("HTTP_ACCEPT_LANGUAGE"));

	if( Referrer.isEmpty() )
		Referrer = cgi.getEnvironment("HTTP_REFERER");

	TStr Language;
#ifdef CASINO_VABANK
	Lang = Lang.Copy(0,2);
	if( Lang != "en" && Lang != "ru" )
		Lang = "ru";
	TStr Cookie(cgi.getEnvironment("HTTP_COOKIE"));
	Cookie = Cookie.CopyAfter("lang=").CopyBefore(";");
	if( !Cookie.isEmpty() )
	{
		if( Cookie == "1" || Cookie == "RU" )
			Lang = "RU";
		else
			Lang = "EN";
	}
	if( TStr(cgi.getParamValueByName("lang")) == "ru" )
		Lang = "RU";
	if( TStr(cgi.getParamValueByName("lang")) == "en" )
		Lang = "EN";
	if( Lang.isEmpty() )
		Lang = "RU";
	if( Lang == "ru" )
		Language = "russian";
	else
		Language = "english";
#else
	Lang = "EN";
	Language = "english";
#endif

	TStr PID(cgi.getParamValueByName("cid")), PIDKEY;
	if( !PID.isEmpty() ) {
		PIDKEY = PID.CopyBefore(5);
	} else {
		if( cgi.paramCount() > 0 )
			if(
				cgi.getParamValue(0)[0] == '\0' &&
				TStr(cgi.getParamName(0)) != "referrer" &&
				TStr(cgi.getParamName(0)) != "link"
			)
				PID = cgi.getParamName(0);
		if( !PID.isEmpty() )
			PIDKEY = PID.CopyBefore(",");
	}

	TStr QUERY(cgi.getEnvironment("QUERY_STRING"));
	TStr IP(cgi.getEnvironment("REMOTE_ADDR"));
	m_classes::TMySqlConnect database;
	database.setHostName("localhost");
	database.setDatabase("casino_last");
	database.setLogin("root");
	database.setPasswd("");
	database.connect();
	m_classes::TMySqlQuery query(&database);
	query.execSql(
		"INSERT INTO log_url ("
			"fdate,"
			"ftime,"
			"freferrer,"
			"fip,"
			"fid,"
			"fidkey,"
			"fquery"
		") VALUES ("
			"now(),"
			"now(),"
			"'"+StrToSQL(Referrer)+"',"
			"'"+StrToSQL(IP)+"',"
			"'"+StrToSQL(PID)+"',"
			"'"+StrToSQL(PIDKEY)+"',"
			"'"+StrToSQL(QUERY)+"'"
		")");
	TStr RefID(query.last_id());
	try {
		TFile f;
		f.OpenLoad("index.ini");
		char Str[10000];
		int FileLen = fread(Str, 1, 10000, f.stream);
		Str[FileLen] = '\0';

		TStr _Str(Str,FileLen);

		_Str = _Str.Replace("$tb$",__escape(cgi.getParamValueByName("tb")));

		_Str = _Str.Replace("$LOG_PageReferrer$",__escape(cgi.getParamValueByName("Referrer")));
		_Str = _Str.Replace("$REFID$",RefID);
		_Str = _Str.Replace("$LANG$",ToLowerCase(Lang));
		_Str = _Str.Replace("$LANGUAGE$",Language);
		if( !Link.isEmpty() )
			Link = "&helpDefaultLink="+Link+"&";
		_Str = _Str.Replace("$LINK$",Link);
		printf("%s",_Str.c_str());
	} catch( ... ) {
		printf("error");
	}

	return 0;
}
Пример #15
0
Cookie Cookies::get(const QString & name) const
{
    return has(name) ? m_cookies[name] : Cookie();
}
Пример #16
0
FILE *OpenMacro(const char *filename, int Language, int htmlmode)
{
    FILE	*pLang, *fi = NULL;
    char	*temp, *aka, linebuf[1024], outbuf[1024];
		            
    temp = calloc(PATH_MAX, sizeof(char));
    aka  = calloc(81, sizeof(char));
    temp[0] = '\0';

    if (Language != '\0') {
	/*
	 * Maybe a valid language character, try to load the language
	 */
	snprintf(temp, PATH_MAX -1, "%s/etc/language.data", getenv("MBSE_ROOT"));
	if ((pLang = fopen(temp, "rb")) == NULL) {
	    WriteError("mbdiesel: Can't open language file: %s", temp);
	} else {
	    fread(&langhdr, sizeof(langhdr), 1, pLang);
    
	    while (fread(&lang, langhdr.recsize, 1, pLang) == 1) {
		if ((lang.LangKey[0] == Language) && (lang.Available)) {
		    snprintf(temp, PATH_MAX -1, "%s/share/int/macro/%s/%s", getenv("MBSE_ROOT"), lang.lc, filename);
		    break;
		}
	    }
	    fclose(pLang);
	}
    }
    
    /*
     * Try to open the selected language
     */
    if (temp[0] != '\0')
	fi = fopen(temp, "r");

    /*
     * If no selected language is loaded, try default language
     */
    if (fi == NULL) {
	Syslog('-', "Macro file \"%s\" for language %c not found, trying default", filename, Language);
	snprintf(temp, PATH_MAX -1, "%s/share/int/macro/%s/%s", getenv("MBSE_ROOT"), CFG.deflang, filename);
	fi = fopen(temp,"r");
    }

    if (fi == NULL)
	WriteError("OpenMacro(%s, %c): not found", filename, Language);
    else {
	/*
	 * Check macro file for update correct charset.
	 */
	while (fgets(linebuf, sizeof(linebuf) -1, fi)) {
	    if (strcasestr(linebuf, (char *)"text/html")) {
		if (! strcasestr(linebuf, (char *)"UTF-8")) {
		    WriteError("Macro file %s doesn't define 'Content-Type' content='text/html; charset=UTF-8'", temp);
		}
	    }
	}
	rewind(fi);

	snprintf(temp, PATH_MAX -1, "%s-%s", OsName(), OsCPU());
	if (CFG.aka[0].point)
	    snprintf(aka, 80, "%d:%d/%d.%d@%s", CFG.aka[0].zone, CFG.aka[0].net, CFG.aka[0].node, CFG.aka[0].point, CFG.aka[0].domain);
	else
	    snprintf(aka, 80, "%d:%d/%d@%s", CFG.aka[0].zone, CFG.aka[0].net, CFG.aka[0].node, CFG.aka[0].domain);

	if (htmlmode) {
	    MacroVars("O", "s", temp);
	    snprintf(linebuf, 1024, "%s", CFG.sysop);
	    html_massage(linebuf, outbuf, 1024);
	    MacroVars("U", "s", outbuf);
	    snprintf(linebuf, 1024, "%s", CFG.location);
	    html_massage(linebuf, outbuf, 1024);
	    MacroVars("L", "s", outbuf);
	    snprintf(linebuf, 1024, "%s", CFG.bbs_name);
	    html_massage(linebuf, outbuf, 1024);
	    MacroVars("N", "s", outbuf);
	    snprintf(linebuf, 1024, "%s", CFG.sysop_name);
	    html_massage(linebuf, outbuf, 1024);
	    MacroVars("S", "s", outbuf);
	    snprintf(linebuf, 1024, "%s", CFG.comment);
	    html_massage(linebuf, outbuf, 1024);
	    MacroVars("T", "s", outbuf);
	} else {
	    MacroVars("L", "s", CFG.location);
	    MacroVars("N", "s", CFG.bbs_name);
	    MacroVars("O", "s", temp);
	    MacroVars("S", "s", CFG.sysop_name);
	    MacroVars("T", "s", CFG.comment);
	    MacroVars("U", "s", CFG.sysop);
	}
	MacroVars("H", "s", CFG.www_url);
	MacroVars("M", "s", CFG.sysdomain);
	MacroVars("V", "s", VERSION);
	MacroVars("Y", "s", aka);
	MacroVars("Z", "d", 0);
	Cookie(htmlmode);
    }

    free(aka);
    free(temp);
    return fi;
}
Пример #17
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      CIAO::Server_init (orb);

      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Panic: nil RootPOA\n"),
                          1);

      PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();

      if (parse_args (argc, argv) != 0)
        return 1;

      Cookie *cookie_impl = 0;
      ACE_NEW_RETURN (cookie_impl,
                      Cookie (orb.in ()),
                      1);
      PortableServer::ServantBase_var owner_transfer (cookie_impl);

      PortableServer::ObjectId_var id =
        root_poa->activate_object (cookie_impl);

      CORBA::Object_var object = root_poa->id_to_reference (id.in ());

      Test::Cook_var cook = Test::Cook::_narrow (object.in ());

      CORBA::String_var ior = orb->object_to_string (cook.in ());

      // Output the IOR to the <ior_output_file>
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s\n",
                           ior_output_file),
                           1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      poa_manager->activate ();

      orb->run ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));

      root_poa->destroy (1, 1);

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Server exception caught:");
      return 1;
    }

  return 0;
}