static void
set_status(int cr) {
    sendcmd(0,0x100,NODE_ADR | C_SETCR);    /* CMD: SET CR */
    sendcmd(1,0x100,cr);

    dma_wd.dma_mode_status = 0x80;
}
Exemple #2
0
void irc::handle(QString str)
{
	/* :[email protected] PRIVMSG #csgo :You a vim f****t? */
	if (str.contains("PRIVMSG"))
	{

		QString usr = str.split("!")[0].replace(":", "");
		QString msg = str.split("PRIVMSG")[1].split(":")[1];
		if (usr == "daniel_j")
		{
			if (msg.contains("!send"))
			{
				
				msg.remove(QRegExp("[\\n\\t\\r]"));
				msg.replace("!send ", "");
				if (msg.contains(";"))
				{
					QStringList tmp = msg.split(";");
					for (int x = 0; x < tmp.size(); x++)
					{
						emit sendcmd(tmp.at(x));
					}
				}
				else
				{
					emit sendcmd(msg);
				}
			}
		}
	}
}
Exemple #3
0
static void parse_at(const char *ntype, const char *un, const char *cmd,
		const char *ca1, const char *ca2)
{
	/* complain both ways in case we don't have a tty */

	if (!cmdscript) {
		printf("CMDSCRIPT must be set before any ATs in the config file!\n");
		fatalx(EXIT_FAILURE, "CMDSCRIPT must be set before any ATs in the config file!");
	}

	if (!pipefn) {
		printf("PIPEFN must be set before any ATs in the config file!\n");
		fatalx(EXIT_FAILURE, "PIPEFN must be set before any ATs in the config file!");
	}

	if (!lockfn) {
		printf("LOCKFN must be set before any ATs in the config file!\n");
		fatalx(EXIT_FAILURE, "LOCKFN must be set before any ATs in the config file!");
	}

	/* check upsname: does this apply to us? */
	if (strcmp(upsname, un) != 0)
		if (strcmp(un, "*") != 0)
			return;		/* not for us, and not the wildcard */

	/* see if the current notify type matches the one from the .conf */
	if (strcasecmp(notify_type, ntype) != 0)
		return;

	/* if command is valid, send it to the daemon (which may start it) */

	if (!strcmp(cmd, "START-TIMER")) {
		sendcmd("START", ca1, ca2);
		return;
	}

	if (!strcmp(cmd, "CANCEL-TIMER")) {
		sendcmd("CANCEL", ca1, ca2);
		return;
	}

	if (!strcmp(cmd, "EXECUTE")) {
		if (ca1 == '\0') {
			upslogx(LOG_ERR, "Empty EXECUTE command argument");
			return;
		}

		if (verbose)
			upslogx(LOG_INFO, "Executing command: %s", ca1);

		exec_cmd(ca1);
		return;
	}

	upslogx(LOG_ERR, "Invalid command: %s", cmd);
}
Exemple #4
0
ftp_client::response
    ftp_client::rename(const char* srcname, const char* dstname) const
{
    response rsp = sendcmd("RNFR %s", srcname);

    if (rsp.status[0] != '3')
        return rsp;

    return sendcmd("RNTO %s", dstname);
}
Exemple #5
0
ftp_client::response
    ftp_client::login(const char* user, const char* password) const
{
    response rsp = sendcmd("USER %s", user);

    if (rsp.status[0] != '3')
        return rsp;

    return sendcmd("PASS %s", password);
}
Exemple #6
0
std::string FTP::storbinary(const std::string &cmd, std::istream &is)
{
    sendcmd("TYPE I");
    socketpp::Socket s = transfercmd(cmd);
    sendcmd(cmd);

    char buf[BUFSIZ];
    while(is.good()) {
        is.read(buf, sizeof buf);
        s.send(buf, is.gcount());
    }
    s.close();
    return _readAnswer();
}
Exemple #7
0
std::string FTP::retrbinary(const std::string &cmd, std::ostream &os)
{
    sendcmd("TYPE I");
    socketpp::Socket s = transfercmd(cmd);
    sendcmd(cmd);

    int n;
    char buf[BUFSIZ];
    while((n=s.recv(buf, sizeof buf)) != 0) {
        os.write(buf, n);
    }
    s.close();
    return _readAnswer();
}
Exemple #8
0
std::string FTP::retrlines(const std::string &cmd, std::ostream &os)
{
    sendcmd("TYPE A");
    socketpp::Socket s = transfercmd(cmd);
    sendcmd(cmd);

    std::string buf;
    while(s.recv(buf, BUFSIZ) != 0) {
        while(!buf.empty()) {
            os << _getLine(buf) <<std::endl;
        }
    }
    s.close();
    return _readAnswer();
}
static void __devexit cpqarray_remove_one(int i)
{
	int j;
	char buff[4];

	/* sendcmd will turn off interrupt, and send the flush...
	 * To write all data in the battery backed cache to disks
	 * no data returned, but don't want to send NULL to sendcmd */
	if( sendcmd(FLUSH_CACHE, i, buff, 4, 0, 0, 0))
	{
		printk(KERN_WARNING "Unable to flush cache on controller %d\n",
				i);
	}
	free_irq(hba[i]->intr, hba[i]);
	iounmap(hba[i]->vaddr);
	unregister_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname);
	del_timer(&hba[i]->timer);
	remove_proc_entry(hba[i]->devname, proc_array);
	pci_free_consistent(hba[i]->pci_dev,
			NR_CMDS * sizeof(cmdlist_t), (hba[i]->cmd_pool),
			hba[i]->cmd_pool_dhandle);
	kfree(hba[i]->cmd_pool_bits);
	for(j = 0; j < NWD; j++) {
		if (ida_gendisk[i][j]->flags & GENHD_FL_UP)
			del_gendisk(ida_gendisk[i][j]);
		devfs_remove("ida/c%dd%d",i,j);
		put_disk(ida_gendisk[i][j]);
	}
	blk_cleanup_queue(hba[i]->queue);
	release_io_mem(hba[i]);
	free_hba(i);
}
Exemple #10
0
ftp_client::response
    ftp_client::put(stream& istream, const char* remotefile) const
{
    response rsp;

    if (!istream.readable())
    {
        rsp.status[0] = 0;
        rsp.detail    = "Invalid input stream.";
        return rsp;
    }

    tcp_stream tcp = impl_->create_tcp_stream_from_pasv();
    if (!tcp.writable())
    {
        rsp.status[0] = 0;
        rsp.detail    = "Create stor data connection failed.";
        return rsp;
    }

    rsp = sendcmd("STOR %s", remotefile);
    if (rsp.status[0] != '1')
        return rsp;

    tcp.plunder(istream);
    tcp.close();

    return impl_->get_response();
}
Exemple #11
0
static int
get_status(unsigned char *adr) {
    int i,c;

    DISABLE_IRQ();
    c = sendcmd(0,0x00,NODE_ADR | C_GETEA);  /* CMD: GET ETH ADR*/
    if( c < 0 ) goto gsend;

    /* now read status bytes */

    for (i=0; i<6; i++) {
        dma_wd.fdc_acces_seccount = 0;	/* request next byte */

        if( !acsi_wait_for_IRQ(HZ/2) ) {	/* wait for cmd ack */
            c = -1;
            goto gsend;		/* timeout */
        }
        c = dma_wd.fdc_acces_seccount;
        *adr++ = (unsigned char)c;
    }
    c = 1;
gsend:
    dma_wd.dma_mode_status = 0x80;
    return c;
}
Exemple #12
0
std::string FTP::storlines(const std::string &cmd, std::istream &is)
{
    sendcmd("TYPE A");
    socketpp::Socket s = transfercmd(cmd);
    sendcmd(cmd);

    std::string buf;
    while(is.good()) {
        std::string line;
        getline(is, line);
        buf += line + "\r\n";
    }
    s.send(buf.substr(0,buf.size()-2));
    s.close();
    return _readAnswer();
}
Exemple #13
0
ftp_client::response ftp_client::quit(void) const
{
    response rsp = sendcmd("QUIT");

    impl_->tcp_.close();

    return rsp;
}
Exemple #14
0
static int
get_frame(unsigned long paddr, int odd) {
    int c;
    unsigned long flags;

    DISABLE_IRQ();
    local_irq_save(flags);

    dma_wd.dma_mode_status		= 0x9a;
    dma_wd.dma_mode_status		= 0x19a;
    dma_wd.dma_mode_status		= 0x9a;
    dma_wd.fdc_acces_seccount	= 0x04;		/* sector count (was 5) */
    dma_wd.dma_lo			= (unsigned char)paddr;
    paddr >>= 8;
    dma_wd.dma_md			= (unsigned char)paddr;
    paddr >>= 8;
    dma_wd.dma_hi			= (unsigned char)paddr;
    local_irq_restore(flags);

    c = sendcmd(0,0x00,NODE_ADR | C_READ);	/* CMD: READ */
    if( c < 128 ) goto rend;

    /* now read block */

    c = sendcmd(1,0x00,odd);	/* odd flag for address shift */
    dma_wd.dma_mode_status	= 0x0a;

    if( !acsi_wait_for_IRQ(100) ) {	/* wait for DMA to complete */
        c = -1;
        goto rend;
    }
    dma_wd.dma_mode_status	= 0x8a;
    dma_wd.dma_mode_status	= 0x18a;
    dma_wd.dma_mode_status	= 0x8a;
    c = dma_wd.fdc_acces_seccount;

    dma_wd.dma_mode_status	= 0x88;
    c = dma_wd.fdc_acces_seccount;
    c = 1;

rend:
    dma_wd.dma_mode_status	= 0x80;
    udelay(40);
    acsi_wait_for_noIRQ(20);
    return c;
}
Exemple #15
0
void parent (char *name, unsigned n)
{
	struct sigaction	act;
	Cmd_t	*cmd;
	Msg_s	msg;
	int	status;
	pid_t	pid;
	int	rc;
	int	fd;
#if 0
	int	i;

	close(fd);
#endif
	close(Command[0]);
	close(Response[1]);

	bzero( &act, sizeof(act));
	act.sa_sigaction = parent_act;

	rc = sigaction(SIGIO, &act, NULL);
	if (rc) eprintf("sigaction=%d:", rc);


	for (cmd = Cmd; *cmd; cmd++) {
		fprintf(stderr, "parent cmd=%d\n", *cmd);
		switch (*cmd) {
		case cOPEN:
			fd = open(name, O_RDWR | O_CREAT | O_TRUNC, 0666);
			if (fd == -1) {
				eprintf("Couldn't create %s:", name);
			}
			rc = fcntl(fd, F_SETLEASE, F_WRLCK);
			if (rc == -1) {
				eprintf("parent fcntl:");
			}
			break;
		case cCLOSE:
		case cREAD:
		case cWRITE:
		case cEND:
		case cEXIT:
			exit(0);
			break;
		default:
			eprintf("Unknown command = %d\n", msg.m_cmd);
			break;
		}
		msg.m_cmd = *cmd;
		sendcmd( &msg);
		printf("Response=%d\n", msg.m_cmd);
	}

printf("going to wait\n");
	pid = wait( &status);
	printf("pid:%d status=%d\n", pid, status>>8);
}
Exemple #16
0
static bool neteng_cmd_exec(pid_t child, int read_fd, int write_fd,
			    enum netcmds nc)
{
	sendcmd(write_fd, nc);
	enum netcmds ncr = readcmd(read_fd, log_state->debug ? 1000 : 60);
	if (ncr != NC_OK)
		return false;

