Example #1
0
 Uint32 Long() const
 {
     return (AC()<<24)
            | (RC()<<16)
            | (GC()<<8)
            | BC();
 }
Example #2
0
A ga(I t, I r, I n, I *s) { I k=WP(t,r,n); A z=a_malloc(k);
    AT(z)=t; AC(z)=1; AR(z)=r; AN(z)=n;
    if (r==1)      { *AS(z)=n;        }
    else if (r&&s) { ICPY(AS(z),s,r); }
    gcpush(z);
    R z;
}
Example #3
0
sf::Vector2f Collision::ProjectionI(sf::Vector2f A, sf::Vector2f B, sf::Vector2f C)
{
    sf::Vector2f u(B.x - A.x, B.y - A.y);
    sf::Vector2f AC(C.x - A.x, C.y - A.y);
    float ti = (u.x*AC.x + u.y*AC.y)/(u.x*u.x + u.y*u.y);
    sf::Vector2f I(A.x + ti*u.x, A.y + ti*u.y);
    return I;
}
Example #4
0
static void
update(const struct VSM_data *vd, int period)
{
	struct top *tp, *tp2;
	int l, len;
	double t = 0;
	static time_t last = 0;
	static unsigned n;
	time_t now;

	now = time(NULL);
	if (now == last)
		return;
	last = now;

	l = 1;
	if (n < period)
		n++;
	AC(erase());
	AC(mvprintw(0, 0, "%*s", COLS - 1, VSM_Name(vd)));
	AC(mvprintw(0, 0, "list length %u", ntop));
	for (tp = VRB_MIN(top_tree, &top_tree_head); tp != NULL; tp = tp2) {
		tp2 = VRB_NEXT(top_tree, &top_tree_head, tp);
		if (++l < LINES) {
			len = tp->clen;
			if (len > COLS - 20)
				len = COLS - 20;
			AC(mvprintw(l, 0, "%9.2f %-*.*s %*.*s\n",
			    tp->count, maxfieldlen, maxfieldlen,
			    VSL_tags[tp->tag],
			    len, len, tp->rec_data));
			t = tp->count;
		}
		tp->count += (1.0/3.0 - tp->count) / (double)n;
		if (tp->count * 10 < t || l > LINES * 10) {
			VRB_REMOVE(top_tree, &top_tree_head, tp);
			free(tp->rec_data);
			free(tp);
			ntop--;
		}
	}
	AC(refresh());
}
Example #5
0
    int64_t solveXorAnd(std::vector<int64_t> &A, std::vector<int64_t> &C, int64_t n, int64_t m) {
        std::vector<std::vector<int64_t>> AC(n, std::vector<int64_t>(n, 0));
        
        for (int64_t i = 0; i < n; i++) AC[n - 1][i] = C[n - i - 1];
        for (int64_t i = 0; i < n - 1; i++) AC[i][i + 1] = -1;

        std::vector<std::vector<int64_t>> R = powMatrix(AC, m - 1);
        int64_t res = 0;
        for (int64_t i = 0; i < n; i++) res ^= R[0][i] & A[i];
        return res;
    }
//-----------------------------------------------------------------------------------------------
void ScenarioStartFunction_Responsibility( Scenario& scenario )
{
	DebuggerPrintf( "Starting scenario '%s'...\n", scenario.m_name.c_str() );
	
	//1024x576
	Actor *player=new Actor();
	player->m_position = Vector2(352+144, 320+128);
	player->m_isPlayer = true;
	player->m_baseColor = Rgba::BLUE;
	scenario.m_actors.push_back( player );

	RelationshipToOtherActor followPlayer;
	followPlayer.m_attractionRepulsionAtOuterDistance = Vector2(0.75f, 0.75f);
	followPlayer.m_attractionRepulsionAtInnerDistance = Vector2(-0.25f, -0.25f);
	followPlayer.m_outerDistance = 128;
	followPlayer.m_innerDistance = 16;
	followPlayer.m_otherActor = player;

	for(int i = 0; i < 5; i++) {
		for(int j = 0; j < 5; j++) {
			if(i == 2 && j == 2) { continue; }
			AC(a, player->m_position.x-(i-2)*30, player->m_position.y-(j-2)*30);
		}
	}

	for(int i = 0; i < scenario.m_actors.size(); i++) {
		Actor *a = scenario.m_actors[i];
		RelationshipToOtherActor dontBumpA;
		dontBumpA.m_innerDistance = 0;
		dontBumpA.m_outerDistance = 64;
		dontBumpA.m_attractionRepulsionAtOuterDistance = Vector2(0,0);
		dontBumpA.m_attractionRepulsionAtInnerDistance = Vector2(-3,-3);
		dontBumpA.m_otherActor = a;
		for(int j = 0; j < scenario.m_actors.size(); j++) {
			if(i == j) { continue; }
			Actor *b = scenario.m_actors[j];
			b->m_relationships.push_back(dontBumpA);
		}
	}

	AR(ar1, 352, 320, 288, 256);
	AR(ar2, 96, 256, 288, 256);
	AR(ar3, 224, 32, 288, 256);
	AR(ar4, 352, 320, 288, 256);
	AR(ar5, 512, 128, 288, 256);
	AR(ar6, 800, 32, 288, 256);

	Area *pGoal=new Area();
	pGoal->m_bounds.SetFromMinXYMaxXY( 928, 32, 1500, 32+256 );
	pGoal->m_color = Rgba::WHITE;
	pGoal->m_alpha = 1.0f;
	scenario.m_areas.push_back( pGoal );
}
Example #7
0
	void Add(T* Req)
	{
		C_ConsecutiveAccess AC(&m_Section);
		long prev;
		if (ReleaseSemaphore(m_ItemsCounter, 1, &prev))
		{
			m_Collection.push_back(Req);
		}
		else
		{
			throw "Collection is overloaded, message was not added";
		}
	}
Example #8
0
    // template<typename T>
    T* Get(DWORD* res = 0,DWORD sec = INFINITE)
    {
        HANDLE h[2];
        h[0] = m_ItemsCounter;
        h[1] = m_FinishEvent;

        T* Req = 0;
        DWORD Code = WaitForMultipleObjects(2, h, FALSE, sec);
        switch(Code)
        {
            case WAIT_OBJECT_0:
            {
                if (res)
                    *res = SC_GotMessage;

                C_ConsecutiveAccess AC(&m_Section);
                typename std::list<T*>::iterator It;
                It = m_Collection.begin();
                if (It != m_Collection.end())
                {
                    Req = *It;
                    m_Collection.erase(It);
                }
                break;
            }
            case WAIT_OBJECT_0 + 1:
            {
                if (res)
                *res = SC_FinishEvent;
                break;
            }
            case WAIT_TIMEOUT:
            {
                if (res)
                *res = SC_TimeOut;
                break;
            }
            case WAIT_FAILED:
            {
                if (res)
                *res = GetLastError();
                break;
            }
            default:
            {
                if (res)
                *res = SC_Unexpected;
            }
        }
        return Req;
    }
