Guest User

Untitled

a guest
Nov 26th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #include <libircclient.h>
  6.  
  7. void my_event(irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count){
  8. printf("event: %s\n",event);
  9. }
  10.  
  11. int main(int argc, char **argv) {
  12.  
  13. irc_session_t *S = NULL;
  14.  
  15. const char *addr = "irc.freenode.net";
  16. int port = 6667;
  17. const char *nick = "testnick";
  18. const char *pass = NULL;
  19. const char *user = NULL;
  20. const char *real = NULL;
  21.  
  22. printf("Connecting to: %s:%s@%s:%d [%s|%s]\n",nick,pass?pass:"",addr,port,user?user:"",real?real:"");
  23.  
  24. irc_callbacks_t cbs = {
  25. my_event,
  26. my_event,
  27. my_event,
  28. my_event,
  29. my_event,
  30. my_event,
  31. my_event,
  32. my_event,
  33. my_event,
  34. my_event,
  35. my_event,
  36. my_event,
  37. // my_event_channel_notice,
  38. my_event,
  39. my_event,
  40. my_event,
  41. my_event,
  42. my_event,
  43. NULL,
  44. NULL,
  45. NULL
  46. };
  47.  
  48. int ircerrno;
  49. S = irc_create_session(&cbs);
  50. if(S==NULL){
  51. printf("could not create session\n");
  52. return(0);
  53. }
  54.  
  55. irc_option_set(S, LIBIRC_OPTION_STRIPNICKS|LIBIRC_OPTION_DEBUG);
  56.  
  57. ircerrno = irc_connect( S, addr, port, pass, nick, user, real );
  58. if(ircerrno!=0){
  59. printf("could not connect to server: %s\n",irc_strerror(ircerrno));
  60. return(0);
  61. }
  62.  
  63. ircerrno = irc_run(S);
  64. if(ircerrno!=0){
  65. printf("irc_run: %s\n",irc_strerror(ircerrno));
  66. ircerrno = irc_errno(S);
  67. printf("irc_run: %s\n",irc_strerror(ircerrno));
  68. }
  69.  
  70. return 0;
  71. }
  72.  
  73.  
  74. **** OUTPUT
  75. Connecting to: testnick:@irc.freenode.net:6667 [|]
  76. irc_run: Invalid argument
  77. irc_run: No error
Add Comment
Please, Sign In to add comment