Example #1
0
int main(int argc, char **argv )
{
	int status;
	longword host;

	if (argc > 2)
	{
		puts("Quote of the Day (Cookie) - retrieves a witty message");
		puts("Usage: COOKIE [server]");
		exit( 3 );
	}

	sock_init();

	if ( argc == 1)
	{
		status = cookie ((longword) NULL);
	}
	else
	{
		if ( (host = resolve( argv[1])) != 0uL )
		{
			status = cookie( host );
		}
		else
		{
			printf("Could not resolve host '%s'\n", argv[1]);
			status = 3;
		}
	}

	exit( status );
        return (0);  /* not reached */
}
Example #2
0
void VcsCommand::run(QFutureInterface<void> &future)
{
    // Check that the binary path is not empty
    if (binaryPath().isEmpty()) {
        emit errorText(tr("Unable to start process, binary is empty"));
        return;
    }

    QString stdOut;
    QString stdErr;

    if (d->m_progressParser)
        d->m_progressParser->setFuture(&future);
    else
        future.setProgressRange(0, 1);
    const int count = d->m_jobs.size();
    d->m_lastExecExitCode = -1;
    d->m_lastExecSuccess = true;
    for (int j = 0; j < count; j++) {
        const Internal::VcsCommandPrivate::Job &job = d->m_jobs.at(j);
        const int timeOutSeconds = job.timeout;
        Utils::SynchronousProcessResponse resp = runVcs(
                    job.arguments,
                    timeOutSeconds >= 0 ? timeOutSeconds * 1000 : -1,
                    job.exitCodeInterpreter);
        stdOut += resp.stdOut;
        stdErr += resp.stdErr;
        d->m_lastExecExitCode = resp.exitCode;
        d->m_lastExecSuccess = resp.result == Utils::SynchronousProcessResponse::Finished;
        if (!d->m_lastExecSuccess)
            break;
    }

    if (!d->m_aborted) {
        if (!d->m_progressiveOutput) {
            emit output(stdOut);
            if (!stdErr.isEmpty())
                emit errorText(stdErr);
        }

        emit finished(d->m_lastExecSuccess, d->m_lastExecExitCode, cookie());
        if (d->m_lastExecSuccess)
            emit success(cookie());
        future.setProgressValue(future.progressMaximum());
    }

    if (d->m_progressParser)
        d->m_progressParser->setFuture(0);
    // As it is used asynchronously, we need to delete ourselves
    this->deleteLater();
}
Example #3
0
AbstractSession& BaseSessionStore::getSession(Poco::Net::HTTPServerRequest& request,
                                              Poco::Net::HTTPServerResponse& response)
{
    // Get the cookies from the client.
    Poco::Net::NameValueCollection cookies;

    // Get the cookies
    request.getCookies(cookies);

    // Try to find a cookie with our session key name.
    Poco::Net::NameValueCollection::ConstIterator cookieIter = cookies.begin();

    std::string sessionId;

    while (cookieIter != cookies.end())
    {
        if (0 == cookieIter->first.compare(_sessionKeyName))
        {
            if (sessionId.empty())
            {
                sessionId = cookieIter->second;
            }
            else
            {
                Poco::Net::HTTPCookie cookie(_sessionKeyName);
                cookie.setMaxAge(0); // Invalidate the cookie.
                response.addCookie(cookie);
            }
        }

        ++cookieIter;
    }

    if (hasSession(sessionId))
    {
        return getSession(sessionId);
    }
    else
    {
        // Create a new sesssion and return a reference.
        AbstractSession& session = createSession();

        // Create a cookie with the session id.
        Poco::Net::HTTPCookie cookie(_sessionKeyName, session.getId());

        // Send our cookie with the response.
        response.addCookie(cookie);

        return session;
    }
}
Example #4
0
    //_______________________________________________________
    bool ShadowHelper::checkSupported( void ) const
    {

        // create atom
        #if MENDA_HAVE_X11

        // make sure we are on X11
        if( !Helper::isX11() ) return false;

        // create atom
        xcb_atom_t netSupportedAtom( _helper.createAtom( "_NET_SUPPORTED" ) );
        if( !netSupportedAtom ) return false;

        // store connection locally
        xcb_connection_t* connection( Helper::connection() );

        // get property
        const quint32 maxLength = std::string().max_size();
        xcb_get_property_cookie_t cookie( xcb_get_property( connection, 0, QX11Info::appRootWindow(), netSupportedAtom, XCB_ATOM_ATOM, 0, (maxLength+3) / 4 ) );
        ScopedPointer<xcb_get_property_reply_t> reply( xcb_get_property_reply( connection, cookie, nullptr ) );
        if( !reply ) return false;

        // get reply length and data
        const int count( xcb_get_property_value_length( reply.data() )/sizeof( xcb_atom_t ) );
        xcb_atom_t *atoms = reinterpret_cast<xcb_atom_t*>( xcb_get_property_value( reply.data() ) );

        bool found( false );
        for( int i = 0; i < count && !found; ++i )
        {
            // get atom name and print
            xcb_atom_t atom( atoms[i] );

            xcb_get_atom_name_cookie_t cookie( xcb_get_atom_name( connection, atom ) );
            ScopedPointer<xcb_get_atom_name_reply_t> reply( xcb_get_atom_name_reply( connection, cookie, 0 ) );
            if( !reply ) continue;

            // get name and compare
            const QString name( QByteArray( xcb_get_atom_name_name( reply.data() ), xcb_get_atom_name_name_length( reply.data() ) ) );
            if( strcmp( netWMShadowAtomName, xcb_get_atom_name_name( reply.data() ) ) == 0 ) found = true;

        }

        return found;

        #else
        return false;
        #endif

    }