Example #9
0
sf::Vector2f Collision::GetNormale(sf::Vector2f A, sf::Vector2f B, sf::Vector2f C)
{
    sf::Vector2f u(B.x - A.x, B.y - A.y);
    std::cout<<"u <"<<u.x<<","<<u.y<<">"<<std::endl;
    sf::Vector2f     AC(C.x - A.x, C.y - A.y);
    std::cout<<"AC <"<<AC.x<<","<<AC.y<<">"<<std::endl;
    float parenthesis = u.x*AC.y - u.y*AC.x;
    std::cout<<"Parenthese "<<parenthesis<<std::endl;
    sf::Vector2f N(u.y*(parenthesis), u.x*(parenthesis));
    std::cout<<"Normal <"<<N.x<<","<<N.y<<">"<<std::endl;
    float norme = std::sqrt(N.x*N.x + N.y*N.y);
    std::cout<<"Norme "<<norme<<std::endl;
    N.x /= norme;
    N.y /= norme;


    return N;
}
Example #10
0
bool	CollisionDroiteCercle(const t_vec2f& A, const t_vec2f&  B, const t_vec2f& C, float radius)
{
	if (!CollisionDroiteCercle_BBox(A,B,C,radius))
		return false;

	t_vec2f	u(B.x - A.x, B.y - A.y);
	t_vec2f	AC(C.x - A.x, C.y - A.y);

	float numerateur = u.x * AC.y - u.y * AC.x;   // norme du vecteur v

	if (numerateur < 0)
		numerateur = -numerateur ;   // valeur absolue ; si c'est négatif, on prend l'opposé.

	float denominateur = sqrtf(u.x * u.x + u.y * u.y);  // norme de u
	float CI = numerateur / denominateur;

	return (CI < radius);
}
Example #11
0
static void
update(int p)
{
	struct top *tp, *tp2;
	int l, len;
	double t = 0;
	static time_t last = 0;
	static unsigned n;
	time_t now;

	now = time(NULL);
	if (now == last)
		return;
	last = now;

	l = 1;
	if (n < p)
		n++;
	AC(erase());
	if (end_of_file)
		AC(mvprintw(0, COLS - 1 - strlen(VUT.name) - 5, "%s (EOF)",
			VUT.name));
	else
		AC(mvprintw(0, COLS - 1 - strlen(VUT.name), "%s", VUT.name));
	AC(mvprintw(0, 0, "list length %u", ntop));
	for (tp = VRB_MIN(t_order, &h_order); tp != NULL; tp = tp2) {
		tp2 = VRB_NEXT(t_order, &h_order, tp);

		if (++l < LINES) {
			len = tp->clen;
			if (len > COLS - 20)
				len = COLS - 20;
			AC(mvprintw(l, 0, "%9.2f %-*.*s %*.*s\n",
				tp->count, maxfieldlen, maxfieldlen,
				VSL_tags[tp->tag],
				len, len, tp->rec_data));
			t = tp->count;
		}
		if (end_of_file)
			continue;
		tp->count += (1.0/3.0 - tp->count) / (double)n;
		if (tp->count * 10 < t || l > LINES * 10) {
			VRB_REMOVE(t_key, &h_key, tp);
			VRB_REMOVE(t_order, &h_order, tp);
			free(tp->rec_buf);
			free(tp);
			ntop--;
		}
	}
	AC(refresh());
}
Example #12
0
void test_circuit_parallel()
{
	//circuit 1
	ngac AC("ac1", 0, 5, 1);
	ngresistor R("r1", 370);
	ngled LED("LED1", 7e-3);
	ngground GND;

	ngline L0(AC.p1, GND.p1);
	ngline L1(AC.p2, R.p1);
	ngline L2(R.p2, LED.p1);
	ngline L3(LED.p2, AC.p1);

	schema SCH;
	SCH.AddDevices(&AC, &R, &LED, &GND, 0);
	SCH.AddLines(&L0, &L1, &L2, &L3, 0);

	circuit CIR(&SCH);
	CIR.Tran("20", "1m");

	//circuit 2
	ngac ac("ac1", 0, 5, 1);
	ngresistor r("r1", 370);
	ngled led("led1", 5e-3);
	ngground gnd;

	ngline l0(ac.p1, gnd.p1);
	ngline l1(ac.p2, r.p1);
	ngline l2(r.p2, led.p1);
	ngline l3(led.p2, ac.p1);

	schema sch;
	sch.AddDevices(&ac, &r, &led, &gnd, 0);
	sch.AddLines(&l0, &l1, &l2, &l3, 0);

	circuit cir(&sch);
	cir.Tran("20", "1m");

	do 
	{
		Sleep(200);
	} while (CIR.IsRunning() || cir.IsRunning());
}
Example #13
0
//  checks whether M is inside the triangle
//  Gives incorrect result if M is not in plane ABC ( check this before! )
bool R3DTriangle::isInside(R3DPoint D)
{      

// if point M is in plane of triangle ABC
// and AM,BM,CM do not cross the sides

R3DPoint X;

R3DPoint M = (A+B+C)/3;

R3DLineSegment DM(D,M);

R3DLineSegment AB(A,B);
R3DLineSegment BC(B,C);
R3DLineSegment AC(A,C);

return !( intersect(DM,AB,&X)  ||
           intersect(DM,AC,&X)  ||
           intersect(DM,BC,&X) 
         );

}
Example #14
0
bool Collision::CircleSegmentCollision(sf::Vector2f circleCenter, int radius, sf::Vector2f pointA, sf::Vector2f pointB)///Collision type Cercle - Segement
{
    std::cout<<"\nTest 1 Point A <"<<pointA.x<<","<<pointA.y<<"> Point B <"<<pointB.x<<","<<pointB.y<<">";
    if(!CircleDroiteCollision(pointA, pointB, circleCenter, radius))
        return false;
    std::cout<<" - Completed\nTest 2";
    sf::Vector2f AB(pointB.x - pointA.x, pointB.y - pointA.y);
    sf::Vector2f AC(circleCenter.x - pointA.x, circleCenter.y - pointA.y);
    sf::Vector2f BC(circleCenter.x - pointB.x, circleCenter.y - pointB.y);
    float pascal1 = AB.x * AC.x + AB.y * AC.y;
    float pascal2 = (-AB.x)*BC.x + (-AB.y)*BC.y;
    std::cout<<" - Completed\nTest 3";
    if(pascal1 >= 0 && pascal2 >=0)
        return true;
    std::cout<<" - Completed\nTest 4";
    if(PointCircleCollision(pointA, circleCenter, radius))
        return true;
    std::cout<<" - Completed\nTest 5";
    if(PointCircleCollision(pointB, circleCenter, radius))
        return true;
    std::cout<<" - Completed";
    return false;
}
Example #15
0
File: cx.c Project: zeotrope/j7-src
static DF2(xd){PROLOG;DECLFG;A f,*line,loc=local,name,seq,z=0;B b;DC dv;
  I i=0,n,old;
 b=a&&w; f=*(b+AAV(sv->h));
 line=AAV(f); n=nline=AN(f); ASSERT(n,EVDOMAIN);
 GA(local,SYMB,twprimes[0],1,0);
 symbis(scnm(CALPHA),a,local);
 symbis(scnm(COMEGA),w,local);
 RZ(dv=debadd(DCDEFN)); dv->p=sv->s; drun=0;
 old=tbase+ttop;
 ra(self);
 for(;0<=i&&i<n;i++){
  tpop(old);
  dv->ln=i; dv->n=1+(0!=a);
  z=parse(ca(line[i]));
  if(!debugb&&!z) break;
 }
 if(debugb&&!z){z=tpush(qpopres); qpopres=0;}
 z=car(z); ++AC(local); fa(local); local=loc;
 asgn=0;
 fa(self);
 debz();
 if(!z) jsignal(EVRESULT);
 EPILOG(z);
}
Example #16
0
    ACS(ramWatchRecent[2]),
    ACS(ramWatchRecent[3]),
    ACS(ramWatchRecent[4]),

    ACS(recentProjectsArray[0]),
    ACS(recentProjectsArray[1]),
    ACS(recentProjectsArray[2]),
    ACS(recentProjectsArray[3]),
    ACS(recentProjectsArray[4]),
    ACS(recentProjectsArray[5]),
    ACS(recentProjectsArray[6]),
    ACS(recentProjectsArray[7]),
    ACS(recentProjectsArray[8]),
    ACS(recentProjectsArray[9]),

    AC(AutoResumePlay),
    ACS(ResumeROM),

    AC(gNoBGFillColor),
    AC(ntsccol),AC(ntsctint),AC(ntschue),
    AC(force_grayscale),
    AC(dendy),

    NAC("palyo",pal_emulation),
    NAC("genie",genie),
    NAC("fs",fullscreen),
    NAC("vgamode",vmod),
    NAC("sound",soundo),
    NAC("sicon",status_icon),

    AC(newppu),