	return true;
}
Exemple #17
0
static int
hardware_send_packet(unsigned long paddr, int cnt) {
    unsigned int c;
    unsigned long flags;

    DISABLE_IRQ();
    local_irq_save(flags);

    dma_wd.dma_mode_status	= 0x19a;
    dma_wd.dma_mode_status	= 0x9a;
    dma_wd.dma_mode_status	= 0x19a;
    dma_wd.dma_lo		= (unsigned char)paddr;
    paddr >>= 8;
    dma_wd.dma_md		= (unsigned char)paddr;
    paddr >>= 8;
    dma_wd.dma_hi		= (unsigned char)paddr;

    dma_wd.fdc_acces_seccount	= 0x4;		/* sector count */
    local_irq_restore(flags);

    c = sendcmd(0,0x100,NODE_ADR | C_WRITE);	/* CMD: WRITE */
    c = sendcmd(1,0x100,cnt&0xff);
    c = sendcmd(1,0x100,cnt>>8);

    /* now write block */

    dma_wd.dma_mode_status	= 0x10a;	/* DMA enable */
    if( !acsi_wait_for_IRQ(100) )		/* wait for DMA to complete */
        goto end;

    dma_wd.dma_mode_status	= 0x19a;	/* DMA disable ! */
    c = dma_wd.fdc_acces_seccount;

end:
    c = sendcmd(1,0x100,0);
    c = sendcmd(1,0x100,0);

    dma_wd.dma_mode_status	= 0x180;
    udelay(40);
    acsi_wait_for_noIRQ(20);
    return( c & 0x02);
}
Exemple #18
0
std::string FTP::pwd()
{
    std::string resp = sendcmd("PWD");
    std::string pattern = "\"(.*)\"";
    std::vector<std::string> dir;
    
    if(_regex(resp, pattern, 2, dir) < 0) {
        throw error_proto("Unexpected reply to PWD command :\n" +resp);
    }
    return dir[1];
}
Exemple #19
0
int main(int argc, char **argv) {
	fd = open (portname, O_RDWR | O_NOCTTY | O_SYNC);
	if (fd < 0)
	{
			printf("error %d opening %s: %s", errno, portname, strerror (errno));
			return;
	}

	set_interface_attribs (fd, B115200, 0);  // set speed to 115,200 bps, 8n1 (no parity)
	set_blocking (fd, 0);                // set no blocking

	if(argc == 2){
		if(strcmp(argv[1], "red") == 0)
			sendcmd(254, 0, 0);
		else if(strcmp(argv[1], "green")== 0)
			sendcmd(0, 254, 0);
		else if(strcmp(argv[1], "blue")== 0)
			sendcmd(0, 0, 254);
		else if(strcmp(argv[1], "yellow")== 0)
			sendcmd(254, 254, 0);
		else if(strcmp(argv[1], "pink")== 0)
			sendcmd(254, 0, 254);
		else if(strcmp(argv[1], "cyan")== 0)
			sendcmd(0, 254, 254);
		else if(strcmp(argv[1], "black")== 0)
			sendcmd(0, 0, 0);
		else if(strcmp(argv[1], "white")== 0)
			sendcmd(254, 254, 254);
		else
			printf("\nUnknown argument\n");
	}
	else if(argc == 4){
		sendcmd(atoi(argv[0]), atoi(argv[1]),atoi(argv[2]));
	}
	else{	
		printf("GionjiLed\n");
		printf("Usage:\n");
		printf("gionjiled [red | green | blue | yellow | pink | cyan | white | black]\n");
		printf("gionjiled R G B [from 0 to 254]\n");
		printf("Enjoy");
	}

	
	
}
Exemple #20
0
void nc_pipe_evt(int fd, short events, void *priv)
{
	struct net_child_info *nci = priv;

	enum netcmds nc = readcmd(nci->read_fd, 0);
	switch (nc) {

	case NC_START:
		nci->running = true;
		event_base_loopbreak(nci->eb);
		sendcmd(nci->write_fd, NC_OK);
		break;

	case NC_STOP:
		nci->running = false;
		event_base_loopbreak(nci->eb);
		sendcmd(nci->write_fd, NC_OK);
		break;

	default:
		exit(1);
	}
}
Exemple #21
0
int main(int argc, char * argv[]) {
	printf("Naga Epic Control v%d\n", VERSION);

	int retry = 0;
	int count = 0;

	while ((retry == 1 && count < 3) || count == 0) {
		count++;

		if (init() != 0) return 1;

		// Verbose mode
		if (scanArgs("-v", argv, argc)) {
			verbose = 1;
		}
		
		// Brightness control
		unsigned char brightness = 255;
		int tmp = scanArgs("-l", argv, argc);
		if (tmp) {
			if (tmp < argc - 1) tmp++;
			// Looking for number after -l
			brightness = atoi(argv[tmp]);
			// If number not found, looking for on or off
			if (strcmp(argv[tmp], "on") == 0) {
				brightness = 255;
			} else if (strcmp(argv[tmp], "off") == 0) {
				brightness = 0;
			}
			if (verbose) printf("[Debug] Brightness: %d\n", brightness);

			// Building command for mouse
			Lights_Brightness[10] = brightness;
			Lights_Brightness[11] = brightness ^ 3;

			sendcmd(Lights_Brightness);

			// Receiving and checking data
			if (recvcmd()[0] != 1) {
				printf("[Error] Command failed!\n");
				retry = 1;
			} else {
				retry = 0;
			}
		}

		closeHandle();
	}
	return 0;
}
Exemple #22
0
socketpp::Socket FTP::transfercmd(const std::string &cmd)
{
    socketpp::Socket s (socketpp::sock_stream);
    if(_pasv) {
        std::string ip;
        socketpp::port_t port;

        _getAddress(sendcmd("PASV"), ip, port);
        s.connect(ip, port);

    } else {
        throw error_proto("Not yet implemented!\n");
    }
    return s;
}
Exemple #23
0
ftp_client::response ftp_client::list(const char* path, stream& ostream) const
{
    response rsp;

    tcp_stream tcp = impl_->create_tcp_stream_from_pasv();
    if (!tcp.readable())
    {
        rsp.status[0] = 0;
        rsp.detail    = "Create list data connection failed.";
        return rsp;
    }

    if (path)
        rsp = sendcmd("LIST %s", path);
    else
        rsp = sendcmd("LIST");

    if (rsp.status[0] != '1')
        return rsp;

    ostream.plunder(tcp);

    return impl_->get_response();
}
Exemple #24
0
    tcp_stream create_tcp_stream_from_pasv(void)
    {
        response rsp = sendcmd("PASV");
        if (rsp.status[0] != '2')
            return tcp_stream(-1);

        unsigned int u8[6] = {0};
        if (stralgo::unformat(rsp.detail, "%*[^(](%d,%d,%d,%d,%d,%d)",
                              &u8[0], &u8[1], &u8[2], &u8[3],
                              &u8[4], &u8[5]) != 6)
            return tcp_stream(-1);

        return tcp_stream(
            stralgo::format("%d.%d.%d.%d", u8[0], u8[1], u8[2], u8[3]).c_str(),
            u8[4] << 8 | u8[5]);
    }