int move_g(GUSANO *g) {
	POINT *p, *q;
	int item;

	if(!g->growth)
	{
		p = extract_l(g->cuerpo);
		item = tablero[p->x/GORDO][p->y/GORDO];
		tablero[p->x/GORDO][p->y/GORDO] = 0;
	}
	else
		p = (POINT *)malloc(sizeof(POINT));
	
	q = tail_l(g->cuerpo);
	p->x = q->x; p->y = q->y;
	switch(g->dir)
	{
		case 0: /* N */
			p->y = q->y-GORDO;
			break;
		case 1: /* E */
	    p->x = q->x+GORDO;
			break;
		case 2: /* S */
	    p->y = q->y+GORDO;
			break;
		case 3: /* W */
			p->x = q->x-GORDO;
			break;
	}

	if(p->x >= MAXX || p->x < 0 || p->y >= MAXY || p->y < 0 ||
		(tablero[p->x/GORDO][p->y/GORDO] != 0 && (galleta.x != p->x || galleta.y != p->y)))
	{
		if(!g->growth) delete_w(item);
		free(p);
		return 0;
	}

	add_l(g->cuerpo, p);
	if(g->growth)
	{
		g->growth--;
		item = create_obj_w(p->x, p->y, GORDO, "oval", "red");
	}
	else
		coords_w(item, p->x, p->y, GORDO);
 
	/* A comerse la galleta */
	if(galleta.x == p->x && galleta.y == p->y)
	{
		g->growth += tablero[p->x/GORDO][p->y/GORDO];
		tablero[p->x/GORDO][p->y/GORDO] = 0;
		cookie(MAXX, MAXY);
	}

	tablero[p->x/GORDO][p->y/GORDO] = item;

	return 1;
}
Example #6
0
int main(int argc, char** argv)
{
	avhttp::cookies cookie;
	cookie("sf_mirror_attempt=avplayer:optimate|softlayer-ams:/avplayer/exe/release-2013-03-13.7z; expires=Tue, 3-Dec-2013 14:52:55 GMT; Path=/");
	BOOST_ASSERT(cookie["sf_mirror_attempt"] == std::string("avplayer:optimate|softlayer-ams:/avplayer/exe/release-2013-03-13.7z"));
	return 0;
}
Example #7
0
void BaseSessionStore::destroySession(Poco::Net::HTTPServerRequest& request,
                                      Poco::Net::HTTPServerResponse& response)
{
    // Get the cookies from the client.
    Poco::Net::NameValueCollection cookies;

    // Get the cookies
    request.getCookies(cookies);

    // Try to find a cookie with our session key name.
    Poco::Net::NameValueCollection::ConstIterator cookieIter = cookies.begin();

    while (cookieIter != cookies.end())
    {
        if (0 == cookieIter->first.compare(_sessionKeyName))
        {
            // Destroy the session data.
            destroySession(cookieIter->second);

            // Invalidate the cookies.
            Poco::Net::HTTPCookie cookie(_sessionKeyName, cookieIter->second);

            cookie.setMaxAge(0);
            response.addCookie(cookie);
        }

        ++cookieIter;
    }
}
    //_____________________________________________________________
    WindowManager::WindowManager( QObject* parent ):
        QObject( parent ),
        _enabled( true ),
        _useWMMoveResize( true ),
        _dragMode( StyleConfigData::WD_FULL ),
        _dragDistance( QApplication::startDragDistance() ),
        _dragDelay( QApplication::startDragTime() ),
        _dragAboutToStart( false ),
        _dragInProgress( false ),
        _locked( false ),
        _cursorOverride( false ),
        _isX11( false )
    {

        // install application wise event filter
        _appEventFilter = new AppEventFilter( this );
        qApp->installEventFilter( _appEventFilter );

        #if HAVE_X11
        _isX11 = QGuiApplication::platformName() == QStringLiteral("xcb");
        _moveResizeAtom = 0;
        if( _isX11 )
        {
            // create move-resize atom
            xcb_connection_t* connection( QX11Info::connection() );
            const QString atomName( QStringLiteral( "_NET_WM_MOVERESIZE" ) );
            xcb_intern_atom_cookie_t cookie( xcb_intern_atom( connection, false, atomName.size(), qPrintable( atomName ) ) );
            Helper::ScopedPointer<xcb_intern_atom_reply_t> reply( xcb_intern_atom_reply( connection, cookie, nullptr) );
            _moveResizeAtom = reply ? reply->atom:0;
        }
        #endif

    }