Example #17
0
int
main ()
{
	float S[8][16], val;
	int i,k, count = 0;
	int vali;

	printf("/* sbc_coeffs.h - Automatically generated by cosdata.c. */\n\n");

	vali = SI_MULTI;
	printf("#define SIMULTI\t%d\n\n", vali);

	printf("static const int32_t sbc_coeffs8[] = {\n    ");
	for (k = 0;k < AC(sbc8_coeffs);k++) {
		if (count % 8 == 0 && count != 0)
			printf("\n    ");
		val = sbc8_coeffs[k] * COEFFS_MULTI;
		vali = roundf(val);
		printf("%d, ",vali);
		count++;
	}
	printf("\n};\n");

	count = 0;
	printf("static const int32_t sbc_coeffs4[] = {\n    ");
	for (k = 0;k < AC(sbc4_coeffs);k++) {
		if (count % 8 == 0 && count != 0)
			printf("\n    ");
		val = sbc4_coeffs[k] * COEFFS_MULTI;
		vali = roundf(val);
		printf("%d, ",vali);
		count++;
	}
	printf("\n};\n");

	count = 0;
	printf("static const int32_t cosdata8[8][16] = {\n    ");
	for (i = 0; i < 8; i++) {
		for (k = 0;k < 16;k++) {
			S[i][k] = cosf((i+0.5)*(k-4)*(M_PI_4/2));

			if (count % 8 == 0 && count != 0)
				printf("\n    ");
			if (k == 0)
				printf("{ ");
			val = S[i][k] * SI_MULTI;
			vali = roundf(val);
			printf("%d, ",vali);

			if (k == 15)
				printf("},");
			count++;
		}
	}
	printf("\n};\n");

	count = 0;
	printf("static const int32_t cosdata4[4][8] = {\n    ");
	for (i = 0; i < 4; i++) {
		for (k = 0;k < 8;k++) {
			S[i][k] = cosf((i+0.5)*(k-2)*(M_PI_4));

			if (count % 8 == 0 && count != 0)
				printf("\n    ");
			if (k == 0)
				printf("{ ");

			val = S[i][k] * SI_MULTI;
			vali = roundf(val);
			printf("%d, ",vali);

			if (k == 7)
				printf("},");
			count++;
		}
	}
	printf("\n};\n");

	return 0;
}
Example #18
0
/*********************************************
Finger
    Performs the finger for the specified address
    the information that is returned can be 
    retrieved with the GetReturnLine function.

    If filename parameter was specified all the 
    received data is saved in the file. In this 
    case you can't access data with GetReturnLine 
    function.

Params
    address     - address to perform the finger on. 
                  address format is: @domain.com or 
                  [email protected]

    dest        - data source for saving received data
    [fileType]  -   -1              - don't use
                    UTM_OM_WRITING  - open writing
                    UTM_OM_APPEND   - open for appending 


Return
    UTE_SUCCESS                 - success
    UTE_INVALID_ADDRESS_FORMAT  - invalid address format
    UTE_INVALID_ADDRESS         - invalid address
    UTE_CONNECT_FAILED          - connection failed
    UTE_NO_RESPONSE             - no response
    UTE_ABORTED                 - aborted
    UTE_CONNECT_TIMEOUT         - time out
**********************************************/
int CUT_FingerClient::Finger(LPTSTR address, CUT_DataSource & dest, OpenMsgType fileType) 
{
    
    int     error = UTE_SUCCESS;
    int     len;
    char    buf[MAX_PATH+1];
    char    domain[MAX_PATH+1];

    //delete prev finger information
    m_listReturnLines.ClearList();          

    //split the address apart
	// v4.2 address splitting into name and domain allows AC macro, hence LPTSTR in interface.
    if(SplitAddress(buf,domain,AC(address)) != UTE_SUCCESS)
        return OnError(UTE_INVALID_ADDRESS_FORMAT);

    //check to see if the domain is a name or address
    if(IsIPAddress(domain) != TRUE) {
        //get the name from the address
        if(GetAddressFromName(domain,domain,sizeof(domain)) != UTE_SUCCESS)
            return OnError(UTE_INVALID_ADDRESS);
        }

    //connect using a timeout
    if((error=Connect(m_nPort, domain, m_nConnectTimeout)) != UTE_SUCCESS)
        return OnError(error);

    if(IsAborted())                         // Test abort flag
        error = UTE_ABORTED;                // Aborted

    if(error == UTE_SUCCESS) {

        //send the name to finger
        Send(buf);
        Send("\r\n");

        // Read data into the file
        if(fileType != -1) {
            error = Receive(dest, fileType, m_nReceiveTimeout);
            }

        // Read data line by line & save it in the string list
        else {
            //read in the return lines

			// v4.2 change to eliminate C4127:conditional expression is constant
			for(;;) {
				if(IsAborted()) {                       // Test abort flag
                    error = UTE_ABORTED;                // Aborted
                    break;
                    }

                //wait for a receive
                if(WaitForReceive(m_nReceiveTimeout, 0)!= UTE_SUCCESS)
                    break;
        
                //get the information
                len = ReceiveLine(buf, sizeof(buf)-1);
                if(len <= 0)
                    break;
        
                buf[len]=0;
                CUT_StrMethods::RemoveCRLF(buf);

                //store the information
                m_listReturnLines.AddString(buf);
                }

            if (error == UTE_SUCCESS && m_listReturnLines.GetCount() == 0)
                error = UTE_NO_RESPONSE;                // No response
            }
        }

    // Close connection
    CloseConnection();

    return OnError(error);
}
Example #19
0
static void *
do_curses(void *arg)
{
	int i;

	(void)arg;
	for (i = 0; i < 256; i++) {
		if (VSL_tags[i] == NULL)
			continue;
		if (maxfieldlen < strlen(VSL_tags[i]))
			maxfieldlen = strlen(VSL_tags[i]);
	}

	(void)initscr();
	AC(raw());
	AC(noecho());
	AC(nonl());
	AC(intrflush(stdscr, FALSE));
	(void)curs_set(0);
	AC(erase());
	for (;;) {
		AZ(pthread_mutex_lock(&mtx));
		update(period);
		AZ(pthread_mutex_unlock(&mtx));

		timeout(1000);
		switch (getch()) {
		case ERR:
			break;
#ifdef KEY_RESIZE
		case KEY_RESIZE:
			AC(erase());
			break;
#endif
		case '\014': /* Ctrl-L */
		case '\024': /* Ctrl-T */
			AC(redrawwin(stdscr));
			AC(refresh());
			break;
		case '\032': /* Ctrl-Z */
			AC(endwin());
			AZ(raise(SIGTSTP));
			break;
		case '\003': /* Ctrl-C */
		case '\021': /* Ctrl-Q */
		case 'Q':
		case 'q':
			AZ(raise(SIGINT));
			AC(endwin());
			return NULL;
		default:
			AC(beep());
			break;
		}
	}
	return NULL;

}
Example #20
0
/********************************
OnConnect
    This function is called when a new
    connection comes in. This routine
    processes all commands from the 
    connection and only returns when
    the connection is finished
Params
    none
Return
    none

Revisions:
	Added string length limitations 
	as enforced by RFC 821

	There are several objects that have required minimum maximum
	sizes.  That is, every implementation must be able to receive
	objects of at least these sizes, but must not send objects
	larger than these sizes.


	****************************************************
	*                                                  *
	*  TO THE MAXIMUM EXTENT POSSIBLE, IMPLEMENTATION  *
	*  TECHNIQUES WHICH IMPOSE NO LIMITS ON THE LENGTH *
	*  OF THESE OBJECTS SHOULD BE USED.                *
	*                                                  *
	****************************************************
	user
	The maximum total length of a user name is 64 characters.

	domain
	The maximum total length of a domain name or number is 64
	 characters.

	path

	   The maximum total length of a reverse-path or
	   forward-path is 256 characters (including the punctuation
	   and element separators).

	command line

	   The maximum total length of a command line including the
	   command word and the <CRLF> is 512 characters.

	reply line

	   The maximum total length of a reply line including the
	   reply code and the <CRLF> is 512 characters.

	recipients buffer

               The maximum total number of recipients that must be
               buffered is 100 recipients.

*********************************/
void CUT_SMTPThread::OnConnect()
{
    char            szMailFrom[WSS_BUFFER_SIZE + 1];
    char            szHeloName[WSS_BUFFER_SIZE + 1];     
    char            szBuffer[WSS_LINE_BUFFER_SIZE + 1];
    char            szRcpt[WSS_LINE_BUFFER_SIZE + 1];
    int             nLength             = 0;
    int             nNumBadCommands     = 0;
    int             bQuit               = FALSE;
    SMTPCommandID   nLastCommand        = CMD_UNKNOWN_SMTP;
    SMTPCommandID   nCommand            = CMD_UNKNOWN_SMTP;
    CUT_MailServer  *ptrMailServer  = ((CUT_SMTPServer *)m_winsockclass_this)->m_ptrMailServer;
    CUT_DataManager     *ptrDataManager     = ptrMailServer->m_ptrDataManager;
    CUT_StringList  m_listRcpt;   
	BOOL			greeted = FALSE;
	time_t			ltime;
		

	char szReceivedHeader[2*WSS_LINE_BUFFER_SIZE];

	if(ptrMailServer->GetSMTPServer()->GetShutDownFlag())
		return;


	time( &ltime );
	ZeroMemory( szBuffer, sizeof(szBuffer));
	_snprintf(szBuffer,sizeof(szBuffer)-1, "**** Client [%s] connected at (%s) ***** ", GetClientAddress(), (const char *)ctime( &ltime ));
	CUT_StrMethods::RemoveCRLF (szBuffer);
	ptrMailServer->OnStatus(szBuffer);

#ifdef CUT_SECURE_SOCKET

	BOOL            bHandshakeDone	= FALSE;	

	// Disable security while connecting
	BOOL bSecureFlag = GetSecurityEnabled();

	if(!ptrMailServer->GetSMTPServer()->m_bImmediateNegotiation)
		SetSecurityEnabled(FALSE);
	else
		bHandshakeDone = TRUE;

#endif


    // Send inital message
	ZeroMemory( szBuffer, sizeof(szBuffer));
    _snprintf(szBuffer,sizeof(szBuffer)-1,"220 %s Service Ready. Ultimate TCP/IP Enterprise Edition\r\n",ptrMailServer->Sys_GetLocalName(0));
    Send(szBuffer);

    // Main message pump
    while(bQuit == FALSE) {
		if(ptrMailServer->GetSMTPServer()->GetShutDownFlag())
		{
			ZeroMemory( szBuffer, sizeof(szBuffer));
			_snprintf(szBuffer,sizeof(szBuffer)-1,"421 %s Service not available, closing transmission channel\r\n",ptrMailServer->Sys_GetLocalName(0));
			Send(szBuffer);	
			break;             
		}
		
        ptrMailServer->OnStatus("NEW Command:");

		if (nNumBadCommands > 10)
			break; 

        // Receive a line from the client
		ZeroMemory( szBuffer, sizeof(szBuffer));
        nLength = ReceiveLine(szBuffer, WSS_LINE_BUFFER_SIZE);
	
	

        // Exit on an error
        if(nLength <= 0)
            break;  

		// command line
		// The maximum total length of a command line including the
		// command word and the <CRLF> is 512 characters.
		 if(nLength > 512)
		{
			Send("500 Line too long.\r\n");
			ptrMailServer->OnStatus("500 Line too long.");
			continue;
		}

        CUT_StrMethods::RemoveCRLF(szBuffer);
        ptrMailServer->OnStatus(szBuffer);

        // Store the last command
        nLastCommand = nCommand;

        // Get the command that was sent
        nCommand = GetCommand(szBuffer);




#ifdef CUT_SECURE_SOCKET

		// Only this commands allowed without establishing secure connection
		if(	nCommand != CMD_SMTPNOOP && 
			nCommand != CMD_SMTPSTARTTLS && 
			nCommand != CMD_SMTPEHLO && 
			nCommand != CMD_SMTPQUIT)
		{
			if(!bHandshakeDone  && bSecureFlag )
			{
				if(!OnNonSecureConnection(GetClientAddress()))
				{
					Send("530 Must issue a STARTTLS command first\r\n");
					ptrMailServer->OnStatus("Must issue a STARTTLS command first");
					continue;
				}
			}
		}
				
#endif


        // Check to see if it is a command that can run without logging in
        switch(nCommand) {

            case CMD_SMTPHELO:
				{

                // Get the param
                *szHeloName = NULL;
				
				//\b Backspace  \f Formfeed \n New line \r Carriage return \t Horizontal tab \v 
				// 

                CUT_StrMethods::ParseString(szBuffer," \t\b\v\f",1, szHeloName,sizeof(szHeloName)-1);

				// the domain name must be sorter than 
               // The maximum total length of a domain name or number is 64
				// characters
				//  see rfc 821 section 
				// 4.5.3.  SIZES 
				if (szHeloName == 0 || strlen(szHeloName) < 2 )
				{
					 Send("501 Syntax Error In Parameters Or Arguments.\r\n");
					 nNumBadCommands++;
					 ptrMailServer->OnStatus("501 Syntax Error In Parameters Or Arguments.");
					  nCommand = nLastCommand ;
					  continue;				
				}
				CUT_StrMethods::RemoveCRLF (szHeloName);
				CUT_StrMethods::RemoveSpaces (szHeloName);
				
				if (szHeloName == 0 || strlen(szHeloName)  > 64 )
				{
					 Send("501 Syntax Error In Parameters Or Arguments.\r\n");
					 ptrMailServer->OnStatus("501 Syntax Error In Parameters Or Arguments");
					 nNumBadCommands++;
					  nCommand = nLastCommand ;
					  continue;				
				}

                // Send acknowlegment				
				time( &ltime );
				char szTimeStr[29];
				ZeroMemory( szTimeStr, 29 );
				
				
				//	The string result produced by ctime contains exactly 26 characters and has the form: 
				// Wed Jan 02 02:03:55 1980\n\0 
				// So we need 29
				_snprintf(szTimeStr,sizeof(szTimeStr)-1,"at %s", (const char *)ctime( &ltime ));
				// A 24-hour clock is used.
				// All fields have a constant width.
				// The newline character ('\n') and the null character 
				// ('\0') occupy the last two positions of the string.
				CUT_StrMethods::RemoveCRLF (szTimeStr);		
				// ok you may wonder what was that about
				//I found out that ctime adds a \n to the end 
				// so I wanted to remove any \r or \n 
				// the add a new one
				ZeroMemory( szReceivedHeader, sizeof(szReceivedHeader)-1 );
				_snprintf(szReceivedHeader,sizeof(szReceivedHeader)-1,"Received: from %s [%s];\r\n\tby %s %s;\r\n\twith Codepro Mail Server  (R2hhemkgVyBOb3YgMDYA);\r\n\tPowered by Ultimate TCP-IP v4.2 Enterprise Edition (www.theultimatetoolbox.com).\r\n", szHeloName, GetClientAddress(), ptrMailServer->Sys_GetLocalName(0), szTimeStr);

				ZeroMemory( szBuffer, sizeof(szBuffer));
			    _snprintf(szBuffer,sizeof(szBuffer)-1,"250 %s %s [%s] \r\n",ptrMailServer->Sys_GetLocalName(0), szHeloName, GetClientAddress());

				greeted = TRUE;
                Send(szBuffer);
				ptrMailServer->OnStatus(szBuffer);
                continue;
		}

            case CMD_SMTPHELP:
                OnHelpCommand();
                continue;
                
            case CMD_SMTPQUIT:
                Send("221 Goodbye\r\n");
                ptrMailServer->OnStatus("QUIT");
                bQuit = TRUE;
                break;

            case CMD_SMTPNOOP:
                Send("250 Requested mail action ok, completed\r\n");
                continue;

            case CMD_SMTPRSET:
                m_listRcpt.ClearList();
                Send("250 Ok\r\n");
                continue;

            case CMD_SMTPEHLO:
				{

		
                // Get the param
                // Get the param
                *szHeloName = NULL;
				
				//\b Backspace  \f Formfeed \n New line \r Carriage return \t Horizontal tab \v 
				// 

                CUT_StrMethods::ParseString(szBuffer," \t\b\v\f",1, szHeloName,sizeof(szHeloName)-1);

				// the domain name must be sorter than 
               // The maximum total length of a domain name or number is 64
				// characters
				//  see rfc 821 section 
				// 4.5.3.  SIZES 
				if (szHeloName == 0 || strlen(szHeloName) < 2 )
				{
					 Send("501 Syntax Error In Parameters Or Arguments.\r\n");
					 nNumBadCommands++;
					 ptrMailServer->OnStatus("501 Syntax Error In Parameters Or Arguments.");
					  nCommand = nLastCommand ;
					  continue;				
				}
				CUT_StrMethods::RemoveCRLF (szHeloName);
				CUT_StrMethods::RemoveSpaces (szHeloName);
				
				if (szHeloName == 0 || strlen(szHeloName)  > 64 )
				{
					 Send("501 Syntax Error In Parameters Or Arguments.\r\n");
					 ptrMailServer->OnStatus("501 Syntax Error In Parameters Or Arguments");
					 nNumBadCommands++;
					  nCommand = nLastCommand ;
					  continue;				
				}
				char szTimeStr[29];
				ZeroMemory( szTimeStr, sizeof(szTimeStr));
				
			     // Send acknowlegment				
				time( &ltime );
		
				_snprintf(szTimeStr,sizeof(szTimeStr)-1,"at %s", (const char *)ctime( &ltime ));
				// A 24-hour clock is used.
				// All fields have a constant width.
				// The newline character ('\n') and the null character 
				// ('\0') occupy the last two positions of the string.
				CUT_StrMethods::RemoveCRLF (szTimeStr);		
				// ok you may wonder what was that about
				//I found out that ctime adds a \n to the end 
				// so I wanted to remove any \r or \n 
				// the add a new one
				ZeroMemory( szReceivedHeader, sizeof(szReceivedHeader)-1 );
				_snprintf(szReceivedHeader,sizeof(szReceivedHeader)-1,"Received: from %s [%s];\r\n\tby %s %s;\r\n\twith Ultimate TCP/IP Mail Server ;\r\n\tPowered by Ultimate TCP/IP v4.2 Enterprise Edition (www.theultimatetoolbox.com).\r\n", szHeloName, GetClientAddress(), ptrMailServer->Sys_GetLocalName(0), szTimeStr);		
				

                // Send acknowlegment
#ifdef CUT_SECURE_SOCKET
				ZeroMemory( szBuffer, sizeof(szBuffer));
                _snprintf(szBuffer,sizeof(szBuffer)-1,"250-%s %s [%s] \r\n250 STARTTLS\r\n",ptrMailServer->Sys_GetLocalName(0), szHeloName, GetClientAddress());
#else
				ZeroMemory( szBuffer, sizeof(szBuffer));
				_snprintf(szBuffer,sizeof(szBuffer)-1,"250 %s %s [%s] \r\n",ptrMailServer->Sys_GetLocalName(0), szHeloName, GetClientAddress());
#endif
				greeted = TRUE;
                Send(szBuffer);
				ptrMailServer->OnStatus(szBuffer);

                continue;
				}

			case CMD_SMTPSTARTTLS:

#ifdef CUT_SECURE_SOCKET

				if(bSecureFlag)
				{
					// Already done
					if(bHandshakeDone)
					{
						Send("502 Command not permitted when TLS active\r\n");
						continue;
					}

					// Send an OK command
					Send("220 Ready to start TLS\r\n");

					// Set security flag
					SetSecurityEnabled(TRUE);

					// Start negotiation
					int nResult = CUT_SecureSocket::SocketOnConnected(m_clientSocket, "");
					if (nResult != UTE_SUCCESS)
					{
						SetSecurityEnabled(FALSE);									
						Send("554  The SSL negotiation failed during the handshake");
						bQuit = TRUE;
						continue;
					} 
					else
					{
						bHandshakeDone =  TRUE;
						continue;
					}
				}
				else
					Send("454 TLS not available due to temporary reason\r\n");
#else

				Send("454 TLS not available due to temporary reason\r\n");
#endif

				continue;

			
			case CMD_SMTPMAIL:
				{
					if (!greeted)
					{
					  Send("503 Bad sequence of commands. Nice People Say Helo first\r\n");
					   continue;
					}

				// 				
				char firstString[WSS_LINE_BUFFER_SIZE];
                // Special case "MAIL FROM: <>"
                if (strstr(szBuffer,"<>")) {
                    strcpy(szMailFrom,szHeloName);
                }
				else {
					// Get number of components
					int counter = 0;
					int piecesCount= 0;
					piecesCount = CUT_StrMethods::GetParseStringPieces (szBuffer, "\t\b\v\f: ,\r\n");
					for (; counter < piecesCount;counter ++)
					{
						if ( CUT_StrMethods::ParseString (szBuffer,"\t\b\v\f: ,\r\n",counter, firstString,sizeof(firstString)) == UTE_SUCCESS)
						{
							// does it include an @ sign
							// then there should be 2 peices
							if (  CUT_StrMethods::GetParseStringPieces (firstString, "@")  > 1){
								// now remove the > and < signs from the email
								// this function call should pass even if the line does not include 
								// a <> tag
								CUT_StrMethods::ParseString (firstString,"<>",0, szMailFrom,sizeof(szMailFrom));
								break;
							}
						}
					}
					// if we have reached the number of peices 
					// then the from is not found
					// then we should let the client know of the error
					if (counter == piecesCount)
					{
					  Send("501 Syntax Error In Parameters Or Arguments.\r\n");
					  nCommand = nLastCommand ;
					  continue;
					}
				}
			    m_listRcpt.ClearList();

                // Send acknowlegment
				ZeroMemory( szBuffer, sizeof(szBuffer));
                _snprintf(szBuffer,sizeof(szBuffer)-1,"250 OK it is from %s\r\n",szMailFrom);
                Send(szBuffer);
				ptrMailServer->OnStatus(szBuffer);              
                continue;
				}
                
            case CMD_SMTPRCPT:
				{
				
					if (!greeted)
					{
					  Send("503 Bad sequence of commands. Nice People Say Helo first\r\n");
					  ptrMailServer->OnStatus("503 Bad sequence of commands. Nice People Say Helo first");;              
					   continue;
					}
					
                if(nLastCommand != CMD_SMTPRCPT && nLastCommand != CMD_SMTPMAIL) {
                    Send("503 Bad Sequence Of Commands.\r\n");
				   ptrMailServer->OnStatus("503 Bad sequence of commands.");;              
				
                    nCommand = nLastCommand ;
                    continue;
                    }

				// 				
				char firstString[WSS_LINE_BUFFER_SIZE];
				// Get number of components
				int counter = 0;
				int piecesCount= 0;
				piecesCount = CUT_StrMethods::GetParseStringPieces (szBuffer, "\t\b\v\f: ,\r\n");
				for (; counter < piecesCount;counter ++)
				{
					if ( CUT_StrMethods::ParseString (szBuffer,"\t\b\v\f: ,\r\n",counter, firstString,sizeof(firstString)) == UTE_SUCCESS)
					{
						// does it include an @ sign
						// then there should be 2 peices
						if (  CUT_StrMethods::GetParseStringPieces (firstString, "@")  > 1){
							// now remove the > and < signs from the email address
							// this function call should pass even if the line does not include 
							// a <> tag
							CUT_StrMethods::ParseString (firstString,"<>",0, szRcpt,sizeof(szRcpt));
							break;
						}
					}
				}
				// if we have reached the number of peices 
				// then the to is not found
				// then we should let the client know of the error
				if (counter == piecesCount)
				{
				  Send("501 Syntax Error In Parameters Or Arguments.\r\n");
			  	   ptrMailServer->OnStatus("501 Syntax Error In Parameters Or Arguments..");;              			
				  nCommand = nLastCommand ;
				  continue;
				}


				//	recipients buffer
				//	The maximum total number of recipients that must be
				//	buffered is 100 recipients.
				if (m_listRcpt.GetCount () >= 100)
				{
					Send("552 Too many recipients.\r\n");
					ptrMailServer->OnStatus("552 Too many recipients.");
					nCommand = nLastCommand ;
					continue;
				}

                // Add the name to the rcpt list
				// GetRelay here
				if (!CheckRelay(szMailFrom,szRcpt,szHeloName))
				{
					 Send("550 Relaying not allowed .\r\n");
				  	 ptrMailServer->OnStatus("550 Relaying not allowed.");				
					 nNumBadCommands++;
				 	  nCommand = nLastCommand ;
					  continue;
				}


                m_listRcpt.AddString(szRcpt);
                // Send acknowlegment
                Send("250 OK it is for ");
                Send(szRcpt);
			    Send(" \r\n");

				ZeroMemory( szBuffer, sizeof(szBuffer));
             	_snprintf(szBuffer,sizeof(szBuffer)-1,"Ok so it is for %s" ,szRcpt);
				ptrMailServer->OnStatus(szBuffer);								 
                continue;
				}
            
		           
            case CMD_SMTPDATA:
                {
                if(nLastCommand != CMD_SMTPRCPT) {
                    Send("503 Bad Sequence Of Commands.\r\n");
					ptrMailServer->OnStatus("503 Bad Sequence Of Commands");
					 nNumBadCommands++;
			         continue;
                    }			

                Send("354 Start mail input, end with <CRLF>.<CRLF>\r\n");

                long fileHandle = ptrDataManager->Que_CreateFile();
                if(INVALID_HANDLE_VALUE == (void*)(ULONG_PTR)fileHandle) {

                    bQuit = TRUE;
                    // Hard kill - read what's left of transaction and discard...
					ZeroMemory( szBuffer, sizeof(szBuffer));
                    while(ReceiveLine(szBuffer,sizeof(szBuffer)-1));

                    Send("451 Requested action aborted - error in processing\r\n");
                    ptrMailServer->OnStatus("SMTPDATA error - Requested action aborted ");

                    break;
                    }

                BOOLEAN deleteFlag = FALSE;

                // Write the message header
                ptrDataManager->Que_WriteFileHeader(fileHandle,m_listRcpt.GetString(0L),szMailFrom,0,0);

                // Read lines in until  <CRLF>.<CRLF> and save it
                // Check header portion for message id - if none, 
                // add one.
                int     len;
                BOOL    IdOk            = FALSE;
                BOOL    EndOfHeaderSeen = FALSE;
				
				// the return path is the first thing to be written
				ptrDataManager->Que_WriteFile(fileHandle,(LPBYTE)szReceivedHeader,(int)strlen(szReceivedHeader));
				for(;;) {
					if(ptrMailServer->GetSMTPServer()->GetShutDownFlag())
						{
                        Send("421 Service not available, closing transmission channel\r\n");
                        ptrMailServer->OnStatus("421  Service not available, closing transmission channel");
                        deleteFlag = TRUE;
                        break;
                        }


					ZeroMemory( szBuffer, sizeof(szBuffer)-1);
                    len = ReceiveLine(szBuffer,sizeof(szBuffer)-1);

                    if(len <= 0) {
                        Send("554 Transaction failed\r\n");
                        ptrMailServer->OnStatus("SMTPDATA error 554 Transaction failed");
                        deleteFlag = TRUE;
                        break;
                        }
					


					// make sure we have enough chars
					if (szBuffer[0] != 0 && strlen(szBuffer) > 11) 
					{
						if(!EndOfHeaderSeen) 
						{
							if(_strnicmp(szBuffer, "Message-Id:",11) == 0)
								IdOk = TRUE;
                        }
					}

                 if(len < 3) 
				 {
                        EndOfHeaderSeen = TRUE;
                       
						   // Did this message have a valid ID?
                        if(!IdOk) {
                            char    szMsgID[WSS_LINE_BUFFER_SIZE + 1];      

                            // Create a unique ID and write to the file!
                            ptrMailServer->BuildUniqueID(szMsgID, sizeof(szMsgID)-1);
                            ptrDataManager->Que_WriteFile(fileHandle,(LPBYTE)"Message-ID: ",12);
                            strcat(szMsgID, "\r\n");
                            ptrDataManager->Que_WriteFile(fileHandle,(LPBYTE)szMsgID, (int)strlen(szMsgID));
                            IdOk = TRUE;
                            }
				 }
				

                    ptrDataManager->Que_WriteFile(fileHandle,(LPBYTE)szBuffer,len);

                    if(len == 3)
					{
                        if(szBuffer[0]=='.' && szBuffer[1]=='\r' && szBuffer[2]=='\n')
						{
                            Send("250 Mail Received OK\r\n");
                            break;
						}
					}
                    
                }
                ptrMailServer->OnStatus("Data finished");
				
				// Make sure that the server is not relaying messages to itself,
				// it is possible for the server to relay a message to itself
				// when the destination of the email contains a domain name
				// that resolves to the same IP as the server but the names
				// are different.

				// v4.2 using AC here - names now _TCHAR")
				if ( strcmp( AC(ptrMailServer->Sys_GetLocalName(0)), szHeloName ) == 0 )
				{
					// Bad message found, receive it but also delete it from the queue
					// to prevent further resending of the message.
					deleteFlag = TRUE;
				}

                // Get the number of rcpt to lines
                // Copy the original file for each rcpt in the rcpt list
                if(!deleteFlag)
                    for(int loop = 1;loop < m_listRcpt.GetCount(); loop++)      // bypass first - it's done
                        ptrDataManager->Que_CarbonCopyFile(fileHandle,m_listRcpt.GetString(loop));
                
                // Close the file                
                ptrDataManager->Que_CloseFile(fileHandle,deleteFlag);

                continue;
                }           
            default:
                Send("502 Command not implemented\r\n");

                // Break after 5 unreconized commands
                nNumBadCommands ++;
                if(nNumBadCommands == 5) {
                    bQuit = TRUE;
                    break;
                    }
            
            }
        }
		CloseConnection();
}
Example #21
0
/*
 * Handle read modes: 'x', 't' and 'p'.
 */
