Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <libircclient.h>
- void my_event(irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count){
- printf("event: %s\n",event);
- }
- int main(int argc, char **argv) {
- irc_session_t *S = NULL;
- const char *addr = "irc.freenode.net";
- int port = 6667;
- const char *nick = "testnick";
- const char *pass = NULL;
- const char *user = NULL;
- const char *real = NULL;
- printf("Connecting to: %s:%s@%s:%d [%s|%s]\n",nick,pass?pass:"",addr,port,user?user:"",real?real:"");
- irc_callbacks_t cbs = {
- my_event,
- my_event,
- my_event,
- my_event,
- my_event,
- my_event,
- my_event,
- my_event,
- my_event,
- my_event,
- my_event,
- my_event,
- // my_event_channel_notice,
- my_event,
- my_event,
- my_event,
- my_event,
- my_event,
- NULL,
- NULL,
- NULL
- };
- int ircerrno;
- S = irc_create_session(&cbs);
- if(S==NULL){
- printf("could not create session\n");
- return(0);
- }
- irc_option_set(S, LIBIRC_OPTION_STRIPNICKS|LIBIRC_OPTION_DEBUG);
- ircerrno = irc_connect( S, addr, port, pass, nick, user, real );
- if(ircerrno!=0){
- printf("could not connect to server: %s\n",irc_strerror(ircerrno));
- return(0);
- }
- ircerrno = irc_run(S);
- if(ircerrno!=0){
- printf("irc_run: %s\n",irc_strerror(ircerrno));
- ircerrno = irc_errno(S);
- printf("irc_run: %s\n",irc_strerror(ircerrno));
- }
- return 0;
- }
- **** OUTPUT
- Connecting to: testnick:@irc.freenode.net:6667 [|]
- irc_run: Invalid argument
- irc_run: No error
Add Comment
Please, Sign In to add comment