void LocalCookieStore::doGetCookies()
{
    Cookies cookies;
    m_db.setDatabaseName(m_dbPath);

    if (Q_UNLIKELY(!m_db.open())) {
        qCritical() << "Could not open cookie database:" << m_dbPath
            << m_db.lastError();
        return;
    }

    QSqlQuery q(m_db);
    q.exec("SELECT host_key, name, value, path, expires_utc, secure, httponly, has_expires FROM cookies;");

    while (q.next()) {
        /* Build the cookie string from its parts */
        QNetworkCookie cookie(q.value(1).toString().toUtf8(),
                              q.value(2).toString().toUtf8());
        cookie.setSecure(q.value(5).toBool());
        cookie.setHttpOnly(q.value(6).toBool());
        if (q.value(7).toBool()) {
            QDateTime expires = dateTimeFromChrome(q.value(4).toULongLong());
            cookie.setExpirationDate(expires);
        }
        cookie.setDomain(q.value(0).toString());
        cookie.setPath(q.value(3).toString());
        cookies.append(cookie);
    }

    m_db.close();

    emit gotCookies(cookies);
}
Example #10
0
void setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url, const String& value)
{
    SoupCookieJar* jar = cookieJarForSession(session);
    if (!jar)
        return;

    GUniquePtr<SoupURI> origin = url.createSoupURI();
    GUniquePtr<SoupURI> firstPartyURI = firstParty.createSoupURI();

    // Get existing cookies for this origin.
    GSList* existingCookies = soup_cookie_jar_get_cookie_list(jar, origin.get(), TRUE);

    Vector<String> cookies;
    value.split('\n', cookies);
    const size_t cookiesCount = cookies.size();
    for (size_t i = 0; i < cookiesCount; ++i) {
        GUniquePtr<SoupCookie> cookie(soup_cookie_parse(cookies[i].utf8().data(), origin.get()));
        if (!cookie)
            continue;

        // Make sure the cookie is not httpOnly since such cookies should not be set from JavaScript.
        if (soup_cookie_get_http_only(cookie.get()))
            continue;

        // Make sure we do not overwrite httpOnly cookies from JavaScript.
        if (httpOnlyCookieExists(existingCookies, soup_cookie_get_name(cookie.get()), soup_cookie_get_path(cookie.get())))
            continue;

        soup_cookie_jar_add_cookie_with_first_party(jar, firstPartyURI.get(), cookie.release());
    }

    soup_cookies_free(existingCookies);
}
Example #11
0
    //_________________________________________________________
    WId DetectDialog::findWindow()
    {

        #if BREEZE_HAVE_X11
        if (!QX11Info::isPlatformX11()) {
            return 0;
        }
        // check atom
        if( !m_wmStateAtom ) return 0;

        xcb_connection_t* connection( QX11Info::connection() );
        xcb_window_t parent( QX11Info::appRootWindow() );

        // why is there a loop of only 10 here
        for( int i = 0; i < 10; ++i )
        {

            // query pointer
            xcb_query_pointer_cookie_t pointerCookie( xcb_query_pointer( connection, parent ) );
            QScopedPointer<xcb_query_pointer_reply_t, QScopedPointerPodDeleter> pointerReply( xcb_query_pointer_reply( connection, pointerCookie, nullptr ) );
            if( !( pointerReply && pointerReply->child ) ) return 0;

            const xcb_window_t child( pointerReply->child );
            xcb_get_property_cookie_t cookie( xcb_get_property( connection, 0, child, m_wmStateAtom, XCB_GET_PROPERTY_TYPE_ANY, 0, 0 ) );
            QScopedPointer<xcb_get_property_reply_t, QScopedPointerPodDeleter> reply( xcb_get_property_reply( connection, cookie, nullptr ) );
            if( reply  && reply->type ) return child;
            else parent = child;

        }
        #endif

        return 0;

    }
