示例#1
0
int main(int argc, char *argv[]){
	who();
	log_out("pts/1");
	puts("======================================");
	who();
	return 0;
}
示例#2
0
文件: five99.c 项目: yrchen/Athena
int p_five()
{
   int i=0;
   srandom(time(0));

restart:
  setutmpmode(FIVE);
  showtitle("天地五子棋", BOARDNAME);

  outs("┌┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┐\n");
for(sum=0;sum<20;sum++)
  outs("├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤\n");
  outs("└┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┘\n");


   gotoxy(48,1); outs("=-=-=-=-=-=-=-=-=-=");
   gotoxy(48,2); outs("|   天地五子棋    |");
   gotoxy(48,3); outs("=-=-=-=-=-=-=-=-=-=");
   who(0); who(1);

   gotoxy(45,17); outs(" ↓↑→← >> 控制方向");
   gotoxy(45,18); outs("  空白鍵  >> 確定");
   gotoxy(45,19); outs("     2    >> 二號玩家換人");
   gotoxy(45,20); outs("     b    >> 悔棋");
   gotoxy(45,21); outs("     r    >> 重新開始");
   gotoxy(45,22); outs("     q    >> 離開");

   for(m=1;m<22;m++)
    for(n=1;n<22;n++)
      chess[m][n]=0;

   sum=fturn=0;
   m=n=mm=nn=11;
   for(;;)
   {
     if(role[fturn]==1)
     {
       int tmp=fplayer(fturn+1);
       if(tmp==1) goto restart;
       if(tmp==2) return;
     }
     else
     {
       int hk=think(fturn+1);
       if(hk)
       {
         i=show_win(hk);
         if(i=='q'||i=='n') return;
         goto restart;
       }
     }
     fturn=abs(fturn-1);
   }
}
示例#3
0
void create_parents( const fs::path &dpath )
{
  string     err( "create_parent(): " );
  fs::path       branch( dpath.branch_path() );
  string     who("create_parents");

  if( dpath.empty() ) {
    err.append( "cannot create an empty path." );

    throw CannotCreateParents( err );
  }
  else if( !exists(dpath) ) {
    if( branch.empty() ) create_directory( dpath );
    else if( !exists(branch) ) {
      create_parents( branch );
      create_directory( dpath );
    }
    else if( is_directory(branch) ) create_directory( dpath );
    else {
      err.append( branch.native_file_string() ); err.append( " is not a directory." );

      throw CannotCreateParents( err );
    }
  }
  else if( !is_directory(dpath) ) {
    err.append( dpath.native_file_string() ); err.append( " is not a directory." );

    throw CannotCreateParents( err );
  }

  return;
}
示例#4
0
int CYahooProto::Authorize( HANDLE hdbe )
{
	debugLogA("[YahooAuthAllow]");
	if ( !m_bLoggedIn ) {
		debugLogA("[YahooAuthAllow] Not Logged In!");
		return 1;
	}

	DBEVENTINFO dbei = { sizeof(dbei) };
	if (( dbei.cbBlob = db_event_getBlobSize(hdbe)) == -1 )
		return 1;

	dbei.pBlob = ( PBYTE )_alloca( dbei.cbBlob );
	if (db_event_get(hdbe, &dbei))
		return 1;

	if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
		return 1;

	if ( strcmp(dbei.szModule, m_szModuleName))
		return 1;

	/* Need to remove the buddy from our Miranda Lists */
	MCONTACT hContact = DbGetAuthEventContact(&dbei);
	if (hContact != NULL) {
		ptrA who( getStringA(hContact, YAHOO_LOGINID));
		if (who) {
			ptrA myid( getStringA(hContact, "MyIdentity"));
			debugLogA("Accepting buddy:%s", who);
			accept(myid, who, getWord(hContact, "yprotoid", 0));
		}
	}

	return 0;
}
示例#5
0
static mode_t
newmode(const char *ms, const mode_t pm)
{
	register mode_t	o, m, b;
	int	lock, setsgid = 0, cleared = 0, copy = 0;
	mode_t	nm, om, mm;

	nm = om = pm;
	m = absol(&ms);
	if (!*ms) {
		nm = m;
		goto out;
	}
	if ((lock = (nm&S_IFMT) != S_IFDIR && (nm&(S_ENFMT|S_IXGRP)) == S_ENFMT)
			== 01)
		nm &= ~(mode_t)S_ENFMT;
	do {
		m = who(&ms, &mm);
		while (o = what(&ms)) {
			b = where(&ms, nm, &lock, &copy, pm);
			switch (o) {
			case '+':
				nm |= b & m & ~mm;
				if (b & S_ISGID)
					setsgid = 1;
				if (lock & 04)
					lock |= 02;
				break;
			case '-':
				nm &= ~(b & m & ~mm);
				if (b & S_ISGID)
					setsgid = 1;
				if (lock & 04)
					lock = 0;
				break;
			case '=':
				nm &= ~m;
				nm |= b & m & ~mm;
				lock &= ~01;
				if (lock & 04)
					lock |= 02;
				om = 0;
				if (copy == 0)
					cleared = 1;
				break;
			}
			lock &= ~04;
		}
	} while (*ms++ == ',');
	if (*--ms)
		failed(&badumask[4], badumask);
out:	if (pm & S_IFDIR) {
		if ((pm & S_ISGID) && setsgid == 0)
			nm |= S_ISGID;
		else if ((nm & S_ISGID) && setsgid == 0)
			nm &= ~(mode_t)S_ISGID;
	}
	return(nm);
}
示例#6
0
void management::parseWhois()
{
    output::instance().addOutput("void management::parseWhois()");
    std::vector< std::string > data;
    while(m_Run)
    {
        data = m_IrcData->getWhoisQueue();
        if (data.size() >= 4)
        {
            if (data[1] == "001")   //welcome
            {
                g_BotNick = data[2];
            }
            if (data[1] == "307")       //WHOIS regged userName
            {
                if (m_NickServer)
                {
                    std::string userName = data[3];
                    std::string auth = data[3];
                    userAuth(userName, auth);
                }
            }
            if (data[1] == "318")       //WHOIS end
            {
                endWhois(data[3]);
            }
            if (data[1] == "330")       //WHOIS auth
            {
                if (!m_NickServer)
                {
                    std::string userName = data[3];
                    std::string auth = data[4];
                    userAuth(userName, auth);
                }
            }
            if (data[1] == "402")       //WHOIS no server
            {
                //WHOIS(data);
            }
        }
        if (data.size() == 7)
        {
            if (data[1] == "354")       //WHOEXTRA
            {
                whoextra(data);
            }
        }
        if (data.size() >= 11)
        {
            if (data[1] == "352")       //WHO
            {
                who(data);
            }
        }
    }
}
/*
  Initializes the global values. The global log file will be assigned the global
  write mutex. Then the IDS_SHARED_LOG_FILE_ID will be assigned the log file.
  Afterwards the logToScreen and debugMode will be set.
 */
