Esempio n. 1
0
bool ProxyHost(EDF *pEDF)
{
   STACKTRACE
   int iHostname = 0, iAddress = 0;
   socklen_t iSockLen = 0;
   char szHostname[NI_MAXHOST], szAddress[NI_MAXSERV], pBuffer[BUFSIZ]; //, *szReturn = NULL;
   struct sockaddr pSockAddr;

   debug(DEBUGLEVEL_INFO, "ProxyHost entry %p\n", pEDF);

   iSockLen = sizeof(pSockAddr);
   if(getpeername(fileno(stdin), (struct sockaddr *)&pSockAddr, &iSockLen) < 0)
   {
      debug(DEBUGLEVEL_ERR, "ProxyHost getpeername failed, %s\n", strerror(errno));

      iSockLen = sizeof(pSockAddr);
      if(recvfrom(fileno(stdin), pBuffer, sizeof(pBuffer), MSG_PEEK, (struct sockaddr *)&pSockAddr, &iSockLen) < 0)
      {
         debug(DEBUGLEVEL_INFO, "ProxyHost exit false, recvfrom failed\n");
         return false;
      }
   }

   mappedtov4(&pSockAddr);

   szHostname[0] = '\0';
   szAddress[0] = '\0';

   iHostname = getnameinfo(&pSockAddr, sizeof(struct sockaddr), szHostname, sizeof(szHostname), NULL, 0, NI_NAMEREQD);
   iAddress = getnameinfo(&pSockAddr, sizeof(struct sockaddr), szAddress, sizeof(szAddress), NULL, 0, NI_NUMERICHOST);

   debug(DEBUGLEVEL_INFO, "ProxyHost '%s'(%d) / '%s'(%d)\n", szHostname, iHostname, szAddress, iAddress);

   if(strlen(szHostname) > 0)
   {
      pEDF->AddChild("hostname", szHostname);
      if(strlen(szAddress) > 0 && ProtocolVersion("2.5") >= 0)
      {
         pEDF->AddChild("address", szAddress);
      }
   }
   else if(strlen(szAddress) > 0)
   {
      pEDF->AddChild(ProtocolVersion("2.5") >= 0 ? "address" : "hostname", szAddress);
   }

   // debugEDFPrint("ProxyHost fields", pEDF);

   debug(DEBUGLEVEL_INFO, "ProxyHost exit true\n");
   return true;
}
Esempio n. 2
0
// Called in update thread or deliver thread.
void Cluster::checkUpdateIn(Lock& l) {
    if (state != UPDATEE) return; // Wait till we reach the stall point.
    if (!updateClosed) return;  // Wait till update connection closes.
    if (updatedMap) { // We're up to date
        map = *updatedMap;
        mcast.mcastControl(ClusterReadyBody(ProtocolVersion(), myUrl.str()), self);
        state = CATCHUP;
        /* In CATCHUP mode the update has finished, and we are consuming
        ** whatever backlog of messages has built up during the update.
        ** We should enable queue events here, or messages that are received
        ** during this phase will not be replicated properly. ( If there are
        ** relevant replication queues. ) */
        broker.getQueueEvents().enable();
        memberUpdate(l);
        // Must be called *after* memberUpdate() to avoid sending an extra update.
        failoverExchange->setReady();
        // NB: don't updateMgmtMembership() here as we are not in the deliver
        // thread. It will be updated on delivery of the "ready" we just mcast.
        broker.setClusterUpdatee(false);
        broker.setAcl(acl);     // Restore ACL
        discarding = false;     // OK to set, we're stalled for update.
        QPID_LOG(notice, *this << " update complete, starting catch-up.");
        QPID_LOG(debug, debugSnapshot()); // OK to call because we're stalled.
        if (mAgent) {
            // Update management agent now, after all update activity is complete.
            updateDataExchange->updateManagementAgent(mAgent);
            mAgent->suppress(false); // Enable management output.
            mAgent->clusterUpdate();
        }
        // Restore alternate exchange settings on exchanges.
        broker.getExchanges().eachExchange(
            boost::bind(&broker::Exchange::recoveryComplete, _1,
                        boost::ref(broker.getExchanges())));
        enableClusterSafe();    // Enable cluster-safe assertions
        deliverEventQueue.start();
        // FIXME aconway 2012-04-04: unregister/delete Update[Data]Exchange
        updateDataExchange.reset();
        broker.getExchanges().destroy(UpdateDataExchange::EXCHANGE_NAME);
        broker.getExchanges().destroy(UpdateClient::UPDATE);
    }
    else if (updateRetracted) { // Update was retracted, request another update
        updateRetracted = false;
        updateClosed = false;
        state = JOINER;
        QPID_LOG(notice, *this << " update retracted, sending new update request.");
        mcast.mcastControl(ClusterUpdateRequestBody(ProtocolVersion(), myUrl.str()), self);
        deliverEventQueue.start();
    }
}
Esempio n. 3
0
void Cluster::makeOffer(const MemberId& id, Lock& ) {
    if (state == READY && map.isJoiner(id)) {
        state = OFFER;
        QPID_LOG(info, *this << " send update-offer to " << id);
        mcast.mcastControl(ClusterUpdateOfferBody(ProtocolVersion(), id), self);
    }
}
Esempio n. 4
0
SSL_METHOD* SSLv23_client_method()
{
    // compatibility only, no version 2 support, but does SSL 3 and TLS 1
    // though it sends TLS1 hello not SSLv2 so SSLv3 only servers will decline
    // TODO: maybe add support to send SSLv2 hello ???
    return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,2), true);
}
Esempio n. 5
0
/**
 * Do deferred logging after initialisation
 */