void AbstractRequestHandler::sessionStart()
{
  if (app_->sessionStart(this))
  {
    QNetworkCookie cookie(C_SID.toUtf8(), session_->id.toUtf8());
    cookie.setPath("/");
    header(HEADER_SET_COOKIE, cookie.toRawForm());
  }
}
Example #13
0
void add_cookie(struct pt_regs *regs, int cpu)
{
	unsigned long pc;
	off_t off;

	if (regs == 0)
		return;

	pc = profile_pc(regs);

	if (user_mode(regs)) {
		struct mm_struct *mm;
		struct vm_area_struct *vma;
		struct path *ppath;

		mm = current->mm;
		for (vma = find_vma(mm, s.pc); vma; vma = vma->vm_next) {

			if (s.pc < vma->vm_start || s.pc >= vma->vm_end)
				continue;

			if (vma->vm_file) {
				ppath = &(vma->vm_file->f_path);
				off = (vma->vm_pgoff << PAGE_SHIFT) + s.pc - vma->vm_start;
				cookie(current->comm, pc, (char *)(ppath->dentry->d_name.name), off, 0);
			} else {
				/* must be an anonymous map */
				cookie(current->comm, pc, "nofile", pc, 0);
			}
			break;
		}
	} else {
		struct module *mod = __module_address(s.pc);
		if (mod) {
			s.off = s.pc - (unsigned long)mod->module_core;
			cookie(current->comm, pc, mod->name, off, 1);
		} else {
			s.off = 0;
			cookie(current->comm, pc, "vmlinux", off, 0);
		}
	}
}
 void open(const GUID &p_owner, bool p_decode, t_size p_param1,
           const void *p_param2, t_size p_param2size,
           abort_callback &p_abort)
 {
     auto setup = static_cast<const matroska_setup *>(p_param2);
     std::vector<char> cookie(4); /* 4 bytes room for version and flags */
     auto p = static_cast<const char*>(setup->codec_private);
     std::copy(p, p + 24, std::back_inserter(cookie));
     packet_decoder::g_open(m_decoder, p_decode, owner_MP4_ALAC, 0,
                            cookie.data(), cookie.size(), p_abort);
 }