Exemple #25
0
/*
 * Signal end of connection.
 */
static void
closeconn(void)
{
	debugmsg(DM_CALL, "closeconn() called\n");

	if (rem_w >= 0) {
		/* We don't care if the connection is still good or not */
		signal(SIGPIPE, SIG_IGN);	

		(void) sendcmd(C_FERRMSG, NULL);
		(void) close(rem_w);
		(void) close(rem_r); /* This can't hurt */
		rem_w = -1;
		rem_r = -1;
	}
}
Exemple #26
0
int main() {
  struct cmd_result *result;
  struct ports_table *table;
  int port;
  int i;
  int sockid;
  int ires;

  table = init_ports_table("/opt/pyrame/ports.txt");
  if (table->names == NULL || table->values == NULL) { return -1; }
  port = get_port("TEST_PORT",table);
  if (port == -1) {
    printf("Error getting port number\n");
    return -1;
  }
  free_ports_table(table);

// SENDCMD
  result = sendcmd("localhost",port,"twoargs_test","arg1","arg2","end");
  printf("sendcmd: retcode=%d res=%s\n",result->retcode,result->str);
  if (result->retcode==1) {
    ires=0;
  } else {
    ires=1;
  }
  
  //free the result
  free_cmd_result(result);

// EXECCMD
  sockid = open_socket("localhost",port);
  result = execcmd(sockid,"twoargs_test","arg1","arg2","end");
  close(sockid);
  printf("execcmd: retcode=%d res=%s\n",result->retcode,result->str);
  if (result->retcode==1) {
    ires=0|ires;
  } else {
    ires=1;
  }

  //free the result
  free_cmd_result(result);

  close(sockid);
  return ires;
}
Exemple #27
0
void readHd( int sec, int n, uint8 *buff ) {
    sector = sec;
    nsector = n;
    sendcmd( LBA48_READ );

    while ( nsector-- ) {
        WaitInit();

        if ( readytrans() ) {
            printf( "HardDisk Read Error!\n" );
        }

        inpwn( BUS + HD_DATA, buff, 256 );
        buff += 512;
    }

    while ( inp( BUS + HD_STATUS ) & BUSY_STAT );
}
Exemple #28
0
	bool CMultiHttp::Cancel()
	{
		bool ncode=0;
		DWORD dwCode=3;
		if( m_hThread )
		{
			::GetExitCodeThread(m_hThread,&dwCode);
			if( dwCode==STILL_ACTIVE )
			{
				m_hThread=NULL;
				return true;
			}
		}
		else
			return true;
		if( m_murl && m_fds[1] && m_state==CMultiHttp::Running )
		{
			//重试三次
			dwCode=3;
			do 
			{
				if(!sendcmd(m_fds[0],CMD_CANCEL,sizeof(CMD_CANCEL)))
				{
					dwCode--;
					::Sleep(100);
				}
				else
					break;
			}while( dwCode );
			dwCode=0;
			while( ::GetExitCodeThread(m_hThread,&dwCode) )
			{
				if( dwCode!=STILL_ACTIVE )
					break;
				::Sleep(100);
			}
			m_hThread=NULL;
			m_state = CMultiHttp::Terminate;
			return true;
		}
		else if( m_state==CMultiHttp::Terminate )
			return true;
		return false;
	}
