44 PROCESS(shell_irc_process,
"irc");
47 "irc <server> <nick>: start an IRC chat",
51 #define MAX_SERVERLEN 16
52 #define MAX_NICKLEN 16
54 static uip_ipaddr_t serveraddr;
55 static char server[MAX_SERVERLEN + 1];
56 static char nick[MAX_NICKLEN + 1];
58 static struct ircc_state s;
60 static unsigned char running;
64 ircc_text_output(
struct ircc_state *s,
char *text1,
char *text2)
66 char buf1[MAX_NICKLEN + MAX_SERVERLEN];
69 strncpy(buf1, text1,
sizeof(buf1));
71 if(len <
sizeof(buf1) - 1) {
79 parse_line(
char *line)
82 if(strncmp(&line[1],
"join", 4) == 0) {
83 ircc_join(&s, &line[6]);
84 ircc_text_output(&s,
"Join", &line[6]);
85 }
else if(strncmp(&line[1],
"list", 4) == 0) {
87 ircc_text_output(&s,
"Channel list",
"");
88 }
else if(strncmp(&line[1],
"part", 4) == 0) {
90 ircc_text_output(&s,
"Leaving channel",
"");
91 }
else if(strncmp(&line[1],
"quit", 4) == 0) {
93 }
else if(strncmp(&line[1],
"me", 2) == 0) {
94 ircc_actionmsg(&s, &line[4]);
95 ircc_text_output(&s,
"*", &line[4]);
97 ircc_text_output(&s, &line[1],
"Not implemented");
100 ircc_msg(&s, &line[0]);
101 ircc_text_output(&s, nick, line);
106 ircc_sent(
struct ircc_state *s)
112 ircc_closed(
struct ircc_state *s)
114 ircc_text_output(s, server,
"connection closed");
119 ircc_connected(
struct ircc_state *s)
121 ircc_text_output(s, server,
"connected");
131 next = strchr(data,
' ');
134 "irc <server> <nick>: server as address",
"");
139 strncpy(server, data,
sizeof(server));
140 strncpy(nick, next,
sizeof(nick));
145 ircc_connect(&s, server, &serveraddr, nick);
151 if(input->len1 > 0) {
152 parse_line(input->data1);
159 if((
char *)data !=
NULL &&
162 ircc_connect(&s, server, serveraddr, nick);
Hostname is fresh and usable.
void shell_output_str(struct shell_command *c, char *text1, const char *text2)
Output strings from a shell command.
#define PROCESS_EXIT()
Exit the currently running process.
#define PROCESS_BEGIN()
Define the beginning of a process.
Main header file for the Contiki shell
#define NULL
The null pointer.
#define uiplib_ipaddrconv
Convert a textual representation of an IP address to a numerical representation.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define PROCESS_END()
Define the end of a process.
CCIF process_event_t resolv_event_found
Event that is broadcasted when a DNS name has been resolved.
#define uip_ipaddr_copy(dest, src)
Copy an IP address from one place to another.
Structure for shell input data.
void shell_register_command(struct shell_command *c)
Register a command with the shell.
#define PROCESS_WAIT_EVENT()
Wait for an event to be posted to the process.
#define PROCESS(name, strname)
Declare a process.
int shell_event_input
The event number for shell input data.
process_event_t tcpip_event
The uIP event.
#define SHELL_COMMAND(name, command, description, process)
Define a shell command.