void doXKeyboardLogging(Display *dpy)
{
    if (((1 == gfByTypeOK) || (1 == gfByXkbOK)) && (gfByLayoutOK != 1))
        dumpLayout(dpy);
    if (((1 == gfByLayoutOK) || (1 == gfByXkbOK)) && (gfByTypeOK != 1))
        dumpType(dpy);
    if ((gfByLayoutOK != 1) && (gfByTypeOK != 1) && (gfByXkbOK != 1))
    {
        LogRel(("Failed to recognize the keyboard mapping or to guess it based on\n"
                "the keyboard layout.  It is very likely that some keys will not\n"
                "work correctly in the guest.  If this is the case, please submit\n"
                "a bug report, giving us information about your keyboard type,\n"
                "its layout and other relevant information such as whether you\n"
                "are using a remote X server or something similar. \n"));
        unsigned *keyc2scan = X11DRV_getKeyc2scan();

        LogRel(("The keycode-to-scancode table is: %d=%d",0,keyc2scan[0]));
        for (int i = 1; i < 256; i++)
            LogRel((",%d=%d",i,keyc2scan[i]));
        LogRel(("\n"));
    }
    LogRel(("X Server details: vendor: %s, release: %d, protocol version: %d.%d, display string: %s\n",
            ServerVendor(dpy), VendorRelease(dpy), ProtocolVersion(dpy),
            ProtocolRevision(dpy), DisplayString(dpy)));
    LogRel(("Using %s for keycode to scan code conversion\n",
              gfByXkbOK ? "XKB"
            : gfByTypeOK ? "known keycode mapping"
            : "host keyboard layout detection"));
}
Esempio n. 6
0
void TestReconnect::onPlayerConnected()
{
    setTimeout(20);

    if (++count <= 1) {
        sender()->ownVersion = ProtocolVersion(1337, 508);
        sender()->login(TeamHolder("ultimate version"), false);
    } else {
        sender()->reconnect(id, oldSender->reconnectPass, oldSender->commandCount);
    }
}
Esempio n. 7
0
int NvCtrlGetProtocolVersion(NvCtrlAttributeHandle *handle)
{
    NvCtrlAttributePrivateHandle *h;

    if (!handle) return -1;

    h = (NvCtrlAttributePrivateHandle *) handle;

    if (!h->dpy) return -1;
    return ProtocolVersion(h->dpy);

} /* NvCtrlGetProtocolVersion() */
Esempio n. 8
0
bool ProxyHostEntry(EDF *pEDF, struct utmp *pEntry)
{
   char *szAddress = NULL;

   if(pEntry != NULL)
   {
      if(strlen(pEntry->ut_host) > 0)
      {
#ifndef CYGWIN
         szAddress = Conn::AddressToString(ntohl(pEntry->ut_addr_v6[0]));
#else
         szAddress = Conn::AddressToString(ntohl(pEntry->ut_addr));
#endif
         debug(DEBUGLEVEL_DEBUG, "ProxyHostEntry parent connected from '%s' / '%s'\n", pEntry->ut_host, szAddress);

         if(strcmp(pEntry->ut_host, szAddress) != 0)
         {
            pEDF->AddChild("hostname", pEntry->ut_host);
            if(ProtocolVersion("2.5") >= 0)
            {
               pEDF->AddChild("address", szAddress);
            }
         }
         else if(ProtocolVersion("2.5") < 0)
         {
            pEDF->AddChild("hostname", szAddress);
         }

         delete[] szAddress;
      }
      else
      {
         debug(DEBUGLEVEL_DEBUG, "ProxyHostEntry parent connected locally\n");

         return false;
      }
   }

   return true;
}
Esempio n. 9
0
void
TkGetServerInfo(
    Tcl_Interp *interp,		/* The server information is returned in this
				 * interpreter's result. */
    Tk_Window tkwin)		/* Token for window; this selects a particular
				 * display and server. */
{
    Tcl_SetObjResult(interp, Tcl_ObjPrintf("X%dR%d %s %d",
	    ProtocolVersion(Tk_Display(tkwin)),
	    ProtocolRevision(Tk_Display(tkwin)),
	    ServerVendor(Tk_Display(tkwin)),
	    VendorRelease(Tk_Display(tkwin))));
}
Esempio n. 10
0
Player::Player(const GenericSocket &sock, int id)
{
    loginInfo() = NULL;
    m_bundle.id = id;

    myrelay = new Analyzer(sock, id);
    lockCount = 0;
    battleSearch() = false;
    myip = relay().ip();
    server_pass_sent = false;
    needToUpdate = false;


    m_bundle.auth = 0;

    doConnections();

    /* Version control, whatever happens, because the problem could be because of an old version */
    relay().notify(NetworkServ::VersionControl_, ProtocolVersion(), Flags(), ProtocolVersion(1,1), ProtocolVersion(0,0), ProtocolVersion(0,0), Server::serverIns->servName());

    /* Autokick after 3 minutes if still not logged in */
    QTimer::singleShot(1000*180, this, SLOT(firstAutoKick()));
}
Esempio n. 11
0
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
{
    // get X protocol version
    Display *display = wxGlobalDisplay();
    if (display)
    {
        if ( verMaj )
            *verMaj = ProtocolVersion (display);
        if ( verMin )
            *verMin = ProtocolRevision (display);
    }

    return wxPORT_X11;
}
void
TkGetServerInfo(
    Tcl_Interp *interp,		/* The server information is returned in this
				 * interpreter's result. */
    Tk_Window tkwin)		/* Token for window; this selects a particular
				 * display and server. */
{
    char buffer[8 + TCL_INTEGER_SPACE * 2];
    char buffer2[TCL_INTEGER_SPACE];

    sprintf(buffer, "X%dR%d ", ProtocolVersion(Tk_Display(tkwin)),
	    ProtocolRevision(Tk_Display(tkwin)));
    sprintf(buffer2, " %d", VendorRelease(Tk_Display(tkwin)));
    Tcl_AppendResult(interp, buffer, ServerVendor(Tk_Display(tkwin)),
	    buffer2, (char *) NULL);
}
Esempio n. 13
0
void Cluster::configChange(const MemberId&,
                           const std::string& membersStr,
                           const std::string& leftStr,
                           const std::string& joinedStr,
                           Lock& l)
{
    if (state == LEFT) return;
    MemberSet members = decodeMemberSet(membersStr);
    MemberSet left = decodeMemberSet(leftStr);
    MemberSet joined = decodeMemberSet(joinedStr);
    QPID_LOG(notice, *this << " configuration change: " << members);
    QPID_LOG_IF(notice, !left.empty(), *this << " Members left: " << left);
    QPID_LOG_IF(notice, !joined.empty(), *this << " Members joined: " << joined);

    // If we are still joining, make sure there is someone to give us an update.
    elders = intersection(elders, members);
    if (elders.empty() && INIT < state && state < CATCHUP) {
        QPID_LOG(critical, "Cannot update, all potential updaters left the cluster.");
        leave(l);
        return;
    }
    bool memberChange = map.configChange(members);

    // Update initital status for members joining or leaving.
    initMap.configChange(members);
    if (initMap.isResendNeeded()) {
        mcast.mcastControl(
            ClusterInitialStatusBody(
                ProtocolVersion(), CLUSTER_VERSION, state > INIT, clusterId,
                store.getState(), store.getShutdownId(),
                initMap.getFirstConfigStr(),
                vectorToUrlArray(getUrls(l))
            ),
            self);
    }
    if (initMap.transitionToComplete()) initMapCompleted(l);

    if (state >= CATCHUP && memberChange) {
        memberUpdate(l);
        if (elders.empty()) becomeElder(l);
    }

    updateMgmtMembership(l);     // Update on every config change for consistency
}
Esempio n. 14
0
wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
{
    static wxToolkitInfo info;

    info.shortName = _T("motif");
    info.name = _T("wxMotif");
#ifdef __WXUNIVERSAL__
    info.shortName << _T("univ");
    info.name << _T("/wxUniversal");
#endif
    // FIXME TODO
    // This code is WRONG!! Does NOT return the
    // Motif version of the libs but the X protocol
    // version!
    Display *display = wxGlobalDisplay();
    info.versionMajor = ProtocolVersion (display);
    info.versionMinor = ProtocolRevision (display);
    info.os = wxMOTIF_X;
    return info;
}
Esempio n. 15
0
// CPG config-change callback.
void Cluster::configChange (
    cpg_handle_t /*handle*/,
    const cpg_name */*group*/,
    const cpg_address *members, int nMembers,
    const cpg_address *left, int nLeft,
    const cpg_address *joined, int nJoined)
{
    Mutex::ScopedLock l(lock);
    string membersStr, leftStr, joinedStr;
    // Encode members and enqueue as an event so the config change can
    // be executed in the correct thread.
    for (const cpg_address* p = members; p < members+nMembers; ++p)
        membersStr.append(MemberId(*p).str());
    for (const cpg_address* p = left; p < left+nLeft; ++p)
        leftStr.append(MemberId(*p).str());
    for (const cpg_address* p = joined; p < joined+nJoined; ++p)
        joinedStr.append(MemberId(*p).str());
    deliverEvent(Event::control(ClusterConfigChangeBody(
                                    ProtocolVersion(), membersStr, leftStr, joinedStr),
                                self));
}
main()
{
	Display * display;
	int       screen;
	char *    display_name=NULL;
	Window    root;
	Visual*   visual;

	/* Connect to X display server.		*/
	display=XOpenDisplay(display_name);

	/* Get screen ID			*/
	screen=DefaultScreen(display);


	printf("\n\tInformation extracted from the X server\n");
	printf("\t---------------------------------------\n\n");

	printf(" X server by \'%s\'\n",        ServerVendor(display));

	printf(" X Server protocol %d\n",      ProtocolVersion(display));

	printf(" X server Release %d\n",       VendorRelease(display));

	printf(" Screen is %dmm high.\n",      DisplayHeightMM(display, screen));

	printf(" Screen is %dmm wide.\n",      DisplayWidthMM(display, screen));

	printf(" Screen is %d pixels high.\n", DisplayHeight(display, screen));

	printf(" Screen is %d pixels wide.\n", DisplayWidth(display, screen));

	visual = DefaultVisual(display,screen);
	printf(" %3d Colour map entries", visual->map_entries);
	printf(" (Number of colours on the screen at one time).\n");

	printf(" %3d Display planes (bits per screen pixel).\n", DisplayPlanes(display, screen));

	printf(" There is %d screen(s).\n", ScreenCount (display));
}
Esempio n. 17
0
long SSL_CTX_set_options(SSL_CTX* ctx, long options)
{
    ProtocolVersion pv= ctx->getMethod()->getVersion();
    bool multi_proto= ctx->getMethod()->multipleProtocol();
    unsigned long ssl_ctx_mask= SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1;

    do
    {
      if (options == 0)
       break;
      // only TLSv1.1
      if ((options & ssl_ctx_mask) == ssl_ctx_mask)
      {
        pv.minor_= 2;
        multi_proto= false;
        break;
      }
      // only TLSv1
      ssl_ctx_mask= SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1_1;
      if((options & ssl_ctx_mask) == ssl_ctx_mask)
      {
        pv.minor_= 1;
        multi_proto= false;
        break;
      }
      // TLSv1.1 and TLSv1
      ssl_ctx_mask= SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3;
      if((options & ssl_ctx_mask) == ssl_ctx_mask)
      {
        pv.minor_= 2;
        multi_proto= true;
        break;
      }
    }while(0);

    SSL_METHOD *meth= NEW_YS SSL_METHOD(ctx->getMethod()->getSide(), ProtocolVersion(3,pv.minor_), multi_proto);
    ctx->SetMethod(meth);
    return SSL_SUCCESS;
}
Esempio n. 18
0
void Cluster::initialStatus(const MemberId& member, uint32_t version, bool active,
                            const framing::Uuid& id,
                            framing::cluster::StoreState store,
                            const framing::Uuid& shutdownId,
                            const std::string& firstConfig,
                            const framing::Array& urls,
                            Lock& l)
{
    if (version != CLUSTER_VERSION) {
        QPID_LOG(critical, *this << " incompatible cluster versions " <<
                 version << " != " << CLUSTER_VERSION);
        leave(l);
        return;
    }
    QPID_LOG_IF(debug, state == PRE_INIT, *this
                << " received initial status from " << member);
    initMap.received(
        member,
        ClusterInitialStatusBody(ProtocolVersion(), version, active, id,
                                 store, shutdownId, firstConfig, urls)
    );
    if (initMap.transitionToComplete()) initMapCompleted(l);
}
Esempio n. 19
0
// Handler for deliverFrameQueue.
// This thread executes the main logic.
void Cluster::deliveredFrame(const EventFrame& efConst) {
    Mutex::ScopedLock l(lock);
    sys::ClusterSafeScope css; // Don't trigger cluster-safe asserts.
    if (state == LEFT) return;
    EventFrame e(efConst);
    const ClusterUpdateOfferBody* offer = castUpdateOffer(e.frame.getBody());
    if (offer && error.isUnresolved()) {
        // We can't honour an update offer that is delivered while an
        // error is in progress so replace it with a retractOffer and re-start
        // the event queue.
        e.frame = AMQFrame(
            ClusterRetractOfferBody(ProtocolVersion(), offer->getUpdatee()));
        deliverEventQueue.start();
    }
    // Process each frame through the error checker.
    if (error.isUnresolved()) {
        error.delivered(e);
        while (error.canProcess())  // There is a frame ready to process.
            processFrame(error.getNext(), l);
    }
    else
        processFrame(e, l);
}
Esempio n. 20
0
SSL_METHOD* SSLv3_client_method()
{
    return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,0));
}
Esempio n. 21
0
/* Create a new system object for the dummy X11 driver. */
static ALLEGRO_SYSTEM *xglx_initialize(int flags)
{
   Display *x11display;
   Display *gfxdisplay;
   ALLEGRO_SYSTEM_XGLX *s;

   (void)flags;

#ifdef DEBUG_X11
   _Xdebug = 1;
#endif

   XInitThreads();

   /* Get an X11 display handle. */
   x11display = XOpenDisplay(0);
   if (!x11display) {
      ALLEGRO_ERROR("XOpenDisplay failed.\n");
      return NULL;
   }

   /* Never ask. */
   gfxdisplay = XOpenDisplay(0);
   if (!gfxdisplay) {
      ALLEGRO_ERROR("XOpenDisplay failed.\n");
      XCloseDisplay(x11display);
      return NULL;
   }

   _al_unix_init_time();

   s = _AL_MALLOC(sizeof *s);
   memset(s, 0, sizeof *s);

   /* We need to put *some* atom into the ClientMessage we send for
    * faking mouse movements with al_set_mouse_xy - so lets ask X11
    * for one here.
    */
   s->AllegroAtom = XInternAtom(x11display, "AllegroAtom", False);

   _al_mutex_init_recursive(&s->lock);
   _al_cond_init(&s->resized);
   s->inhibit_screensaver = false;

   _al_vector_init(&s->system.displays, sizeof (ALLEGRO_DISPLAY_XGLX *));

   s->gfxdisplay = gfxdisplay;
   s->x11display = x11display;

   s->system.vt = xglx_vt;

   ALLEGRO_INFO("XGLX driver connected to X11 (%s %d).\n",
      ServerVendor(s->x11display), VendorRelease(s->x11display));
   ALLEGRO_INFO("X11 protocol version %d.%d.\n",
      ProtocolVersion(s->x11display), ProtocolRevision(s->x11display));

#ifdef ALLEGRO_XWINDOWS_WITH_XINERAMA
   _al_xsys_xinerama_init(s);
#endif

   _al_xglx_store_video_mode(s);
   
   _al_thread_create(&s->thread, xglx_background_thread, s);

   ALLEGRO_INFO("events thread spawned.\n");

   return &s->system;
}
Esempio n. 22
0
SSL_METHOD* TLSv1_1_server_method()
{
    return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,2));
}
Esempio n. 23
0
static ALLEGRO_SYSTEM *xglx_initialize(int flags)
{
   Display *x11display;
   Display *gfxdisplay;
   ALLEGRO_SYSTEM_XGLX *s;

   (void)flags;

#ifdef DEBUG_X11
   _Xdebug = 1;
#endif

   XInitThreads();

   /* Get an X11 display handle. */
   x11display = XOpenDisplay(0);
   if (x11display) {
      /* Never ask. */
      gfxdisplay = XOpenDisplay(0);
      if (!gfxdisplay) {
         ALLEGRO_ERROR("XOpenDisplay failed second time.\n");
         XCloseDisplay(x11display);
         return NULL;
      }
   }
   else {
      ALLEGRO_INFO("XOpenDisplay failed; assuming headless mode.\n");
      gfxdisplay = NULL;
   }
   
   _al_unix_init_time();

   s = al_calloc(1, sizeof *s);

   _al_mutex_init_recursive(&s->lock);
   _al_cond_init(&s->resized);
   s->inhibit_screensaver = false;

   _al_vector_init(&s->system.displays, sizeof (ALLEGRO_DISPLAY_XGLX *));

   s->system.vt = xglx_vt;

   s->gfxdisplay = gfxdisplay;
   s->x11display = x11display;

   if (s->x11display) {
      ALLEGRO_INFO("XGLX driver connected to X11 (%s %d).\n",
         ServerVendor(s->x11display), VendorRelease(s->x11display));
      ALLEGRO_INFO("X11 protocol version %d.%d.\n",
         ProtocolVersion(s->x11display), ProtocolRevision(s->x11display));

      /* We need to put *some* atom into the ClientMessage we send for
       * faking mouse movements with al_set_mouse_xy - so let's ask X11
       * for one here.
       */
      s->AllegroAtom = XInternAtom(x11display, "AllegroAtom", False);

      /* Message type for XEmbed protocol. */
      s->XEmbedAtom = XInternAtom(x11display, "_XEMBED", False);

      _al_thread_create(&s->xevents_thread, _al_xwin_background_thread, s);
      s->have_xevents_thread = true;
      ALLEGRO_INFO("events thread spawned.\n");
   }

   return &s->system;
}
Esempio n. 24
0
SSL_METHOD* TLSv1_1_client_method()
{
    return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,2));
}
Esempio n. 25
0
void ServerPacketHandler(CSocket *pSocket, const char *szFormat, va_list vPacket)
{
	BYTE pPacketHeader = *vPacket;

	switch (pPacketHeader)
	{
		case 0x00:
		{
			ProtocolVersion(pSocket, vPacket);
		
			break;
		}

		case 0x04:
		{
			UserInfo(pSocket, vPacket);

			break;
		}

		case 0x13:
		{
			CharSelectInfo(pSocket, vPacket);

			break;
		}

		case 0x1B:
		{
			ItemList(pSocket, vPacket);

			break;
		}

		case 0x27:
		{
			ItemListUpdate(pSocket, vPacket);

			break;
		}

		case 0x41:
		{
			WarehouseDepositList(pSocket, vPacket);

			break;
		}

		case 0x42:
		{
			WarehouseWithdrawalList(pSocket, vPacket);

			break;
		}

		case 0x44:
		{
			ShortCutRegister(pSocket, vPacket);

			break;
		}

		case 0x45:
		{
			ShortCutInit(pSocket, vPacket);

			break;
		}

		case 0x58:
		{
			SkillList(pSocket, vPacket);

			break;
		}

		case 0xD0:
		{
			MultiSellList(pSocket, vPacket);

			break;
		}

		default:
		{
			BYTE opCode = *vPacket;
			char buf[32];
			sprintf_s(buf, "%d", opCode);
			MessageBox(NULL, buf, buf, MB_OK);

			pSocket->SendV(szFormat, vPacket);

			break;
		}
	}
}
Esempio n. 26
0
 ProtocolVersion
 from_version (std::uint16_t major, std::uint16_t minor)
 {
     return ProtocolVersion (major, minor);
 }