Example #15
0
void AccessManager::setRawCookie(const QByteArray &rawCookie, const  QUrl &url)
{
    QNetworkCookie cookie(rawCookie.left(rawCookie.indexOf('=')),
                          rawCookie.mid(rawCookie.indexOf('=')+1));
    qDebug() << Q_FUNC_INFO << cookie.name() << cookie.value();
    QList<QNetworkCookie> cookieList;
    cookieList.append(cookie);

    QNetworkCookieJar *jar = cookieJar();
    jar->setCookiesFromUrl(cookieList, url);
}
/*!
  \~english
  Adds the cookie to the internal list of cookies.

  \~japanese
  クッキーをHTTPレスポンスに追加する
 */
bool TActionController::addCookie(const QByteArray &name, const QByteArray &value, const QDateTime &expire,
                                  const QString &path, const QString &domain, bool secure, bool httpOnly)
{
    TCookie cookie(name, value);
    cookie.setExpirationDate(expire);
    cookie.setPath(path);
    cookie.setDomain(domain);
    cookie.setSecure(secure);
    cookie.setHttpOnly(httpOnly);
    return addCookie(cookie);
}
const prop_info *__system_property_find_nth(unsigned n)
{
    find_nth_cookie cookie(n);

    const int err = __system_property_foreach(find_nth_fn, &cookie);
    if (err < 0) {
        return NULL;
    }

    return cookie.pi;
}
Example #18
0
void getHostnamesWithCookies(NetworkingContext* context, HashSet<String>& hostnames)
{
    SoupCookieJar* cookieJar = context ? cookieJarForContext(context) : soupCookieJar();
    GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar));
    for (GSList* item = cookies.get(); item; item = g_slist_next(item)) {
        GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(item->data));
        if (!cookie->domain)
            continue;
        hostnames.add(String::fromUTF8(cookie->domain));
    }
}
Example #19
0
    int commit(Request& req, Response& resp, int program_status
              , boost::system::error_code& ec)
    {
      typedef typename Request::string_type string_type;
#ifdef BOOST_CGI_ENABLE_SESSIONS
      if (!program_status)
      {
        string_type path(
            Request::traits::session_options == path_session
              ? req.script_name()
              : "/"
          );
        if (req.session.id().empty())
          resp<< cookie(BOOST_CGI_SESSION_COOKIE_NAME, "", path, BOOST_CGI_DATE_IN_THE_PAST);
        else
          resp<< cookie(BOOST_CGI_SESSION_COOKIE_NAME, req.session.id(), path);
      }
#endif // BOOST_CGI_ENABLE_SESSIONS
      resp.send(req.client(), ec);
      return ec ? -1 : req.close(resp.status(), program_status, ec);
    }