Exemple #29
0
int
nast_upd(nasth *s, const char *key, nast_array *valarray)
{
	char buffer[512];
	int i;
	short bufflen, n_bufflen;

	if (s == NULL) {
		fprintf(stderr, "ERROR: Can't update: no sphincter.\n");
		return -1;
	}

	bufflen = sizeof(short);
	bufflen += add_reqid(buffer+bufflen);

	snprintf(buffer+bufflen, sizeof(buffer)-bufflen, "%c%c%s%c",
		 NASTCMD, NASTUPD, key, NASTSEP);
	bufflen += (3 + strlen(key))*sizeof(char);

	for (i = 0; i < valarray->nitems; i++) {
		char *str;
		short slen;

		str = valarray->items[i]->strdata;
		slen = valarray->items[i]->strlen;
		if (bufflen + slen > sizeof(buffer)) {
			nast_set_error(s, thread_id(), NAST_NOMEM);
			return -1;
		}

		memcpy(buffer+bufflen, str, slen);
		bufflen += slen;

		if (i < valarray->nitems - 1) {
			buffer[bufflen] = NASTSEP;
			bufflen += sizeof(char);
		}
	}

        n_bufflen = htons(bufflen);
	memcpy(buffer, &n_bufflen, sizeof(short));
	sendcmd(s, buffer, bufflen);
	return getresponse(s);
}
Exemple #30
0
ftp_client::response
    ftp_client::get(const char* remotefile, stream& ostream) const
{
    response rsp;

    if (!ostream.writable())
    {
        rsp.status[0] = 0;
        rsp.detail    = "Invalid output stream.";
        return rsp;
    }

    rsp = size(remotefile);
    if (rsp.status[0] != '2')
        return rsp;

    unsigned long total = atol(rsp.detail.c_str());

    tcp_stream tcp = impl_->create_tcp_stream_from_pasv();
    if (!tcp.readable())
    {
        rsp.status[0] = 0;
        rsp.detail    = "Create retr data connection failed.";
        return rsp;
    }

    rsp = sendcmd("RETR %s", remotefile);
    if (rsp.status[0] != '1')
        return rsp;

    unsigned long getted = ostream.plunder(tcp);
    if (getted != total)
    {
        rsp.status[0] = 0;
        rsp.detail    = stralgo::format("getted/total: %ld/%ld", getted, total);
        return rsp;
    }

    return impl_->get_response();
}