Esempio n. 27
0
void
check_AfterStep_dirtree ( char * ashome, Bool create_non_conf )
{
	char         *fullfilename;
	/* Create missing directories & put there defaults */
	if (CheckDir (ashome) != 0)
	{
		CheckOrCreate (ashome);

#if defined(DO_SEND_POSTCARD) /*&& defined(HAVE_POPEN) */
		/* send some info to sasha @ aftercode.net */
		{
			FILE *p;
			char *filename = make_file_name(ashome, ".postcard");
			/*p = popen ("mail -s \"AfterStep installation info\" [email protected]", "w");*/
			p = fopen( filename, "wt" );
			free(filename);
			if (p)
			{
				fprintf( p, "AfterStep_Version=\"%s\";\n", VERSION );
				fprintf( p, "CanonicalBuild=\"%s\";\n", CANONICAL_BUILD );
				fprintf( p, "CanonicalOS=\"%s\";\n", CANONICAL_BUILD_OS );
				fprintf( p, "CanonicalCPU=\"%s\";\n", CANONICAL_BUILD_CPU );
				fprintf( p, "CanonicalVendor=\"%s\";\n", CANONICAL_BUILD_VENDOR );
				if( dpy )
				{
					fprintf (p, "X_DefaultScreenNumber=%d;\n", DefaultScreen (dpy));
					fprintf (p, "X_NumberOfScreens=%d;\n", ScreenCount (dpy));
					fprintf (p, "X_Display=\"%s\";\n", DisplayString (dpy));
					fprintf (p, "X_ProtocolVersion=%d.%d;\n", ProtocolVersion (dpy), ProtocolRevision (dpy));
					fprintf (p, "X_Vendor=\"%s\";\n", ServerVendor (dpy));
					fprintf (p, "X_VendorRelease=%d;\n", VendorRelease (dpy));
					if (strstr(ServerVendor (dpy), "XFree86"))
					{
						int vendrel = VendorRelease(dpy);
						fprintf(p, "X_XFree86Version=");
						if (vendrel < 336)
						{
							fprintf(p, "%d.%d.%d", vendrel / 100, (vendrel / 10) % 10, vendrel       % 10);
						} else if (vendrel < 3900)
						{
							fprintf(p, "%d.%d", vendrel / 1000,  (vendrel /  100) % 10);
							if (((vendrel / 10) % 10) || (vendrel % 10))
							{
								fprintf(p, ".%d", (vendrel / 10) % 10);
								if (vendrel % 10)
									fprintf(p, ".%d", vendrel % 10);
							}
						} else if (vendrel < 40000000)
						{
							fprintf(p, "%d.%d", vendrel/1000,  (vendrel/10) % 10);
							if (vendrel % 10)
								fprintf(p, ".%d", vendrel % 10);
						} else
						{
							fprintf(p, "%d.%d.%d", vendrel/10000000,(vendrel/100000)%100, (vendrel/1000)%100);
							if (vendrel % 1000)
								fprintf(p, ".%d", vendrel % 1000);
						}
						fprintf(p, ";\n");
					}
					if( ASDefaultScrWidth > 0 )
					{
						fprintf( p, "AS_Screen=%ld;\n", ASDefaultScr->screen );
						fprintf( p, "AS_RootGeometry=%dx%d;\n", ASDefaultScrWidth, ASDefaultScrHeight );
					}
					if( ASDefaultVisual )
					{
						fprintf( p, "AS_Visual=0x%lx;\n", ASDefaultVisual->visual_info.visualid );
						fprintf( p, "AS_Colordepth=%d;\n", ASDefaultVisual->visual_info.depth );
						fprintf( p, "AS_RedMask=0x%lX;\n", ASDefaultVisual->visual_info.red_mask );
						fprintf( p, "AS_GreenMask=0x%lX;\n", ASDefaultVisual->visual_info.green_mask );
						fprintf( p, "AS_BlueMask=0x%lX;\n", ASDefaultVisual->visual_info.blue_mask );
						fprintf( p, "AS_ByteOrdering=%s;\n", (ImageByteOrder(ASDefaultVisual->dpy)==MSBFirst)?"MSBFirst":"LSBFirst" );
					}
				}
				fclose(p);
				/*pclose (p);*/
			/*p = popen ("mail -s \"AfterStep installation info\" [email protected]", "w");*/
			}
		}
#endif
	}
	fullfilename = make_file_name (ashome, AFTER_SAVE);
	CheckOrCreateFile (fullfilename);
	free( fullfilename );

#if 0
	fullfilename = make_file_name (ashome, THEME_FILE_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, LOOK_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, FEEL_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, THEME_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, COLORSCHEME_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, BACK_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );
#endif
	fullfilename = make_file_name (ashome, DESKTOP_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, ICON_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, FONT_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, TILE_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, WEBCACHE_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );
	
	if( create_non_conf )
	{
		char *postcard_fname ;
		FILE *f ;
		fullfilename = make_file_name (ashome, AFTER_NONCF);
		/* legacy non-configurable dir: */
		CheckOrCreate(fullfilename);
		postcard_fname = make_file_name( fullfilename, "send_postcard.sh" );
		free( fullfilename );
		
		f = fopen( postcard_fname, "wt" );
		if( f ) 
		{
			fprintf( f, "#!/bin/sh\n\n" );
			fprintf( f, "if [ -r %s/.postcard ] \nthen echo -n \nelse rm %s \nexit\nfi\n", ashome, postcard_fname );
			fprintf( f, "x-terminal-emulator -e \"%s/tools/postcard.sh\"\n", AFTER_SHAREDIR );
			fprintf( f, "if [ -r %s/.postcard ] \nthen echo -n \nelse rm %s \nfi\n", ashome, postcard_fname );
			fclose( f );
		}
		chmod (postcard_fname, 0700);
		free(postcard_fname);
	}

	char *cachefilename = make_file_name(ashome, THUMBNAILS_DIR);
	CheckOrCreate(cachefilename);
	extern void set_asimage_thumbnails_cache_dir(const char*);
	set_asimage_thumbnails_cache_dir(cachefilename);
	free( cachefilename );
}
Esempio n. 28
0
/*
 * This function sets up all of our connections to X
 */