Example #20
0
void WebSessionManager::addCookie(const std::string& appName, const Poco::Net::HTTPServerRequest& request, WebSession::Ptr pSession)
{
	Poco::Net::HTTPCookie cookie(cookieName(appName), pSession->id());
	if (_cookiePersistence == COOKIE_PERSISTENT)
	{
		cookie.setMaxAge(pSession->timeout());
	}
	cookie.setPath(cookiePath(appName));
	cookie.setDomain(cookieDomain(appName));
	cookie.setHttpOnly();
	request.response().addCookie(cookie);
}
Example #21
0
void StaticObject::setTree(int i){
	m_type = ObjectType::TREE;
	m_name = "CookieTree";

	Item cookie(1);
	cookie.setName("Cookie");
	cookie.setTypeId(ItemType::COOKIE);
	Item branch(2);
	branch.setName("Branch");
	branch.setTypeId(ItemType::BRANCH);
	m_inventory->addItem(&cookie, 25);
	m_inventory->addItem(&branch, i);
}
XnStatus XnSensorStreamHelper::MapFirmwareProperty(XnActualIntProperty& Property, XnActualIntProperty& FirmwareProperty, XnBool bAllowChangeWhileOpen, XnSensorStreamHelper::ConvertCallback pStreamToFirmwareFunc /* = 0 */)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	// init data
	XnSensorStreamHelperCookie cookie(&Property, &FirmwareProperty, bAllowChangeWhileOpen, pStreamToFirmwareFunc);

	// add it to the list
	nRetVal = m_FirmwareProperties.Set(&Property, cookie);
	XN_IS_STATUS_OK(nRetVal);

	return (XN_STATUS_OK);
}
Example #23
0
void
CookieTest::DomainMatchingTest()
{
	const BUrl setter("http://testsuites.opera.com/cookies/304.php");
	const BUrl getter("http://testsuites.opera.com/cookies/304-1.php");

	BString bigData("304-12=1; Domain=\"");
	for (int i = 0; i < 1500; i++)
		bigData << "abcdefghijklmnopqrstuvwxyz";
	bigData << "\";";

	struct Test {
		const char* cookieString;
		bool shouldMatch;
	};

	const Test tests[] = {
		{ "304-01=1; Domain=\"opera.com\"", true },
		{ "304-02=1; Domain=\".opera.com\"", true },
		{ "304-03=1; Domain=\".com\"", false },
		{ "304-04=1; Domain=\"pera.com\"", false },
		{ "304-05=1; Domain=\"?pera.com\"", false },
		{ "304-06=1; Domain=\"*.opera.com\"", false },
		{ "304-07=1; Domain=\"300.300.300.300\"", false },
		{ "304-08=1; Domain=\"123456123456123456\"", false },
		{ "304-09=1; Domain=\"/opera.com\"", false },
		{ "304-10=1; Domain=\"opera.com/\"", false },
		{ "304-11=1; Domain=\"example.com\"", false },
		{ bigData, false },
		{ "304-13=1; Domain=\"opera com\"", false },
		{ "304-14=1; Domain=opera.com\"", false },
		{ "304-15=1; Domain=\"opera.com", false },
		{ "304-16=1; Domain=opera.com", true },
		{ "304-17=1; Domain=\"*.com\"", false },
		{ "304-18=1; Domain=\"*opera.com\"", false },
		{ "304-19=1; Domain=\"*pera.com\"", false },
		{ "304-20=1; Domain=\"\"", false },
		{ "304-21=1; Domain=\"\346\227\245\346\234\254\"", false },
		{ "304-22=1; Domain=\"OPERA.COM\"", true },
		{ "304-23=1; Domain=\"195.189.143.182\"", false },
	};

	for (unsigned int i = 0; i < sizeof(tests) / sizeof(Test); i++)
	{
		NextSubTest();

		BNetworkCookie cookie(tests[i].cookieString, setter);
		CPPUNIT_ASSERT_EQUAL(tests[i].shouldMatch,
			cookie.IsValidForUrl(getter));
	}
}
//------------------------------------------------------------------------------
bool ofxWebServerBaseRouteHandler::isValidRequest(const Settings& settings,
                                                  HTTPServerRequest& request,
                                                  HTTPServerResponse& response) {
    
    string sessionId = "";
    
    // extract cookie from request
    NameValueCollection cookies;
    request.getCookies(cookies);
    NameValueCollection::ConstIterator it = cookies.find(settings.sessionCookieName);
    if (it != cookies.end()) {
        sessionId = it->second;
    } else {
        sessionId = ofxWebServerSessionManager::generateSessionKey(request);
        HTTPCookie cookie(settings.sessionCookieName,sessionId);
        cookie.setPath("/");
        // set no age, so it expires @ end of session
        response.addCookie(cookie);
    }
    
    // TODO: update session manager
    
    URI uri(request.getURI());
    
    const string path = uri.getPath(); // just get the path

    if(settings.requireAuthentication) {
        if(request.hasCredentials()) {
            HTTPBasicCredentials credentials(request);
            const string& user = credentials.getUsername();
            const string& pwd = credentials.getPassword();
            
            if(settings.username == credentials.getUsername() &&
               settings.password == credentials.getPassword()) {
                // add an authentication cookie?
                return true;
            } else {
                response.setStatusAndReason(HTTPResponse::HTTP_UNAUTHORIZED);
                sendErrorResponse(response);
                return false;
            }
        } else {
            response.requireAuthentication(settings.realm);
            response.setContentLength(0);
            response.send();
            return false;
        }
    } else {
        return true;
    }
}
Example #25
0
void makeacthash(stralloc *act)
/* act is expected to be -reject-ddddd.ttttt or -accept-ddddd.ttttt and
 * has to be 0-terminated. */