static void
read_archive(struct bsdar *bsdar, char mode)
{
	struct archive		 *a;
	struct archive_entry	 *entry;
	struct stat		  sb;
	struct tm		 *tp;
	const char		 *bname;
	const char		 *name;
	mode_t			  md;
	size_t			  size;
	time_t			  mtime;
	uid_t			  uid;
	gid_t			  gid;
	char			**av;
	char			  buf[25];
	char			  find;
	int			  flags, r, i;

	if ((a = archive_read_new()) == NULL)
		bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed");
	archive_read_support_format_ar(a);
	AC(archive_read_open_filename(a, bsdar->filename, DEF_BLKSZ));

	for (;;) {
		r = archive_read_next_header(a, &entry);
		if (r == ARCHIVE_WARN || r == ARCHIVE_RETRY ||
		    r == ARCHIVE_FATAL)
			bsdar_warnc(bsdar, archive_errno(a), "%s",
			    archive_error_string(a));
		if (r == ARCHIVE_EOF || r == ARCHIVE_FATAL)
			break;
		if (r == ARCHIVE_RETRY) {
			bsdar_warnc(bsdar, 0, "Retrying...");
			continue;
		}

		if ((name = archive_entry_pathname(entry)) == NULL)
			break;

		/* Skip pseudo members. */
		if (strcmp(name, "/") == 0 || strcmp(name, "//") == 0 ||
		    strcmp(name, "/SYM64/") == 0)
			continue;

		if (bsdar->argc > 0) {
			find = 0;
			for(i = 0; i < bsdar->argc; i++) {
				av = &bsdar->argv[i];
				if (*av == NULL)
					continue;
				if ((bname = basename(*av)) == NULL)
					bsdar_errc(bsdar, EX_SOFTWARE, errno,
					    "basename failed");
				if (strcmp(bname, name) != 0)
					continue;

				*av = NULL;
				find = 1;
				break;
			}
			if (!find)
				continue;
		}

		if (mode == 't') {
			if (bsdar->options & AR_V) {
				md = archive_entry_mode(entry);
				uid = archive_entry_uid(entry);
				gid = archive_entry_gid(entry);
				size = archive_entry_size(entry);
				mtime = archive_entry_mtime(entry);
				(void)strmode(md, buf);
				(void)fprintf(stdout, "%s %6d/%-6d %8ju ",
				    buf + 1, uid, gid, (uintmax_t)size);
				tp = localtime(&mtime);
				(void)strftime(buf, sizeof(buf),
				    "%b %e %H:%M %Y", tp);
				(void)fprintf(stdout, "%s %s", buf, name);
			} else
				(void)fprintf(stdout, "%s", name);
			r = archive_read_data_skip(a);
			if (r == ARCHIVE_WARN || r == ARCHIVE_RETRY ||
			    r == ARCHIVE_FATAL) {
				(void)fprintf(stdout, "\n");
				bsdar_warnc(bsdar, archive_errno(a), "%s",
				    archive_error_string(a));
			}

			if (r == ARCHIVE_FATAL)
				break;

			(void)fprintf(stdout, "\n");
		} else {
			/* mode == 'x' || mode = 'p' */
			if (mode == 'p') {
				if (bsdar->options & AR_V) {
					(void)fprintf(stdout, "\n<%s>\n\n",
					    name);
					fflush(stdout);
				}
				r = archive_read_data_into_fd(a, 1);
			} else {
				/* mode == 'x' */
				if (stat(name, &sb) != 0) {
					if (errno != ENOENT) {
						bsdar_warnc(bsdar, 0,
						    "stat %s failed",
						    bsdar->filename);
						continue;
					}
				} else {
					/* stat success, file exist */
					if (bsdar->options & AR_CC)
						continue;
					if (bsdar->options & AR_U &&
					    archive_entry_mtime(entry) <=
					    sb.st_mtime)
						continue;
				}

				if (bsdar->options & AR_V)
					(void)fprintf(stdout, "x - %s\n", name);
				/* Disallow absolute paths. */
				if (name[0] == '/') {
					bsdar_warnc(bsdar, 0,
					    "Absolute path '%s'", name);
					continue;
				}
				/* Basic path security flags. */
				flags = ARCHIVE_EXTRACT_SECURE_SYMLINKS |
				    ARCHIVE_EXTRACT_SECURE_NODOTDOT;
				if (bsdar->options & AR_O)
					flags |= ARCHIVE_EXTRACT_TIME;

				r = archive_read_extract(a, entry, flags);
			}

			if (r)
				bsdar_warnc(bsdar, archive_errno(a), "%s",
				    archive_error_string(a));
		}
	}
	AC(archive_read_close(a));
	AC(archive_read_free(a));
}
Example #22
0
#include "sdl.h"
#endif
#include "sdl-video.h"
#if NETWORK
#include "unix-netplay.h"
#endif