void
SetupX(const char *dstr)
{
   int                 err;
   char                buf[128];
   unsigned int        mask;

   if (!dstr)
      dstr = getenv("DISPLAY");
   if (!dstr)
      dstr = ":0.0";

   /* Open a connection to the diplay nominated by the DISPLAY variable */
   err = EDisplayOpen(dstr, Dpy.screen);
   if (err)
     {
	Alert(_("Enlightenment cannot connect to the display nominated by\n"
		"your shell's DISPLAY environment variable. You may set this\n"
		"variable to indicate which display name Enlightenment is to\n"
		"connect to. It may be that you do not have an Xserver already\n"
		"running to serve that Display connection, or that you do not\n"
		"have permission to connect to that display. Please make sure\n"
		"all is correct before trying again. Run an Xserver by running\n"
		"xdm or startx first, or contact your local system\n"
		"administrator, or Xserver vendor, or read the X, xdm and\n"
		"startx manual pages before proceeding.\n"));
	EExit(1);
     }

   if (getenv("ESYNCHRONIZE"))
      XSynchronize(disp, True);

   Dpy.screens = ScreenCount(disp);
   Dpy.screen = DefaultScreen(disp);

   if (Mode.wm.master ||
       Mode.wm.master_screen < 0 || Mode.wm.master_screen >= Dpy.screens)
      Mode.wm.master_screen = Dpy.screen;

   /* Start up on multiple heads, if appropriate */
   if (Dpy.screens > 1 && !Mode.wm.single && !Mode.wm.restart)
     {
	int                 i;

	for (i = 0; i < Dpy.screens; i++)
	  {
	     pid_t               pid;

	     if (i == Dpy.screen)
		continue;

	     pid = fork();
	     if (pid)
	       {
		  /* We are the master */
		  Mode.wm.child_count++;
		  Mode.wm.children =
		     EREALLOC(pid_t, Mode.wm.children, Mode.wm.child_count);
		  Mode.wm.children[Mode.wm.child_count - 1] = pid;
	       }
	     else
	       {
		  /* We are a slave */
		  EDisplayDisconnect();
		  Mode.wm.master = 0;
		  Mode.wm.pid = getpid();
		  Dpy.screen = i;
		  ExtInitWinSet(NoXID);
#ifdef SIGSTOP
		  kill(getpid(), SIGSTOP);
#endif
		  EDisplayOpen(dstr, i);
		  /* Terminate the loop as I am the child process... */
		  break;
	       }
	  }
     }

   Dpy.name = Estrdup(DisplayString(disp));
   Esetenv("DISPLAY", Dpy.name);

   Dpy.pixel_black = BlackPixel(disp, Dpy.screen);
   Dpy.pixel_white = WhitePixel(disp, Dpy.screen);

   EDisplaySetErrorHandlers(EventShowError, HandleXIOError);

   /* Root defaults */
   RROOT = ERegisterWindow(DefaultRootWindow(disp), NULL);

   if (Mode.wm.window)
     {
	VROOT = ECreateWindow(RROOT, 0, 0, Mode.wm.win_w, Mode.wm.win_h, 0);

	/* Enable eesh and edox to pick up the virtual root */
	Esnprintf(buf, sizeof(buf), "%#x", WinGetXwin(VROOT));
	Esetenv("ENL_WM_ROOT", buf);
     }
   else
     {
	/* Running E normally on the root window */
	VROOT = RROOT;
     }

   Dpy.root_gc = EXCreateGC(WinGetXwin(VROOT), 0, NULL);

   /* Initialise event handling */
   EventsInit();

   /* select all the root window events to start managing */
   Dpy.last_error_code = 0;
   mask =
      StructureNotifyMask | SubstructureNotifyMask | SubstructureRedirectMask;
   ESelectInput(VROOT, mask);
   ESync(0);
   if (Dpy.last_error_code)
     {
	AlertX(_("Another Window Manager is already running"),
	       _("OK"), NULL, NULL,
	       _("Another Window Manager is already running.\n" "\n"
		 "You will have to quit your current Window Manager first before\n"
		 "you can successfully run Enlightenment.\n"));
	EExit(1);
     }

   mask |= ButtonPressMask | ButtonReleaseMask;
   ESelectInput(VROOT, mask);
   ESync(0);
   if (Dpy.last_error_code)
     {
	AlertX(_("Cannot select root window button press events"),
	       _("OK"), NULL, NULL,
	       _("Root window button actions will not work.\n"));
     }

   /* warn, if necessary about X version problems */
   if (ProtocolVersion(disp) != 11)
     {
	AlertX(_("X server version error"), _("Ignore this error"), "",
	       _("Quit Enlightenment"),
	       _("WARNING:\n"
		 "This is not an X11 Xserver. It in fact talks the X%i protocol.\n"
		 "This may mean Enlightenment will either not function, or\n"
		 "function incorrectly. If it is later than X11, then your\n"
		 "server is one the author of Enlightenment neither have\n"
		 "access to, nor have heard of.\n"), ProtocolVersion(disp));
     }

   /* damn that bloody numlock stuff - ok I'd rather XFree got fixed to not */
   /* have it as a modifier and everyone have to write specific code to mask */
   /* it out - but well.... */
   /* ok under Xfree Numlock and Scollock are lock modifiers and we need */
   /* to hunt them down to mask them out - EVIL EVIL EVIL hack but needed */
   {
      XModifierKeymap    *mod;
      EX_KeyCode          nl, sl;
      unsigned int        numlock, scrollock;
      int                 i;

      int                 masks[8] = {
	 ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask,
	 Mod4Mask, Mod5Mask
      };

      numlock = scrollock = 0;
      mod = XGetModifierMapping(disp);
      nl = EKeysymToKeycode(XK_Num_Lock);
      sl = EKeysymToKeycode(XK_Scroll_Lock);
      if ((mod) && (mod->max_keypermod > 0))
	{
	   for (i = 0; i < (8 * mod->max_keypermod); i++)
	     {
		if ((nl) && (mod->modifiermap[i] == nl))
		   numlock = masks[i / mod->max_keypermod];
		else if ((sl) && (mod->modifiermap[i] == sl))
		   scrollock = masks[i / mod->max_keypermod];
	     }
	}
      Mode.masks.mod_combos[0] = 0;
      Mode.masks.mod_combos[1] = LockMask;
      if (numlock)
	{
	   Mode.masks.mod_combos[2] = numlock;
	   Mode.masks.mod_combos[5] = LockMask | numlock;
	}
      if (scrollock)
	{
	   Mode.masks.mod_combos[3] = scrollock;
	   Mode.masks.mod_combos[6] = LockMask | scrollock;
	}
      if (numlock && scrollock)
	{
	   Mode.masks.mod_combos[4] = numlock | scrollock;
	   Mode.masks.mod_combos[7] = LockMask | numlock | scrollock;
	}

      Mode.masks.mod_key_mask =
	 (ShiftMask | ControlMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask |
	  Mod5Mask) & (~(numlock | scrollock | LockMask));

      if (mod)
	 XFreeModifiermap(mod);
   }

   ScreenInit();
}
Esempio n. 29
0
SSL_METHOD* SSLv23_server_method()
{
    // compatibility only, no version 2 support, but does SSL 3 and TLS 1
    return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,2), true);
}
Esempio n. 30
0
File: main.c Progetto: da4089/xguess
int main(int argc, char *argv[]) {
  Display  *display;
  char     *display_name;
  int      c = 0;
  int      operation = 0;
  int      long_index = 0;

  /*-- parse arguments and decide what to do */
  while (operation == 0) {
    c = getopt_long(argc, argv, "xyzmnrs:vkhV", long_options, &long_index);
    switch (c) {
    case 's':
      screen_number = strtol(optarg, NULL, 10);
      break;
    case 'x':
    case 'y':
    case 'z':
    case 'm':
    case 'n':
    case 'r':
    case 'v':
    case 'k':
      operation = c;
      break;
    case 'h':
      usage(argv[0]);
      exit(0);
    case 'V':
      printf("%s\n", VERSION);
      exit(0);
    case -1:
      operation = -1;
      break;
    case '?':
      usage(argv[0]);
      exit(1);
    }
  }

  /* check whether operation is set yet */
  if (operation < 1) {
    usage(argv[0]);
    exit(1);
  }

  /* check that we have a DISPLAY environment variable */
  if (!(display_name = getenv(DISPLAY))) {
    fprintf(stderr, "Cannot locate display - DISPLAY variable not set.\n\n");
    exit(1);
  }

  /* check that we have access to the display */
  if (!(display = XOpenDisplay(display_name))) {
    fprintf(stderr, "Cannot open display from DISPLAY variable.\n\n");
    exit(1);
  }

  /* check screen number */
  if (screen_number >= ScreenCount(display)) {
    fprintf(stderr, "cannot use screen %d, only %d screen(s) available.\n", screen_number, ScreenCount(display));
    usage(argv[0]);
    exit(1);
  }

  switch (operation) {
  case 'x':
    printf("%d\n", DisplayWidth(display, screen_number));
    break;
  case 'y':
    printf("%d\n", DisplayHeight(display, screen_number));
    break;
  case 'z':
    printf("%d\n", DefaultDepth(display, screen_number));
    break;
  case 'm':
    printf("%s\n", ServerVendor(display));
    break;
  case 'n':
    printf("%d\n", ScreenCount(display));
    break;
  case 'r':
    printf("%d\n", VendorRelease(display));
    break;
  case 'v':
    printf("%d.%d\n", ProtocolVersion(display), ProtocolRevision(display));
    break;
  case 'k':
    printf("%s\n", keyboard_guess(display));
    break;
  }

  exit(0);
}