Changeset b9766ea


Ignore:
Timestamp:
Dec 19, 2014, 1:49:13 AM (6 years ago)
Author:
Edward Z. Yang <ezyang@mit.edu>
Parents:
5f3f1e4 (diff), 416a7e5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge 416a7e53b80360ba0764edaa41a78445e5a9465c into 5f3f1e484f3c4b262b481efbd32602853bb41a27
Files:
1 added
3 deleted
45 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r41064be rb9766ea  
    171171our $showOffline = 0;
    172172
     173sub blist_getBuddyStatus {
     174    my $jid = shift;
     175    my $buddy = shift;
     176    my $roster = $conn->getRosterFromJID($jid);
     177    my %jq  = $roster->query($buddy);
     178    my $res = $roster->resource($buddy);
     179    if ($res) {
     180        my %rq = $roster->resourceQuery( $buddy, $res );
     181        return $rq{show} ? $rq{show} : 'online';
     182    } else {
     183        return "unknown";
     184    }
     185}
     186
    173187sub blist_listBuddy {
    174188    my $roster = shift;
     
    303317            summary => "Show your Jabber roster.",
    304318            usage   => "jlist"
     319        }
     320    );
     321    BarnOwl::new_command(
     322        jabber_get_buddy_status => \&cmd_jabber_get_buddy_status,
     323        {
     324            summary => "Get the status of a given buddy.",
     325            usage   => "jabber_get_buddy_status [-a account] buddy"
    305326        }
    306327    );
     
    859880}
    860881
     882sub cmd_jabber_get_buddy_status {
     883    my $cmd = shift;
     884    local @ARGV = @_;
     885    my $getopt = Getopt::Long::Parser->new;
     886    my ($jid, $buddy);
     887
     888    $getopt->configure('no_getopt_compat');
     889    $getopt->getoptions(
     890        'account=s' => \$jid,
     891    );
     892    $jid ||= defaultJID();
     893    if ($jid) {
     894        $jid = resolveConnectedJID($jid);
     895        return unless $jid;
     896    }
     897    else {
     898        die("You must specify an account with -a <jid>\n");
     899    }
     900    $buddy = shift @ARGV;
     901    if(!$buddy) {
     902        die("You must specify a JID to get the status of.\n");
     903    }
     904    my $buddy_jid = resolveDestJID($buddy, $jid);
     905    return blist_getBuddyStatus($jid, $buddy_jid);
     906}
     907
    861908
    862909sub jroster_sub {
     
    14911538}
    14921539
     1540sub complete_jabber_get_buddy_status {
     1541    my $ctx = shift;
     1542    return complete_flags($ctx,
     1543                          [qw()],
     1544                          {
     1545                              "-a" => \&complete_account,
     1546                          },
     1547                          \&complete_user_or_muc
     1548        );
     1549}
     1550
    14931551BarnOwl::Completion::register_completer(jwrite => sub { BarnOwl::Module::Jabber::complete_jwrite(@_) });
    14941552BarnOwl::Completion::register_completer(jabberlogout => sub { BarnOwl::Module::Jabber::complete_jabberlogout(@_) });
     1553BarnOwl::Completion::register_completer(jabber_get_buddy_status => sub { BarnOwl::Module::Jabber::complete_jabber_get_buddy_status(@_) });
    14951554
    149615551;
  • .gitignore

    r1c22155 r7834bb5  
     1# Generated by autoreconf
     2Makefile.in
     3/aclocal.m4
     4/autom4te.cache/
     5/compile
     6/config.h.in
     7/config.h.in~
     8/configure
     9/depcomp
     10/install-sh
     11/missing
     12/test-driver
     13
     14# Generated by configure
     15Makefile
     16.deps/
     17/config.cache
     18/config.h
     19/config.log
     20/config.status
     21/stamp-h1
     22
     23# Generated by make
     24*.o
    125*.a
    2 *.o
    3 *.par
    4 .deps
     26/BUILD_VERSION.mk
     27/barnowl
    528/bin/
    6 META.yml
    7 MYMETA.yml
    8 Makefile
    9 Makefile.in
    10 Makefile.old
     29/gmarshal_funcs.c
     30/gmarshal_funcs.h
     31/owl_prototypes.h
     32/owl_prototypes.h.new
     33/perlglue.c
     34/varstubs.c
     35/version.c
     36/version.c.new
     37/zcrypt
     38
     39# Generated by make check
     40/runtests.sh.log
     41/runtests.sh.trs
     42/test-suite.log
     43/tester
     44
     45# Generated by make tags et al.
     46ID
    1147TAGS
    12 aclocal.m4
    13 autom4te.cache
    14 barnowl
    15 blib
    16 config.cache
    17 config.h
    18 config.h.in
    19 config.h.in~
    20 config.log
    21 config.status
    22 configure
    23 core
    24 depcomp
    25 gmarshal_funcs.c
    26 gmarshal_funcs.h
    27 inc/
    28 install-sh
    29 jabber.log
    30 missing
    31 owl_prototypes.h
    32 owl_prototypes.h.new
    33 perlglue.c
    34 pm_to_blib
    35 runtests.sh.log
    36 runtests.sh.trs
    37 stamp-h1
    38 test-driver
    39 test-suite.log
    40 tester
    41 varstubs.c
    42 zcrypt
     48tags
     49/GPATH
     50/GRTAGS
     51/GSYMS
     52/GTAGS
     53/cscope.files
     54/cscope.in.out
     55/cscope.out
     56/cscope.po.out
  • .travis.yml

    r48c09d4 r5f3f1e4  
     1
    12language: perl
    23compiler:
     
    910  - "5.16"
    1011  - "5.18"
    11   - "5.19"
     12  - "5.20"
    1213install:
    1314  - sudo apt-get update -q
  • ChangeLog

    r1b17f50 r6f87658  
    111.9
     2 * Update Jabber module for Net::DNS changes -james2vegas@aim.com
     3 * Update and make configurable the Zephyr default format -adehnert@mit.edu
     4 * Fix a crash when zcrypt fails -andersk@mit.edu
     5 * Fix building with OpenSSL before 0.9.8 -andersk@mit.edu
     6 * Make :loadsubs reload instanced personals too -davidben@mit.edu
     7 * Make Perl zephyr_zwrite call die() when it fails -jgross@mit.edu
     8 * Tell gpg calls from zcrypt to ignore ~/.gnupg -andersk@mit.edu
     9 * Replace outgoing zephyr default format with a small URL -geofft@mit.edu
    210 * Add getnumlines() to perl interface -asedeno@mit.edu
    311 * Include names of invalid filters on filter errors -adehnert@mit.edu
     
    321329 * Support --program-{prefix,suffix,transform}. -nelhage
    322330 * Send instanced pings and give useful error messages -adehnert
    323  * Add <message,*,%me%> to default Barnowl subs. -adehnert
     331 * Add <message,*,%me%> to default BarnOwl subs. -adehnert
    324332 * Maintain instance when using shift-R on personals -adehnert
    325333 * Improve handling of outgoing instanced personals -adehnert
  • Makefile.am

    ra223b6b rca1fb26a  
    11ACLOCAL_AMFLAGS = -I m4
    22
    3 GIT_DESCRIPTION := $(if $(wildcard .git),$(shell git describe --match='barnowl-*' HEAD 2>/dev/null))
    4 GIT_FLAGS := $(if $(GIT_DESCRIPTION),-DGIT_VERSION=$(GIT_DESCRIPTION:barnowl-%=%))
     3GIT_DESCRIPTION := $(if $(wildcard $(srcdir)/.git),$(shell cd $(srcdir) && git describe --match='barnowl-*' HEAD 2>/dev/null))
     4VERSION = $(if $(GIT_DESCRIPTION),$(GIT_DESCRIPTION:barnowl-%=%),@VERSION@)
     5-include BUILD_VERSION.mk
     6
     7FORCE:
     8BUILD_VERSION.mk: $(if $(filter-out $(BUILD_VERSION),$(VERSION)),FORCE)
     9        echo 'BUILD_VERSION = $(VERSION)' > $@
    510
    611bin_PROGRAMS = bin/barnowl
     
    914endif
    1015
    11 zcrypt_SOURCES = zcrypt.c filterproc.c
     16zcrypt_SOURCES = zcrypt.c filterproc.c version.c
    1217
    1318check_PROGRAMS = bin/tester
     
    4752           -I$(top_srcdir)/libfaim/ \
    4853           -DDATADIR='"$(pkgdatadir)"' \
    49            -DBINDIR='"$(bindir)"' \
    50            $(GIT_FLAGS)
     54           -DBINDIR='"$(bindir)"'
    5155
    5256CODELIST_SRCS=message.c mainwin.c popwin.c zephyr.c messagelist.c \
     
    6468BASE_SRCS = $(CODELIST_SRCS) $(NORMAL_SRCS)
    6569
    66 GEN_C = varstubs.c perlglue.c gmarshal_funcs.c
     70GEN_C = varstubs.c perlglue.c gmarshal_funcs.c version.c version.c.new
    6771GEN_H = owl_prototypes.h owl_prototypes.h.new gmarshal_funcs.h
    6872
    69 BUILT_SOURCES = $(GEN_C) $(GEN_H)
     73BUILT_SOURCES = $(GEN_H)
    7074
    7175# Only copy file into place if file.new is different
    72 %: %.new
     76owl_prototypes.h version.c: %: %.new
    7377        @diff -U0 $@ $< || { \
    7478         test -f $@ && echo '$@ changed!'; \
     
    8791        $(AM_V_GEN)perl $< $(sort $(filter-out $<,$+)) > $@
    8892
     93version.c.new: Makefile BUILD_VERSION.mk
     94        $(AM_V_GEN)echo 'const char *version = "$(VERSION)";' > $@
     95
    8996gmarshal_funcs.h: marshal_types
    9097        glib-genmarshal --header $< > $@
     
    96103        $(COMPILE) -Wall -Wextra -pedantic -fsyntax-only $(CHK_SOURCES)
    97104
    98 CLEANFILES = $(BUILT_SOURCES) $(noinst_SCRIPTS) $(check_SCRIPTS)
     105CLEANFILES = $(BUILT_SOURCES) $(GEN_C) $(noinst_SCRIPTS) $(check_SCRIPTS) BUILD_VERSION.mk
    99106EXTRA_DIST = \
    100107    autogen.sh \
  • aim.c

    r8258ea5 r7dcef03  
    10491049  wrapmsg=owl_text_wordwrap(stripmsg, 70);
    10501050  nz_screenname=owl_aim_normalize_screenname(userinfo->sn);
    1051   m=g_new(owl_message, 1);
     1051  m=g_slice_new(owl_message);
    10521052  owl_message_create_aim(m,
    10531053                         nz_screenname,
  • buddy.c

    rd4927a7 r7dcef03  
    7272{
    7373  owl_buddy_cleanup(b);
    74   g_free(b);
     74  g_slice_free(owl_buddy, b);
    7575}
  • buddylist.c

    r3cdd6d2 r7dcef03  
    1111{
    1212  owl_buddy *b;
    13   b=g_new(owl_buddy, 1);
     13  b=g_slice_new(owl_buddy);
    1414 
    1515  owl_buddy_create(b, OWL_PROTOCOL_AIM, screenname);
     
    5050
    5151    /* if not, create the login message */
    52     m=g_new(owl_message, 1);
     52    m=g_slice_new(owl_message);
    5353    owl_message_create_aim(m,
    5454                           screenname,
     
    6969
    7070  if (owl_buddylist_is_aim_buddy_loggedin(bl, screenname)) {
    71     m=g_new(owl_message, 1);
     71    m=g_slice_new(owl_message);
    7272    owl_message_create_aim(m,
    7373                           screenname,
  • cmd.c

    rf271129 r7dcef03  
    3535void owl_cmddict_add_alias(owl_cmddict *cd, const char *alias_from, const char *alias_to) {
    3636  owl_cmd *cmd;
    37   cmd = g_new(owl_cmd, 1);
     37  cmd = g_slice_new(owl_cmd);
    3838  owl_cmd_create_alias(cmd, alias_from, alias_to);
    3939  owl_perlconfig_new_command(cmd->name);
     
    4242
    4343int owl_cmddict_add_cmd(owl_cmddict *cd, const owl_cmd * cmd) {
    44   owl_cmd * newcmd = g_new(owl_cmd, 1);
     44  owl_cmd * newcmd = g_slice_new(owl_cmd);
    4545  if(owl_cmd_create_from_template(newcmd, cmd) < 0) {
    46     g_free(newcmd);
     46    g_slice_free(owl_cmd, newcmd);
    4747    return -1;
    4848  }
     
    141141{
    142142  owl_cmd_cleanup(cmd);
    143   g_free(cmd);
     143  g_slice_free(owl_cmd, cmd);
    144144}
    145145
  • commands.c

    ra38becd rca1fb26a  
    11141114void owl_command_version(void)
    11151115{
    1116   owl_function_makemsg("BarnOwl version %s", OWL_VERSION_STRING);
     1116  owl_function_makemsg("BarnOwl version %s", version);
    11171117}
    11181118
  • context.c

    rf271129 r7dcef03  
    1010  if (!(mode & OWL_CTX_MODE_BITS))
    1111    mode |= OWL_CTX_INTERACTIVE;
    12   c = g_new0(owl_context, 1);
     12  c = g_slice_new0(owl_context);
    1313  c->mode = mode;
    1414  c->data = data;
     
    7171  if (ctx->delete_cb)
    7272    ctx->delete_cb(ctx);
    73   g_free(ctx);
     73  g_slice_free(owl_context, ctx);
    7474}
  • editwin.c

    r8258ea5 r7dcef03  
    6868static CALLER_OWN owl_editwin *owl_editwin_allocate(void)
    6969{
    70   owl_editwin *e = g_new0(owl_editwin, 1);
     70  owl_editwin *e = g_slice_new0(owl_editwin);
    7171  e->refcount = 1;
    7272  return e;
     
    8787  oe_destroy_cbdata(e);
    8888
    89   g_free(e);
     89  g_slice_free(owl_editwin, e);
    9090}
    9191
     
    373373owl_editwin_excursion *owl_editwin_begin_excursion(owl_editwin *e)
    374374{
    375   owl_editwin_excursion *x = g_new(owl_editwin_excursion, 1);
     375  owl_editwin_excursion *x = g_slice_new(owl_editwin_excursion);
    376376  oe_save_excursion(e, x);
    377377  return x;
     
    381381{
    382382  oe_restore_excursion(e, x);
    383   g_free(x);
     383  g_slice_free(owl_editwin_excursion, x);
    384384}
    385385
  • filter.c

    rc068c03 r7dcef03  
    1818  owl_filter *f;
    1919
    20   f = g_new(owl_filter, 1);
     20  f = g_slice_new(owl_filter);
    2121
    2222  f->name=g_strdup(name);
     
    6969  if(!argc) return NULL;
    7070
    71   fe = g_new(owl_filterelement, 1);
     71  fe = g_slice_new(owl_filterelement);
    7272  owl_filterelement_create(fe);
    7373
     
    114114err:
    115115  owl_filterelement_cleanup(fe);
    116   g_free(fe);
     116  g_slice_free(owl_filterelement, fe);
    117117  return NULL;
    118118}
     
    132132    op2 = owl_filter_parse_primitive_expression(argc-i-1, argv+i+1, &skip);
    133133    if(!op2) goto err;
    134     tmp = g_new(owl_filterelement, 1);
     134    tmp = g_slice_new(owl_filterelement);
    135135    if(!strcasecmp(argv[i], "and")) {
    136136      owl_filterelement_create_and(tmp, op1, op2);
     
    152152  if(op1) {
    153153    owl_filterelement_cleanup(op1);
    154     g_free(op1);
     154    g_slice_free(owl_filterelement, op1);
    155155  }
    156156  return NULL;
     
    262262  if (f->root) {
    263263    owl_filterelement_cleanup(f->root);
    264     g_free(f->root);
     264    g_slice_free(owl_filterelement, f->root);
    265265  }
    266266  if (f->name)
    267267    g_free(f->name);
    268   g_free(f);
    269 }
     268  g_slice_free(owl_filter, f);
     269}
  • filterelement.c

    r7756dde r7dcef03  
    328328  if (fe->left) {
    329329    owl_filterelement_cleanup(fe->left);
    330     g_free(fe->left);
     330    g_slice_free(owl_filterelement, fe->left);
    331331  }
    332332  if (fe->right) {
    333333    owl_filterelement_cleanup(fe->right);
    334     g_free(fe->right);
     334    g_slice_free(owl_filterelement, fe->right);
    335335  }
    336336  owl_regex_cleanup(&(fe->re));
  • functions.c

    ra38becd rb61ad80  
    115115void owl_function_show_license(void)
    116116{
    117   const char *text;
    118 
    119   text=""
    120     "BarnOwl version " OWL_VERSION_STRING "\n"
     117  char *text = g_strdup_printf(
     118    "BarnOwl version %s\n"
    121119    "Copyright (c) 2006-2011 The BarnOwl Developers. All rights reserved.\n"
    122120    "Copyright (c) 2004 James Kretchmar. All rights reserved.\n"
     
    155153    "WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n"
    156154    "OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n"
    157     "IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n";
     155    "IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n",
     156    version);
    158157  owl_function_popless_text(text);
     158  g_free(text);
    159159}
    160160
     
    196196  owl_message *m;
    197197
    198   m=g_new(owl_message, 1);
     198  m=g_slice_new(owl_message);
    199199  owl_message_create_admin(m, header, body);
    200200 
     
    218218  if (z->cc && owl_zwrite_is_personal(z)) {
    219219    /* create the message */
    220     owl_message *m = g_new(owl_message, 1);
     220    owl_message *m = g_slice_new(owl_message);
    221221    owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z), 0);
    222222
     
    231231
    232232      /* create the message */
    233       m = g_new(owl_message, 1);
     233      m = g_slice_new(owl_message);
    234234      owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z), i);
    235235
     
    251251  if (!owl_global_is_aimloggedin(&g)) return(NULL);
    252252 
    253   m=g_new(owl_message, 1);
     253  m=g_slice_new(owl_message);
    254254  owl_message_create_aim(m,
    255255                         owl_global_get_aim_screenname(&g),
     
    270270
    271271  /* create the message */
    272   m=g_new(owl_message, 1);
     272  m=g_slice_new(owl_message);
    273273  owl_message_create_loopback(m, body);
    274274  owl_message_set_direction_out(m);
     
    516516  /* create a message and put it on the message queue.  This simulates
    517517   * an incoming message */
    518   min=g_new(owl_message, 1);
     518  min=g_slice_new(owl_message);
    519519  mout=owl_function_make_outgoing_loopback(msg);
    520520
     
    12271227  time_t now;
    12281228  va_list ap;
    1229   va_start(ap, fmt);
    12301229
    12311230  if (!owl_global_is_debug_fast(&g))
     
    12421241          (int) getpid(), tmpbuff, now - owl_global_get_starttime(&g));
    12431242  g_free(tmpbuff);
     1243
     1244  va_start(ap, fmt);
    12441245  vfprintf(file, fmt, ap);
     1246  va_end(ap);
     1247
    12451248  putc('\n', file);
    12461249  fflush(file);
    1247 
    1248   va_end(ap);
    12491250}
    12501251
     
    13591360void owl_function_about(void)
    13601361{
    1361   owl_function_popless_text(
    1362     "This is BarnOwl version " OWL_VERSION_STRING ".\n\n"
     1362  char *text = g_strdup_printf(
     1363    "This is BarnOwl version %s.\n\n"
    13631364    "BarnOwl is a fork of the Owl zephyr client, written and\n"
    13641365    "maintained by Alejandro Sedeno and Nelson Elhage at the\n"
     
    13791380    "This program is free software. You can redistribute it and/or\n"
    13801381    "modify under the terms of the Sleepycat License. Use the \n"
    1381     "':show license' command to display the full license\n"
    1382   );
     1382      "':show license' command to display the full license\n",
     1383      version);
     1384  owl_function_popless_text(text);
     1385  g_free(text);
    13831386}
    13841387
     
    14701473        owl_fmtext_append_normal(&fm, "\n");
    14711474        owl_fmtext_appendf_normal(&fm, "  Port      : %i\n", ntohs(n->z_port));
     1475        owl_fmtext_appendf_normal(&fm, "  Charset   : %s\n", owl_zephyr_get_charsetstr(n));
    14721476        owl_fmtext_appendf_normal(&fm, "  Auth      : %s\n", owl_zephyr_get_authstr(n));
    14731477
     
    17811785
    17821786  owl_fmtext_append_normal(&fm, "  Version: ");
    1783   owl_fmtext_append_normal(&fm, OWL_VERSION_STRING);
     1787  owl_fmtext_append_normal(&fm, version);
    17841788  owl_fmtext_append_normal(&fm, "\n");
    17851789
     
    34793483  while (zaldptr) {
    34803484    ZFreeALD(zaldptr->data);
    3481     g_free(zaldptr->data);
     3485    g_slice_free(ZAsyncLocateData_t, zaldptr->data);
    34823486    zaldptr = g_list_next(zaldptr);
    34833487  }
     
    34893493    for (i = 0; i < anyone->len; i++) {
    34903494      user = anyone->pdata[i];
    3491       zald = g_new(ZAsyncLocateData_t, 1);
     3495      zald = g_slice_new(ZAsyncLocateData_t);
    34923496      if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) {
    34933497        *zaldlist = g_list_append(*zaldlist, zald);
    34943498      } else {
    3495         g_free(zald);
     3499        g_slice_free(ZAsyncLocateData_t, zald);
    34963500      }
    34973501    }
  • global.c

    r120dac7 r7dcef03  
    553553  e->g->filterlist = g_list_remove(e->g->filterlist, e->f);
    554554  owl_filter_delete(e->f);
    555   g_free(e);
     555  g_slice_free(owl_global_filter_ent, e);
    556556}
    557557
    558558void owl_global_add_filter(owl_global *g, owl_filter *f) {
    559   owl_global_filter_ent *e = g_new(owl_global_filter_ent, 1);
     559  owl_global_filter_ent *e = g_slice_new(owl_global_filter_ent);
    560560  e->g = g;
    561561  e->f = f;
  • keybinding.c

    rf271129 r7dcef03  
    1414CALLER_OWN owl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)
    1515{
    16   owl_keybinding *kb = g_new(owl_keybinding, 1);
     16  owl_keybinding *kb = g_slice_new(owl_keybinding);
    1717
    1818  owl_function_debugmsg("owl_keybinding_init: creating binding for <%s> with desc: <%s>", keyseq, desc);
    1919  if (command && function_fn) {
    20     g_free(kb);
     20    g_slice_free(owl_keybinding, kb);
    2121    return NULL;
    2222  } else if (command && !function_fn) {
     
    2929
    3030  if (owl_keybinding_make_keys(kb, keyseq) != 0) {
    31     g_free(kb);
     31    g_slice_free(owl_keybinding, kb);
    3232    return NULL;
    3333  }
     
    7070  g_free(kb->desc);
    7171  g_free(kb->command);
    72   g_free(kb);
     72  g_slice_free(owl_keybinding, kb);
    7373}
    7474
  • keymap.c

    rf271129 r7dcef03  
    189189{
    190190  owl_keymap *km;
    191   km = g_new(owl_keymap, 1);
     191  km = g_slice_new(owl_keymap);
    192192  owl_keymap_init(km, name, desc, default_fn, prealways_fn, postalways_fn);
    193193  owl_keyhandler_add_keymap(kh, km);
  • logging.c

    r0792d99 r7dcef03  
    177177    g_free(msg->message);
    178178    g_free(msg->filename);
    179     g_free(msg);
     179    g_slice_free(owl_log_entry, msg);
    180180  }
    181181}
     
    184184{
    185185  owl_log_entry *log_msg = NULL;
    186   log_msg = g_new(owl_log_entry,1);
     186  log_msg = g_slice_new(owl_log_entry);
    187187  log_msg->message = g_strdup(buffer);
    188188  log_msg->filename = g_strdup(filename);
     
    266266   * owl_log_shouldlog_message(void)
    267267   */
    268   m = g_new(owl_message, 1);
     268  m = g_slice_new(owl_message);
    269269  /* recip_index = 0 because there can only be one recipient anyway */
    270270  owl_message_create_from_zwrite(m, zw, text, 0);
  • mainwin.c

    rab88b05 r7dcef03  
    66CALLER_OWN owl_mainwin *owl_mainwin_new(owl_window *window)
    77{
    8   owl_mainwin *mw = g_new(owl_mainwin, 1);
     8  owl_mainwin *mw = g_slice_new(owl_mainwin);
    99  mw->curtruncated=0;
    1010  mw->lastdisplayed=-1;
  • message.c

    r2354e9a r7dcef03  
    7070
    7171  if(pair ==  NULL) {
    72     pair = g_new(owl_pair, 1);
     72    pair = g_slice_new(owl_pair);
    7373    owl_pair_create(pair, attrname, NULL);
    7474    g_ptr_array_add(m->attributes, pair);
     
    10191019    p = m->attributes->pdata[i];
    10201020    g_free(owl_pair_get_value(p));
    1021     g_free(p);
     1021    g_slice_free(owl_pair, p);
    10221022  }
    10231023
     
    10301030{
    10311031  owl_message_cleanup(m);
    1032   g_free(m);
    1033 }
     1032  g_slice_free(owl_message, m);
     1033}
  • messagelist.c

    r219f52c r7dcef03  
    33CALLER_OWN owl_messagelist *owl_messagelist_new(void)
    44{
    5   owl_messagelist *ml = g_new(owl_messagelist, 1);
     5  owl_messagelist *ml = g_slice_new(owl_messagelist);
    66  ml->list = g_ptr_array_new();
    77  return ml;
     
    1313    g_ptr_array_foreach(ml->list, (GFunc)owl_message_delete, NULL);
    1414  g_ptr_array_free(ml->list, true);
    15   g_free(ml);
     15  g_slice_free(owl_messagelist, ml);
    1616}
    1717
  • owl.c

    r120dac7 r441fd42  
    3636void usage(FILE *file)
    3737{
    38   fprintf(file, "Barnowl version %s\n", OWL_VERSION_STRING);
     38  fprintf(file, "BarnOwl version %s\n", version);
    3939  fprintf(file, "Usage: barnowl [-n] [-d] [-D] [-v] [-h] [-c <configfile>] [-s <confdir>] [-t <ttyname>]\n");
    4040  fprintf(file, "  -n,--no-subs        don't load zephyr subscriptions\n");
    4141  fprintf(file, "  -d,--debug          enable debugging\n");
    42   fprintf(file, "  -v,--version        print the Barnowl version number and exit\n");
     42  fprintf(file, "  -v,--version        print the BarnOwl version number and exit\n");
    4343  fprintf(file, "  -h,--help           print this help message\n");
    4444  fprintf(file, "  -s,--config-dir     specify an alternate config dir (default ~/.owl)\n");
     
    8080      break;
    8181    case 'v':
    82       printf("This is BarnOwl version %s\n", OWL_VERSION_STRING);
     82      printf("This is BarnOwl version %s\n", version);
    8383      exit(0);
    8484    case 'h':
     
    578578  /* welcome message */
    579579  owl_function_debugmsg("startup: creating splash message");
    580   owl_function_adminmsg("",
     580  char *welcome = g_strdup_printf(
    581581    "-----------------------------------------------------------------------\n"
    582     "Welcome to BarnOwl version " OWL_VERSION_STRING ".\n"
     582    "Welcome to BarnOwl version %s.\n"
    583583    "To see a quick introduction, type ':show quickstart'.                  \n"
    584584    "Press 'h' for on-line help.                                            \n"
     
    588588    "                                                                 OvO   \n"
    589589    "Please report any bugs or suggestions to bug-barnowl@mit.edu    (   )  \n"
    590     "-----------------------------------------------------------------m-m---\n"
    591   );
     590    "-----------------------------------------------------------------m-m---\n",
     591    version);
     592  owl_function_adminmsg("", welcome);
     593  g_free(welcome);
    592594
    593595  owl_function_debugmsg("startup: setting context interactive");
  • owl.h

    r120dac7 rca1fb26a  
    6464#include "window.h"
    6565
    66 #ifndef OWL_VERSION_STRING
    67 #ifdef  GIT_VERSION
    68 #define stringify(x)       __stringify(x)
    69 #define __stringify(x)     #x
    70 #define OWL_VERSION_STRING stringify(GIT_VERSION)
    71 #else
    72 #define OWL_VERSION_STRING PACKAGE_VERSION
    73 #endif
    74 #endif /* !OWL_VERSION_STRING */
     66extern const char *version;
    7567
    7668/* Feature that is being tested to redirect stderr through a pipe.
  • perl/lib/BarnOwl/Style/Default.pm

    r732d5c0 rebc6f77  
    129129    my $self = shift;
    130130    my $m = shift;
    131     my $sender = $m->long_sender;
    132     $sender =~ s/\n.*$//s;
     131    my $sender = $self->humanize($m->long_sender, 1);
    133132    if (BarnOwl::getvar('colorztext') eq 'on') {
    134133      return "  (" . $sender . '@color[default]' . ")";
  • perl/modules/Facebook/README

    rf4037cf r441fd42  
    1414
    1515  This token will persist across BarnOwls until you change your
    16   Facebook password or you revoke permissions for Barnowl at:
     16  Facebook password or you revoke permissions for BarnOwl at:
    1717    http://www.facebook.com/settings/?tab=applications&app_id=235537266461636
    1818
    19   (3) Start receiving wall updates in Barnowl!
     19  (3) Start receiving wall updates in BarnOwl!
    2020  You can post updates with the ":facebook" command.
    2121
  • perl/modules/IRC/lib/BarnOwl/Module/IRC.pm

    r4f7b1f4 r926c721  
    2121
    2222use AnyEvent::IRC;
     23use Encode;
     24use File::Spec;
    2325use Getopt::Long;
    24 use Encode;
    2526use Text::Wrap;
    2627
    2728our $VERSION = 0.02;
     29
     30our $IRC_SUBS_FILENAME = "ircchannels";
    2831
    2932our $irc;
     
    169172            summary => 'Connect to an IRC server',
    170173            usage =>
    171 'irc-connect [-a ALIAS ] [-s] [-p PASSWORD] [-n NICK] SERVER [port]',
     174'irc-connect [-a ALIAS] [-s] [-p PASSWORD] [-n NICK] SERVER [port]',
    172175            description => <<END_DESCR
    173176Connect to an IRC server. Supported options are:
     
    230233        {
    231234            summary => 'Join an IRC channel',
    232             usage   => 'irc-join [-a ALIAS] #channel [KEY]',
    233 
    234             description => <<END_DESCR
    235 Join an IRC channel.
     235            usage   => 'irc-join [-a ALIAS] [-t] #channel [KEY]',
     236
     237            description => <<END_DESCR
     238Join an IRC channel.  If the -t option is present the subscription will only be
     239temporary, i.e., it will not be written to the subscription file and will
     240therefore not be present the next time BarnOwl is started, and will disappear
     241if the connection is lost.
    236242END_DESCR
    237243        }
     
    242248        {
    243249            summary => 'Leave an IRC channel',
    244             usage   => 'irc-part [-a ALIAS] #channel',
    245 
    246             description => <<END_DESCR
    247 Part from an IRC channel.
     250            usage   => 'irc-part [-a ALIAS] [-t] #channel',
     251
     252            description => <<END_DESCR
     253Part from an IRC channel.  If the -t option is present the unsubscription will
     254only be temporary, i.e., it will not be updated in the subscription file and
     255will therefore not be in effect the next time BarnOwl is started, or if the
     256connection is lost.
    248257END_DESCR
    249258        }
     
    342351This can be used to perform some operation not yet supported by
    343352BarnOwl, or to define new IRC commands.
     353END_DESCR
     354        }
     355    );
     356
     357    BarnOwl::new_command(
     358        'irc-loadchannels' => \&cmd_loadchannels,
     359        {
     360            summary => 'Reload persistent channels',
     361            usage   => 'irc-loadchannels [-a ALIAS] [<file>]',
     362
     363            description => <<END_DESCR
     364Load persistent channels from a file.  The file defaults to
     365\$HOME/.owl/$IRC_SUBS_FILENAME.  If the ALIAS is present, only channels
     366on the given alias are loaded.  The ALIAS is case-sensitive.
     367
     368Each line of the file should describe a single channel, in the format
     369'\$alias \$channel' (without quotes).
    344370END_DESCR
    345371        }
     
    356382######################## Owl command handlers ##################################
    357383################################################################################
     384
     385sub make_autoconnect_filename {
     386    # can't use ||, or else we'll treat '0' as invalid.  We could check for eq "" ...
     387    # TODO(jgross): When we move to requiring perl 5.10, combine the
     388    # following two lines using //
     389    my $filename = shift;
     390    $filename = File::Spec->catfile(BarnOwl::get_config_dir(), $IRC_SUBS_FILENAME) unless defined $filename;
     391    if (!File::Spec->file_name_is_absolute($filename)) {
     392        $filename = File::Spec->catfile($ENV{HOME}, $filename);
     393    }
     394    return $filename;
     395}
     396
     397sub _get_autoconnect_lines {
     398    my $filename = shift;
     399
     400    # TODO(jgross): Write a C-side function to do this, asynchronously;
     401    #               AIUI, perl doesn't do asynchronous I/O in any useful way
     402    if (open (my $subsfile, "<:encoding(UTF-8)", $filename)) {
     403        my @lines = <$subsfile>;
     404        close($subsfile);
     405
     406        # strip trailing newlines
     407        local $/ = "";
     408        chomp(@lines);
     409
     410        return @lines;
     411    }
     412
     413    return ();
     414}
     415
     416sub get_autoconnect_channels {
     417    my $filename = make_autoconnect_filename(shift);
     418    my %channel_hash = ();
     419
     420    # Load the subs from the file
     421    my @lines = _get_autoconnect_lines($filename);
     422
     423    foreach my $line (@lines) {
     424        my @parsed_args = split(' ', $line);
     425        if (scalar @parsed_args == 2) {
     426            push @{$channel_hash{$parsed_args[0]}}, $parsed_args[1];
     427        } else {
     428            warn "Trouble parsing irc configuration file '$filename' line '$line'; the format is '\$alias \$channel', with no spaces in either\n";
     429        }
     430    }
     431
     432    return %channel_hash;
     433}
     434
     435sub add_autoconnect_channel {
     436    my $conn = shift;
     437    my $channel = shift;
     438    my $alias = $conn->alias;
     439    my $filename = make_autoconnect_filename(shift);
     440
     441    # we already checked for spaces in $channel in cmd_join, but we still need
     442    # to check $alias
     443    die "Alias name '$alias' contains a space; parsing will fail.  Use the -t flag.\n" unless index($alias, " ") == -1;
     444
     445    my $line = "$alias $channel";
     446
     447    my @lines = _get_autoconnect_lines($filename);
     448
     449    # We don't want to be noisy about duplicated joins.  For example, some
     450    # people might have :irc-join in startup files, even though that doesn't
     451    # work correctly anymore because connect is asynchronous and so join on
     452    # startup races with connect.  Regardless, just fail silently if the line
     453    # already exists.
     454    return if grep { $_ eq $line } @lines;
     455
     456    open (my $subsfile, ">>:encoding(UTF-8)", make_autoconnect_filename($filename))
     457        or die "Cannot open $filename for writing: $!\n";
     458    local $, = "";
     459    local $/ = "";
     460    print $subsfile "$line\n";
     461    close($subsfile);
     462}
     463
     464sub remove_autoconnect_channel {
     465    my $conn = shift;
     466    my $channel = shift;
     467    my $alias = $conn->alias;
     468    my $filename = make_autoconnect_filename(shift);
     469
     470    BarnOwl::Internal::file_deleteline($filename, "$alias $channel", 1);
     471}
     472
     473sub cmd_loadchannels {
     474    my $cmd = shift;
     475    my $alias;
     476    my $getopt = Getopt::Long::Parser->new;
     477
     478    local @ARGV = @_;
     479    $getopt->configure(qw(pass_through permute no_getopt_compat prefix_pattern=-|--));
     480    $getopt->getoptions("alias=s" => \$alias);
     481
     482    my %channel_hash = get_autoconnect_channels(@ARGV);
     483
     484    my $aliases = (defined $alias) ? [$alias] : [keys %channel_hash];
     485
     486    foreach my $cur_alias (@$aliases) {
     487        # get_connection_by_alias might die, and we don't want to
     488        eval {
     489            my $conn = get_connection_by_alias($cur_alias, 1);
     490            my %existing_channels = map { $_ => 1 } @{$conn->autoconnect_channels}, @{$channel_hash{$cur_alias}};
     491            $conn->autoconnect_channels([keys %existing_channels]);
     492        };
     493        foreach my $channel (@{$channel_hash{$cur_alias}}) {
     494            if ($cur_alias eq "") {
     495                BarnOwl::command("irc-join", "-t", $channel);
     496            } else {
     497                BarnOwl::command("irc-join", "-t", "-a", $cur_alias, $channel);
     498            }
     499        }
     500    }
     501}
    358502
    359503sub cmd_connect {
     
    393537    }
    394538
     539    my %channel_hash = get_autoconnect_channels;
     540
    395541    my $conn = BarnOwl::Module::IRC::Connection->new($alias, $host, $port, {
    396         nick      => $nick,
    397         user      => $username,
    398         real      => $ircname,
    399         password  => $password,
    400         SSL       => $ssl,
    401         timeout   => sub {0}
     542        nick                 => $nick,
     543        user                 => $username,
     544        real                 => $ircname,
     545        password             => $password,
     546        SSL                  => $ssl,
     547        timeout              => sub {0},
     548        autoconnect_channels => $channel_hash{$alias}
    402549       });
    403550    $ircnets{$alias} = $conn;
     
    486633sub cmd_join {
    487634    my $cmd = shift;
    488     my $conn = shift;
    489     my $chan = shift or die("Usage: $cmd channel\n");
    490     $conn->conn->send_msg(join => $chan, @_);
     635    my $is_temporary;
     636
     637    my $getopt = Getopt::Long::Parser->new;
     638
     639    local @ARGV = @_;
     640    $getopt->configure(qw(pass_through permute no_getopt_compat prefix_pattern=-|--));
     641    $getopt->getoptions("temporary" => \$is_temporary);
     642
     643    my $conn = shift @ARGV;
     644    my $chan = shift @ARGV or die("Usage: $cmd channel\n");
     645
     646    die "Channel name '$chan' contains a space.  As per RFC 2812, IRC channel names may not contain spaces.\n" unless index($chan, " ") == -1;
     647
     648    $conn->conn->send_msg(join => $chan, @ARGV);
     649
     650    # regardless of whether or not this is temporary, we want to persist it
     651    # across reconnects.
     652
     653    # check if the channel is already in the list
     654    if (!grep { $_ eq $chan } @{$conn->autoconnect_channels}) {
     655        push @{$conn->autoconnect_channels}, $chan;
     656    }
     657
     658    if (!$is_temporary) {
     659        # add the line to the subs file
     660        add_autoconnect_channel($conn, $chan);
     661    }
     662
    491663    return;
    492664}
     
    494666sub cmd_part {
    495667    my $cmd = shift;
    496     my $conn = shift;
    497     my $chan = shift;
     668    my $is_temporary;
     669
     670    my $getopt = Getopt::Long::Parser->new;
     671
     672    local @ARGV = @_;
     673    $getopt->configure(qw(pass_through permute no_getopt_compat prefix_pattern=-|--));
     674    $getopt->getoptions("temporary" => \$is_temporary);
     675
     676    my $conn = shift @ARGV;
     677    my $chan = shift @ARGV or die("Usage: $cmd channel\n");
     678
    498679    $conn->conn->send_msg(part => $chan);
     680
     681    # regardless of whether or not this is temporary, we want to persist it
     682    # across reconnects
     683    my %existing_channels = map { $_ => 1 } @{$conn->autoconnect_channels};
     684    delete $existing_channels{$chan};
     685    $conn->autoconnect_channels([keys %existing_channels]);
     686
     687    if (!$is_temporary) {
     688        # remove the line from the subs file
     689        remove_autoconnect_channel($conn, $chan);
     690    }
     691
    499692    return;
    500693}
     
    596789        my $alias;
    597790        my $channel;
     791        my $is_temporary;
    598792        my $getopt = Getopt::Long::Parser->new;
    599793        my $m = BarnOwl::getcurmsg();
     
    601795        local @ARGV = @_;
    602796        $getopt->configure(qw(pass_through permute no_getopt_compat prefix_pattern=-|--));
    603         $getopt->getoptions("alias=s" => \$alias);
     797        $getopt->getoptions("alias=s" => \$alias,
     798                            "temporary" => \$is_temporary);
    604799
    605800        if(defined($alias)) {
     
    640835            die("You must specify an IRC network using -a.\n");
    641836        }
     837        push @ARGV, "-t" if $is_temporary;
    642838        if($flags & CHANNEL_ARG) {
    643839            $sub->($cmd, $conn, $channel, @ARGV);
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Completion.pm

    rdace02a r76e80de  
    5757}
    5858
     59sub complete_irc_join_part {
     60    my $ctx = shift;
     61    return complete_flags($ctx,
     62        [qw(-t)],
     63        {
     64            "-a" => \&complete_networks,
     65        },
     66        \&complete_channels
     67       );
     68}
     69
    5970sub complete_irc_channel {
    6071    my $ctx = shift;
     
    95106BarnOwl::Completion::register_completer('irc-msg'        => \&complete_irc_dest);
    96107BarnOwl::Completion::register_completer('irc-mode'       => \&complete_irc_dest);
    97 BarnOwl::Completion::register_completer('irc-join'       => \&complete_irc_channel);
    98 BarnOwl::Completion::register_completer('irc-part'       => \&complete_irc_channel);
     108BarnOwl::Completion::register_completer('irc-join'       => \&complete_irc_join_part);
     109BarnOwl::Completion::register_completer('irc-part'       => \&complete_irc_join_part);
    99110BarnOwl::Completion::register_completer('irc-names'      => \&complete_irc_channel);
    100111BarnOwl::Completion::register_completer('irc-whois'      => \&complete_irc_nick);
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

    r13ee8f2 rbe43554  
    3939    my $self = bless({}, $class);
    4040    $self->conn($conn);
    41     $self->autoconnect_channels([]);
     41    # TODO(jgross): use // when we move to requiring perl 5.10
     42    $self->autoconnect_channels(defined $args->{autoconnect_channels} ? $args->{autoconnect_channels} : []);
    4243    $self->alias($alias);
    4344    $self->server($host);
     
    412413        $self->{reconnect_timer}->stop;
    413414    }
    414     $self->{reconnect_timer} = 
     415    $self->{reconnect_timer} =
    415416        BarnOwl::Timer->new( {
    416417            name  => 'IRC (' . $self->alias . ') reconnect_timer',
     
    445446            $self->conn->send_msg(join => $c);
    446447        }
    447         $self->autoconnect_channels([]);
    448448    }
    449449    $self->conn->enable_ping(60, sub {
     
    458458    my $backoff = $self->backoff;
    459459
    460     $self->autoconnect_channels([keys(%{$self->{channel_list}})]);
    461460    $self->conn->connect(@{$self->connect_args});
    462461}
  • perl/modules/Twitter/lib/BarnOwl/Module/Twitter.pm

    rb8a3e00 r140429f  
    137137        my $twitter_args = { username   => $cfg->{user},
    138138                             password   => $cfg->{password},
    139                              source     => 'barnowl',
     139                             source     => 'barnowl',
     140                             ssl        => 1,
     141                             legacy_lists_api => 0,
    140142                         };
    141143        if (defined $cfg->{service}) {
     
    274276);
    275277
     278BarnOwl::new_command( 'twitter-favorite' => sub { cmd_twitter_favorite(@_) },
     279    {
     280    summary     => 'Favorite the current Twitter message',
     281    usage       => 'twitter-favorite [ACCOUNT]',
     282    description => <<END_DESCRIPTION
     283Favorite the current Twitter message using ACCOUNT (defaults to the
     284account that received the tweet).
     285END_DESCRIPTION
     286    }
     287);
     288
    276289BarnOwl::new_command( 'twitter-follow' => sub { cmd_twitter_follow(@_); },
    277290    {
     
    355368    $account = $m->account unless defined($account);
    356369    find_account($account)->twitter_retweet($m);
     370    return;
     371}
     372
     373sub cmd_twitter_favorite {
     374    my $cmd = shift;
     375    my $account = shift;
     376    my $m = BarnOwl::getcurmsg();
     377    if(!$m || $m->type ne 'Twitter') {
     378        die("$cmd must be used with a Twitter message selected.\n");
     379    }
     380
     381    $account = $m->account unless defined($account);
     382    find_account($account)->twitter_favorite($m);
    357383    return;
    358384}
  • perl/modules/Twitter/lib/BarnOwl/Module/Twitter/Handle.pm

    r4ebbfbc r140429f  
    371371        $self->twitter_direct($1, $2);
    372372    } elsif(defined $self->{twitter}) {
    373         if(length($msg) > 140) {
    374             die("Twitter: Message over 140 characters long.\n");
    375         }
    376373        $self->twitter_command('update', {
    377374            status => $msg,
     
    432429}
    433430
     431sub twitter_favorite {
     432    my $self = shift;
     433    my $msg = shift;
     434
     435    if($msg->service ne $self->{cfg}->{service}) {
     436        die("Cannot favorite a message from a different service.\n");
     437    }
     438    $self->twitter_command(create_favorite => $msg->{status_id});
     439}
     440
     441
    434442sub twitter_follow {
    435443    my $self = shift;
  • perlconfig.c

    r96d80e9 r7dcef03  
    188188  hash = (HV*)SvRV(msg);
    189189
    190   m = g_new(owl_message, 1);
     190  m = g_slice_new(owl_message);
    191191  owl_message_init(m);
    192192
     
    336336  }
    337337
    338   sv_setpv(get_sv("BarnOwl::VERSION", TRUE), OWL_VERSION_STRING);
     338  sv_setpv(get_sv("BarnOwl::VERSION", TRUE), version);
    339339
    340340  /* Add the system lib path to @INC */
  • perlglue.xs

    r1ced34f r7dcef03  
    232232     CODE:
    233233        {
    234                 s = g_new(owl_style, 1);
     234                s = g_slice_new(owl_style);
    235235                owl_style_create_perl(s, name, newSVsv(object));
    236236                owl_global_add_style(&g, s);
     
    397397MODULE = BarnOwl                PACKAGE = BarnOwl::Internal
    398398
     399
     400int
     401file_deleteline(filename, line, backup)
     402        const char *filename
     403        const char *line
     404        int backup
     405        CODE:
     406                RETVAL = owl_util_file_deleteline(filename, line, backup);
     407        OUTPUT:
     408                RETVAL
    399409
    400410void
  • popexec.c

    re146cd7 r7dcef03  
    2323  }
    2424
    25   pe = g_new(owl_popexec, 1);
     25  pe = g_slice_new(owl_popexec);
    2626  pe->winactive=0;
    2727  pe->pid=0;
     
    179179  if (pe->refcount<=0) {
    180180    owl_function_debugmsg("doing free of %p", pe);
    181     g_free(pe);
     181    g_slice_free(owl_popexec, pe);
    182182  }
    183183}
  • popwin.c

    r6829afc r7dcef03  
    33CALLER_OWN owl_popwin *owl_popwin_new(void)
    44{
    5   owl_popwin *pw = g_new0(owl_popwin, 1);
     5  owl_popwin *pw = g_slice_new0(owl_popwin);
    66
    77  pw->border = owl_window_new(NULL);
     
    9292  g_object_unref(pw->content);
    9393
    94   g_free(pw);
     94  g_slice_free(owl_popwin, pw);
    9595}
    9696
  • runtests.sh

    r5db8835 r7dcef03  
    11#!/bin/sh
     2export G_SLICE=debug-blocks
    23exec env HARNESS_PERL=./tester prove --failures "${srcdir:=$(dirname "$0")}/t/"
  • select.c

    r84a071f r7dcef03  
    4141  if (t->destroy_cbdata)
    4242    t->destroy_cbdata(t->cbdata);
    43   g_free(t);
     43  g_slice_free(owl_task, t);
    4444}
    4545
     
    4747{
    4848  GSource *source = g_idle_source_new();
    49   owl_task *t = g_new0(owl_task, 1);
     49  owl_task *t = g_slice_new0(owl_task);
    5050  t->cb = cb;
    5151  t->cbdata = cbdata;
  • style.c

    r92ffd89 r7dcef03  
    103103{
    104104  owl_style_cleanup(s);
    105   g_free(s);
     105  g_slice_free(owl_style, s);
    106106}
  • tester.c

    r6a8b519 r21dc927  
    2525int owl_history_regtest(void);
    2626int call_filter_regtest(void);
     27int owl_smartstrip_regtest(void);
    2728
    2829extern void owl_perl_xs_init(pTHX);
     
    116117  numfailures += owl_history_regtest();
    117118  numfailures += call_filter_regtest();
     119  numfailures += owl_smartstrip_regtest();
    118120  if (numfailures) {
    119121      fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures);
     
    10181020  return numfailed;
    10191021}
     1022
     1023int owl_smartstrip_regtest(void)
     1024{
     1025  int numfailed = 0;
     1026
     1027  printf("# BEGIN testing owl_zephyr_smartstripped_user\n");
     1028
     1029#define CHECK_SMARTSTRIP(in, expected)                  \
     1030  do {                                                  \
     1031    char *__value = owl_zephyr_smartstripped_user(in);  \
     1032    FAIL_UNLESS("owl_zephyr_smartstripped_user " in,    \
     1033                strcmp((expected), __value) == 0);      \
     1034    g_free(__value);                                    \
     1035  } while (0)
     1036
     1037  CHECK_SMARTSTRIP("foo", "foo");
     1038  CHECK_SMARTSTRIP("foo.bar", "foo");
     1039  CHECK_SMARTSTRIP("foo/bar", "foo");
     1040  CHECK_SMARTSTRIP("host/bar", "host/bar");
     1041  CHECK_SMARTSTRIP("rcmd.bar", "rcmd.bar");
     1042  CHECK_SMARTSTRIP("daemon/bar", "daemon/bar");
     1043  CHECK_SMARTSTRIP("daemon.bar", "daemon.bar");
     1044
     1045  CHECK_SMARTSTRIP("foo@ATHENA.MIT.EDU", "foo@ATHENA.MIT.EDU");
     1046  CHECK_SMARTSTRIP("foo.bar@ATHENA.MIT.EDU", "foo@ATHENA.MIT.EDU");
     1047  CHECK_SMARTSTRIP("foo/bar@ATHENA.MIT.EDU", "foo@ATHENA.MIT.EDU");
     1048  CHECK_SMARTSTRIP("host/bar@ATHENA.MIT.EDU", "host/bar@ATHENA.MIT.EDU");
     1049  CHECK_SMARTSTRIP("rcmd.bar@ATHENA.MIT.EDU", "rcmd.bar@ATHENA.MIT.EDU");
     1050  CHECK_SMARTSTRIP("daemon/bar@ATHENA.MIT.EDU", "daemon/bar@ATHENA.MIT.EDU");
     1051  CHECK_SMARTSTRIP("daemon.bar@ATHENA.MIT.EDU", "daemon.bar@ATHENA.MIT.EDU");
     1052
     1053  printf("# END testing owl_zephyr_smartstripped_user\n");
     1054
     1055  return numfailed;
     1056}
  • util.c

    r7b89e8c rcba6b9c  
    468468  if (fstat(fileno(old), &st) != 0) {
    469469    owl_function_error("Cannot stat %s: %s", filename, strerror(errno));
     470    fclose(old);
    470471    return -1;
    471472  }
     
    473474  /* resolve symlinks, because link() fails on symlinks, at least on AFS */
    474475  actual_filename = owl_util_recursive_resolve_link(filename);
    475   if (actual_filename == NULL)
     476  if (actual_filename == NULL) {
     477    fclose(old);
    476478    return -1; /* resolving the symlink failed, but we already logged this error */
     479  }
    477480
    478481  newfile = g_strdup_printf("%s.new", actual_filename);
  • variable.c

    r9d4dfdc r94b9ee0  
    627627
    628628static owl_variable *owl_variable_newvar(int type, const char *name, const char *summary, const char *description, const char *validsettings) {
    629   owl_variable *var = g_new0(owl_variable, 1);
     629  owl_variable *var = g_slice_new0(owl_variable);
    630630  var->type = type;
    631631  var->name = g_strdup(name);
     
    793793  g_closure_unref(v->set_fromstring_fn);
    794794
    795   g_free(v);
     795  g_slice_free(owl_variable, v);
    796796}
    797797
     
    10381038CALLER_OWN char *owl_variable_bool_get_tostring_default(const owl_variable *v, void *dummy)
    10391039{
    1040   bool val = owl_variable_get_bool(v);
    1041   if (val == 0) {
    1042     return g_strdup("off");
    1043   } else if (val == 1) {
    1044     return g_strdup("on");
    1045   } else {
    1046     return g_strdup("<invalid>");
    1047   }
     1040  return g_strdup(owl_variable_get_bool(v) ? "on" : "off");
    10481041}
    10491042
  • viewwin.c

    r7803326 r7dcef03  
    1313CALLER_OWN owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text)
    1414{
    15   owl_viewwin *v = g_new0(owl_viewwin, 1);
     15  owl_viewwin *v = g_slice_new0(owl_viewwin);
    1616  owl_fmtext_init_null(&(v->fmtext));
    1717  if (text) {
     
    3636{
    3737  char *text;
    38   owl_viewwin *v = g_new0(owl_viewwin, 1);
     38  owl_viewwin *v = g_slice_new0(owl_viewwin);
    3939
    4040  owl_fmtext_copy(&(v->fmtext), fmtext);
     
    424424  g_object_unref(v->status);
    425425  owl_fmtext_cleanup(&(v->fmtext));
    426   g_free(v);
    427 }
     426  g_slice_free(owl_viewwin, v);
     427}
  • zcrypt.c

    r8f335a8 rca1fb26a  
    2929#include "filterproc.h"
    3030
    31 #ifndef OWL_VERSION_STRING
    32 #ifdef  GIT_VERSION
    33 #define stringify(x)       __stringify(x)
    34 #define __stringify(x)     #x
    35 #define OWL_VERSION_STRING stringify(GIT_VERSION)
    36 #else
    37 #define OWL_VERSION_STRING PACKAGE_VERSION
    38 #endif
    39 #endif /* !OWL_VERSION_STRING */
     31extern const char *version;
    4032
    4133/* Annotate functions in which the caller owns the return value and is
     
    157149      case OPT_VERSION:
    158150        /* Version */
    159         printf("This is zcrypt version %s\n", OWL_VERSION_STRING);
     151        printf("This is zcrypt version %s\n", version);
    160152        exit(0);
    161153      case OPT_HELP:
  • zephyr.c

    r80d7b44 r18380fd  
    125125    owl_zephyr_loadsubs_helper(subs->subs, subs->nsubs);
    126126    deferred_subs = g_list_delete_link(deferred_subs, deferred_subs);
    127     g_free(subs);
     127    g_slice_free(owl_sub_list, subs);
    128128  }
    129129
     
    152152  ret_sd = owl_zephyr_loaddefaultsubs();
    153153
    154   /* load Barnowl default subscriptions */
     154  /* load BarnOwl default subscriptions */
    155155  ret_bd = owl_zephyr_loadbarnowldefaultsubs();
    156156
     
    261261    g_free(subs);
    262262  } else {
    263     owl_sub_list *s = g_new(owl_sub_list, 1);
     263    owl_sub_list *s = g_slice_new(owl_sub_list);
    264264    s->subs = subs;
    265265    s->nsubs = count;
     
    283283#ifdef HAVE_LIBZEPHYR
    284284  FILE *file;
     285  int fopen_errno;
    285286  char *tmp, *start;
    286287  char *buffer = NULL;
     
    289290  int subSize = 1024;
    290291  int count;
    291   struct stat statbuff;
    292292
    293293  subsfile = owl_zephyr_dotfile(".zephyr.subs", filename);
    294294
    295   if (stat(subsfile, &statbuff) != 0) {
    296     g_free(subsfile);
    297     if (error_on_nofile == 1)
     295  count = 0;
     296  file = fopen(subsfile, "r");
     297  fopen_errno = errno;
     298  g_free(subsfile);
     299  if (!file) {
     300    if (error_on_nofile == 1 || fopen_errno != ENOENT)
    298301      return -1;
    299302    return 0;
    300303  }
    301 
    302   ZResetAuthentication();
    303   count = 0;
    304   file = fopen(subsfile, "r");
    305   g_free(subsfile);
    306   if (!file)
    307     return -1;
    308304
    309305  subs = g_new(ZSubscription_t, subSize);
     
    348344    g_free(buffer);
    349345
     346  ZResetAuthentication();
    350347  return owl_zephyr_loadsubs_helper(subs, count);
    351348#else
     
    354351}
    355352
    356 /* Load default Barnowl subscriptions
     353/* Load default BarnOwl subscriptions
    357354 *
    358355 * Returns 0 on success.
     
    363360#ifdef HAVE_LIBZEPHYR
    364361  ZSubscription_t *subs;
    365   int subSize = 10; /* Max Barnowl default subs we allow */
     362  int subSize = 10; /* Max BarnOwl default subs we allow */
    366363  int count, ret;
    367364
     
    412409  char *buffer = NULL;
    413410  int count;
    414   struct stat statbuff;
    415411
    416412  subs = g_new(ZSubscription_t, numSubs);
    417413  subsfile = owl_zephyr_dotfile(".anyone", filename);
    418414
    419   if (stat(subsfile, &statbuff) == -1) {
    420     g_free(subs);
    421     g_free(subsfile);
    422     return 0;
    423   }
    424 
    425   ZResetAuthentication();
    426415  count = 0;
    427416  file = fopen(subsfile, "r");
     
    445434    fclose(file);
    446435  } else {
     436    g_free(subs);
    447437    return 0;
    448438  }
    449439  g_free(buffer);
    450440
     441  ZResetAuthentication();
    451442  return owl_zephyr_loadsubs_helper(subs, count);
    452443#else
     
    11061097}
    11071098
     1099#ifdef HAVE_LIBZEPHYR
     1100const char *owl_zephyr_get_charsetstr(const ZNotice_t *n)
     1101{
     1102#ifdef ZCHARSET_UTF_8
     1103  return ZCharsetToString(n->z_charset);
     1104#else
     1105  return "";
     1106#endif
     1107}
     1108#else
     1109const char *owl_zephyr_get_charsetstr(const void *n)
     1110{
     1111  return "";
     1112}
     1113#endif
     1114
    11081115/* return auth string */
    11091116#ifdef HAVE_LIBZEPHYR
     
    13031310CALLER_OWN char *owl_zephyr_smartstripped_user(const char *in)
    13041311{
    1305   char *slash, *dot, *realm, *out;
    1306 
    1307   out = g_strdup(in);
    1308 
    1309   /* bail immeaditly if we don't have to do any work */
    1310   slash = strchr(out, '/');
    1311   dot = strchr(out, '.');
    1312   if (!slash && !dot) {
    1313     return(out);
    1314   }
    1315 
    1316   if (!strncasecmp(out, OWL_ZEPHYR_NOSTRIP_HOST, strlen(OWL_ZEPHYR_NOSTRIP_HOST)) ||
    1317       !strncasecmp(out, OWL_ZEPHYR_NOSTRIP_RCMD, strlen(OWL_ZEPHYR_NOSTRIP_RCMD)) ||
    1318       !strncasecmp(out, OWL_ZEPHYR_NOSTRIP_DAEMON5, strlen(OWL_ZEPHYR_NOSTRIP_DAEMON5)) ||
    1319       !strncasecmp(out, OWL_ZEPHYR_NOSTRIP_DAEMON4, strlen(OWL_ZEPHYR_NOSTRIP_DAEMON4))) {
    1320     return(out);
    1321   }
    1322 
    1323   realm = strchr(out, '@');
    1324   if (!slash && dot && realm && (dot > realm)) {
    1325     /* There's no '/', and the first '.' is in the realm */
    1326     return(out);
    1327   }
    1328 
    1329   /* remove the realm from out, but hold on to it */
    1330   if (realm) realm[0]='\0';
    1331 
    1332   /* strip */
    1333   if (slash) slash[0] = '\0';  /* krb5 style user/instance */
    1334   else if (dot) dot[0] = '\0'; /* krb4 style user.instance */
    1335 
    1336   /* reattach the realm if we had one */
    1337   if (realm) {
    1338     strcat(out, "@");
    1339     strcat(out, realm+1);
    1340   }
    1341 
    1342   return(out);
     1312  int n = strcspn(in, "./");
     1313  char *realm = strchrnul(in, '@');
     1314
     1315  if (in + n >= realm ||
     1316      g_str_has_prefix(in, OWL_ZEPHYR_NOSTRIP_HOST) ||
     1317      g_str_has_prefix(in, OWL_ZEPHYR_NOSTRIP_RCMD) ||
     1318      g_str_has_prefix(in, OWL_ZEPHYR_NOSTRIP_DAEMON5) ||
     1319      g_str_has_prefix(in, OWL_ZEPHYR_NOSTRIP_DAEMON4))
     1320    return g_strdup(in);
     1321  else
     1322    return g_strdup_printf("%.*s%s", n, in, realm);
    13431323}
    13441324
     
    14241404          if (ret == ZERR_NONE) {
    14251405            /* Send a PSEUDO LOGIN! */
    1426             m = g_new(owl_message, 1);
     1406            m = g_slice_new(owl_message);
    14271407            owl_message_create_pseudo_zlogin(m, 0, zald->user,
    14281408                                             location.host,
     
    14371417        /* Send a PSEUDO LOGOUT! */
    14381418        if (notify) {
    1439           m = g_new(owl_message, 1);
     1419          m = g_slice_new(owl_message);
    14401420          owl_message_create_pseudo_zlogin(m, 1, zald->user, "", "", "");
    14411421          owl_global_messagequeue_addmsg(&g, m);
     
    14461426    }
    14471427    ZFreeALD(zald);
    1448     g_free(zald);
     1428    g_slice_free(ZAsyncLocateData_t, zald);
    14491429  }
    14501430}
     
    15131493
    15141494      /* create the new message */
    1515       m=g_new(owl_message, 1);
     1495      m=g_slice_new(owl_message);
    15161496      owl_message_create_from_znotice(m, &notice);
    15171497
  • zwrite.c

    r919cbf2 r7dcef03  
    33CALLER_OWN owl_zwrite *owl_zwrite_new_from_line(const char *line)
    44{
    5   owl_zwrite *z = g_new(owl_zwrite, 1);
     5  owl_zwrite *z = g_slice_new(owl_zwrite);
    66  if (owl_zwrite_create_from_line(z, line) != 0) {
    7     g_free(z);
     7    g_slice_free(owl_zwrite, z);
    88    return NULL;
    99  }
     
    1313CALLER_OWN owl_zwrite *owl_zwrite_new(int argc, const char *const *argv)
    1414{
    15   owl_zwrite *z = g_new(owl_zwrite, 1);
     15  owl_zwrite *z = g_slice_new(owl_zwrite);
    1616  if (owl_zwrite_create(z, argc, argv) != 0) {
    17     g_free(z);
     17    g_slice_free(owl_zwrite, z);
    1818    return NULL;
    1919  }
     
    356356{
    357357  owl_zwrite_cleanup(z);
    358   g_free(z);
     358  g_slice_free(owl_zwrite, z);
    359359}
    360360
Note: See TracChangeset for help on using the changeset viewer.