//
// Original version of sdl.c -- Not included in flash builds!
// 


DSETTINGS Settings;
CFGSTRUCT DriverConfig[]={
	#ifdef OPENGL
	AC(_stretchx),
	AC(_stretchy),
	AC(_opengl),
	AC(_openglip),
	#endif
	AC(Settings.special),
	AC(Settings.specialfs),
	AC(_doublebuf),
	AC(_xscale),
	AC(_yscale),
	AC(_xscalefs),
	AC(_yscalefs),
	AC(_bpp),
	AC(_efx),
	AC(_efxfs),
	AC(_fullscreen),
Example #23
0
A gsa(I t, I r, I n, I *s) { A z=ga(t,r,n,s); AC(z)=INT_MAX; R z; }
Example #24
0
   for(x=0;x<10;x++)
   {
    sprintf(buf,"GamePad #%d: %s",arg+1,str[x]);
    subcon(buf,&GamePadConfig[arg][x]);
   }
  }
  break;
 }

 ButtonConfigEnd();
}


CFGSTRUCT InputConfig[]={
        ACA(UsrInputType),
        AC(powerpadsc),
        AC(QuizKingButtons),
        AC(FTrainerButtons),
        AC(HyperShotButtons),
        AC(MahjongButtons),
        AC(GamePadConfig),
        AC(fkbmap),
        ENDCFGSTRUCT
};


