Changes in / [7cfb1df:69c3878]


Ignore:
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    r42ad917 r1703f72  
    44*~
    55.#*
     6.*.swp
    67.deps
    78META.yml
  • Makefile.am

    r42ad917 rb373d44  
    2020perl_tester_SOURCES = $(BASE_SRCS) \
    2121     owl.h owl_perl.h config.h \
    22      libzcrypt.a \
    2322     $(GEN_C) $(GEN_H) \
    2423     perl_tester.c
    2524
    26 perl_tester_LDADD = libfaim/libfaim.a libzcrypt.a
     25perl_tester_LDADD = libfaim/libfaim.a
    2726
    2827TESTS=runtests.sh
     
    4342GEN_H = owl_prototypes.h
    4443
     44TYPEMAP = typemap
     45
    4546BUILT_SOURCES = $(GEN_C) $(GEN_H)
    4647
     
    5455proto: owl_prototypes.h
    5556
    56 perlglue.c: perlglue.xs
    57         $(AM_V_GEN)perl $(XSUBPPDIR)/xsubpp $(XSUBPPFLAGS) -prototypes perlglue.xs > perlglue.c
     57perlglue.c: perlglue.xs $(TYPEMAP)
     58        $(AM_V_GEN)perl $(XSUBPPDIR)/xsubpp $(XSUBPPFLAGS) -prototypes perlglue.xs -typemap $(TYPEMAP) > perlglue.c
    5859
    5960varstubs.c: stubgen.pl variable.c
  • aim.c

    rc79a047 r1fdca1b  
    249249}
    250250
     251/*
     252 * I got these constants by skimming libfaim/im.c
     253 *
     254 * "UNICODE" actually means "UCS-2BE".
     255 */
     256#define AIM_CHARSET_ISO_8859_1         0x0003
     257#define AIM_CHARSET_UNICODE            0x0002
     258
     259int owl_aim_do_send(const char *to, const char *msg, int flags) /* noproto */
     260{
     261  int ret;
     262  char *encoded;
     263  struct aim_sendimext_args args;
     264    gsize len;
     265
     266  encoded = g_convert(msg, -1, "ISO-8859-1", "UTF-8", NULL, &len, NULL);
     267  if (encoded) {
     268    owl_function_debugmsg("Encoded outgoing AIM as ISO-8859-1");
     269    args.charset = AIM_CHARSET_ISO_8859_1;
     270    args.charsubset = 0;
     271    args.flags = AIM_IMFLAGS_ISO_8859_1;
     272  } else {
     273    owl_function_debugmsg("Encoding outgoing IM as UCS-2BE");
     274    encoded = g_convert(msg, -1, "UCS-2BE", "UTF-8", NULL, &len, NULL);
     275    if (!encoded) {
     276      /*
     277       * TODO: Strip or HTML-encode characters, or figure out how to
     278       * send in a differen charset.
     279       */
     280      owl_function_error("Unable to encode outgoing AIM message in UCS-2");
     281      return 1;
     282    }
     283
     284    args.charset = AIM_CHARSET_UNICODE;
     285    args.charsubset = 0;
     286    args.flags = AIM_IMFLAGS_UNICODE;
     287  }
     288
     289  args.destsn = to;
     290  args.msg = encoded;
     291  args.msglen = len;
     292  args.flags |= flags;
     293
     294  ret=aim_im_sendch1_ext(owl_global_get_aimsess(&g), &args);
     295
     296  owl_free(encoded);
     297
     298  return(ret);
     299}
     300
    251301int owl_aim_send_im(const char *to, const char *msg)
    252302{
    253   int ret;
    254 
    255   ret=aim_im_sendch1(owl_global_get_aimsess(&g), to, 0, msg);
    256    
    257   /* I don't know how to check for an error yet */
    258   return(ret);
     303  return owl_aim_do_send(to, msg, 0);
    259304}
    260305
    261306int owl_aim_send_awaymsg(const char *to, const char *msg)
    262307{
    263   int ret;
    264 
    265   ret=aim_im_sendch1(owl_global_get_aimsess(&g), to, AIM_IMFLAGS_AWAY, msg);
    266 
    267   /* I don't know how to check for an error yet */
    268   return(ret);
     308  return owl_aim_do_send(to, msg, AIM_IMFLAGS_AWAY);
    269309}
    270310
     
    11491189  owl_message *m;
    11501190  char *stripmsg, *nz_screenname, *wrapmsg;
    1151   char realmsg[8192+1] = "";
    1152   /* int clienttype = AIM_CLIENTTYPE_UNKNOWN; */
    1153 
    1154   /* clienttype = aim_fingerprintclient(args->features, args->featureslen); */
    1155 
    1156   /*
    1157   printf("icbm: sn = \"%s\"\n", userinfo->sn);
    1158   printf("icbm: probable client type: %d\n", clienttype);
    1159   printf("icbm: warnlevel = %f\n", aim_userinfo_warnlevel(userinfo));
    1160   printf("icbm: flags = 0x%04x = ", userinfo->flags);
    1161   printuserflags(userinfo->flags);
    1162   printf("\n");
    1163   */
    1164 
    1165   /*
    1166   printf("icbm: membersince = %lu\n", userinfo->membersince);
    1167   printf("icbm: onlinesince = %lu\n", userinfo->onlinesince);
    1168   printf("icbm: idletime = 0x%04x\n", userinfo->idletime);
    1169   printf("icbm: capabilities = %s = 0x%08lx\n", (userinfo->present & AIM_USERINFO_PRESENT_CAPABILITIES) ? "present" : "not present", userinfo->capabilities);
    1170   */
    1171 
    1172   /*
    1173   printf("icbm: icbmflags = ");
    1174   if (args->icbmflags & AIM_IMFLAGS_AWAY) printf("away ");
    1175   if (args->icbmflags & AIM_IMFLAGS_ACK) printf("ackrequest ");
    1176   if (args->icbmflags & AIM_IMFLAGS_OFFLINE) printf("offline ");
    1177   if (args->icbmflags & AIM_IMFLAGS_BUDDYREQ) printf("buddyreq ");
    1178   if (args->icbmflags & AIM_IMFLAGS_HASICON) printf("hasicon ");
    1179   printf("\n");
    1180   */
    1181 
    1182   /*
    1183   if (args->icbmflags & AIM_IMFLAGS_CUSTOMCHARSET) {
    1184   printf("icbm: encoding flags = {%04x, %04x}\n", args->charset, args->charsubset);
    1185   }
    1186   */
    1187  
    1188   /*
    1189    * Quickly convert it to eight bit format, replacing non-ASCII UNICODE
    1190    * characters with their equivelent HTML entity.
    1191    */
    1192   if (args->icbmflags & AIM_IMFLAGS_UNICODE) {
    1193     int i;
    1194    
    1195     for (i=0; i<args->msglen; i+=2) {
    1196       fu16_t uni;
    1197 
    1198       uni = ((args->msg[i] & 0xff) << 8) | (args->msg[i+1] & 0xff);
    1199       if ((uni < 128) || ((uni >= 160) && (uni <= 255))) { /* ISO 8859-1 */
    1200         snprintf(realmsg+strlen(realmsg), sizeof(realmsg)-strlen(realmsg), "%c", uni);
    1201       } else { /* something else, do UNICODE entity */
    1202         snprintf(realmsg+strlen(realmsg), sizeof(realmsg)-strlen(realmsg), "&#%04x;", uni);
    1203       }
    1204     }
     1191  char *realmsg = NULL;
     1192
     1193  if (!args->msg) {
     1194    realmsg = owl_strdup("");
     1195  } else if (args->icbmflags & AIM_IMFLAGS_UNICODE) {
     1196    realmsg = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE",
     1197                        NULL, NULL, NULL);
     1198  } else if(args->icbmflags & AIM_IMFLAGS_ISO_8859_1) {
     1199    realmsg = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1",
     1200                        NULL, NULL, NULL);
    12051201  } else {
    1206     /*
    1207      * For non-UNICODE encodings (ASCII and ISO 8859-1), there is
    1208      * no need to do anything special here.  Most
    1209      * terminals/whatever will be able to display such characters
    1210      * unmodified.
    1211      *
    1212      * Beware that PC-ASCII 128 through 159 are _not_ actually
    1213      * defined in ASCII or ISO 8859-1, and you should send them as
    1214      * UNICODE.  WinAIM will send these characters in a UNICODE
    1215      * message, so you need to do so as well.
    1216      *
    1217      * You may not think it necessary to handle UNICODE messages. 
    1218      * You're probably wrong.  For one thing, Microsoft "Smart
    1219      * Quotes" will be sent by WinAIM as UNICODE (not HTML UNICODE,
    1220      * but real UNICODE). If you don't parse UNICODE at all, your
    1221      * users will get a blank message instead of the message
    1222      * containing Smart Quotes.
    1223      *
    1224      */
    1225     if (args->msg && args->msglen)
    1226       strncpy(realmsg, args->msg, sizeof(realmsg));
     1202    realmsg = owl_strdup(args->msg);
     1203  }
     1204
     1205  if (!realmsg) {
     1206    realmsg = owl_strdup("[Error decoding incoming IM]");
    12271207  }
    12281208
     
    12691249  }
    12701250
    1271   /*
    1272   if (realmsg) {
    1273     int i = 0;
    1274     while (realmsg[i] == '<') {
    1275       if (realmsg[i] == '<') {
    1276         while (realmsg[i] != '>')
    1277           i++;
    1278         i++;
    1279       }
    1280     }
    1281     tmpstr = realmsg+i;
    1282     faimtest_handlecmd(sess, conn, userinfo, tmpstr);
    1283   }
    1284   */
    1285  
     1251  owl_free(realmsg);
     1252
    12861253  return(1);
    12871254}
  • commands.c

    r61de085 r5ade618  
    861861  OWLCMD_VOID_CTX("edit:history-next", owl_command_edit_history_next,
    862862                  OWL_CTX_EDIT,
    863                   "replaces the text with the previous history",
     863                  "replaces the text with the next history",
    864864                  "", ""),
    865865
  • editwin.c

    r2184001 r6c171f1  
    326326static void oe_release_excursion(owl_editwin *e, oe_excursion *x)
    327327{
    328   oe_excursion *p;
     328  oe_excursion **px;
    329329
    330330  x->valid = 0;
    331   if (e->excursions == NULL)
    332     /* XXX huh. */ ;
    333   else if (e->excursions == x)
    334     e->excursions = x->next;
    335   else {
    336     for (p = e->excursions; p->next != NULL; p = p->next)
    337       if (p->next == x) {
    338         p->next = p->next->next;
    339         break;
    340       }
    341     /* and if we ran off the end? XXX */
    342   }
     331  for (px = &e->excursions; *px != NULL; px = &(*px)->next)
     332    if (*px == x) {
     333      *px = x->next;
     334      return;
     335    }
     336  abort();
    343337}
    344338
     
    12581252
    12591253  if (!g_unichar_iscntrl(c) || c == '\n' || c== '\t' ) {
    1260     memset(tmp, 0, 7);
    1261 
    12621254    if (c == '\n' && e->style == OWL_EDITWIN_STYLE_ONELINE) {
    12631255      return;
     
    13021294      return; /* our work here is done */
    13031295
    1304     g_unichar_to_utf8(c, tmp);
     1296    tmp[g_unichar_to_utf8(c, tmp)] = '\0';
    13051297    owl_editwin_replace(e, 0, tmp);
    13061298  }
  • fmtext.c

    rf119757 r6c171f1  
    5757
    5858  /* Set attributes */
    59   if (a) {
    60     memset(attrbuff,0,6);
    61     g_unichar_to_utf8(OWL_FMTEXT_UC_ATTR | attr, attrbuff);
    62     strcat(f->textbuff, attrbuff);     
    63   }
    64   if (fg) {
    65     memset(attrbuff,0,6);
    66     g_unichar_to_utf8(OWL_FMTEXT_UC_FGCOLOR | fgcolor, attrbuff);
    67     strcat(f->textbuff, attrbuff);     
    68   }
    69   if (bg) {
    70     memset(attrbuff,0,6);
    71     g_unichar_to_utf8(OWL_FMTEXT_UC_BGCOLOR | bgcolor, attrbuff);
    72     strcat(f->textbuff, attrbuff);     
    73   }
     59  if (a)
     60    strncat(f->textbuff, attrbuff,
     61            g_unichar_to_utf8(OWL_FMTEXT_UC_ATTR | attr, attrbuff));
     62  if (fg)
     63    strncat(f->textbuff, attrbuff,
     64            g_unichar_to_utf8(OWL_FMTEXT_UC_FGCOLOR | fgcolor, attrbuff));
     65  if (bg)
     66    strncat(f->textbuff, attrbuff,
     67            g_unichar_to_utf8(OWL_FMTEXT_UC_BGCOLOR | bgcolor, attrbuff));
    7468 
    7569  strcat(f->textbuff, text);
     
    202196  _owl_fmtext_realloc(f, newlen);
    203197
    204   if (a) {
    205     memset(attrbuff,0,6);
    206     g_unichar_to_utf8(OWL_FMTEXT_UC_ATTR | attr, attrbuff);
    207     strcat(f->textbuff, attrbuff);     
    208   }
    209   if (fg) {
    210     memset(attrbuff,0,6);
    211     g_unichar_to_utf8(OWL_FMTEXT_UC_FGCOLOR | fgcolor, attrbuff);
    212     strcat(f->textbuff, attrbuff);     
    213   }
    214   if (bg) {
    215     memset(attrbuff,0,6);
    216     g_unichar_to_utf8(OWL_FMTEXT_UC_BGCOLOR | bgcolor, attrbuff);
    217     strcat(f->textbuff, attrbuff);     
    218   }
     198  if (a)
     199    strncat(f->textbuff, attrbuff,
     200            g_unichar_to_utf8(OWL_FMTEXT_UC_ATTR | attr, attrbuff));
     201  if (fg)
     202    strncat(f->textbuff, attrbuff,
     203            g_unichar_to_utf8(OWL_FMTEXT_UC_FGCOLOR | fgcolor, attrbuff));
     204  if (bg)
     205    strncat(f->textbuff, attrbuff,
     206            g_unichar_to_utf8(OWL_FMTEXT_UC_BGCOLOR | bgcolor, attrbuff));
    219207
    220208  strncat(f->textbuff, in->textbuff+start, stop-start+1);
     
    315303        int start, end;
    316304        while (owl_regex_compare(owl_global_get_search_re(&g), s, &start, &end) == 0) {
     305          /* Prevent an infinite loop matching the empty string. */
     306          if (end == 0)
     307            break;
     308
    317309          /* Found search string, highlight it. */
    318310
  • functions.c

    r340c3e7 rdca3b27  
    19411941{
    19421942  owl_fmtext fm;
    1943   char *ptr, buff[LINE];
     1943  char *ptr;
     1944  char *result;
    19441945  int i;
    19451946
     
    19471948
    19481949  for (i=0; i<argc; i++) {
    1949     ptr=long_zuser(argv[i]);
    1950     owl_zephyr_zlocate(ptr, buff, auth);
    1951     owl_fmtext_append_normal(&fm, buff);
     1950    ptr = long_zuser(argv[i]);
     1951    result = owl_zephyr_zlocate(ptr, auth);
     1952    owl_fmtext_append_normal(&fm, result);
     1953    owl_free(result);
    19521954    owl_free(ptr);
    19531955  }
  • perl/lib/BarnOwl.pm

    rde3f641 r77c87b2  
    435435sub default_zephyr_signature
    436436{
    437   if (my $zsig = getvar('zsig')) {
    438     return $zsig;
     437  my $zsig = getvar('zsig');
     438  if (!$zsig && (my $zsigproc = getvar('zsigproc'))) {
     439    $zsig = `$zsigproc`;
     440  } elsif (!defined($zsig = get_zephyr_variable('zwrite-signature'))) {
     441    $zsig = ((getpwuid($<))[6]);
     442    $zsig =~ s/,.*//;
    439443  }
    440   if (my $zsigproc = getvar('zsigproc')) {
    441     return `$zsigproc`;
    442   }
    443   my $zwrite_signature = get_zephyr_variable('zwrite-signature');
    444   if (defined($zwrite_signature)) {
    445     return $zwrite_signature;
    446   }
    447   my $name = ((getpwuid($<))[6]);
    448   $name =~ s/,.*//;
    449   return $name;
     444  chomp($zsig);
     445  return $zsig;
    450446}
    451447
  • perl/modules/IRC/lib/BarnOwl/Module/IRC.pm

    recee82f r0c4a190  
    399399    $body =~ tr/\n\r/  /;
    400400    if ($body =~ /^\/me (.*)/) {
    401         $conn->conn->me($to, $1);
     401        $conn->conn->me($to, Encode::encode('utf-8', $1));
    402402        $body = '* '.$conn->nick.' '.$1;
    403403    } else {
    404         $conn->conn->privmsg($to, $body);
     404        $conn->conn->privmsg($to, Encode::encode('utf-8', $body));
    405405    }
    406406    my $msg = BarnOwl::Message->new(
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r5118b32 r26cde20  
    321321              . "add <jid>     Adds <jid> to your roster.\n\n"
    322322              . "unsub <jid>   Unsubscribe from <jid>'s presence.\n\n"
    323               . "remove <jid>  Removes <jid> to your roster. (implicit unsub)\n\n"
     323              . "remove <jid>  Removes <jid> from your roster. (implicit unsub)\n\n"
    324324              . "auth <jid>    Authorizes <jid> to subscribe to your presence.\n\n"
    325325              . "deauth <jid>  De-authorizes <jid>'s subscription to your presence.\n\n"
  • perl_tester.c

    r42ad917 r737b8f1  
    3232  perl_free(my_perl);
    3333  PERL_SYS_TERM();
     34  return 0;
    3435}
    3536
  • perlglue.xs

    r9e5b5fd r5791bf7  
    99
    1010#define SV_IS_CODEREF(sv) (SvROK((sv)) && SvTYPE(SvRV((sv))) == SVt_PVCV)
     11
     12typedef char utf8;
    1113
    1214        /*************************************************************
     
    2931MODULE = BarnOwl                PACKAGE = BarnOwl
    3032
    31 const char *
     33const utf8 *
    3234command(cmd, ...)
    3335        const char *cmd
     
    7779                RETVAL
    7880
    79 const char *
     81const utf8 *
    8082zephyr_getrealm()
    8183        CODE:
     
    8486                RETVAL
    8587
    86 const char *
     88const utf8 *
    8789zephyr_getsender()
    8890        CODE:
     
    100102                i = owl_zwrite_create_and_send_from_line(cmd, msg);
    101103
    102 const char *
     104const utf8 *
    103105ztext_stylestrip(ztext)
    104106        const char *ztext
     
    113115                if (rv) owl_free(rv);
    114116
    115 const char *
     117const utf8 *
    116118zephyr_smartstrip_user(in)
    117119        const char *in
     
    128130                owl_free(rv);
    129131
    130 const char *
     132const utf8 *
    131133zephyr_getsubs()
    132134        PREINIT:
     
    140142                if (rv) owl_free(rv);
    141143
    142 void queue_message(msg)
     144void
     145queue_message(msg)
    143146        SV *msg
    144147        PREINIT:
     
    155158        }
    156159
    157 void admin_message(header, body)
     160void
     161admin_message(header, body)
    158162        const char *header
    159163        const char *body
     
    163167        }
    164168
    165 void start_question(line, callback)
     169void
     170start_question(line, callback)
    166171        const char *line
    167172        SV *callback
     
    178183        }
    179184
    180 void start_password(line, callback)
     185void
     186start_password(line, callback)
    181187        const char *line
    182188        SV *callback
     
    193199        }
    194200
    195 void start_edit_win(line, callback)
     201void
     202start_edit_win(line, callback)
    196203        const char *line
    197204        SV *callback
     
    309316        }
    310317
    311 const char *
     318const utf8 *
    312319wordwrap(in, cols)
    313320        const char *in
     
    321328                RETVAL
    322329        CLEANUP:
    323                 if (rv) owl_free(rv);
     330                if (rv)
     331                        owl_free(rv);
    324332
    325333void
     
    424432                RETVAL
    425433
    426 const char *
     434const utf8 *
    427435skiptokens(str, n)
    428436        const char *str;
     
    564572                RETVAL
    565573
    566 const char *
     574const utf8 *
    567575get_region()
    568576        PREINIT:
  • zephyr.c

    rc79a047 rdca3b27  
    911911#endif
    912912
    913 void owl_zephyr_zlocate(const char *user, char *out, int auth)
     913char *owl_zephyr_zlocate(const char *user, int auth)
    914914{
    915915#ifdef HAVE_LIBZEPHYR
     
    918918  ZLocations_t locations;
    919919  char *myuser;
    920  
    921   strcpy(out, "");
     920  char *p, *result;
     921
    922922  ZResetAuthentication();
    923   ret=ZLocateUser(zstr(user),&numlocs,auth?ZAUTH:ZNOAUTH);
    924   if (ret != ZERR_NONE) {
    925     sprintf(out, "Error locating user %s\n", user);
    926     return;
    927   }
    928 
    929   if (numlocs==0) {
    930     myuser=short_zuser(user);
    931     sprintf(out, "%s: Hidden or not logged in\n", myuser);
    932     owl_free(myuser);
    933     return;
    934   }
    935    
    936   for (;numlocs;numlocs--) {
    937     ZGetLocations(&locations,&one);
    938     myuser=short_zuser(user);
    939     sprintf(out + strlen(out), "%s: %s\t%s\t%s\n", myuser,
    940             locations.host ? locations.host : "?",
    941             locations.tty ? locations.tty : "?",
    942             locations.time ? locations.time : "?");
    943     owl_free(myuser);
    944   }
     923  ret = ZLocateUser(zstr(user), &numlocs, auth ? ZAUTH : ZNOAUTH);
     924  if (ret != ZERR_NONE)
     925    return owl_sprintf("Error locating user %s: %s\n",
     926                       user, error_message(ret));
     927
     928  myuser = short_zuser(user);
     929  if (numlocs == 0) {
     930    result = owl_sprintf("%s: Hidden or not logged in\n", myuser);
     931  } else {
     932    result = owl_strdup("");
     933    for (; numlocs; numlocs--) {
     934      ZGetLocations(&locations, &one);
     935      p = owl_sprintf("%s%s: %s\t%s\t%s\n",
     936                          result, myuser,
     937                          locations.host ? locations.host : "?",
     938                          locations.tty ? locations.tty : "?",
     939                          locations.time ? locations.time : "?");
     940      owl_free(result);
     941      result = p;
     942    }
     943  }
     944
     945  return result;
     946#else
     947  return owl_strdup("");
    945948#endif
    946949}
Note: See TracChangeset for help on using the changeset viewer.