/* The routine will add .hash@outhost to act. act will NOT be 0-terminated */
{
  int d;

  d = 2 + str_chr(act->s + 1,'-');
  cookie(hash,key.s,key.len,act->s + d,"","a");
  *(act->s + act->len - 1) = '.';	/* we put a '.' Bad, but works */
  if (!stralloc_catb(act,hash,COOKIE)) die_nomem();
  if (!stralloc_cats(act,"@")) die_nomem();
  if (!stralloc_cat(act,&outhost)) die_nomem();
}
main()
{
    GUSANO *g;
    int i,j;
    int dir = 1; /* 0: N, 1: E, 2: S, 3: W */
    char s[200];

    srandom(time(NULL));

    for(i=0; i<MAXX/GORDO; i++)
        for(j=0; j<MAXY/GORDO; j++)
            tablero[i][j] = 0;

    init_w(MAXX, MAXY);

    g = init_g(MAXX/2, MAXY/2, dir, 4); /* x,y,dir,largo */
    if(!galleta_id) cookie(MAXX, MAXY);

    for(;;) {
        usleep(100000);
        switch(getchar()) {
        case 'h': /* back */
            dir = 3;
            break;
        case 'j': /* down */
            dir = 2;
            break;
        case 'k': /* up */
            dir = 0;
            break;
        case 'l': /* forward */
            dir = 1;
            break;
        case EOF:
            goto fin;
            break;
        default:
            continue;
            break;
        }
        g->dir = dir;
        if( !move_g(g) ) {
fin:
            sprintf(s, "Boing!!, score = %d", size_l(g->cuerpo));
            free_g(g);
            close_w(s, 100, 100);
            exit(0);
        }
    }
}
void AbstractRequestHandler::sessionEnd()
{
  if (sessionActive())
  {
    QNetworkCookie cookie(C_SID.toUtf8(), session_->id.toUtf8());
    cookie.setPath("/");
    cookie.setExpirationDate(QDateTime::currentDateTime());

    if (app_->sessionEnd(this))
    {
      header(HEADER_SET_COOKIE, cookie.toRawForm());
    }
  }
}
bool AbstractWebApplication::sessionStart()
{
    if (session_ == 0) {
        session_ = new WebSession(generateSid());
        session_->updateTimestamp();
        sessions_[session_->id] = session_;

        QNetworkCookie cookie(C_SID, session_->id.toUtf8());
        cookie.setPath(QLatin1String("/"));
        header(Http::HEADER_SET_COOKIE, cookie.toRawForm());

        return true;
    }

    return false;
}
Example #29
0
InfoExtractor::InfoExtractor(QObject *parent) :
    QObject(parent), m_queue(), m_url(), m_replyTimer(new QTimer(this)),
    m_accessManager(new QNetworkAccessManager(this)), m_reply(NULL)
{
    //Définition du cookie pour avoir la page en anglais
    QNetworkCookieJar *jar = new QNetworkCookieJar(this);
    QNetworkCookie cookie("l", "en");
    QList<QNetworkCookie> liste;
    liste << cookie;
    jar->setCookiesFromUrl(liste, MEGAUPLOAD);
    m_accessManager->setCookieJar(jar);

    m_replyTimer->setSingleShot(true);
    m_replyTimer->setInterval(INFO_EXTRACTION_TIMEOUT);
    connect(m_replyTimer, SIGNAL(timeout()), this, SLOT(replyTimeout()));
}
Example #30
0
void Site::initManager()
{
	if (m_manager == NULL)
	{
        m_cookieJar = new QNetworkCookieJar(this);

		// Hotfix "giantessbooru.com"
		QNetworkCookie cookie("agreed", "true");
		cookie.setPath("/");
		cookie.setDomain("giantessbooru.com");
		m_cookieJar->insertCookie(cookie);

		m_manager = new QNetworkAccessManager(this);
		m_manager->setCookieJar(m_cookieJar);
		connect(m_manager, SIGNAL(finished(QNetworkReply*)), this, SIGNAL(finished(QNetworkReply*)));
		connect(m_manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), this, SLOT(sslErrorHandler(QNetworkReply*,QList<QSslError>)));
	}