static void InputCfg(char *text)
{
         if(!strncasecmp(text,"gamepad",strlen("gamepad")))
         {
          ConfigDevice(FCFGD_GAMEPAD,(text[strlen("gamepad")]-'1')&3);
Example #25
0
	ACS(recent_lua[3]),
	ACS(recent_lua[4]),

	ACS(recent_movie[0]),
	ACS(recent_movie[1]),
	ACS(recent_movie[2]),
	ACS(recent_movie[3]),
	ACS(recent_movie[4]),

	ACS(ramWatchRecent[0]),
	ACS(ramWatchRecent[1]),
	ACS(ramWatchRecent[2]),
	ACS(ramWatchRecent[3]),
	ACS(ramWatchRecent[4]),

	AC(gNoBGFillColor),
	AC(ntsccol),AC(ntsctint),AC(ntschue),

	NAC("palyo",pal_emulation),
	NAC("genie",genie),
	NAC("fs",fullscreen),
	NAC("vgamode",vmod),
	NAC("sound",soundo),
	NAC("sicon",status_icon),

    AC(newppu),

	NACS("odroms",directory_names[0]),
	NACS("odnonvol",directory_names[1]),
	NACS("odstates",directory_names[2]),
	NACS("odfdsrom",directory_names[3]),
Example #26
0
int CUT_HTTPServer::SetPath(LPCWSTR path) {
	return SetPath(AC(path));}
Example #27
0
    if(!ioctlsocket(Socket,FIONREAD,&beefie))
     if(beefie)
      NoWaiting|=2;
    return(1);
   }
   else
    return(0);
  }
  else
   return(0);
  }
  return 0;
}