void MessageHandlerFactory::init(string logFile, bool logToScreen, bool debugMode){
  /* creating and assigning the global mutex */
  pthread_mutex_t sharedLogMutex = PTHREAD_MUTEX_INITIALIZER;
  logFileMutex[logFile] = &sharedLogMutex; 
  
  /* assigning the global log file and setting the global values */
  string who( IDS_SHARED_LOG_FILE_ID );
  this->logFile[who] = logFile;
  this->logToScreen = logToScreen;
  this->debugMode = debugMode;
}
示例#8
0
int	channelwin::user_selected(const cstring &user) const
{
	int	size = userlist->size();

	for(int i = 0; i < size; i++)
	{
		cstring	who(userlist->get(i) + 1);
		if(who == user && userlist->selected(i))
			return true;
	}
	return false;
}
示例#9
0
int	channelwin::del_user(const cstring &user)
{
	int	size = userlist->size();

	for(int i = 0; i < size; i++)
	{
		cstring	who = userlist->get(i);
		cstring	stripped = who(1);
		if(stripped == user)
		{
			userlist->del(i);
			return i;
		}
	}
	return -1;
}
示例#10
0
文件: cmdlib.cpp 项目: Marqt/ViZDoom
FString NicePath(const char *path)
{
#ifdef _WIN32
	return ExpandEnvVars(path);
#else
	if (path == NULL || *path == '\0')
	{
		return FString("");
	}
	if (*path != '~')
	{
		return ExpandEnvVars(path);
	}

	const char *slash;
	FString where;

	if (path[1] == '/' || path[1] == '\0')
	{ // Get my home directory from environment var
		where = getenv("HOME");
		slash = path + 1;
	}
	else
	{ // Get somebody else's home directory, from getpwnam
		slash = strchr(path, '/');
		if (slash == NULL)
		{
			slash = path + strlen(path);
		}
		FString who(path, slash - path);
		passwd *pwstruct = getpwnam(who);

		if (pwstruct == NULL)
		{
			return ExpandEnvVars(path);
		}
		where = pwstruct->pw_dir;
	}
	if (*slash != '\0')
	{
		where += ExpandEnvVars(slash);
	}
	return where;
#endif
}
示例#11
0
FString NicePath(const char *path)
{
#ifdef _WIN32
	return ExpandEnvVars(path);
#else
	if (path == NULL || *path == '\0')
	{
		return FString("");
	}
	if (*path != '~')
	{
		return ExpandEnvVars(path);
	}

	passwd *pwstruct;
	const char *slash;

	if (path[1] == '/' || path[1] == '\0')
	{ // Get my home directory
		pwstruct = getpwuid(getuid());
		slash = path + 1;
	}
	else
	{ // Get somebody else's home directory
		slash = strchr(path, '/');
		if (slash == NULL)
		{
			slash = path + strlen(path);
		}
		FString who(path, slash - path);
		pwstruct = getpwnam(who);
	}
	if (pwstruct == NULL)
	{
		return ExpandEnvVars(path);
	}
	FString where(pwstruct->pw_dir);
	if (*slash != '\0')
	{
		where += ExpandEnvVars(slash);
	}
	return where;
#endif
}
示例#12
0
int CYahooProto::AuthDeny( HANDLE hdbe, const TCHAR* reason )
{
	debugLogA("[YahooAuthDeny]");
	if ( !m_bLoggedIn )
		return 1;

	DBEVENTINFO dbei = { sizeof( dbei ) };
	if (( dbei.cbBlob = db_event_getBlobSize(hdbe)) == -1 ) {
		debugLogA("[YahooAuthDeny] ERROR: Can't get blob size");
		return 1;
	}

	dbei.pBlob = ( PBYTE )alloca( dbei.cbBlob );
	if (db_event_get(hdbe, &dbei)) {
		debugLogA("YahooAuthDeny - Can't get db event!");
		return 1;
	}

	if (dbei.eventType != EVENTTYPE_AUTHREQUEST) {
		debugLogA("YahooAuthDeny - not Authorization event");
		return 1;
	}

	if (strcmp( dbei.szModule, m_szModuleName)) {
		debugLogA("YahooAuthDeny - wrong module?");
		return 1;
	}

	/* Need to remove the buddy from our Miranda Lists */
	MCONTACT hContact = DbGetAuthEventContact(&dbei);
	if (hContact != NULL) {
		ptrA who( getStringA(hContact, YAHOO_LOGINID));
		if (who) {
			ptrA myid( getStringA(hContact, "MyIdentity"));
			ptrA u_reason( mir_utf8encodeT(reason));

			debugLogA("Rejecting buddy:%s msg: %s", who, u_reason);
			reject(myid, who, getWord(hContact, "yprotoid", 0), u_reason);
			CallService(MS_DB_CONTACT_DELETE, hContact, 0);
		}
	}
	return 0;
}
示例#13
0
int parseInput(char * input) {
	
	const char * delim = " \n";
	char * tok = (char*) malloc(sizeof(char)*(strlen(input) + 1));

	// copy input string to tok
	strcpy(tok, input);
	
	// get commands using strok and delim
	char * getCommand = strtok(tok, delim);


	if(getCommand == NULL) {
		return false;
	}

	int result = false;

	// find what command and then call proper function
	if( 0 == strcmp(getCommand, "/join")) {
		char * channel = strtok(NULL, delim);
		result = join(channel);
	} else if ( 0 == strcmp(getCommand, "/leave")) {
		char * channel = strtok(NULL, delim);
		result = leave(channel);
	} else if ( 0 == strcmp(getCommand, "/who")) {
		char * channel = strtok(NULL, delim);
		result = who(channel);
	} else if ( 0 == strcmp(getCommand, "/list")) {
		result = list();
	} else if ( 0 == strcmp(getCommand, "/exit")) {
		result = logout();
	} else if ( 0 == strcmp(getCommand, "/switch")) {
		char * channel = strtok(NULL, delim);
		result = handleSwitch(channel);
	} else { // this is where /say is handled
		result = say(input);
	}
	
	free(tok);
	return result;
}
示例#14
0
int __cdecl CSteamProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam)
{
	switch (eventType)
	{
	case EV_PROTO_ONLOAD:
		return this->OnModulesLoaded(wParam, lParam);

	case EV_PROTO_ONEXIT:
		return this->OnPreShutdown(wParam, lParam);

	/*case EV_PROTO_ONOPTIONS:
		return this->OnOptionsInit(wParam, lParam);*/

	case EV_PROTO_ONCONTACTDELETED:
		if (IsOnline())
		{
			MCONTACT hContact = (MCONTACT)wParam;

			ptrA token(getStringA("TokenSecret"));
			ptrA sessionId(getStringA("SessionID"));
			ptrA steamId(getStringA("SteamID"));
			ptrA who(getStringA(hContact, "SteamID"));

			// Don't request delete contact from server when we're not friends anyway
			if (getByte(hContact, "Auth", 0) != 0)
				return 0;

			PushRequest(
				new RemoveFriendRequest(token, sessionId, steamId, who),
				&CSteamProto::OnFriendRemoved,
				(void*)hContact);
		}
		return 0;

	case EV_PROTO_ONMENU:
		this->OnInitStatusMenu();
		break;
	}

	return 1;
}
示例#15
0
int CSteamProto::AuthRequest(MCONTACT hContact, const TCHAR*)
{
	if (IsOnline() && hContact)
	{
		UINT hAuth = InterlockedIncrement(&hAuthProcess);

		SendAuthParam *param = (SendAuthParam*)mir_calloc(sizeof(SendAuthParam));
		param->hContact = hContact;
		param->hAuth = (HANDLE)hAuth;

		//ForkThread(&CSteamProto::AddContactThread, param);

		ptrA token(getStringA("TokenSecret"));
		ptrA sessionId(getStringA("SessionID"));
		ptrA steamId(getStringA("SteamID"));
		ptrA who(getStringA(hContact, "SteamID"));

		/*
		posilame: (kdyz my zadame)
		sessionID	MjYzNDM4NDgw
		steamid	76561198166125402
		accept_invite	0

		pri uspesnem pozadavku vrati: {"invited":["76561198166125402"],"success":1}
		kdyz nas ignoruje: {"failed_invites":["76561198166125402"],"failed_invites_result":[41],"success":1}

		*/

		PushRequest(
			new AddFriendRequest(token, sessionId, steamId, who),
			&CSteamProto::OnFriendAdded,
			param);

		return hAuth;
	}

	return 1;
}
示例#16
0
文件: id.c 项目: 2asoft/freebsd
int
main(int argc, char *argv[])
{
	struct group *gr;
	struct passwd *pw;
	int Gflag, Mflag, Pflag, ch, gflag, id, nflag, pflag, rflag, uflag;
	int Aflag, cflag;
	int error;
	const char *myname;
	char loginclass[MAXLOGNAME];

	Gflag = Mflag = Pflag = gflag = nflag = pflag = rflag = uflag = 0;
	Aflag = cflag = 0;

	myname = strrchr(argv[0], '/');
	myname = (myname != NULL) ? myname + 1 : argv[0];
	if (strcmp(myname, "groups") == 0) {
		isgroups = 1;
		Gflag = nflag = 1;
	}
	else if (strcmp(myname, "whoami") == 0) {
		iswhoami = 1;
		uflag = nflag = 1;
	}

	while ((ch = getopt(argc, argv,
	    (isgroups || iswhoami) ? "" : "APGMacgnpru")) != -1)
		switch(ch) {
#ifdef USE_BSM_AUDIT
		case 'A':
			Aflag = 1;
			break;
#endif
		case 'G':
			Gflag = 1;
			break;
		case 'M':
			Mflag = 1;
			break;
		case 'P':
			Pflag = 1;
			break;
		case 'a':
			break;
		case 'c':
			cflag = 1;
			break;
		case 'g':
			gflag = 1;
			break;
		case 'n':
			nflag = 1;
			break;
		case 'p':
			pflag = 1;
			break;
		case 'r':
			rflag = 1;
			break;
		case 'u':
			uflag = 1;
			break;
		case '?':
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	if (iswhoami && argc > 0)
		usage();

	switch(Aflag + Gflag + Mflag + Pflag + gflag + pflag + uflag) {
	case 1:
		break;
	case 0:
		if (!nflag && !rflag)
			break;
		/* FALLTHROUGH */
	default:
		usage();
	}

	pw = *argv ? who(*argv) : NULL;

	if (Mflag && pw != NULL)
		usage();

#ifdef USE_BSM_AUDIT
	if (Aflag) {
		auditid();
		exit(0);
	}
#endif

	if (cflag) {
		error = getloginclass(loginclass, sizeof(loginclass));
		if (error != 0)
			err(1, "loginclass");
		(void)printf("%s\n", loginclass);
		exit(0);
	}

	if (gflag) {
		id = pw ? pw->pw_gid : rflag ? getgid() : getegid();
		if (nflag && (gr = getgrgid(id)))
			(void)printf("%s\n", gr->gr_name);
		else
			(void)printf("%u\n", id);
		exit(0);
	}

	if (uflag) {
		id = pw ? pw->pw_uid : rflag ? getuid() : geteuid();
		if (nflag && (pw = getpwuid(id)))
			(void)printf("%s\n", pw->pw_name);
		else
			(void)printf("%u\n", id);
		exit(0);
	}

	if (Gflag) {
		group(pw, nflag);
		exit(0);
	}

	if (Mflag) {
		maclabel();
		exit(0);
	}

	if (Pflag) {
		pline(pw);
		exit(0);
	}

	if (pflag) {
		pretty(pw);
		exit(0);
	}

	if (pw) {
		id_print(pw, 1, 0, 0);
	}
	else {
		id = getuid();
		pw = getpwuid(id);
		id_print(pw, 0, 1, 1);
	}
	exit(0);
}
示例#17
0
int main(int argc, char **argv)
{
_comm_header *comm;
_tag_detail *tag;
_path *path;
_rack *rack;
_services *services;
//_backplane_data *backplane;
int result,x,debug=0;

result = 0;

  while ((x = getopt(argc, argv, "dh?")) != -1)
  {
    switch (x)
    {
    case 'd':
      debug++;
      break;
    case 'h':
    case '?':
      helpme();
      exit(1);
    }
  }


	
// Note that this is quick and dirty - no error checking...

tag = malloc(sizeof(_tag_detail));
memset(tag,0,sizeof(_tag_detail));

rack = malloc(sizeof(_rack));
memset (rack,0,sizeof(_rack));

//backplane = malloc(sizeof(_backplane_data));
//memset (backplane,0,sizeof(_backplane_data));

path = malloc(sizeof(_path));
memset (path,0,sizeof(_path));

services = malloc(sizeof(_services));
memset (services,0,sizeof(_services));

comm = malloc(sizeof(_comm_header));
memset (comm,0,sizeof(_comm_header));

dprint (DEBUG_TRACE,"setting plc name %d %s.\n",strlen(argv[1]), argv[1]);
comm->hostname = argv[1];
dprint (DEBUG_TRACE,"attaching to plc\n");

establish_connection (comm, services, 0);
if (comm->error != 0)
	{
	printf ("Could not attach to %s\n",argv[1]);
	exit(-1);
	}
path->device1 = -1;
path->device2 = -1;
path->device3 = -1;
path->device4 = -1;
path->device5 = -1;
path->device6 = -1;
path->device7 = -1;
path->device8 = -1;

//get_backplane_data(comm, backplane, rack, path, 0);
dprint (DEBUG_TRACE,"polling PLC rack layout\n");
who(comm, rack, NULL, 0);
path->device1 =1;
path->device2 = rack->cpulocation;
dprint (DEBUG_TRACE,"reading tag\n");
if (argc == 3)
	result = read_tag(comm, path, NULL, argv[2], tag, 0);
if (argc == 4)
	result = read_tag(comm, path, argv[3], argv[2], tag, 0);

if (result != 0)
	{
	printf ("reading tag %s failed - does it exist?\n\n",argv[2]);
	exit(-1);
	}
for (x=0; x<tag->datalen; x++)
	printf ("%02X ",tag->data[x]);
printf ("\n\n");
exit(0);
}
示例#18
0
 const call_order_object* borrow(account_id_type who, asset what, asset collateral)
 { return borrow(who(db), what, collateral); }
示例#19
0
void check_clients(pool *pool)
{
    int i, receiveByteNum;
    char buf[MAXLINE];
    rio_t rio;
    for(i = 0; (i <= pool->maxi) && (pool->nready > 0); i++)
    {
        int conn_fd = pool->clientfd[i];
        /* Check if it is ready */
        if((conn_fd > 0) && (FD_ISSET(conn_fd, &pool->ready_set)))
        {
            pool->nready--;
            rio = pool->clientrio[i];
            if((receiveByteNum = Rio_readlineb(&rio, buf, MAXLINE)) != 0)
            {
                byte_cnt += receiveByteNum;
                printf("Server received %d (%d total) bytes on fd %d\n", receiveByteNum, byte_cnt, conn_fd);
                Rio_writen(conn_fd, buf, receiveByteNum);
                char msg[MAX_MSG_LEN];
                size_t message_len;
                if((message_len =  get_msg(buf, msg)) < 0)
                    app_error("message too long");
                printf("The command you input is: %s\n", msg);
                char tokens[MAX_MSG_TOKENS][MAX_MSG_LEN+1];
                int token_len = tokenize(msg, tokens);
                int command_type = get_command(tokens, token_len);
                switch(command_type)
                {
                    case 1: 
                            if(token_len == 2)
                            {
                                nick(conn_fd, tokens[1]);
                            }
                            else
                            {
                                sprintf(buf, "The command should be like: NICK <nickname>.\n");
                                Write(conn_fd, buf, strlen(buf));
                            }
                            break;
                    case 2: if(token_len == 4)
                            {
                                user(conn_fd, tokens[1], tokens[2], tokens[3]);
                            }
                            else
                            {
                                sprintf(buf, "ERR_NEEDMOREPARAMS. The command should be like: USER <username> <hostname> <servername> <realname>.\n");
                                Write(conn_fd, buf, strlen(buf));
                            }
                            break;
                    case 3: quit(conn_fd); break;
                    case 4: if(token_len == 2)
                            {
                                join(conn_fd, tokens[1]);
                            }
                            else
                            {
                                sprintf(buf, "ERR_NEEDMOREPARAMS. The command should be like: JOIN <channelname>.\n");
                                Write(conn_fd, buf, strlen(buf));
                            }
                            break;
                    case 5: if(token_len == 2)
                            {
                                part(conn_fd, tokens[1]);
                            }
                            else
                            {
                                sprintf(buf, "ERR_NEEDMOREPARAMS. The command should be like: PART <channelname>.\n");
                                Write(conn_fd, buf, strlen(buf));
                            }
                            break;
                    case 6: list(conn_fd);
                            break;
                    case 7: if(token_len == 3)
                            {
                                privmsg(conn_fd, tokens[1], tokens[2]);
                            }
                            else
                            {
                                sprintf(buf, "ERR_NEEDMOREPARAMS. The command should be like: PRIVMSG <nickname/channelname>.\n");
                                Write(conn_fd, buf, strlen(buf));
                            }
                            break;
                    case 8: if(token_len == 2)
                            {
                                who(conn_fd, tokens[1]);
                            }
                            else
                            {
                                sprintf(buf, "ERR_NEEDMOREPARAMS. The command should be like: WHO <nickname/channelname>.\n");
                                Write(conn_fd, buf, strlen(buf));
                            }
                            break;
                    default: 
                            sprintf(buf, "The command you input %s is not understandable!\n", msg);
                            Write(conn_fd, buf, strlen(buf));
                            break;
                }
            }
            /* EOF detected, remove descriptor from pool */
            else
            {
                Close(conn_fd);
                FD_CLR(conn_fd, &pool->read_set);
                pool->clientfd[i] = -1;
                pool->clients[conn_fd].conn_fd = -1;
            }
        }
    }
}
示例#20
0
void AsiMS2000::selectCommand(int commandNum)
{
  switch(commandNum)
  {
      case 0:
          accel();
          break;
      case 1:
          aalign();
          break;
      case 2:
          afcont();
          break;
      case 3:
          aflim();
          break;
      case 4:
          afocus();
          break;
      case 5:
          afset();
          break;
      case 6:
          afmove();
          break;
      case 7:
          ahome();
          break;
      case 8:
          aij();
          break;
      case 9:
          array();
          break;
      case 10:
          azero();
          break;
      case 11:
          backlash();
          break;
      case 12:
          bcustom();
          break;
      case 13:
          benable();
          break;
      case 14:
          build();
          break;
      case 15:
          cdate();
          break;
      case 16:
          cnts();
          break;
      case 17:
          customa();
          break;
      case 18:
          customb();
          break;
      case 19:
          dack();
          break;
      case 20:
          dump();
          break;
      case 21:
          ensync();
          break;
      case 22:
          epolarity();
          break;
      case 23:
          error();
          break;
      case 24:
          halt();
          break;
      case 25:
          here();
          break;
      case 26:
          home();
          break;
      case 27:
          info();
          break;
      case 28:
          joystick();
          break;
      case 29:
          jsspd();
          break;
      case 30:
          kadc();
          break;
      case 31:
          kd();
          break;
      case 32:
          ki();
          break;
      case 33:
          kp();
          break;
      case 34:
          lcd();
          break;
      case 35:
          led();
          break;
      case 36:
          lladdr();
          break;
      case 37:
          load();
          break;
      case 38:
          lock();
          break;
      case 39:
          lockrg();
          break;
      case 40:
          lockset();
          break;
      case 41:
          maintain();
          break;
      case 42:
          motctrl();
          break;
      case 43:
          move();
          break;
      case 44:
          movrel();
          break;
      case 45:
          pcros();
          break;
      case 46:
          pedal();
          break;
      case 47:
          rbmode();
          break;
      case 48:
          rdadc();
          break;
      case 49:
          rdsbyte();
          break;
      case 50:
          rdstat();
          break;
      case 51:
          relock();
          break;
      case 52:
          reset();
          break;
      case 53:
          rt();
          break;
      case 54:
          runaway();
          break;
      case 55:
          saveset();
          break;
      case 56:
          savepos();
          break;
      case 57:
          scan();
          break;
      case 58:
          scanr();
          break;
      case 59:
          scanv();
          break;
      case 60:
          secure();
          break;
      case 61:
          sethome();
          break;
      case 62:
          setlow();
          break;
      case 63:
          setup();
          break;
      case 64:
          si();
          break;
      case 65:
          speed();
          break;
      case 66:
          spin();
          break;
      case 67:
          status();
          break;
      case 68:
          stopbits();
          break;
      case 69:
          ttl();
          break;
      case 70:
          um();
          break;
      case 71:
          units();
          break;
      case 72:
          unlock();
          break;
      case 73:
          vb();
          break;
      case 74:
          vector();
          break;
      case 75:
          version();
          break;
      case 76:
          wait();
          break;
      case 77:
          where();
          break;
      case 78:
          who();
          break;
      case 79:
          wrdac();
          break;
      case 80:
          zero();
          break;
      case 81:
          z2b();
          break;
      case 82:
          zs();
          break;
      case 83:
          overshoot();
          break;
  }
}
示例#21
0
文件: pipe-m.c 项目: webushka/reduce
pmelden(char * fmt,char * p1, char * p2)
   {
      char str[100];
      sprintf(str,fmt,who(),p1,p2);
      if(slave_mode) puts(str); else my_puts(str);
   } 
示例#22
0
文件: cell.c 项目: 376473984/pvb
int main(int argc, char **argv)
{
  _comm_header *comm;
  _path *path;
  _services *services;
  _backplane_data *backplane;
  _rack *rack;
  _tag_data *configtags, *detailtags;
  _tag_data *program_tags[64];
  _tag_list *list;
  _prog_list *progs;
  _struct_list *structs;
  int x, y, z, debug, program_count, quiet, result;
  int c1 = 0, c68 = 0, c69 = 0;
#ifdef WIN32
  int optind = 1;
  debug = DEBUG_DATA;
#endif

#ifndef WIN32
  debug = 0;
#endif

  program_count = 0;
  quiet = FALSE;
  if (argc == 1)
  {
    helpme();
    exit(1);
  }
#ifndef WIN32
  while ((x = getopt(argc, argv, "dhq?")) != -1)
  {
    switch (x)
    {
    case 'd':
      debug++;
      break;
    case 'q':
      quiet = TRUE;
      break;
    case 'h':
    case '?':
      helpme();
      exit(1);
    }
  }

#endif

  if (argv[optind] == NULL)
  {
    printf("Can not connect - need a host name to connect to.\n");
    exit(-1);
  }

  rack = malloc(sizeof(_rack));
  if (rack == NULL)
  {
    printf("Could not allocate memory for rack structure.\n");
    exit(-1);
  }

  comm = malloc(sizeof(_comm_header));
  if (comm == NULL)
  {
    printf("Could not allocate memory for comm header.\n");
    exit(-1);
  }
  services = malloc(sizeof(_services));
  if (services == NULL)
  {
    printf("Could not allocate memory for services structure.\n");
    free(comm);
    exit(-1);
  }

  backplane = malloc(sizeof(_backplane_data));
  if (backplane == NULL)
  {
    printf("Could not allocate memory for backplane structure.\n");
    free(comm);
    free(services);
    exit(-1);
  }
  path = malloc(sizeof(_path));
  if (path == NULL)
  {
    printf("Could not allocate memory for path structure.\n");
    free(backplane);
    free(comm);
    free(services);
    exit(-1);
  }
  configtags = malloc(sizeof(_tag_data));
  if (configtags == NULL)
  {
    printf("Could not allocate memory for configtags structure.\n");
    free(path);
    free(backplane);
    free(comm);
    free(services);
    exit(-1);
  }
  detailtags = malloc(sizeof(_tag_data));
  if (detailtags == NULL)
  {
    printf("Could not allocate memory for detailtags structure.\n");
    free(path);
    free(backplane);
    free(comm);
    free(services);
    exit(-1);
  }
  progs = malloc(sizeof(_prog_list));
  if (progs == NULL)
  {
    printf("Could not allocate memory for program list structure.\n");
    free(detailtags);
    free(path);
    free(backplane);
    free(comm);
    free(services);
    exit(-1);
  }
  structs = malloc(sizeof(_struct_list));
  if (structs == NULL)
  {
    printf("Could not allocate memory for structure list.\n");
    exit(-1);
  }
  list = malloc(sizeof(_tag_list));
  if (list == NULL)
  {
    printf ("Could not allocate memory for tag list.\n");
    exit(-1);
  }



  memset(services, 0, sizeof(_services));
  memset(comm, 0, sizeof(_comm_header));
  memset(backplane, 0, sizeof(_backplane_data));
  memset(rack, 0, sizeof(_rack));
  memset(configtags, 0, sizeof(_tag_data));
  memset(detailtags, 0, sizeof(_tag_data));
  memset(progs, 0, sizeof(_prog_list));
  memset(structs, 0, sizeof(_struct_list));
  memset(list, 0, sizeof(_tag_list));

  comm->hostname = argv[optind];
  if (quiet == FALSE)
    printf("Connecting to host %s\n", comm->hostname);
  establish_connection(comm, services, debug);
  if (comm->error != OK)
  {
    printf("An Error occured while connecting to host %s.\n", comm->hostname);
    exit(-1);
  }

  path->device1 = -1;
  path->device2 = -1;
  path->device3 = -1;
  path->device4 = -1;
  path->device5 = -1;
  path->device6 = -1;
  path->device7 = -1;
  path->device8 = -1;

  if (quiet == FALSE)
    printf("Got Session_ID = %ld\n", comm->session_id);
  get_backplane_data(comm, backplane, rack, path, debug);
  if (debug != DEBUG_NIL)
  {
    dprint(DEBUG_VALUES, "RX_Bad_m :%02X     ", backplane->rx_bad_m);
    dprint(DEBUG_VALUES, "ERR+Threshold: %02X     ",
	   backplane->err_threshold);
    dprint(DEBUG_VALUES, "RX_Bad_CRC :%02X    ", backplane->rx_bad_crc);
    dprint(DEBUG_VALUES, "RX_Bus_Timeout :%02X\n", backplane->rx_bus_timeout);
    dprint(DEBUG_VALUES, "TX_Bad_CRC :%02X   ", backplane->tx_bad_crc);
    dprint(DEBUG_VALUES, "TX_Bus_Timeout :%02X   ",
	   backplane->tx_bus_timeout);
    dprint(DEBUG_VALUES, "TX_Retry :%02X\n", backplane->tx_retry);
    dprint(DEBUG_VALUES, "Status :%02X    ", backplane->status);
    dprint(DEBUG_VALUES, "Address :%04X\n", backplane->address);
    dprint(DEBUG_VALUES, "Major Rev :%02X  ", backplane->rev_major);
    dprint(DEBUG_VALUES, "Minor Rev :%02X  ", backplane->rev_minor);
    dprint(DEBUG_VALUES, "Serial Number :%08lX  ", backplane->serial_number);
    dprint(DEBUG_VALUES, "Backplane size :%d\n", backplane->rack_size);
  }
  who(comm, rack, NULL, debug);
  path->device1 = 1;
  path->device2 = rack->cpulocation;
  path->device3 = -1;
  path->device4 = -1;
  path->device5 = -1;
  path->device6 = -1;
  path->device7 = -1;
  path->device8 = -1;

  get_object_config_list(comm, path, 0, configtags, debug);
  get_object_details_list(comm, path, 0, detailtags, debug);
  get_program_list(comm, path, progs, debug);
/*  get_struct_list(comm, path, structs, debug);


printf ("Got %d structs in the program.\n",structs->count);
for (x=0;x<structs->count; x++)
	{
	printf ("Struct #%02d, type id = %08lX\n",x,structs->base[x]->base);
	get_struct_config (comm, path, structs->base[x], debug);
	get_struct_details (comm, path, structs->base[x], debug);
	printf ("Element count = %d    Detail size = %d\n",structs->base[x]->count, structs->base[x]->detailsize);
	printf ("Element link-id = %04X\n",structs->base[x]->linkid);
	printf ("Structure base name = %s\n",structs->base[x]->name);
	for (y=0;y<structs->base[x]->count;y++)
		{
		printf ("Element #%d, type = %04X, arraysize = %d name = %s\n",y,structs->base[x]->data[y]->type, structs->base[x]->data[y]->arraysize, structs->base[x]->data[y]->name);
		}
	printf ("----------------------------------------\n");
	}

exit;
*/

  y = detailtags->count;
  if (configtags->count > y)
    y = configtags->count;

  printf("Reading tags from ControlLogix...\n");
  for (z = 0; z < y; z++)
  {
    if (z < detailtags->count)
      get_object_details(comm, path, detailtags->tag[z], debug);
    if (z < configtags->count)
      get_object_config(comm, path, configtags->tag[z], debug);
    printf
      ("%08lX - %08lX - %08lX - %08lX - %04X - %04X - %04X - %s - %ld - %ld - %ld - %ld\n",
       detailtags->tag[z]->topbase, detailtags->tag[z]->base,
       detailtags->tag[z]->id, detailtags->tag[z]->linkid,
       detailtags->tag[z]->size, detailtags->tag[z]->type,
       detailtags->tag[z]->alias_type, detailtags->tag[z]->name,
       detailtags->tag[z]->alias_linkid - detailtags->tag[z]->linkid,
       detailtags->tag[z]->arraysize1, detailtags->tag[z]->arraysize2,
       detailtags->tag[z]->arraysize3);

  }
  printf("Checking for aliases...\n");

  for (z = 0; z < detailtags->count; z++)
    aliascheck(detailtags->tag[z], NULL, detailtags, DEBUG_VALUES);

  for (z = 0; z < y; z++)
  {
    if (z < detailtags->count)
    {
    switch (detailtags->tag[z]->type & 255)
      {
      case 0x68:
      case 0x69:
	break;
      default:
	read_object_value(comm, path, detailtags->tag[z], debug);
      }

      if (detailtags->tag[z]->topbase != 0)
	c1++;
      if (z < detailtags->count)
      {
	printf
	  ("%08lX - %08lX - %08lX - %08lX - %08lX - %08lX - %04lX - %04X - %04X - %s - %ld - %ld - %ld - %ld\n",
	   detailtags->tag[z]->topbase, detailtags->tag[z]->base,
	   detailtags->tag[z]->id, detailtags->tag[z]->linkid,
	   detailtags->tag[z]->alias_topbase, detailtags->tag[z]->alias_base,
	   detailtags->tag[z]->alias_id, detailtags->tag[z]->type,
	   detailtags->tag[z]->alias_type, detailtags->tag[z]->name,
	   detailtags->tag[z]->alias_linkid - detailtags->tag[z]->linkid,
	   detailtags->tag[z]->arraysize1, detailtags->tag[z]->arraysize2,
	   detailtags->tag[z]->arraysize3);
      }
      if (z < configtags->count)
      {
	printf("%08lX - %08lX - %04X\n", configtags->tag[z]->topbase,
	       configtags->tag[z]->linkid, configtags->tag[z]->type);
      }

/*

		if (strncmp ( detailtags->tag[z]->name, "IntArray",strlen(detailtags->tag[z]->name)))
			{
			read_object_value(comm, path, detailtags->tag[z], debug);
			printf ("Old:\n");
			for (x=0;x<detailtags->tag[z]->datalen;x++)
				printf ("%02X ",detailtags->tag[z]->data[x]);
			printf ("\n"); 
			for (x=0;x<detailtags->tag[z]->datalen; x++)
				detailtags->tag[z]->data[x]++;
			write_object_value(comm, path, detailtags->tag[z], 4);
			read_object_value(comm, path, detailtags->tag[z], debug);
			printf ("New:\n");
			for (x=0;x<detailtags->tag[z]->datalen;x++)
				printf ("%02X ",detailtags->tag[z]->data[x]);
			printf ("\n"); 
			}			
*/

    }
  }
/*
  for (z = 0; z < y; z+=5)
  {
    if (z < detailtags->count)
    {
    switch (detailtags->tag[z]->type & 255)
      {
      case 0x68:
      case 0x69:
	break;
      default:
	list->count = 1;
	list->tag[0] = detailtags->tag[z];
	if (z+1 < y)
		list->tag[list->count++] = detailtags->tag[z+1];
	if (z+2 < y)
		list->tag[list->count++] = detailtags->tag[z+2];
	if (z+3 < y)
		list->tag[list->count++] = detailtags->tag[z+3];
	if (z+4 < y)
		list->tag[list->count++] = detailtags->tag[z+4];
	read_multi_object_value(comm, path, list, debug);
      }

    }
  }

*/
for (z=0; z<detailtags->count; z++)
	{
	printf ("%s : ",detailtags->tag[z]->name);
	for (x=0;x<detailtags->tag[z]->datalen;x++)
		printf ("%02X ",detailtags->tag[z]->data[x]);
	printf ("\n"); 
	}


//exit(0);
  printf("%d objects with topbase != 0.\n", c1);
  printf("%d objects type 0x68, %d objects type 0x69.\n", c68, c69);
  printf("configtags count = %d    detailtags count = %d\n",
	 configtags->count, detailtags->count);
  printf("Got %d programs...\n", progs->count);

  for (x = 0; x < progs->count; x++)
  {
    program_tags[x] = malloc(sizeof(_tag_data));



    if (program_tags[x] == NULL)
    {
      printf("Could not allocate memory for program tag structure.\n");
      exit(-1);
    }

    get_program_details(comm, path, progs->prog[x], debug);
    for (y = 0; y < detailtags->count; y++)
    {
      if (detailtags->tag[y]->linkid == progs->prog[x]->linkid)
      {
	strcpy(progs->prog[x]->name, detailtags->tag[y]->name);
      }
    }
    printf("id for program #%d is %08lX   link ID = %08lX - %s\n", x,
	   progs->prog[x]->base, progs->prog[x]->linkid,
	   progs->prog[x]->name);
  }




  for (x = 0; x < progs->count; x++)
  {
    if (quiet == FALSE)
      printf("Tag list for %s\n", progs->prog[x]->name);
    get_object_details_list(comm, path, progs->prog[x]->base, program_tags[x],
			    debug);
    printf("tag count = %d\n\n", program_tags[x]->count);

    for (y = 0; y < program_tags[x]->count; y++)
    {
      get_object_details(comm, path, program_tags[x]->tag[y], debug);
/*      aliascheck(program_tags[x]->tag[y], program_tags[x], detailtags,
		 DEBUG_VALUES);
      if (quiet == FALSE)
	printf("%08lX  %08lX  %08lX  %08lX   ",
	       program_tags[x]->tag[y]->topbase,
	       program_tags[x]->tag[y]->base, program_tags[x]->tag[y]->id,
	       program_tags[x]->tag[y]->linkid);
      if (quiet == FALSE)
      {
	printf("type = %04X   Name = %s\n", program_tags[x]->tag[y]->type,
	       program_tags[x]->tag[y]->name);
	printf("arraysize1 = %ld    arraysize2 = %ld    arraysize3 = %ld\n",
	       program_tags[x]->tag[y]->arraysize1,
	       program_tags[x]->tag[y]->arraysize2,
	       program_tags[x]->tag[y]->arraysize3);
      }
*/
    }
    if (quiet == FALSE)
      printf("-----------------------------------\n");
  }

  for (x = 0; x < detailtags->count; x++)
  {
    if ((detailtags->tag[x]->size != 0)
	|| (detailtags->tag[x]->alias_size != 0))
    {
      result = read_object_value(comm, path, detailtags->tag[x], debug);
      if (result != 0)
      {
	printf("Got non-zero return from read_object_value - %02X\n", result);
	printf
	  ("%08lX - %08lX - %08lX - %08lX - %08lX - %08lX - %08lX - %04X - %s - %ld - %ld - %ld\n",
	   detailtags->tag[x]->topbase, detailtags->tag[x]->base,
	   detailtags->tag[x]->id, detailtags->tag[x]->linkid,
	   detailtags->tag[x]->alias_topbase, detailtags->tag[x]->alias_base,
	   detailtags->tag[x]->alias_id, detailtags->tag[x]->type,
	   detailtags->tag[x]->name, detailtags->tag[x]->arraysize1,
	   detailtags->tag[x]->arraysize2, detailtags->tag[x]->arraysize3);
      }

      if (quiet == FALSE)
      {
	printf("Value(s) for %s: ", detailtags->tag[x]->name);
	for (y = 0; y < detailtags->tag[x]->size; y++)
	  printf("%02X ", detailtags->tag[x]->data[y]);
	printf("\n");
      }

    }
  }

  for (x = 0; x < progs->count; x++)
  {
    if (quiet == FALSE)
      printf("Reading %d Data Values for program %s tags...\n",
	     program_tags[x]->count, progs->prog[x]->name);
    for (y = 0; y < program_tags[x]->count; y++)
    {
      if ((program_tags[x]->tag[y]->type & 255) > 0xbf)
      {
	read_object_value(comm, path, program_tags[x]->tag[y], debug);
	if (quiet == FALSE)
	{
	  printf("Value(s) for %s: ", program_tags[x]->tag[y]->name);
	  for (z = 0; z < program_tags[x]->tag[y]->datalen; z++)
	    printf("%02X ", program_tags[x]->tag[y]->data[z]);
	  printf("\n");
	}
      }
      if (quiet == FALSE)
	printf("---------------------------------\n");
    }
  }
  closesocket(comm->file_handle);
  exit(0);
}
示例#23
0
int
main(int argc, char **argv)
{
	struct group *gr;
	struct passwd *pw;
	int Gflag, Pflag, ch, gflag, id, nflag, pflag, rflag, uflag;
	const char *myname;

	Gflag = Pflag = gflag = nflag = pflag = rflag = uflag = 0;

	myname = strrchr(argv[0], '/');
	myname = (myname != NULL) ? myname + 1 : argv[0];
	if (strcmp(myname, "groups") == 0) {
		isgroups = 1;
		Gflag = nflag = 1;
	}
	else if (strcmp(myname, "whoami") == 0) {
		iswhoami = 1;
		uflag = nflag = 1;
	}

	while ((ch = getopt(argc, argv,
	    (isgroups || iswhoami) ? "" : "PGgnpru")) != -1)
		switch(ch) {
		case 'G':
			Gflag = 1;
			break;
		case 'P':
			Pflag = 1;
			break;
		case 'g':
			gflag = 1;
			break;
		case 'n':
			nflag = 1;
			break;
		case 'p':
			pflag = 1;
			break;
		case 'r':
			rflag = 1;
			break;
		case 'u':
			uflag = 1;
			break;
		case '?':
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	if (iswhoami && argc > 0)
		usage();

	switch(Gflag + Pflag + gflag + pflag + uflag) {
	case 1:
		break;
	case 0:
		if (!nflag && !rflag)
			break;
		/* FALLTHROUGH */
	default:
		usage();
	}

	pw = *argv ? who(*argv) : NULL;

	if (gflag) {
		id = pw ? pw->pw_gid : rflag ? getgid() : getegid();
		if (nflag && (gr = getgrgid(id)))
			printf("%s\n", gr->gr_name);
		else
			printf("%u\n", id);
		exit(0);
	}

	if (uflag) {
		id = pw ? pw->pw_uid : rflag ? getuid() : geteuid();
		if (nflag && (pw = getpwuid(id)))
			printf("%s\n", pw->pw_name);
		else
			printf("%u\n", id);
		exit(0);
	}

	if (Gflag) {
		group(pw, nflag);
		exit(0);
	}

	if (Pflag) {
		pline(pw);
		exit(0);
	}

	if (pflag) {
		pretty(pw);
		exit(0);
	}

	if (pw)
		user(pw);
	else
		current();
	exit(0);
}
示例#24
0
文件: info.c 项目: dylanyaga/openMerc
int main(int argc, char *args[])
{
	int cn = 0, srank = 0;

	query = getenv("QUERY_STRING");
	if (query && !strncmp(query, "cn=", 3))
	{
		cn = atoi(query + 3);
	}
	if (query && !strncmp(query, "rank=", 5))
	{
		srank = atoi(query + 5);
	}

	chdir("/home/merc");

	printf("Content-Type: text/html\n\n");
	printf("<html><head><title>Server Info</title></head>\n");
	printf("<BODY TEXT=#D7D700 BGCOLOR=#264A9F LINK=#FFFFBB VLINK=#CCCC00 ALINK=#FFFF9D background=/gfx/back4.gif>");
	printf("<center>");
	printf("<table width=\"100%%\"><tr>");
	printf(
		"    <table width=\"100%%\">"
		"        <tr>"
		"            <td align=\"center\"><a href=\"http://www.astonia.com/\"><img src=\"/gfx/logo.gif\" width=\"100\" height=\"60\" border=\"0\"></a></td>"
		"            <td align=\"center\">"
		"                <a href=\"/\">Home</a>"
		"                <a href=\"/manual.html\">Manual</a>"
		"                <a href=\"/terms.html\">Terms</a>"
		"                <a href=\"/download.html\">Download</a>"
		"                <a href=\"/contact.html\">Contact</a>"
		"                <a href=\"/cgi-bin/info.cgi\">Server&nbsp;Status</a>"
		"                <a href=\"/cgi-bin/who.cgi\">Who's&nbsp;Online</a>"
		"                <a href=\"/bugs.html\">Bugs</a>"
		"                <a href=\"/changes.html\">Changes</a>"
		"                <a href=\"/creators.html\">Creators</a>"
		"                <a href=\"/links.html\">Links</a>"
		"                <a href=\"/privacy.html\">Privacy</a>"
		"            </td>"
		"            <td align=\"center\"><a href=\"http://www.astonia.com/\"><img src=\"/gfx/logo.gif\" width=\"100\" height=\"60\" border=\"0\"></a></td>"
		"        </tr>"
		"    </table>");
	printf("</td></tr></table>");
	printf("<img src=/gfx/barsmall.gif border=0 align=left alt=---- width=100%% height=5><br>");
	printf("<table width=60%%><tr><td>\n");

	if (load())
	{
		printf("<b>Cannot access server data. Exiting... (%s)</b></td></tr></table>", strerror(errno));
		exit(0);
	}

	if (args[0])
	{
		if (strcmp(args[0], "who.cgi")==0)
		{
			who();
		}
		else if (strcmp(args[0], "top.cgi")==0)
		{
			top();
		}
		else if (strcmp(args[0], "info.cgi")==0)
		{
			info(cn);
		}
		else if (strcmp(args[0], "hog.cgi")==0)
		{
			hog();
		}
		else if (strcmp(args[0], "gods.cgi")==0)
		{
			gods();
		}
		else if (strcmp(args[0], "staff.cgi")==0)
		{
			staff();
		}
		else if (strcmp(args[0], "effects.cgi")==0)
		{
			effects();
		}
		else if (strcmp(args[0], "xtop.cgi")==0)
		{
			xtop(srank);
		}
		else if (strcmp(args[0], "dtop.cgi")==0)
		{
			dtop(srank);
		}
		else
		{
			printf("Internal error... (%s)\n", args[0]);
		}
	}
	else
	{
		printf("Internal error...");
	}

	unload();

	printf("</td></tr></table><br>");

	printf(
		"<img src=\"/gfx/barsmall.gif\" border=0 align=\"left\" alt=\"----\" width=\"100%%\" height=5><br>"
		"<table width=\"100%%\" cellpadding=0 cellspacing=0 border=0><tr>"
		"<td width=\"33%%\" align=center><a href=/devel.html>Back to main page</a></td>"
		"<td width=\"33%%\" align=center>&nbsp;</td>"
		"<td width=\"33%%\" align=center><font size=-1>All material on this server is copyright "
		"<a href=mailto:[email protected]>D.Brockhaus</a></font></td>"
		"</tr></table>"
		"</center><br><br>"
		"</body></html>");

	return(0);
}
示例#25
0
文件: Network.cpp 项目: 8102/QNetSoul
void    Network::interpretLine(const QString& line)
{
#ifndef QT_NO_DEBUG
  //qDebug() << line;
#endif
  Q_ASSERT(this->_options);
  QStringList properties;
  QStringList parts = line.split(' ', QString::SkipEmptyParts);
  const int size = parts.size();

  if (size)
    {
      if ((0 == this->_handShakingStep && "salut" == parts.at(0))         ||
          (1 == this->_handShakingStep && line.startsWith("rep 002 --"))  ||
          (2 == this->_handShakingStep && line.startsWith("rep 002 --")))
        {
          emit handShaking(this->_handShakingStep++, parts);
        }
      else if (line.startsWith("user_cmd") && size >= 4)
        {
          if ("msg" == parts.at(3) && size >= 5)
            {
              const QString message = url_decode(parts.at(4).toStdString().c_str());
              const QString login = parts.at(1).section(':', 3, 3).section('@', 0, 0);
              if (this->_options->blockedWidget->isBlocked(login))
                {
#ifndef QT_NO_DEBUG
                  qDebug() << "[Network::interpretLine]"
                           << "Message blocked from"
                           << login << ":" << message;
#endif
                  return;
                }
#ifndef QT_NO_DEBUG
              qDebug() << "[Network::interpretLine]"
                       << "Message received from"
                       << login << ":" << message;
#endif
              // user_cmd 566:user:1/3:[email protected]:~:maison:epitech_2011 | msg test dst=dally_r
              properties << login // login
                         << parts.at(1).section(':', 0, 0) // id
                         << parts.at(1).section(':', 3, 3).section('@', -1) // ip
                         << parts.at(1).section(':', -1) // group
                         << "actif" // state
                         << url_decode(parts.at(1).section(':', -2, -2).toStdString().c_str()) // Location
                         << ""; // Comment
              emit msg(properties, message);
            }
          else if ("state" == parts.at(3) && size >= 5)
            {
              //user_cmd 185:user:1/3:[email protected]:~:Trolltech%20World:epitech_2011 | state lock
              // properties.at(0): Login
              // properties.at(1): Id
              // properties.at(2): Ip
              // properties.at(3): Promo
              // properties.at(4): State
              // properties.at(5): Location
              // properties.at(6): Comment
              properties << parts.at(1).section(':', 3, 3).section('@', 0, 0) // login
                         << parts.at(1).section(':', 0, 0) // id
                         << parts.at(1).section(':', 3, 3).section('@', -1) // ip
                         << parts.at(1).section(':', -1) // group
                         << parts.at(4).section(':', 0, 0) // state
                         << url_decode(parts.at(1).section(':', -2, -2).toStdString().c_str()) // location
                         << ""; // comment
              emit state(properties);
            }
          else if (("login" == parts.at(3) || "logout" == parts.at(3)) && (size >= 4))
            {
              properties << parts.at(1).section(':', 3, 3).section('@', 0, 0) // login
                         << parts.at(1).section(':', 0, 0) // id
                         << parts.at(1).section(':', 3, 3).section('@', -1) // ip
                         << parts.at(1).section(':', -1) // group
                         << parts.at(3) // state
                         << url_decode(parts.at(1).section(':', -2, -2).toStdString().c_str()) // location
                         << ""; // comment
              emit state(properties);
            }
          else if ("who" == parts.at(3) && size >= 15)
            {
              // user_cmd 199:user:1/3:[email protected]:~:maison:epitech_2011
              // | who 329 sundas_c 0.0.0.0 1281146904 1281147024 3 1 ~ maison epitech_2011 actif:1281147031 qnetsoul

              QStringList properties;
              properties << parts.at(5) // login
                         << parts.at(4) // id
                         << parts.at(6) // ip
                         << parts.at(13) // group
                         << parts.at(14).section(':', 0, 0) // state
                         << url_decode(parts.at(12).toStdString().c_str()); // location
              if (size < 16)
                properties << ""; // blank comment
              else
                properties << url_decode(parts.at(15).toStdString().c_str()); // comment
              emit who(properties);
            }
          else if (("dotnetSoul_UserTyping" == parts.at(3) || "dotnetSoul_UserCancelledTyping" == parts.at(3)) && size >= 4)
            {
              // Emits id, bool
              bool ok;
              const int id = parts.at(1).section(':', 0, 0).toInt(&ok);
              if (ok)
                emit typingStatus(id, ("dotnetSoul_UserTyping" == parts.at(3)));
            }
        }
      else if (line.startsWith("ping"))
        {
          sendMessage("ping\n");
#ifndef QT_NO_DEBUG
          qDebug() << "[Network::interpretLine]"
                   << "Ping received, ping answered.";
#endif
        }
      else if (line.startsWith("rep 033 --"))
        {
          emit handShaking(-1, QStringList());
#ifndef QT_NO_DEBUG
          qDebug() << "[Network::interpretLine]"
                   << "Failure...\n"
                   << "Reason:" << line;
#endif
        }
#ifndef QT_NO_DEBUG
      else
        {
          qDebug() << "[Network::interpretLine]"
                   << "Unparsed command:" << line;
        }
#endif
    }
}
示例#26
0
//start 提示:自动阅卷起始唯一标识,请勿删除或增加。
int main()
{
    char Test[30];
    scanf("%s", Test);
    printf("%d",who(Test));
}
示例#27
0
int
main(int argc, char *argv[])
{
	struct group *gr;
	struct passwd *pw;
	int Gflag, ch, gflag, nflag, pflag, rflag, uflag;
	uid_t uid;
	gid_t gid;

	Gflag = gflag = nflag = pflag = rflag = uflag = 0;
	while ((ch = getopt(argc, argv, "Ggnpru")) != -1)
		switch(ch) {
		case 'G':
			Gflag = 1;
			break;
		case 'g':
			gflag = 1;
			break;
		case 'n':
			nflag = 1;
			break;
		case 'p':
			pflag = 1;
			break;
		case 'r':
			rflag = 1;
			break;
		case 'u':
			uflag = 1;
			break;
		case '?':
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	switch(Gflag + gflag + pflag + uflag) {
	case 1:
		break;
	case 0:
		if (!nflag && !rflag)
			break;
		/* FALLTHROUGH */
	default:
		usage();
	}

	pw = *argv ? who(*argv) : NULL;

	if (gflag) {
		gid = pw ? pw->pw_gid : rflag ? getgid() : getegid();
		if (nflag && (gr = getgrgid(gid)))
			(void)printf("%s\n", gr->gr_name);
		else
			(void)printf("%u\n", gid);
		exit(0);
	}

	if (uflag) {
		uid = pw ? pw->pw_uid : rflag ? getuid() : geteuid();
		if (nflag && (pw = getpwuid(uid)))
			(void)printf("%s\n", pw->pw_name);
		else
			(void)printf("%u\n", uid);
		exit(0);
	}

	if (Gflag) {
		group(pw, nflag);
		exit(0);
	}

	if (pflag) {
		pretty(pw);
		exit(0);
	}

	if (pw)
		user(pw);
	else
		current();
	exit(0);
}
示例#28
0
bool Omegle_client::events()
{
	HANDLE_ENTRY;

	std::string data = "id=" + this->chat_id_;

	// Get update
	http::response resp = flap(OMEGLE_REQUEST_EVENTS, &data);

	// Return
	switch (resp.code)
	{
	case HTTP_CODE_OK:
	{
		if (resp.data == "null") {
			// Everything is OK, no new message received -- OR it is a problem
			// TODO: if we are waiting for Stranger with common likes, then we should try standard Stranger if this takes too long
			return HANDLE_ERROR(false);
		}
		else if (resp.data == "fail") {
			// Something went wrong
			return HANDLE_ERROR(false);
		}

		JSONROOT root(resp.data.c_str());
		if (root == NULL)
			return HANDLE_ERROR(false);

		bool newStranger = false;
		bool waiting = false;

		for (size_t i = 0; i < json_size(root); i++) {
			JSONNode *item = json_at(root, i);
			if (item == NULL)
				continue;

			std::string name = _T2A(json_as_string(json_at(item, 0)));
		
			if (name == "waiting") {
				// We are just waiting for new Stranger
				waiting = true;
			}
			else if (name == "identDigests") {
				// We get some comma separated hashes, I'm not sure what for
			}
			else if (name == "statusInfo") {
				JSONNode *data = json_at(item, 1);

				// We got some object as second parameter
				//data["antinudepercent"]; // probably 1 by default
				//data["antinudeservers"]; // array of server names, like "waw3.omegle.com"
				//data["rtmfp"]; // some rtmfp protocol address
				//data["servers"]; // array of server names, like "front5.omegle.com"
				//data["spyeeQueueTime"]; // some float number, e.g. 0.0701999903
				//data["spyQueueTime"]; // some float number, e.g. 4.7505000114
				//data["timestamp"]; // e.g. 1445336566.0196209

				// We got info about count of connected people there
				ptrT count(json_as_string(json_get(data, "count")));
				TCHAR strT[255];
				mir_sntprintf(strT, TranslateT("On whole Omegle are %s strangers online now."), count);

				parent->UpdateChat(NULL, strT);
			}
			else if (name == "serverMessage") {
				ptrT message(json_as_string(json_at(item, 1)));
				parent->UpdateChat(NULL, TranslateTS(message));
			}
			else if (name == "connected") {
				// Stranger connected
				if (this->spy_mode_ && !this->question_.empty()) {
					parent->AddChatContact(TranslateT("Stranger 1"));
					parent->AddChatContact(TranslateT("Stranger 2"));
					this->state_ = STATE_SPY;
				}
				else {
					parent->AddChatContact(TranslateT("Stranger"));
					this->state_ = STATE_ACTIVE;
				}

				newStranger = true;
				waiting = false;
			}
			else if (name == "commonLikes") {
				std::tstring likes = TranslateT("You and the Stranger both like: ");

				JSONNode *items = json_at(item, 1);
				size_t size = json_size(items);
				for (size_t i = 0; i < size; i++) {
					likes += ptrT(json_as_string(json_at(items, i)));
					if (i < size - 1)
						likes += _T(", ");
				}
				
				parent->debugLog(_T("Got common likes: '%s'"), likes.c_str());
				parent->SetTopic(likes.c_str());
			}
			else if (name == "question") {
				ptrT question(json_as_string(json_at(item, 1)));
				parent->SetTopic(question);
			}
			else if (name == "typing" || name == "spyTyping") {
				// Stranger is typing, not supported by chat module yet
				SkinPlaySound("StrangerTyp");

				StatusTextData st = { 0 };
				st.cbSize = sizeof(st);
				st.hIcon = IcoLib_GetIconByHandle(GetIconHandle("typing_on"));

				ptrT who(name == "spyTyping" ? json_as_string(json_at(item, 1)) : mir_tstrdup(_T("Stranger")));
				mir_sntprintf(st.tszText, TranslateT("%s is typing."), TranslateTS(who));

				CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), (LPARAM)&st);
			}
			else if (name == "stoppedTyping" || name == "spyStoppedTyping") {
				// Stranger stopped typing, not supported by chat module yet
				SkinPlaySound("StrangerTypStop");

				StatusTextData st = { 0 };
				st.cbSize = sizeof(st);
				st.hIcon = IcoLib_GetIconByHandle(GetIconHandle("typing_off"));

				ptrT who(name == "spyTyping" ? json_as_string(json_at(item, 1)) : mir_tstrdup(_T("Stranger")));
				mir_sntprintf(st.tszText, TranslateT("%s stopped typing."), TranslateTS(who));

				CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), (LPARAM)&st);
			}
			else if (name == "gotMessage") {
				CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), NULL);

				// Play sound as we received message
				SkinPlaySound("StrangerMessage");

				if (state_ == STATE_ACTIVE) {
					ptrT msg(json_as_string(json_at(item, 1)));
					parent->UpdateChat(TranslateT("Stranger"), msg);
				}
			}
			else if (name == "spyMessage") {
				CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), NULL);

				// Play sound as we received message
				SkinPlaySound("StrangerMessage");

				if (state_ == STATE_SPY) {
					ptrT stranger(json_as_string(json_at(item, 1)));
					ptrT msg(json_as_string(json_at(item, 2)));
					parent->UpdateChat(stranger, msg);
				}
			}
			else if (name == "strangerDisconnected") {
				CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), NULL);

				// Stranger disconnected
				if (db_get_b(NULL, parent->m_szModuleName, OMEGLE_KEY_DONT_STOP, 0))
				{
					SkinPlaySound("StrangerChange");
					parent->NewChat();
				}
				else
					parent->StopChat(false);
			}
			else if (name == "spyDisconnected") {
				CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), NULL);

				ptrT stranger(json_as_string(json_at(item, 1)));

				TCHAR strT[255];
				mir_sntprintf(strT, TranslateT("%s disconnected."), TranslateTS(stranger));
				parent->UpdateChat(NULL, strT);

				// Stranger disconnected
				if (db_get_b(NULL, parent->m_szModuleName, OMEGLE_KEY_DONT_STOP, 0))
				{
					SkinPlaySound("StrangerChange");
					parent->NewChat();
				}
				else
					parent->StopChat(false);
			}
			else if (name == "recaptchaRequired") {
				// Nothing to do with recaptcha
				parent->UpdateChat(NULL, TranslateT("Recaptcha is required.\nOpen http://omegle.com , solve Recaptcha and try again."));
				parent->StopChat(false);
			}
			else if (name == "recaptchaRejected") {
				// Nothing to do with recaptcha
				parent->StopChat(false);
			}
			else if (name == "error") {
				ptrT error(json_as_string(json_at(item, 1)));

				TCHAR strT[255];
				mir_sntprintf(strT, TranslateT("Error: %s"), TranslateTS(error));
				parent->UpdateChat(NULL, strT);
			}
		}
		
		if (newStranger && !spy_mode_) {
			// We got new stranger in this event, lets say him "Hi message" if enabled			
			if (db_get_b(NULL, parent->m_szModuleName, OMEGLE_KEY_HI_ENABLED, 0)) {
				DBVARIANT dbv;
				if (!db_get_utf(NULL, parent->m_szModuleName, OMEGLE_KEY_HI, &dbv)) {
					std::vector<std::string> messages;
					utils::text::explode(std::string(dbv.pszVal), "\r\n", &messages);
					db_free(&dbv);

					int pos = rand() % messages.size();
					std::string *message = new std::string(messages.at(pos));

					parent->debugLogA("**Chat - saying Hi! message");
					parent->ForkThread(&OmegleProto::SendMsgWorker, message);
				}
				else parent->debugLogA("**Chat - Hi message is enabled but not used");
			}
		}

		if (waiting) {
			// If we are only waiting in this event...
			parent->UpdateChat(NULL, TranslateT("We are still waiting..."));
		}

		return HANDLE_SUCCESS;
	}

	case HTTP_CODE_FAKE_DISCONNECTED:
		// timeout
		return HANDLE_SUCCESS;

	case HTTP_CODE_FAKE_ERROR:
	default:
		return HANDLE_ERROR(false);
	}
}
示例#29
0
void judge(char from[], int mon, char to[])
{
	a[who(from)].money -= mon;
	a[who(to)].money += mon;
}
示例#30
0
文件: five99.c 项目: yrchen/Athena
static int fplayer(int race)
{
  int l;
    while(-1)
    {
      gotoxy(48,15); prints("目前位置(%2d,%2d)",m,n);
      put_box(mm,nn,0);
      put_box(m,n,race);
      mm=m; nn=n;
      l=igetkey();
      switch(l)
      {
//      case '1':
        case '2':
         if(role[l-'1']==1)
         {
           role[l-'1']=2; 
           attack[l-'1']=0;
         }
         else if(attack[l-'1']==0)
           attack[l-'1']=1;
         else
           role[l-'1']=1;

         who(l-'1');
         break;
        case 'q': return 2;
        case 'r': return 1;
        case 'b':
         if(sum>2)
         {
           int i;
           for(i=0;i<2;i++)
           {
             int x=repent[sum-1][1],y=repent[sum-1][2];
             put_chess(x,y,0);
             move(y+1,x*2); outs("┼");
             sum-=2;
           }
           for(i=sum;i>=sum-5;i--)
           {
             gotoxy(48,i-sum+13);
             if(i>0)
               prints("第%d步: %s (%2d,%2d)  ",i,(repent[i-1][0]==1)?"●":"○",
                 repent[i-1][1],repent[i-1][2]);
             else
               outs("                  ");
           }
         }
         break;
        case ' ':
         if(!chess[m-1][n-1])
         {
           int hk=put_chess(m,n,race);
           if(hk)
           {
             int dk = show_win(hk);
             if(dk=='n'||dk=='q') return 2;
             return 1;
           }
           return 0;
         }
         break;
        case KEY_DOWN:  //down
          if(legal(m,n+1)) n++; 
          break; 
        case KEY_UP:	//up
          if(legal(m,n-1)) n--; 
          break;
        case KEY_RIGHT:	//right
          if(legal(m+1,n)) m++; 
          break;
        case KEY_LEFT:	//left
          if(legal(m-1,n)) m--; 
          break;
      }
    }
}