CFGSTRUCT NetplayConfig[]={
        AC(remotetport),
        AC(netlocalplayers),
        ACS(netgamekey),
        ACS(netplayhost),
        ACS(netplaynick),
        ACS(netpassword),
        ENDCFGSTRUCT
};


static BOOL CALLBACK NetCon(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch(uMsg)
  {
   case WM_CLOSE:
                        GetSettings(hwndDlg);
Example #28
0
	int x;

	FTrainerData=0;

	for(x=0;x<12;x++)
	{
		if(DTestButton(&FTrainerButtons[x]))
			FTrainerData|=1<<x;
	}
}

int DWaitButton(HWND hParent, const uint8 *text, ButtConfig *bc);
int DWaitSimpleButton(HWND hParent, const uint8 *text);

CFGSTRUCT InputConfig[]={
	AC(powerpadsc),
	AC(QuizKingButtons),
	AC(FTrainerButtons),
	AC(HyperShotButtons),
	AC(MahjongButtons),
	AC(GamePadConfig),
	AC(GamePadPreset1),
	AC(GamePadPreset2),
	AC(GamePadPreset3),
	AC(fkbmap),
	AC(suborkbmap),
	ENDCFGSTRUCT
};

void InitInputStuff(void)
{
Example #29
0
int CUT_POP3Client::POP3Connect(LPCWSTR mailHost, LPCWSTR user, LPCWSTR password) {
	return POP3Connect( AC(mailHost), AC(user), AC(password));}
Example #30
0
File: gsubr.c Project: teyc/guile
     (while (<= i n)
       (generate-bytecode i)
       (setq i (1+ i)))))
*/
static const scm_t_uint32 subr_stub_code[] = {
  /* C-u 1 0 M-x generate-bytecodes RET */
  /* 0 arguments */
  A(0),

  /* 1 arguments */
  A(1), B(1),
  C(),

  /* 2 arguments */
  A(2), AB(1,1), B(2),
  AC(1), BC(1),

  /* 3 arguments */
  A(3), AB(2,1), AB(1,2), B(3),
  AC(2), ABC(1,1), BC(2),

  /* 4 arguments */
  A(4), AB(3,1), AB(2,2), AB(1,3), B(4),
  AC(3), ABC(2,1), ABC(1,2), BC(3),

  /* 5 arguments */
  A(5), AB(4,1), AB(3,2), AB(2,3), AB(1,4), B(5),
  AC(4), ABC(3,1), ABC(2,2), ABC(1,3), BC(4),

  /* 6 arguments */
  A(6), AB(5,1), AB(4,2), AB(3,3), AB(2,4), AB(1,5), B(6),