ruby: be consistent with notmuch's coding style

No functional change, just indentation
This commit is contained in:
Ali Polatel 2011-10-04 16:41:52 +03:00
parent 898613116d
commit 05dddf883d
13 changed files with 593 additions and 595 deletions

View file

@ -21,9 +21,9 @@
#include "defs.h" #include "defs.h"
VALUE VALUE
notmuch_rb_database_alloc(VALUE klass) notmuch_rb_database_alloc (VALUE klass)
{ {
return Data_Wrap_Struct(klass, NULL, NULL, NULL); return Data_Wrap_Struct (klass, NULL, NULL, NULL);
} }
/* /*
@ -36,7 +36,7 @@ notmuch_rb_database_alloc(VALUE klass)
* The argument :mode specifies the open mode of the database. * The argument :mode specifies the open mode of the database.
*/ */
VALUE VALUE
notmuch_rb_database_initialize(int argc, VALUE *argv, VALUE self) notmuch_rb_database_initialize (int argc, VALUE *argv, VALUE self)
{ {
const char *path; const char *path;
int create, mode; int create, mode;
@ -44,43 +44,42 @@ notmuch_rb_database_initialize(int argc, VALUE *argv, VALUE self)
VALUE modev; VALUE modev;
#if !defined(RSTRING_PTR) #if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr) # define RSTRING_PTR(v) (RSTRING((v))->ptr)
#endif /* !defined(RSTRING_PTR) */ #endif /* !defined(RSTRING_PTR) */
/* Check arguments */ /* Check arguments */
rb_scan_args(argc, argv, "11", &pathv, &hashv); rb_scan_args (argc, argv, "11", &pathv, &hashv);
SafeStringValue(pathv); SafeStringValue (pathv);
path = RSTRING_PTR(pathv); path = RSTRING_PTR (pathv);
if (!NIL_P(hashv)) { if (!NIL_P (hashv)) {
Check_Type(hashv, T_HASH); Check_Type (hashv, T_HASH);
create = RTEST(rb_hash_aref(hashv, ID2SYM(ID_db_create))); create = RTEST (rb_hash_aref (hashv, ID2SYM (ID_db_create)));
modev = rb_hash_aref(hashv, ID2SYM(ID_db_mode)); modev = rb_hash_aref (hashv, ID2SYM (ID_db_mode));
if (NIL_P(modev)) if (NIL_P (modev))
mode = NOTMUCH_DATABASE_MODE_READ_ONLY; mode = NOTMUCH_DATABASE_MODE_READ_ONLY;
else if (!FIXNUM_P(modev)) else if (!FIXNUM_P (modev))
rb_raise(rb_eTypeError, ":mode isn't a Fixnum"); rb_raise (rb_eTypeError, ":mode isn't a Fixnum");
else { else {
mode = FIX2INT(modev); mode = FIX2INT (modev);
switch (mode) { switch (mode) {
case NOTMUCH_DATABASE_MODE_READ_ONLY: case NOTMUCH_DATABASE_MODE_READ_ONLY:
case NOTMUCH_DATABASE_MODE_READ_WRITE: case NOTMUCH_DATABASE_MODE_READ_WRITE:
break; break;
default: default:
rb_raise(rb_eTypeError, "Invalid mode"); rb_raise ( rb_eTypeError, "Invalid mode");
} }
} }
} } else {
else { create = 0;
create = 0; mode = NOTMUCH_DATABASE_MODE_READ_ONLY;
mode = NOTMUCH_DATABASE_MODE_READ_ONLY;
} }
Check_Type(self, T_DATA); Check_Type (self, T_DATA);
DATA_PTR(self) = create ? notmuch_database_create(path) : notmuch_database_open(path, mode); DATA_PTR (self) = create ? notmuch_database_create (path) : notmuch_database_open (path, mode);
if (!DATA_PTR(self)) if (!DATA_PTR (self))
rb_raise(notmuch_rb_eDatabaseError, "Failed to open database"); rb_raise (notmuch_rb_eDatabaseError, "Failed to open database");
return self; return self;
} }
@ -93,15 +92,15 @@ notmuch_rb_database_initialize(int argc, VALUE *argv, VALUE self)
* the block. * the block.
*/ */
VALUE VALUE
notmuch_rb_database_open(int argc, VALUE *argv, VALUE klass) notmuch_rb_database_open (int argc, VALUE *argv, VALUE klass)
{ {
VALUE obj; VALUE obj;
obj = rb_class_new_instance(argc, argv, klass); obj = rb_class_new_instance (argc, argv, klass);
if (!rb_block_given_p()) if (!rb_block_given_p ())
return obj; return obj;
return rb_ensure(rb_yield, obj, notmuch_rb_database_close, obj); return rb_ensure (rb_yield, obj, notmuch_rb_database_close, obj);
} }
/* /*
@ -110,13 +109,13 @@ notmuch_rb_database_open(int argc, VALUE *argv, VALUE klass)
* Close the notmuch database. * Close the notmuch database.
*/ */
VALUE VALUE
notmuch_rb_database_close(VALUE self) notmuch_rb_database_close (VALUE self)
{ {
notmuch_database_t *db; notmuch_database_t *db;
Data_Get_Notmuch_Database(self, db); Data_Get_Notmuch_Database (self, db);
notmuch_database_close(db); notmuch_database_close (db);
DATA_PTR(self) = NULL; DATA_PTR (self) = NULL;
return Qnil; return Qnil;
} }
@ -127,13 +126,13 @@ notmuch_rb_database_close(VALUE self)
* Return the path of the database * Return the path of the database
*/ */
VALUE VALUE
notmuch_rb_database_path(VALUE self) notmuch_rb_database_path (VALUE self)
{ {
notmuch_database_t *db; notmuch_database_t *db;
Data_Get_Notmuch_Database(self, db); Data_Get_Notmuch_Database (self, db);
return rb_str_new2(notmuch_database_get_path(db)); return rb_str_new2 (notmuch_database_get_path (db));
} }
/* /*
@ -142,13 +141,13 @@ notmuch_rb_database_path(VALUE self)
* Return the version of the database * Return the version of the database
*/ */
VALUE VALUE
notmuch_rb_database_version(VALUE self) notmuch_rb_database_version (VALUE self)
{ {
notmuch_database_t *db; notmuch_database_t *db;
Data_Get_Notmuch_Database(self, db); Data_Get_Notmuch_Database (self, db);
return INT2FIX(notmuch_database_get_version(db)); return INT2FIX (notmuch_database_get_version (db));
} }
/* /*
@ -157,20 +156,20 @@ notmuch_rb_database_version(VALUE self)
* Return the +true+ if the database needs upgrading, +false+ otherwise * Return the +true+ if the database needs upgrading, +false+ otherwise
*/ */
VALUE VALUE
notmuch_rb_database_needs_upgrade(VALUE self) notmuch_rb_database_needs_upgrade (VALUE self)
{ {
notmuch_database_t *db; notmuch_database_t *db;
Data_Get_Notmuch_Database(self, db); Data_Get_Notmuch_Database (self, db);
return notmuch_database_needs_upgrade(db) ? Qtrue : Qfalse; return notmuch_database_needs_upgrade (db) ? Qtrue : Qfalse;
} }
static void static void
notmuch_rb_upgrade_notify(void *closure, double progress) notmuch_rb_upgrade_notify (void *closure, double progress)
{ {
VALUE *block = (VALUE *)closure; VALUE *block = (VALUE *) closure;
rb_funcall(*block, ID_call, 1, rb_float_new(progress)); rb_funcall (*block, ID_call, 1, rb_float_new (progress));
} }
/* /*
@ -182,24 +181,24 @@ notmuch_rb_upgrade_notify(void *closure, double progress)
* floating point value in the range of [0.0..1.0]. * floating point value in the range of [0.0..1.0].
*/ */
VALUE VALUE
notmuch_rb_database_upgrade(VALUE self) notmuch_rb_database_upgrade (VALUE self)
{ {
notmuch_status_t ret; notmuch_status_t ret;
void (*pnotify) (void *closure, double progress); void (*pnotify) (void *closure, double progress);
notmuch_database_t *db; notmuch_database_t *db;
VALUE block; VALUE block;
Data_Get_Notmuch_Database(self, db); Data_Get_Notmuch_Database (self, db);
if (rb_block_given_p()) { if (rb_block_given_p ()) {
pnotify = notmuch_rb_upgrade_notify; pnotify = notmuch_rb_upgrade_notify;
block = rb_block_proc(); block = rb_block_proc ();
} }
else else
pnotify = NULL; pnotify = NULL;
ret = notmuch_database_upgrade(db, pnotify, pnotify ? &block : NULL); ret = notmuch_database_upgrade (db, pnotify, pnotify ? &block : NULL);
notmuch_rb_status_raise(ret); notmuch_rb_status_raise (ret);
return Qtrue; return Qtrue;
} }
@ -210,15 +209,15 @@ notmuch_rb_database_upgrade(VALUE self)
* Begin an atomic database operation. * Begin an atomic database operation.
*/ */
VALUE VALUE
notmuch_rb_database_begin_atomic(VALUE self) notmuch_rb_database_begin_atomic (VALUE self)
{ {
notmuch_status_t ret; notmuch_status_t ret;
notmuch_database_t *db; notmuch_database_t *db;
Data_Get_Notmuch_Database(self, db); Data_Get_Notmuch_Database (self, db);
ret = notmuch_database_begin_atomic(db); ret = notmuch_database_begin_atomic (db);
notmuch_rb_status_raise(ret); notmuch_rb_status_raise (ret);
return Qtrue; return Qtrue;
} }
@ -229,15 +228,15 @@ notmuch_rb_database_begin_atomic(VALUE self)
* Indicate the end of an atomic database operation. * Indicate the end of an atomic database operation.
*/ */
VALUE VALUE
notmuch_rb_database_end_atomic(VALUE self) notmuch_rb_database_end_atomic (VALUE self)
{ {
notmuch_status_t ret; notmuch_status_t ret;
notmuch_database_t *db; notmuch_database_t *db;
Data_Get_Notmuch_Database(self, db); Data_Get_Notmuch_Database (self, db);
ret = notmuch_database_end_atomic(db); ret = notmuch_database_end_atomic (db);
notmuch_rb_status_raise(ret); notmuch_rb_status_raise (ret);
return Qtrue; return Qtrue;
} }
@ -248,26 +247,26 @@ notmuch_rb_database_end_atomic(VALUE self)
* Retrieve a directory object from the database for 'path' * Retrieve a directory object from the database for 'path'
*/ */
VALUE VALUE
notmuch_rb_database_get_directory(VALUE self, VALUE pathv) notmuch_rb_database_get_directory (VALUE self, VALUE pathv)
{ {
const char *path; const char *path;
notmuch_directory_t *dir; notmuch_directory_t *dir;
notmuch_database_t *db; notmuch_database_t *db;
Data_Get_Notmuch_Database(self, db); Data_Get_Notmuch_Database (self, db);
#if !defined(RSTRING_PTR) #if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr) # define RSTRING_PTR(v) (RSTRING((v))->ptr)
#endif /* !defined(RSTRING_PTR) */ #endif /* !defined(RSTRING_PTR) */
SafeStringValue(pathv); SafeStringValue (pathv);
path = RSTRING_PTR(pathv); path = RSTRING_PTR (pathv);
dir = notmuch_database_get_directory(db, path); dir = notmuch_database_get_directory (db, path);
if (!dir) if (!dir)
rb_raise(notmuch_rb_eXapianError, "Xapian exception"); rb_raise (notmuch_rb_eXapianError, "Xapian exception");
return Data_Wrap_Struct(notmuch_rb_cDirectory, NULL, NULL, dir); return Data_Wrap_Struct (notmuch_rb_cDirectory, NULL, NULL, dir);
} }
/* /*
@ -279,30 +278,30 @@ notmuch_rb_database_get_directory(VALUE self, VALUE pathv)
* duplicate. * duplicate.
*/ */
VALUE VALUE
notmuch_rb_database_add_message(VALUE self, VALUE pathv) notmuch_rb_database_add_message (VALUE self, VALUE pathv)
{ {
const char *path; const char *path;
notmuch_status_t ret; notmuch_status_t ret;
notmuch_message_t *message; notmuch_message_t *message;
notmuch_database_t *db; notmuch_database_t *db;
Data_Get_Notmuch_Database(self, db); Data_Get_Notmuch_Database (self, db);
#if !defined(RSTRING_PTR) #if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr) # define RSTRING_PTR(v) (RSTRING((v))->ptr)
#endif /* !defined(RSTRING_PTR) */ #endif /* !defined(RSTRING_PTR) */
SafeStringValue(pathv); SafeStringValue (pathv);
path = RSTRING_PTR(pathv); path = RSTRING_PTR (pathv);
ret = notmuch_database_add_message(db, path, &message); ret = notmuch_database_add_message (db, path, &message);
notmuch_rb_status_raise(ret); notmuch_rb_status_raise (ret);
return rb_assoc_new(Data_Wrap_Struct(notmuch_rb_cMessage, NULL, NULL, message), return rb_assoc_new (Data_Wrap_Struct (notmuch_rb_cMessage, NULL, NULL, message),
(ret == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) ? Qtrue : Qfalse); (ret == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) ? Qtrue : Qfalse);
} }
/* /*
* call-seq: DB.remove_message(path) => isdup * call-seq: DB.remove_message (path) => isdup
* *
* Remove a message from the database. * Remove a message from the database.
* *
@ -310,23 +309,23 @@ notmuch_rb_database_add_message(VALUE self, VALUE pathv)
* duplicate. * duplicate.
*/ */
VALUE VALUE
notmuch_rb_database_remove_message(VALUE self, VALUE pathv) notmuch_rb_database_remove_message (VALUE self, VALUE pathv)
{ {
const char *path; const char *path;
notmuch_status_t ret; notmuch_status_t ret;
notmuch_database_t *db; notmuch_database_t *db;
Data_Get_Notmuch_Database(self, db); Data_Get_Notmuch_Database (self, db);
#if !defined(RSTRING_PTR) #if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr) # define RSTRING_PTR(v) (RSTRING((v))->ptr)
#endif /* !defined(RSTRING_PTR) */ #endif /* !defined (RSTRING_PTR) */
SafeStringValue(pathv); SafeStringValue (pathv);
path = RSTRING_PTR(pathv); path = RSTRING_PTR (pathv);
ret = notmuch_database_remove_message(db, path); ret = notmuch_database_remove_message (db, path);
notmuch_rb_status_raise(ret); notmuch_rb_status_raise (ret);
return (ret == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) ? Qtrue : Qfalse; return (ret == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) ? Qtrue : Qfalse;
} }
@ -336,27 +335,27 @@ notmuch_rb_database_remove_message(VALUE self, VALUE pathv)
* Find a message by message id. * Find a message by message id.
*/ */
VALUE VALUE
notmuch_rb_database_find_message(VALUE self, VALUE idv) notmuch_rb_database_find_message (VALUE self, VALUE idv)
{ {
const char *id; const char *id;
notmuch_status_t ret; notmuch_status_t ret;
notmuch_database_t *db; notmuch_database_t *db;
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Database(self, db); Data_Get_Notmuch_Database (self, db);
#if !defined(RSTRING_PTR) #if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr) # define RSTRING_PTR(v) (RSTRING((v))->ptr)
#endif /* !defined(RSTRING_PTR) */ #endif /* !defined (RSTRING_PTR) */
SafeStringValue(idv); SafeStringValue (idv);
id = RSTRING_PTR(idv); id = RSTRING_PTR (idv);
ret = notmuch_database_find_message(db, id, &message); ret = notmuch_database_find_message (db, id, &message);
notmuch_rb_status_raise(ret); notmuch_rb_status_raise (ret);
if (message) if (message)
return Data_Wrap_Struct(notmuch_rb_cMessage, NULL, NULL, message); return Data_Wrap_Struct (notmuch_rb_cMessage, NULL, NULL, message);
return Qnil; return Qnil;
} }
@ -366,27 +365,27 @@ notmuch_rb_database_find_message(VALUE self, VALUE idv)
* Find a message by filename. * Find a message by filename.
*/ */
VALUE VALUE
notmuch_rb_database_find_message_by_filename(VALUE self, VALUE pathv) notmuch_rb_database_find_message_by_filename (VALUE self, VALUE pathv)
{ {
const char *path; const char *path;
notmuch_status_t ret; notmuch_status_t ret;
notmuch_database_t *db; notmuch_database_t *db;
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Database(self, db); Data_Get_Notmuch_Database (self, db);
#if !defined(RSTRING_PTR) #if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr) # define RSTRING_PTR(v) (RSTRING((v))->ptr)
#endif /* !defined(RSTRING_PTR) */ #endif /* !defined (RSTRING_PTR) */
SafeStringValue(pathv); SafeStringValue (pathv);
path = RSTRING_PTR(pathv); path = RSTRING_PTR (pathv);
ret = notmuch_database_find_message_by_filename(db, path, &message); ret = notmuch_database_find_message_by_filename (db, path, &message);
notmuch_rb_status_raise(ret); notmuch_rb_status_raise (ret);
if (message) if (message)
return Data_Wrap_Struct(notmuch_rb_cMessage, NULL, NULL, message); return Data_Wrap_Struct (notmuch_rb_cMessage, NULL, NULL, message);
return Qnil; return Qnil;
} }
@ -396,24 +395,24 @@ notmuch_rb_database_find_message_by_filename(VALUE self, VALUE pathv)
* Retrieve a query object for the query string 'query' * Retrieve a query object for the query string 'query'
*/ */
VALUE VALUE
notmuch_rb_database_query_create(VALUE self, VALUE qstrv) notmuch_rb_database_query_create (VALUE self, VALUE qstrv)
{ {
const char *qstr; const char *qstr;
notmuch_query_t *query; notmuch_query_t *query;
notmuch_database_t *db; notmuch_database_t *db;
Data_Get_Notmuch_Database(self, db); Data_Get_Notmuch_Database (self, db);
#if !defined(RSTRING_PTR) #if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr) # define RSTRING_PTR(v) (RSTRING((v))->ptr)
#endif /* !defined(RSTRING_PTR) */ #endif /* !defined (RSTRING_PTR) */
SafeStringValue(qstrv); SafeStringValue (qstrv);
qstr = RSTRING_PTR(qstrv); qstr = RSTRING_PTR (qstrv);
query = notmuch_query_create(db, qstr); query = notmuch_query_create (db, qstr);
if (!query) if (!query)
rb_raise(notmuch_rb_eMemoryError, "Out of memory"); rb_raise (notmuch_rb_eMemoryError, "Out of memory");
return Data_Wrap_Struct(notmuch_rb_cQuery, NULL, NULL, query); return Data_Wrap_Struct (notmuch_rb_cQuery, NULL, NULL, query);
} }

View file

@ -1,6 +1,6 @@
/* The Ruby interface to the notmuch mail library /* The Ruby interface to the notmuch mail library
* *
* Copyright © 2010 Ali Polatel * Copyright © 2010, 2011 Ali Polatel
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -50,279 +50,279 @@ ID ID_call;
ID ID_db_create; ID ID_db_create;
ID ID_db_mode; ID ID_db_mode;
#define Data_Get_Notmuch_Database(obj, ptr) \ #define Data_Get_Notmuch_Database (obj, ptr) \
do { \ do { \
Check_Type(obj, T_DATA); \ Check_Type (obj, T_DATA); \
if (DATA_PTR(obj) == NULL) \ if (DATA_PTR (obj) == NULL) \
rb_raise(rb_eRuntimeError, "database closed"); \ rb_raise (rb_eRuntimeError, "database closed"); \
Data_Get_Struct(obj, notmuch_database_t, ptr); \ Data_Get_Struct (obj, notmuch_database_t, ptr); \
} while(0) } while (0)
#define Data_Get_Notmuch_Directory(obj, ptr) \ #define Data_Get_Notmuch_Directory (obj, ptr) \
do { \ do { \
Check_Type(obj, T_DATA); \ Check_Type (obj, T_DATA); \
if (DATA_PTR(obj) == NULL) \ if (DATA_PTR (obj) == NULL) \
rb_raise(rb_eRuntimeError, "directory destroyed"); \ rb_raise (rb_eRuntimeError, "directory destroyed"); \
Data_Get_Struct(obj, notmuch_directory_t, ptr); \ Data_Get_Struct (obj, notmuch_directory_t, ptr); \
} while(0) } while (0)
#define Data_Get_Notmuch_FileNames(obj, ptr) \ #define Data_Get_Notmuch_FileNames (obj, ptr) \
do { \ do { \
Check_Type(obj, T_DATA); \ Check_Type (obj, T_DATA); \
if (DATA_PTR(obj) == NULL) \ if (DATA_PTR (obj) == NULL) \
rb_raise(rb_eRuntimeError, "filenames destroyed"); \ rb_raise (rb_eRuntimeError, "filenames destroyed"); \
Data_Get_Struct(obj, notmuch_filenames_t, ptr); \ Data_Get_Struct (obj, notmuch_filenames_t, ptr); \
} while(0) } while (0)
#define Data_Get_Notmuch_Query(obj, ptr) \ #define Data_Get_Notmuch_Query (obj, ptr) \
do { \ do { \
Check_Type(obj, T_DATA); \ Check_Type (obj, T_DATA); \
if (DATA_PTR(obj) == NULL) \ if (DATA_PTR (obj) == NULL) \
rb_raise(rb_eRuntimeError, "query destroyed"); \ rb_raise (rb_eRuntimeError, "query destroyed"); \
Data_Get_Struct(obj, notmuch_query_t, ptr); \ Data_Get_Struct (obj, notmuch_query_t, ptr); \
} while(0) } while (0)
#define Data_Get_Notmuch_Threads(obj, ptr) \ #define Data_Get_Notmuch_Threads (obj, ptr) \
do { \ do { \
Check_Type(obj, T_DATA); \ Check_Type (obj, T_DATA); \
if (DATA_PTR(obj) == NULL) \ if (DATA_PTR (obj) == NULL) \
rb_raise(rb_eRuntimeError, "threads destroyed"); \ rb_raise (rb_eRuntimeError, "threads destroyed"); \
Data_Get_Struct(obj, notmuch_threads_t, ptr); \ Data_Get_Struct (obj, notmuch_threads_t, ptr); \
} while(0) } while (0)
#define Data_Get_Notmuch_Messages(obj, ptr) \ #define Data_Get_Notmuch_Messages (obj, ptr) \
do { \ do { \
Check_Type(obj, T_DATA); \ Check_Type (obj, T_DATA); \
if (DATA_PTR(obj) == NULL) \ if (DATA_PTR (obj) == NULL) \
rb_raise(rb_eRuntimeError, "messages destroyed"); \ rb_raise (rb_eRuntimeError, "messages destroyed"); \
Data_Get_Struct(obj, notmuch_messages_t, ptr); \ Data_Get_Struct (obj, notmuch_messages_t, ptr); \
} while(0) } while (0)
#define Data_Get_Notmuch_Thread(obj, ptr) \ #define Data_Get_Notmuch_Thread (obj, ptr) \
do { \ do { \
Check_Type(obj, T_DATA); \ Check_Type (obj, T_DATA); \
if (DATA_PTR(obj) == NULL) \ if (DATA_PTR (obj) == NULL) \
rb_raise(rb_eRuntimeError, "thread destroyed"); \ rb_raise (rb_eRuntimeError, "thread destroyed"); \
Data_Get_Struct(obj, notmuch_thread_t, ptr); \ Data_Get_Struct (obj, notmuch_thread_t, ptr); \
} while(0) } while (0)
#define Data_Get_Notmuch_Message(obj, ptr) \ #define Data_Get_Notmuch_Message (obj, ptr) \
do { \ do { \
Check_Type(obj, T_DATA); \ Check_Type (obj, T_DATA); \
if (DATA_PTR(obj) == NULL) \ if (DATA_PTR (obj) == NULL) \
rb_raise(rb_eRuntimeError, "message destroyed"); \ rb_raise (rb_eRuntimeError, "message destroyed"); \
Data_Get_Struct(obj, notmuch_message_t, ptr); \ Data_Get_Struct (obj, notmuch_message_t, ptr); \
} while(0) } while (0)
#define Data_Get_Notmuch_Tags(obj, ptr) \ #define Data_Get_Notmuch_Tags (obj, ptr) \
do { \ do { \
Check_Type(obj, T_DATA); \ Check_Type (obj, T_DATA); \
if (DATA_PTR(obj) == NULL) \ if (DATA_PTR (obj) == NULL) \
rb_raise(rb_eRuntimeError, "tags destroyed"); \ rb_raise (rb_eRuntimeError, "tags destroyed"); \
Data_Get_Struct(obj, notmuch_tags_t, ptr); \ Data_Get_Struct (obj, notmuch_tags_t, ptr); \
} while(0) } while (0)
/* status.c */ /* status.c */
void void
notmuch_rb_status_raise(notmuch_status_t status); notmuch_rb_status_raise (notmuch_status_t status);
/* database.c */ /* database.c */
VALUE VALUE
notmuch_rb_database_alloc(VALUE klass); notmuch_rb_database_alloc (VALUE klass);
VALUE VALUE
notmuch_rb_database_initialize(int argc, VALUE *argv, VALUE klass); notmuch_rb_database_initialize (int argc, VALUE *argv, VALUE klass);
VALUE VALUE
notmuch_rb_database_open(int argc, VALUE *argv, VALUE klass); notmuch_rb_database_open (int argc, VALUE *argv, VALUE klass);
VALUE VALUE
notmuch_rb_database_close(VALUE self); notmuch_rb_database_close (VALUE self);
VALUE VALUE
notmuch_rb_database_path(VALUE self); notmuch_rb_database_path (VALUE self);
VALUE VALUE
notmuch_rb_database_version(VALUE self); notmuch_rb_database_version (VALUE self);
VALUE VALUE
notmuch_rb_database_needs_upgrade(VALUE self); notmuch_rb_database_needs_upgrade (VALUE self);
VALUE VALUE
notmuch_rb_database_upgrade(VALUE self); notmuch_rb_database_upgrade (VALUE self);
VALUE VALUE
notmuch_rb_database_begin_atomic(VALUE self); notmuch_rb_database_begin_atomic (VALUE self);
VALUE VALUE
notmuch_rb_database_end_atomic(VALUE self); notmuch_rb_database_end_atomic (VALUE self);
VALUE VALUE
notmuch_rb_database_get_directory(VALUE self, VALUE pathv); notmuch_rb_database_get_directory (VALUE self, VALUE pathv);
VALUE VALUE
notmuch_rb_database_add_message(VALUE self, VALUE pathv); notmuch_rb_database_add_message (VALUE self, VALUE pathv);
VALUE VALUE
notmuch_rb_database_remove_message(VALUE self, VALUE pathv); notmuch_rb_database_remove_message (VALUE self, VALUE pathv);
VALUE VALUE
notmuch_rb_database_query_create(VALUE self, VALUE qstrv); notmuch_rb_database_query_create (VALUE self, VALUE qstrv);
/* directory.c */ /* directory.c */
VALUE VALUE
notmuch_rb_directory_destroy(VALUE self); notmuch_rb_directory_destroy (VALUE self);
VALUE VALUE
notmuch_rb_directory_get_mtime(VALUE self); notmuch_rb_directory_get_mtime (VALUE self);
VALUE VALUE
notmuch_rb_directory_set_mtime(VALUE self, VALUE mtimev); notmuch_rb_directory_set_mtime (VALUE self, VALUE mtimev);
VALUE VALUE
notmuch_rb_directory_get_child_files(VALUE self); notmuch_rb_directory_get_child_files (VALUE self);
VALUE VALUE
notmuch_rb_directory_get_child_directories(VALUE self); notmuch_rb_directory_get_child_directories (VALUE self);
/* filenames.c */ /* filenames.c */
VALUE VALUE
notmuch_rb_filenames_destroy(VALUE self); notmuch_rb_filenames_destroy (VALUE self);
VALUE VALUE
notmuch_rb_filenames_each(VALUE self); notmuch_rb_filenames_each (VALUE self);
/* query.c */ /* query.c */
VALUE VALUE
notmuch_rb_query_destroy(VALUE self); notmuch_rb_query_destroy (VALUE self);
VALUE VALUE
notmuch_rb_query_get_sort(VALUE self); notmuch_rb_query_get_sort (VALUE self);
VALUE VALUE
notmuch_rb_query_set_sort(VALUE self, VALUE sortv); notmuch_rb_query_set_sort (VALUE self, VALUE sortv);
VALUE VALUE
notmuch_rb_query_get_string(VALUE self); notmuch_rb_query_get_string (VALUE self);
VALUE VALUE
notmuch_rb_query_search_threads(VALUE self); notmuch_rb_query_search_threads (VALUE self);
VALUE VALUE
notmuch_rb_query_search_messages(VALUE self); notmuch_rb_query_search_messages (VALUE self);
/* threads.c */ /* threads.c */
VALUE VALUE
notmuch_rb_threads_destroy(VALUE self); notmuch_rb_threads_destroy (VALUE self);
VALUE VALUE
notmuch_rb_threads_each(VALUE self); notmuch_rb_threads_each (VALUE self);
/* messages.c */ /* messages.c */
VALUE VALUE
notmuch_rb_messages_destroy(VALUE self); notmuch_rb_messages_destroy (VALUE self);
VALUE VALUE
notmuch_rb_messages_each(VALUE self); notmuch_rb_messages_each (VALUE self);
VALUE VALUE
notmuch_rb_messages_collect_tags(VALUE self); notmuch_rb_messages_collect_tags (VALUE self);
/* thread.c */ /* thread.c */
VALUE VALUE
notmuch_rb_thread_destroy(VALUE self); notmuch_rb_thread_destroy (VALUE self);
VALUE VALUE
notmuch_rb_thread_get_thread_id(VALUE self); notmuch_rb_thread_get_thread_id (VALUE self);
VALUE VALUE
notmuch_rb_thread_get_total_messages(VALUE self); notmuch_rb_thread_get_total_messages (VALUE self);
VALUE VALUE
notmuch_rb_thread_get_toplevel_messages(VALUE self); notmuch_rb_thread_get_toplevel_messages (VALUE self);
VALUE VALUE
notmuch_rb_thread_get_matched_messages(VALUE self); notmuch_rb_thread_get_matched_messages (VALUE self);
VALUE VALUE
notmuch_rb_thread_get_authors(VALUE self); notmuch_rb_thread_get_authors (VALUE self);
VALUE VALUE
notmuch_rb_thread_get_subject(VALUE self); notmuch_rb_thread_get_subject (VALUE self);
VALUE VALUE
notmuch_rb_thread_get_oldest_date(VALUE self); notmuch_rb_thread_get_oldest_date (VALUE self);
VALUE VALUE
notmuch_rb_thread_get_newest_date(VALUE self); notmuch_rb_thread_get_newest_date (VALUE self);
VALUE VALUE
notmuch_rb_thread_get_tags(VALUE self); notmuch_rb_thread_get_tags (VALUE self);
/* message.c */ /* message.c */
VALUE VALUE
notmuch_rb_message_destroy(VALUE self); notmuch_rb_message_destroy (VALUE self);
VALUE VALUE
notmuch_rb_message_get_message_id(VALUE self); notmuch_rb_message_get_message_id (VALUE self);
VALUE VALUE
notmuch_rb_message_get_thread_id(VALUE self); notmuch_rb_message_get_thread_id (VALUE self);
VALUE VALUE
notmuch_rb_message_get_replies(VALUE self); notmuch_rb_message_get_replies (VALUE self);
VALUE VALUE
notmuch_rb_message_get_filename(VALUE self); notmuch_rb_message_get_filename (VALUE self);
VALUE VALUE
notmuch_rb_message_get_filenames(VALUE self); notmuch_rb_message_get_filenames (VALUE self);
VALUE VALUE
notmuch_rb_message_get_flag(VALUE self, VALUE flagv); notmuch_rb_message_get_flag (VALUE self, VALUE flagv);
VALUE VALUE
notmuch_rb_message_set_flag(VALUE self, VALUE flagv, VALUE valuev); notmuch_rb_message_set_flag (VALUE self, VALUE flagv, VALUE valuev);
VALUE VALUE
notmuch_rb_message_get_date(VALUE self); notmuch_rb_message_get_date (VALUE self);
VALUE VALUE
notmuch_rb_message_get_header(VALUE self, VALUE headerv); notmuch_rb_message_get_header (VALUE self, VALUE headerv);
VALUE VALUE
notmuch_rb_message_get_tags(VALUE self); notmuch_rb_message_get_tags (VALUE self);
VALUE VALUE
notmuch_rb_message_add_tag(VALUE self, VALUE tagv); notmuch_rb_message_add_tag (VALUE self, VALUE tagv);
VALUE VALUE
notmuch_rb_message_remove_tag(VALUE self, VALUE tagv); notmuch_rb_message_remove_tag (VALUE self, VALUE tagv);
VALUE VALUE
notmuch_rb_message_remove_all_tags(VALUE self); notmuch_rb_message_remove_all_tags (VALUE self);
VALUE VALUE
notmuch_rb_message_maildir_flags_to_tags(VALUE self); notmuch_rb_message_maildir_flags_to_tags (VALUE self);
VALUE VALUE
notmuch_rb_message_tags_to_maildir_flags(VALUE self); notmuch_rb_message_tags_to_maildir_flags (VALUE self);
VALUE VALUE
notmuch_rb_message_freeze(VALUE self); notmuch_rb_message_freeze (VALUE self);
VALUE VALUE
notmuch_rb_message_thaw(VALUE self); notmuch_rb_message_thaw (VALUE self);
/* tags.c */ /* tags.c */
VALUE VALUE
notmuch_rb_tags_destroy(VALUE self); notmuch_rb_tags_destroy (VALUE self);
VALUE VALUE
notmuch_rb_tags_each(VALUE self); notmuch_rb_tags_each (VALUE self);
/* init.c */ /* init.c */
void void
Init_notmuch(void); Init_notmuch (void);
#endif #endif

View file

@ -1,6 +1,6 @@
/* The Ruby interface to the notmuch mail library /* The Ruby interface to the notmuch mail library
* *
* Copyright © 2010 Ali Polatel * Copyright © 2010, 2011 Ali Polatel
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,14 +26,14 @@
* Destroys the directory, freeing all resources allocated for it. * Destroys the directory, freeing all resources allocated for it.
*/ */
VALUE VALUE
notmuch_rb_directory_destroy(VALUE self) notmuch_rb_directory_destroy (VALUE self)
{ {
notmuch_directory_t *dir; notmuch_directory_t *dir;
Data_Get_Struct(self, notmuch_directory_t, dir); Data_Get_Struct (self, notmuch_directory_t, dir);
notmuch_directory_destroy(dir); notmuch_directory_destroy (dir);
DATA_PTR(self) = NULL; DATA_PTR (self) = NULL;
return Qnil; return Qnil;
} }
@ -45,13 +45,13 @@ notmuch_rb_directory_destroy(VALUE self)
* stored. * stored.
*/ */
VALUE VALUE
notmuch_rb_directory_get_mtime(VALUE self) notmuch_rb_directory_get_mtime (VALUE self)
{ {
notmuch_directory_t *dir; notmuch_directory_t *dir;
Data_Get_Notmuch_Directory(self, dir); Data_Get_Notmuch_Directory (self, dir);
return UINT2NUM(notmuch_directory_get_mtime(dir)); return UINT2NUM (notmuch_directory_get_mtime (dir));
} }
/* /*
@ -60,18 +60,18 @@ notmuch_rb_directory_get_mtime(VALUE self)
* Store an mtime within the database for the directory object. * Store an mtime within the database for the directory object.
*/ */
VALUE VALUE
notmuch_rb_directory_set_mtime(VALUE self, VALUE mtimev) notmuch_rb_directory_set_mtime (VALUE self, VALUE mtimev)
{ {
notmuch_status_t ret; notmuch_status_t ret;
notmuch_directory_t *dir; notmuch_directory_t *dir;
Data_Get_Notmuch_Directory(self, dir); Data_Get_Notmuch_Directory (self, dir);
if (!FIXNUM_P(mtimev)) if (!FIXNUM_P (mtimev))
rb_raise(rb_eTypeError, "First argument not a fixnum"); rb_raise (rb_eTypeError, "First argument not a fixnum");
ret = notmuch_directory_set_mtime(dir, FIX2UINT(mtimev)); ret = notmuch_directory_set_mtime (dir, FIX2UINT (mtimev));
notmuch_rb_status_raise(ret); notmuch_rb_status_raise (ret);
return Qtrue; return Qtrue;
} }
@ -83,16 +83,16 @@ notmuch_rb_directory_set_mtime(VALUE self, VALUE mtimev)
* filenames of messages in the database within the given directory. * filenames of messages in the database within the given directory.
*/ */
VALUE VALUE
notmuch_rb_directory_get_child_files(VALUE self) notmuch_rb_directory_get_child_files (VALUE self)
{ {
notmuch_directory_t *dir; notmuch_directory_t *dir;
notmuch_filenames_t *fnames; notmuch_filenames_t *fnames;
Data_Get_Notmuch_Directory(self, dir); Data_Get_Notmuch_Directory (self, dir);
fnames = notmuch_directory_get_child_files(dir); fnames = notmuch_directory_get_child_files (dir);
return Data_Wrap_Struct(notmuch_rb_cFileNames, NULL, NULL, fnames); return Data_Wrap_Struct (notmuch_rb_cFileNames, NULL, NULL, fnames);
} }
/* /*
@ -102,14 +102,14 @@ notmuch_rb_directory_get_child_files(VALUE self)
* directories in the database within the given directory. * directories in the database within the given directory.
*/ */
VALUE VALUE
notmuch_rb_directory_get_child_directories(VALUE self) notmuch_rb_directory_get_child_directories (VALUE self)
{ {
notmuch_directory_t *dir; notmuch_directory_t *dir;
notmuch_filenames_t *fnames; notmuch_filenames_t *fnames;
Data_Get_Notmuch_Directory(self, dir); Data_Get_Notmuch_Directory (self, dir);
fnames = notmuch_directory_get_child_directories(dir); fnames = notmuch_directory_get_child_directories (dir);
return Data_Wrap_Struct(notmuch_rb_cFileNames, NULL, NULL, fnames); return Data_Wrap_Struct (notmuch_rb_cFileNames, NULL, NULL, fnames);
} }

View file

@ -1,7 +1,6 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# coding: utf-8 # coding: utf-8
# vim: set sw=2 sts=2 et nowrap fenc=utf-8 : # Copyright 2010, 2011 Ali Polatel <alip@exherbo.org>
# Copyright 2010 Ali Polatel <alip@exherbo.org>
# Distributed under the terms of the GNU General Public License v3 # Distributed under the terms of the GNU General Public License v3
require 'mkmf' require 'mkmf'

View file

@ -26,14 +26,14 @@
* Destroys the filenames, freeing all resources allocated for it. * Destroys the filenames, freeing all resources allocated for it.
*/ */
VALUE VALUE
notmuch_rb_filenames_destroy(VALUE self) notmuch_rb_filenames_destroy (VALUE self)
{ {
notmuch_filenames_t *fnames; notmuch_filenames_t *fnames;
Data_Get_Notmuch_FileNames(self, fnames); Data_Get_Notmuch_FileNames (self, fnames);
notmuch_filenames_destroy(fnames); notmuch_filenames_destroy (fnames);
DATA_PTR(self) = NULL; DATA_PTR (self) = NULL;
return Qnil; return Qnil;
} }
@ -45,14 +45,14 @@ notmuch_rb_filenames_destroy(VALUE self)
* parameter. * parameter.
*/ */
VALUE VALUE
notmuch_rb_filenames_each(VALUE self) notmuch_rb_filenames_each (VALUE self)
{ {
notmuch_filenames_t *fnames; notmuch_filenames_t *fnames;
Data_Get_Notmuch_FileNames(self, fnames); Data_Get_Notmuch_FileNames (self, fnames);
for (; notmuch_filenames_valid(fnames); notmuch_filenames_move_to_next(fnames)) for (; notmuch_filenames_valid (fnames); notmuch_filenames_move_to_next (fnames))
rb_yield(rb_str_new2(notmuch_filenames_get(fnames))); rb_yield (rb_str_new2 (notmuch_filenames_get (fnames)));
return self; return self;
} }

View file

@ -43,273 +43,273 @@
*/ */
void void
Init_notmuch(void) Init_notmuch (void)
{ {
VALUE mod; VALUE mod;
ID_call = rb_intern("call"); ID_call = rb_intern ("call");
ID_db_create = rb_intern("create"); ID_db_create = rb_intern ("create");
ID_db_mode = rb_intern("mode"); ID_db_mode = rb_intern ("mode");
mod = rb_define_module("Notmuch"); mod = rb_define_module ("Notmuch");
/* /*
* Document-const: Notmuch::MODE_READ_ONLY * Document-const: Notmuch::MODE_READ_ONLY
* *
* Open the database in read only mode * Open the database in read only mode
*/ */
rb_define_const(mod, "MODE_READ_ONLY", INT2FIX(NOTMUCH_DATABASE_MODE_READ_ONLY)); rb_define_const (mod, "MODE_READ_ONLY", INT2FIX (NOTMUCH_DATABASE_MODE_READ_ONLY));
/* /*
* Document-const: Notmuch::MODE_READ_WRITE * Document-const: Notmuch::MODE_READ_WRITE
* *
* Open the database in read write mode * Open the database in read write mode
*/ */
rb_define_const(mod, "MODE_READ_WRITE", INT2FIX(NOTMUCH_DATABASE_MODE_READ_WRITE)); rb_define_const (mod, "MODE_READ_WRITE", INT2FIX (NOTMUCH_DATABASE_MODE_READ_WRITE));
/* /*
* Document-const: Notmuch::SORT_OLDEST_FIRST * Document-const: Notmuch::SORT_OLDEST_FIRST
* *
* Sort query results by oldest first * Sort query results by oldest first
*/ */
rb_define_const(mod, "SORT_OLDEST_FIRST", INT2FIX(NOTMUCH_SORT_OLDEST_FIRST)); rb_define_const (mod, "SORT_OLDEST_FIRST", INT2FIX (NOTMUCH_SORT_OLDEST_FIRST));
/* /*
* Document-const: Notmuch::SORT_NEWEST_FIRST * Document-const: Notmuch::SORT_NEWEST_FIRST
* *
* Sort query results by newest first * Sort query results by newest first
*/ */
rb_define_const(mod, "SORT_NEWEST_FIRST", INT2FIX(NOTMUCH_SORT_NEWEST_FIRST)); rb_define_const (mod, "SORT_NEWEST_FIRST", INT2FIX (NOTMUCH_SORT_NEWEST_FIRST));
/* /*
* Document-const: Notmuch::SORT_MESSAGE_ID * Document-const: Notmuch::SORT_MESSAGE_ID
* *
* Sort query results by message id * Sort query results by message id
*/ */
rb_define_const(mod, "SORT_MESSAGE_ID", INT2FIX(NOTMUCH_SORT_MESSAGE_ID)); rb_define_const (mod, "SORT_MESSAGE_ID", INT2FIX (NOTMUCH_SORT_MESSAGE_ID));
/* /*
* Document-const: Notmuch::SORT_UNSORTED * Document-const: Notmuch::SORT_UNSORTED
* *
* Do not sort query results * Do not sort query results
*/ */
rb_define_const(mod, "SORT_UNSORTED", INT2FIX(NOTMUCH_SORT_UNSORTED)); rb_define_const (mod, "SORT_UNSORTED", INT2FIX (NOTMUCH_SORT_UNSORTED));
/* /*
* Document-const: Notmuch::MESSAGE_FLAG_MATCH * Document-const: Notmuch::MESSAGE_FLAG_MATCH
* *
* Message flag "match" * Message flag "match"
*/ */
rb_define_const(mod, "MESSAGE_FLAG_MATCH", INT2FIX(NOTMUCH_MESSAGE_FLAG_MATCH)); rb_define_const (mod, "MESSAGE_FLAG_MATCH", INT2FIX (NOTMUCH_MESSAGE_FLAG_MATCH));
/* /*
* Document-const: Notmuch::TAG_MAX * Document-const: Notmuch::TAG_MAX
* *
* Maximum allowed length of a tag * Maximum allowed length of a tag
*/ */
rb_define_const(mod, "TAG_MAX", INT2FIX(NOTMUCH_TAG_MAX)); rb_define_const (mod, "TAG_MAX", INT2FIX (NOTMUCH_TAG_MAX));
/* /*
* Document-class: Notmuch::BaseError * Document-class: Notmuch::BaseError
* *
* Base class for all notmuch exceptions * Base class for all notmuch exceptions
*/ */
notmuch_rb_eBaseError = rb_define_class_under(mod, "BaseError", rb_eStandardError); notmuch_rb_eBaseError = rb_define_class_under (mod, "BaseError", rb_eStandardError);
/* /*
* Document-class: Notmuch::DatabaseError * Document-class: Notmuch::DatabaseError
* *
* Raised when the database can't be created or opened. * Raised when the database can't be created or opened.
*/ */
notmuch_rb_eDatabaseError = rb_define_class_under(mod, "DatabaseError", notmuch_rb_eBaseError); notmuch_rb_eDatabaseError = rb_define_class_under (mod, "DatabaseError", notmuch_rb_eBaseError);
/* /*
* Document-class: Notmuch::MemoryError * Document-class: Notmuch::MemoryError
* *
* Raised when notmuch is out of memory * Raised when notmuch is out of memory
*/ */
notmuch_rb_eMemoryError = rb_define_class_under(mod, "MemoryError", notmuch_rb_eBaseError); notmuch_rb_eMemoryError = rb_define_class_under (mod, "MemoryError", notmuch_rb_eBaseError);
/* /*
* Document-class: Notmuch::ReadOnlyError * Document-class: Notmuch::ReadOnlyError
* *
* Raised when an attempt was made to write to a database opened in read-only * Raised when an attempt was made to write to a database opened in read-only
* mode. * mode.
*/ */
notmuch_rb_eReadOnlyError = rb_define_class_under(mod, "ReadOnlyError", notmuch_rb_eBaseError); notmuch_rb_eReadOnlyError = rb_define_class_under (mod, "ReadOnlyError", notmuch_rb_eBaseError);
/* /*
* Document-class: Notmuch::XapianError * Document-class: Notmuch::XapianError
* *
* Raised when a Xapian exception occurs * Raised when a Xapian exception occurs
*/ */
notmuch_rb_eXapianError = rb_define_class_under(mod, "XapianError", notmuch_rb_eBaseError); notmuch_rb_eXapianError = rb_define_class_under (mod, "XapianError", notmuch_rb_eBaseError);
/* /*
* Document-class: Notmuch::FileError * Document-class: Notmuch::FileError
* *
* Raised when an error occurs trying to read or write to a file. * Raised when an error occurs trying to read or write to a file.
*/ */
notmuch_rb_eFileError = rb_define_class_under(mod, "FileError", notmuch_rb_eBaseError); notmuch_rb_eFileError = rb_define_class_under (mod, "FileError", notmuch_rb_eBaseError);
/* /*
* Document-class: Notmuch::FileNotEmailError * Document-class: Notmuch::FileNotEmailError
* *
* Raised when a file is presented that doesn't appear to be an email message. * Raised when a file is presented that doesn't appear to be an email message.
*/ */
notmuch_rb_eFileNotEmailError = rb_define_class_under(mod, "FileNotEmailError", notmuch_rb_eBaseError); notmuch_rb_eFileNotEmailError = rb_define_class_under (mod, "FileNotEmailError", notmuch_rb_eBaseError);
/* /*
* Document-class: Notmuch::NullPointerError * Document-class: Notmuch::NullPointerError
* *
* Raised when the user erroneously passes a +NULL+ pointer to a notmuch * Raised when the user erroneously passes a +NULL+ pointer to a notmuch
* function. * function.
*/ */
notmuch_rb_eNullPointerError = rb_define_class_under(mod, "NullPointerError", notmuch_rb_eBaseError); notmuch_rb_eNullPointerError = rb_define_class_under (mod, "NullPointerError", notmuch_rb_eBaseError);
/* /*
* Document-class: Notmuch::TagTooLongError * Document-class: Notmuch::TagTooLongError
* *
* Raised when a tag value is too long (exceeds Notmuch::TAG_MAX) * Raised when a tag value is too long (exceeds Notmuch::TAG_MAX)
*/ */
notmuch_rb_eTagTooLongError = rb_define_class_under(mod, "TagTooLongError", notmuch_rb_eBaseError); notmuch_rb_eTagTooLongError = rb_define_class_under (mod, "TagTooLongError", notmuch_rb_eBaseError);
/* /*
* Document-class: Notmuch::UnbalancedFreezeThawError * Document-class: Notmuch::UnbalancedFreezeThawError
* *
* Raised when the notmuch_message_thaw function has been called more times * Raised when the notmuch_message_thaw function has been called more times
* than notmuch_message_freeze. * than notmuch_message_freeze.
*/ */
notmuch_rb_eUnbalancedFreezeThawError = rb_define_class_under(mod, "UnbalancedFreezeThawError", notmuch_rb_eUnbalancedFreezeThawError = rb_define_class_under (mod, "UnbalancedFreezeThawError",
notmuch_rb_eBaseError); notmuch_rb_eBaseError);
/* /*
* Document-class: Notmuch::UnbalancedAtomicError * Document-class: Notmuch::UnbalancedAtomicError
* *
* Raised when notmuch_database_end_atomic has been called more times than * Raised when notmuch_database_end_atomic has been called more times than
* notmuch_database_begin_atomic * notmuch_database_begin_atomic
*/ */
notmuch_rb_eUnbalancedAtomicError = rb_define_class_under(mod, "UnbalancedAtomicError", notmuch_rb_eUnbalancedAtomicError = rb_define_class_under (mod, "UnbalancedAtomicError",
notmuch_rb_eBaseError); notmuch_rb_eBaseError);
/* /*
* Document-class: Notmuch::Database * Document-class: Notmuch::Database
* *
* Notmuch database interaction * Notmuch database interaction
*/ */
notmuch_rb_cDatabase = rb_define_class_under(mod, "Database", rb_cData); notmuch_rb_cDatabase = rb_define_class_under (mod, "Database", rb_cData);
rb_define_alloc_func(notmuch_rb_cDatabase, notmuch_rb_database_alloc); rb_define_alloc_func (notmuch_rb_cDatabase, notmuch_rb_database_alloc);
rb_define_singleton_method(notmuch_rb_cDatabase, "open", notmuch_rb_database_open, -1); /* in database.c */ rb_define_singleton_method (notmuch_rb_cDatabase, "open", notmuch_rb_database_open, -1); /* in database.c */
rb_define_method(notmuch_rb_cDatabase, "initialize", notmuch_rb_database_initialize, -1); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "initialize", notmuch_rb_database_initialize, -1); /* in database.c */
rb_define_method(notmuch_rb_cDatabase, "close", notmuch_rb_database_close, 0); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "close", notmuch_rb_database_close, 0); /* in database.c */
rb_define_method(notmuch_rb_cDatabase, "path", notmuch_rb_database_path, 0); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "path", notmuch_rb_database_path, 0); /* in database.c */
rb_define_method(notmuch_rb_cDatabase, "version", notmuch_rb_database_version, 0); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "version", notmuch_rb_database_version, 0); /* in database.c */
rb_define_method(notmuch_rb_cDatabase, "needs_upgrade?", notmuch_rb_database_needs_upgrade, 0); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "needs_upgrade?", notmuch_rb_database_needs_upgrade, 0); /* in database.c */
rb_define_method(notmuch_rb_cDatabase, "upgrade!", notmuch_rb_database_upgrade, 0); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "upgrade!", notmuch_rb_database_upgrade, 0); /* in database.c */
rb_define_method(notmuch_rb_cDatabase, "begin_atomic", notmuch_rb_database_begin_atomic, 0); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "begin_atomic", notmuch_rb_database_begin_atomic, 0); /* in database.c */
rb_define_method(notmuch_rb_cDatabase, "end_atomic", notmuch_rb_database_end_atomic, 0); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "end_atomic", notmuch_rb_database_end_atomic, 0); /* in database.c */
rb_define_method(notmuch_rb_cDatabase, "get_directory", notmuch_rb_database_get_directory, 1); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "get_directory", notmuch_rb_database_get_directory, 1); /* in database.c */
rb_define_method(notmuch_rb_cDatabase, "add_message", notmuch_rb_database_add_message, 1); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "add_message", notmuch_rb_database_add_message, 1); /* in database.c */
rb_define_method(notmuch_rb_cDatabase, "remove_message", notmuch_rb_database_remove_message, 1); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "remove_message", notmuch_rb_database_remove_message, 1); /* in database.c */
rb_define_method(notmuch_rb_cDatabase, "query", notmuch_rb_database_query_create, 1); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "query", notmuch_rb_database_query_create, 1); /* in database.c */
/* /*
* Document-class: Notmuch::Directory * Document-class: Notmuch::Directory
* *
* Notmuch directory * Notmuch directory
*/ */
notmuch_rb_cDirectory = rb_define_class_under(mod, "Directory", rb_cData); notmuch_rb_cDirectory = rb_define_class_under (mod, "Directory", rb_cData);
rb_undef_method(notmuch_rb_cDirectory, "initialize"); rb_undef_method (notmuch_rb_cDirectory, "initialize");
rb_define_method(notmuch_rb_cDirectory, "destroy!", notmuch_rb_directory_destroy, 0); /* in directory.c */ rb_define_method (notmuch_rb_cDirectory, "destroy!", notmuch_rb_directory_destroy, 0); /* in directory.c */
rb_define_method(notmuch_rb_cDirectory, "mtime", notmuch_rb_directory_get_mtime, 0); /* in directory.c */ rb_define_method (notmuch_rb_cDirectory, "mtime", notmuch_rb_directory_get_mtime, 0); /* in directory.c */
rb_define_method(notmuch_rb_cDirectory, "mtime=", notmuch_rb_directory_set_mtime, 1); /* in directory.c */ rb_define_method (notmuch_rb_cDirectory, "mtime=", notmuch_rb_directory_set_mtime, 1); /* in directory.c */
rb_define_method(notmuch_rb_cDirectory, "child_files", notmuch_rb_directory_get_child_files, 0); /* in directory.c */ rb_define_method (notmuch_rb_cDirectory, "child_files", notmuch_rb_directory_get_child_files, 0); /* in directory.c */
rb_define_method(notmuch_rb_cDirectory, "child_directories", notmuch_rb_directory_get_child_directories, 0); /* in directory.c */ rb_define_method (notmuch_rb_cDirectory, "child_directories", notmuch_rb_directory_get_child_directories, 0); /* in directory.c */
/* /*
* Document-class: Notmuch::FileNames * Document-class: Notmuch::FileNames
* *
* Notmuch file names * Notmuch file names
*/ */
notmuch_rb_cFileNames = rb_define_class_under(mod, "FileNames", rb_cData); notmuch_rb_cFileNames = rb_define_class_under (mod, "FileNames", rb_cData);
rb_undef_method(notmuch_rb_cFileNames, "initialize"); rb_undef_method (notmuch_rb_cFileNames, "initialize");
rb_define_method(notmuch_rb_cFileNames, "destroy!", notmuch_rb_filenames_destroy, 0); /* in filenames.c */ rb_define_method (notmuch_rb_cFileNames, "destroy!", notmuch_rb_filenames_destroy, 0); /* in filenames.c */
rb_define_method(notmuch_rb_cFileNames, "each", notmuch_rb_filenames_each, 0); /* in filenames.c */ rb_define_method (notmuch_rb_cFileNames, "each", notmuch_rb_filenames_each, 0); /* in filenames.c */
rb_include_module(notmuch_rb_cFileNames, rb_mEnumerable); rb_include_module (notmuch_rb_cFileNames, rb_mEnumerable);
/* /*
* Document-class: Notmuch::Query * Document-class: Notmuch::Query
* *
* Notmuch query * Notmuch query
*/ */
notmuch_rb_cQuery = rb_define_class_under(mod, "Query", rb_cData); notmuch_rb_cQuery = rb_define_class_under (mod, "Query", rb_cData);
rb_undef_method(notmuch_rb_cQuery, "initialize"); rb_undef_method (notmuch_rb_cQuery, "initialize");
rb_define_method(notmuch_rb_cQuery, "destroy!", notmuch_rb_query_destroy, 0); /* in query.c */ rb_define_method (notmuch_rb_cQuery, "destroy!", notmuch_rb_query_destroy, 0); /* in query.c */
rb_define_method(notmuch_rb_cQuery, "sort", notmuch_rb_query_get_sort, 0); /* in query.c */ rb_define_method (notmuch_rb_cQuery, "sort", notmuch_rb_query_get_sort, 0); /* in query.c */
rb_define_method(notmuch_rb_cQuery, "sort=", notmuch_rb_query_set_sort, 1); /* in query.c */ rb_define_method (notmuch_rb_cQuery, "sort=", notmuch_rb_query_set_sort, 1); /* in query.c */
rb_define_method(notmuch_rb_cQuery, "to_s", notmuch_rb_query_get_string, 0); /* in query.c */ rb_define_method (notmuch_rb_cQuery, "to_s", notmuch_rb_query_get_string, 0); /* in query.c */
rb_define_method(notmuch_rb_cQuery, "search_threads", notmuch_rb_query_search_threads, 0); /* in query.c */ rb_define_method (notmuch_rb_cQuery, "search_threads", notmuch_rb_query_search_threads, 0); /* in query.c */
rb_define_method(notmuch_rb_cQuery, "search_messages", notmuch_rb_query_search_messages, 0); /* in query.c */ rb_define_method (notmuch_rb_cQuery, "search_messages", notmuch_rb_query_search_messages, 0); /* in query.c */
/* /*
* Document-class: Notmuch::Threads * Document-class: Notmuch::Threads
* *
* Notmuch threads * Notmuch threads
*/ */
notmuch_rb_cThreads = rb_define_class_under(mod, "Threads", rb_cData); notmuch_rb_cThreads = rb_define_class_under (mod, "Threads", rb_cData);
rb_undef_method(notmuch_rb_cThreads, "initialize"); rb_undef_method (notmuch_rb_cThreads, "initialize");
rb_define_method(notmuch_rb_cThreads, "destroy!", notmuch_rb_threads_destroy, 0); /* in threads.c */ rb_define_method (notmuch_rb_cThreads, "destroy!", notmuch_rb_threads_destroy, 0); /* in threads.c */
rb_define_method(notmuch_rb_cThreads, "each", notmuch_rb_threads_each, 0); /* in threads.c */ rb_define_method (notmuch_rb_cThreads, "each", notmuch_rb_threads_each, 0); /* in threads.c */
rb_include_module(notmuch_rb_cThreads, rb_mEnumerable); rb_include_module (notmuch_rb_cThreads, rb_mEnumerable);
/* /*
* Document-class: Notmuch::Messages * Document-class: Notmuch::Messages
* *
* Notmuch messages * Notmuch messages
*/ */
notmuch_rb_cMessages = rb_define_class_under(mod, "Messages", rb_cData); notmuch_rb_cMessages = rb_define_class_under (mod, "Messages", rb_cData);
rb_undef_method(notmuch_rb_cMessages, "initialize"); rb_undef_method (notmuch_rb_cMessages, "initialize");
rb_define_method(notmuch_rb_cMessages, "destroy!", notmuch_rb_messages_destroy, 0); /* in messages.c */ rb_define_method (notmuch_rb_cMessages, "destroy!", notmuch_rb_messages_destroy, 0); /* in messages.c */
rb_define_method(notmuch_rb_cMessages, "each", notmuch_rb_messages_each, 0); /* in messages.c */ rb_define_method (notmuch_rb_cMessages, "each", notmuch_rb_messages_each, 0); /* in messages.c */
rb_define_method(notmuch_rb_cMessages, "tags", notmuch_rb_messages_collect_tags, 0); /* in messages.c */ rb_define_method (notmuch_rb_cMessages, "tags", notmuch_rb_messages_collect_tags, 0); /* in messages.c */
rb_include_module(notmuch_rb_cMessages, rb_mEnumerable); rb_include_module (notmuch_rb_cMessages, rb_mEnumerable);
/* /*
* Document-class: Notmuch::Thread * Document-class: Notmuch::Thread
* *
* Notmuch thread * Notmuch thread
*/ */
notmuch_rb_cThread = rb_define_class_under(mod, "Thread", rb_cData); notmuch_rb_cThread = rb_define_class_under (mod, "Thread", rb_cData);
rb_undef_method(notmuch_rb_cThread, "initialize"); rb_undef_method (notmuch_rb_cThread, "initialize");
rb_define_method(notmuch_rb_cThread, "destroy!", notmuch_rb_thread_destroy, 0); /* in thread.c */ rb_define_method (notmuch_rb_cThread, "destroy!", notmuch_rb_thread_destroy, 0); /* in thread.c */
rb_define_method(notmuch_rb_cThread, "thread_id", notmuch_rb_thread_get_thread_id, 0); /* in thread.c */ rb_define_method (notmuch_rb_cThread, "thread_id", notmuch_rb_thread_get_thread_id, 0); /* in thread.c */
rb_define_method(notmuch_rb_cThread, "total_messages", notmuch_rb_thread_get_total_messages, 0); /* in thread.c */ rb_define_method (notmuch_rb_cThread, "total_messages", notmuch_rb_thread_get_total_messages, 0); /* in thread.c */
rb_define_method(notmuch_rb_cThread, "toplevel_messages", notmuch_rb_thread_get_toplevel_messages, 0); /* in thread.c */ rb_define_method (notmuch_rb_cThread, "toplevel_messages", notmuch_rb_thread_get_toplevel_messages, 0); /* in thread.c */
rb_define_method(notmuch_rb_cThread, "matched_messages", notmuch_rb_thread_get_matched_messages, 0); /* in thread.c */ rb_define_method (notmuch_rb_cThread, "matched_messages", notmuch_rb_thread_get_matched_messages, 0); /* in thread.c */
rb_define_method(notmuch_rb_cThread, "authors", notmuch_rb_thread_get_authors, 0); /* in thread.c */ rb_define_method (notmuch_rb_cThread, "authors", notmuch_rb_thread_get_authors, 0); /* in thread.c */
rb_define_method(notmuch_rb_cThread, "subject", notmuch_rb_thread_get_subject, 0); /* in thread.c */ rb_define_method (notmuch_rb_cThread, "subject", notmuch_rb_thread_get_subject, 0); /* in thread.c */
rb_define_method(notmuch_rb_cThread, "oldest_date", notmuch_rb_thread_get_oldest_date, 0); /* in thread.c */ rb_define_method (notmuch_rb_cThread, "oldest_date", notmuch_rb_thread_get_oldest_date, 0); /* in thread.c */
rb_define_method(notmuch_rb_cThread, "newest_date", notmuch_rb_thread_get_newest_date, 0); /* in thread.c */ rb_define_method (notmuch_rb_cThread, "newest_date", notmuch_rb_thread_get_newest_date, 0); /* in thread.c */
rb_define_method(notmuch_rb_cThread, "tags", notmuch_rb_thread_get_tags, 0); /* in thread.c */ rb_define_method (notmuch_rb_cThread, "tags", notmuch_rb_thread_get_tags, 0); /* in thread.c */
/* /*
* Document-class: Notmuch::Message * Document-class: Notmuch::Message
* *
* Notmuch message * Notmuch message
*/ */
notmuch_rb_cMessage = rb_define_class_under(mod, "Message", rb_cData); notmuch_rb_cMessage = rb_define_class_under (mod, "Message", rb_cData);
rb_undef_method(notmuch_rb_cMessage, "initialize"); rb_undef_method (notmuch_rb_cMessage, "initialize");
rb_define_method(notmuch_rb_cMessage, "destroy!", notmuch_rb_message_destroy, 0); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "destroy!", notmuch_rb_message_destroy, 0); /* in message.c */
rb_define_method(notmuch_rb_cMessage, "message_id", notmuch_rb_message_get_message_id, 0); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "message_id", notmuch_rb_message_get_message_id, 0); /* in message.c */
rb_define_method(notmuch_rb_cMessage, "thread_id", notmuch_rb_message_get_thread_id, 0); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "thread_id", notmuch_rb_message_get_thread_id, 0); /* in message.c */
rb_define_method(notmuch_rb_cMessage, "replies", notmuch_rb_message_get_replies, 0); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "replies", notmuch_rb_message_get_replies, 0); /* in message.c */
rb_define_method(notmuch_rb_cMessage, "filename", notmuch_rb_message_get_filename, 0); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "filename", notmuch_rb_message_get_filename, 0); /* in message.c */
rb_define_method(notmuch_rb_cMessage, "filenames", notmuch_rb_message_get_filenames, 0); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "filenames", notmuch_rb_message_get_filenames, 0); /* in message.c */
rb_define_method(notmuch_rb_cMessage, "get_flag", notmuch_rb_message_get_flag, 1); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "get_flag", notmuch_rb_message_get_flag, 1); /* in message.c */
rb_define_method(notmuch_rb_cMessage, "set_flag", notmuch_rb_message_set_flag, 2); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "set_flag", notmuch_rb_message_set_flag, 2); /* in message.c */
rb_define_method(notmuch_rb_cMessage, "date", notmuch_rb_message_get_date, 0); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "date", notmuch_rb_message_get_date, 0); /* in message.c */
rb_define_method(notmuch_rb_cMessage, "header", notmuch_rb_message_get_header, 1); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "header", notmuch_rb_message_get_header, 1); /* in message.c */
rb_define_alias(notmuch_rb_cMessage, "[]", "header"); rb_define_alias (notmuch_rb_cMessage, "[]", "header");
rb_define_method(notmuch_rb_cMessage, "tags", notmuch_rb_message_get_tags, 0); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "tags", notmuch_rb_message_get_tags, 0); /* in message.c */
rb_define_method(notmuch_rb_cMessage, "add_tag", notmuch_rb_message_add_tag, 1); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "add_tag", notmuch_rb_message_add_tag, 1); /* in message.c */
rb_define_alias(notmuch_rb_cMessage, "<<", "add_tag"); rb_define_alias (notmuch_rb_cMessage, "<<", "add_tag");
rb_define_method(notmuch_rb_cMessage, "remove_tag", notmuch_rb_message_remove_tag, 1); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "remove_tag", notmuch_rb_message_remove_tag, 1); /* in message.c */
rb_define_method(notmuch_rb_cMessage, "remove_all_tags", notmuch_rb_message_remove_all_tags, 0); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "remove_all_tags", notmuch_rb_message_remove_all_tags, 0); /* in message.c */
rb_define_method(notmuch_rb_cMessage, "maildir_flags_to_tags", notmuch_rb_message_maildir_flags_to_tags, 0); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "maildir_flags_to_tags", notmuch_rb_message_maildir_flags_to_tags, 0); /* in message.c */
rb_define_method(notmuch_rb_cMessage, "tags_to_maildir_flags", notmuch_rb_message_tags_to_maildir_flags, 0); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "tags_to_maildir_flags", notmuch_rb_message_tags_to_maildir_flags, 0); /* in message.c */
rb_define_method(notmuch_rb_cMessage, "freeze", notmuch_rb_message_freeze, 0); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "freeze", notmuch_rb_message_freeze, 0); /* in message.c */
rb_define_method(notmuch_rb_cMessage, "thaw", notmuch_rb_message_thaw, 0); /* in message.c */ rb_define_method (notmuch_rb_cMessage, "thaw", notmuch_rb_message_thaw, 0); /* in message.c */
/* /*
* Document-class: Notmuch::Tags * Document-class: Notmuch::Tags
* *
* Notmuch tags * Notmuch tags
*/ */
notmuch_rb_cTags = rb_define_class_under(mod, "Tags", rb_cData); notmuch_rb_cTags = rb_define_class_under (mod, "Tags", rb_cData);
rb_undef_method(notmuch_rb_cTags, "initialize"); rb_undef_method (notmuch_rb_cTags, "initialize");
rb_define_method(notmuch_rb_cTags, "destroy!", notmuch_rb_tags_destroy, 0); /* in tags.c */ rb_define_method (notmuch_rb_cTags, "destroy!", notmuch_rb_tags_destroy, 0); /* in tags.c */
rb_define_method(notmuch_rb_cTags, "each", notmuch_rb_tags_each, 0); /* in tags.c */ rb_define_method (notmuch_rb_cTags, "each", notmuch_rb_tags_each, 0); /* in tags.c */
rb_include_module(notmuch_rb_cTags, rb_mEnumerable); rb_include_module (notmuch_rb_cTags, rb_mEnumerable);
} }

View file

@ -1,6 +1,6 @@
/* The Ruby interface to the notmuch mail library /* The Ruby interface to the notmuch mail library
* *
* Copyright © 2010 Ali Polatel * Copyright © 2010, 2011 Ali Polatel
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,14 +26,14 @@
* Destroys the message, freeing all resources allocated for it. * Destroys the message, freeing all resources allocated for it.
*/ */
VALUE VALUE
notmuch_rb_message_destroy(VALUE self) notmuch_rb_message_destroy (VALUE self)
{ {
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
notmuch_message_destroy(message); notmuch_message_destroy (message);
DATA_PTR(self) = NULL; DATA_PTR (self) = NULL;
return Qnil; return Qnil;
} }
@ -44,16 +44,16 @@ notmuch_rb_message_destroy(VALUE self)
* Get the message ID of 'message'. * Get the message ID of 'message'.
*/ */
VALUE VALUE
notmuch_rb_message_get_message_id(VALUE self) notmuch_rb_message_get_message_id (VALUE self)
{ {
const char *msgid; const char *msgid;
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
msgid = notmuch_message_get_message_id(message); msgid = notmuch_message_get_message_id (message);
return rb_str_new2(msgid); return rb_str_new2 (msgid);
} }
/* /*
@ -62,16 +62,16 @@ notmuch_rb_message_get_message_id(VALUE self)
* Get the thread ID of 'message'. * Get the thread ID of 'message'.
*/ */
VALUE VALUE
notmuch_rb_message_get_thread_id(VALUE self) notmuch_rb_message_get_thread_id (VALUE self)
{ {
const char *tid; const char *tid;
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
tid = notmuch_message_get_thread_id(message); tid = notmuch_message_get_thread_id (message);
return rb_str_new2(tid); return rb_str_new2 (tid);
} }
/* /*
@ -80,16 +80,16 @@ notmuch_rb_message_get_thread_id(VALUE self)
* Get a Notmuch::Messages enumerable for all of the replies to 'message'. * Get a Notmuch::Messages enumerable for all of the replies to 'message'.
*/ */
VALUE VALUE
notmuch_rb_message_get_replies(VALUE self) notmuch_rb_message_get_replies (VALUE self)
{ {
notmuch_messages_t *messages; notmuch_messages_t *messages;
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
messages = notmuch_message_get_replies(message); messages = notmuch_message_get_replies (message);
return Data_Wrap_Struct(notmuch_rb_cMessages, NULL, NULL, messages); return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages);
} }
/* /*
@ -98,16 +98,16 @@ notmuch_rb_message_get_replies(VALUE self)
* Get a filename for the email corresponding to 'message' * Get a filename for the email corresponding to 'message'
*/ */
VALUE VALUE
notmuch_rb_message_get_filename(VALUE self) notmuch_rb_message_get_filename (VALUE self)
{ {
const char *fname; const char *fname;
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
fname = notmuch_message_get_filename(message); fname = notmuch_message_get_filename (message);
return rb_str_new2(fname); return rb_str_new2 (fname);
} }
/* /*
@ -116,52 +116,52 @@ notmuch_rb_message_get_filename(VALUE self)
* Get all filenames for the email corresponding to MESSAGE. * Get all filenames for the email corresponding to MESSAGE.
*/ */
VALUE VALUE
notmuch_rb_message_get_filenames(VALUE self) notmuch_rb_message_get_filenames (VALUE self)
{ {
notmuch_filenames_t *fnames; notmuch_filenames_t *fnames;
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
fnames = notmuch_message_get_filenames(message); fnames = notmuch_message_get_filenames (message);
return Data_Wrap_Struct(notmuch_rb_cFileNames, NULL, NULL, fnames); return Data_Wrap_Struct (notmuch_rb_cFileNames, NULL, NULL, fnames);
} }
/* /*
* call-seq: MESSAGE.get_flag(flag) => true or false * call-seq: MESSAGE.get_flag (flag) => true or false
* *
* Get a value of a flag for the email corresponding to 'message' * Get a value of a flag for the email corresponding to 'message'
*/ */
VALUE VALUE
notmuch_rb_message_get_flag(VALUE self, VALUE flagv) notmuch_rb_message_get_flag (VALUE self, VALUE flagv)
{ {
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
if (!FIXNUM_P(flagv)) if (!FIXNUM_P (flagv))
rb_raise(rb_eTypeError, "Flag not a Fixnum"); rb_raise (rb_eTypeError, "Flag not a Fixnum");
return notmuch_message_get_flag(message, FIX2INT(flagv)) ? Qtrue : Qfalse; return notmuch_message_get_flag (message, FIX2INT (flagv)) ? Qtrue : Qfalse;
} }
/* /*
* call-seq: MESSAGE.set_flag(flag, value) => nil * call-seq: MESSAGE.set_flag (flag, value) => nil
* *
* Set a value of a flag for the email corresponding to 'message' * Set a value of a flag for the email corresponding to 'message'
*/ */
VALUE VALUE
notmuch_rb_message_set_flag(VALUE self, VALUE flagv, VALUE valuev) notmuch_rb_message_set_flag (VALUE self, VALUE flagv, VALUE valuev)
{ {
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
if (!FIXNUM_P(flagv)) if (!FIXNUM_P (flagv))
rb_raise(rb_eTypeError, "Flag not a Fixnum"); rb_raise (rb_eTypeError, "Flag not a Fixnum");
notmuch_message_set_flag(message, FIX2INT(flagv), RTEST(valuev)); notmuch_message_set_flag (message, FIX2INT (flagv), RTEST (valuev));
return Qnil; return Qnil;
} }
@ -172,40 +172,40 @@ notmuch_rb_message_set_flag(VALUE self, VALUE flagv, VALUE valuev)
* Get the date of 'message' * Get the date of 'message'
*/ */
VALUE VALUE
notmuch_rb_message_get_date(VALUE self) notmuch_rb_message_get_date (VALUE self)
{ {
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
return UINT2NUM(notmuch_message_get_date(message)); return UINT2NUM (notmuch_message_get_date (message));
} }
/* /*
* call-seq: MESSAGE.header(name) => String * call-seq: MESSAGE.header (name) => String
* *
* Get the value of the specified header from 'message' * Get the value of the specified header from 'message'
*/ */
VALUE VALUE
notmuch_rb_message_get_header(VALUE self, VALUE headerv) notmuch_rb_message_get_header (VALUE self, VALUE headerv)
{ {
const char *header, *value; const char *header, *value;
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
#if !defined(RSTRING_PTR) #if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr) #define RSTRING_PTR(v) (RSTRING((v))->ptr)
#endif /* !defined(RSTRING_PTR) */ #endif /* !defined(RSTRING_PTR) */
SafeStringValue(headerv); SafeStringValue (headerv);
header = RSTRING_PTR(headerv); header = RSTRING_PTR (headerv);
value = notmuch_message_get_header(message, header); value = notmuch_message_get_header (message, header);
if (!value) if (!value)
rb_raise(notmuch_rb_eMemoryError, "Out of memory"); rb_raise (notmuch_rb_eMemoryError, "Out of memory");
return rb_str_new2(value); return rb_str_new2 (value);
} }
/* /*
@ -214,70 +214,70 @@ notmuch_rb_message_get_header(VALUE self, VALUE headerv)
* Get a Notmuch::Tags enumerable for all of the tags of 'message'. * Get a Notmuch::Tags enumerable for all of the tags of 'message'.
*/ */
VALUE VALUE
notmuch_rb_message_get_tags(VALUE self) notmuch_rb_message_get_tags (VALUE self)
{ {
notmuch_message_t *message; notmuch_message_t *message;
notmuch_tags_t *tags; notmuch_tags_t *tags;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
tags = notmuch_message_get_tags(message); tags = notmuch_message_get_tags (message);
if (!tags) if (!tags)
rb_raise(notmuch_rb_eMemoryError, "Out of memory"); rb_raise (notmuch_rb_eMemoryError, "Out of memory");
return Data_Wrap_Struct(notmuch_rb_cTags, NULL, NULL, tags); return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags);
} }
/* /*
* call-seq: MESSAGE.add_tag(tag) => true * call-seq: MESSAGE.add_tag (tag) => true
* *
* Add a tag to the 'message' * Add a tag to the 'message'
*/ */
VALUE VALUE
notmuch_rb_message_add_tag(VALUE self, VALUE tagv) notmuch_rb_message_add_tag (VALUE self, VALUE tagv)
{ {
const char *tag; const char *tag;
notmuch_status_t ret; notmuch_status_t ret;
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
#if !defined(RSTRING_PTR) #if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr) #define RSTRING_PTR(v) (RSTRING((v))->ptr)
#endif /* !defined(RSTRING_PTR) */ #endif /* !defined(RSTRING_PTR) */
SafeStringValue(tagv); SafeStringValue (tagv);
tag = RSTRING_PTR(tagv); tag = RSTRING_PTR (tagv);
ret = notmuch_message_add_tag(message, tag); ret = notmuch_message_add_tag (message, tag);
notmuch_rb_status_raise(ret); notmuch_rb_status_raise (ret);
return Qtrue; return Qtrue;
} }
/* /*
* call-seq: MESSAGE.remove_tag(tag) => true * call-seq: MESSAGE.remove_tag (tag) => true
* *
* Remove a tag from the 'message' * Remove a tag from the 'message'
*/ */
VALUE VALUE
notmuch_rb_message_remove_tag(VALUE self, VALUE tagv) notmuch_rb_message_remove_tag (VALUE self, VALUE tagv)
{ {
const char *tag; const char *tag;
notmuch_status_t ret; notmuch_status_t ret;
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
#if !defined(RSTRING_PTR) #if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr) #define RSTRING_PTR(v) (RSTRING((v))->ptr)
#endif /* !defined(RSTRING_PTR) */ #endif /* !defined(RSTRING_PTR) */
SafeStringValue(tagv); SafeStringValue (tagv);
tag = RSTRING_PTR(tagv); tag = RSTRING_PTR (tagv);
ret = notmuch_message_remove_tag(message, tag); ret = notmuch_message_remove_tag (message, tag);
notmuch_rb_status_raise(ret); notmuch_rb_status_raise (ret);
return Qtrue; return Qtrue;
} }
@ -288,15 +288,15 @@ notmuch_rb_message_remove_tag(VALUE self, VALUE tagv)
* Remove all tags of the 'message' * Remove all tags of the 'message'
*/ */
VALUE VALUE
notmuch_rb_message_remove_all_tags(VALUE self) notmuch_rb_message_remove_all_tags (VALUE self)
{ {
notmuch_status_t ret; notmuch_status_t ret;
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
ret = notmuch_message_remove_all_tags(message); ret = notmuch_message_remove_all_tags (message);
notmuch_rb_status_raise(ret); notmuch_rb_status_raise (ret);
return Qtrue; return Qtrue;
} }
@ -304,18 +304,18 @@ notmuch_rb_message_remove_all_tags(VALUE self)
/* /*
* call-seq: MESSAGE.maildir_flags_to_tags => true * call-seq: MESSAGE.maildir_flags_to_tags => true
* *
* Add/remove tags according to maildir flags in the message filename(s) * Add/remove tags according to maildir flags in the message filename (s)
*/ */
VALUE VALUE
notmuch_rb_message_maildir_flags_to_tags(VALUE self) notmuch_rb_message_maildir_flags_to_tags (VALUE self)
{ {
notmuch_status_t ret; notmuch_status_t ret;
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
ret = notmuch_message_maildir_flags_to_tags(message); ret = notmuch_message_maildir_flags_to_tags (message);
notmuch_rb_status_raise(ret); notmuch_rb_status_raise (ret);
return Qtrue; return Qtrue;
} }
@ -323,18 +323,18 @@ notmuch_rb_message_maildir_flags_to_tags(VALUE self)
/* /*
* call-seq: MESSAGE.tags_to_maildir_flags => true * call-seq: MESSAGE.tags_to_maildir_flags => true
* *
* Rename message filename(s) to encode tags as maildir flags * Rename message filename (s) to encode tags as maildir flags
*/ */
VALUE VALUE
notmuch_rb_message_tags_to_maildir_flags(VALUE self) notmuch_rb_message_tags_to_maildir_flags (VALUE self)
{ {
notmuch_status_t ret; notmuch_status_t ret;
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
ret = notmuch_message_tags_to_maildir_flags(message); ret = notmuch_message_tags_to_maildir_flags (message);
notmuch_rb_status_raise(ret); notmuch_rb_status_raise (ret);
return Qtrue; return Qtrue;
} }
@ -345,15 +345,15 @@ notmuch_rb_message_tags_to_maildir_flags(VALUE self)
* Freeze the 'message' * Freeze the 'message'
*/ */
VALUE VALUE
notmuch_rb_message_freeze(VALUE self) notmuch_rb_message_freeze (VALUE self)
{ {
notmuch_status_t ret; notmuch_status_t ret;
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
ret = notmuch_message_freeze(message); ret = notmuch_message_freeze (message);
notmuch_rb_status_raise(ret); notmuch_rb_status_raise (ret);
return Qtrue; return Qtrue;
} }
@ -364,15 +364,15 @@ notmuch_rb_message_freeze(VALUE self)
* Thaw a 'message' * Thaw a 'message'
*/ */
VALUE VALUE
notmuch_rb_message_thaw(VALUE self) notmuch_rb_message_thaw (VALUE self)
{ {
notmuch_status_t ret; notmuch_status_t ret;
notmuch_message_t *message; notmuch_message_t *message;
Data_Get_Notmuch_Message(self, message); Data_Get_Notmuch_Message (self, message);
ret = notmuch_message_thaw(message); ret = notmuch_message_thaw (message);
notmuch_rb_status_raise(ret); notmuch_rb_status_raise (ret);
return Qtrue; return Qtrue;
} }

View file

@ -1,6 +1,6 @@
/* The Ruby interface to the notmuch mail library /* The Ruby interface to the notmuch mail library
* *
* Copyright © 2010 Ali Polatel * Copyright © 2010, 2011 Ali Polatel
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,14 +26,14 @@
* Destroys the messages, freeing all resources allocated for it. * Destroys the messages, freeing all resources allocated for it.
*/ */
VALUE VALUE
notmuch_rb_messages_destroy(VALUE self) notmuch_rb_messages_destroy (VALUE self)
{ {
notmuch_messages_t *messages; notmuch_messages_t *messages;
Data_Get_Notmuch_Messages(self, messages); Data_Get_Notmuch_Messages (self, messages);
notmuch_messages_destroy(messages); notmuch_messages_destroy (messages);
DATA_PTR(self) = NULL; DATA_PTR (self) = NULL;
return Qnil; return Qnil;
} }
@ -44,16 +44,16 @@ notmuch_rb_messages_destroy(VALUE self)
* parameter. * parameter.
*/ */
VALUE VALUE
notmuch_rb_messages_each(VALUE self) notmuch_rb_messages_each (VALUE self)
{ {
notmuch_message_t *message; notmuch_message_t *message;
notmuch_messages_t *messages; notmuch_messages_t *messages;
Data_Get_Notmuch_Messages(self, messages); Data_Get_Notmuch_Messages (self, messages);
for (; notmuch_messages_valid(messages); notmuch_messages_move_to_next(messages)) { for (; notmuch_messages_valid (messages); notmuch_messages_move_to_next (messages)) {
message = notmuch_messages_get(messages); message = notmuch_messages_get (messages);
rb_yield(Data_Wrap_Struct(notmuch_rb_cMessage, NULL, NULL, message)); rb_yield (Data_Wrap_Struct (notmuch_rb_cMessage, NULL, NULL, message));
} }
return self; return self;
@ -65,16 +65,16 @@ notmuch_rb_messages_each(VALUE self)
* Collect tags from the messages * Collect tags from the messages
*/ */
VALUE VALUE
notmuch_rb_messages_collect_tags(VALUE self) notmuch_rb_messages_collect_tags (VALUE self)
{ {
notmuch_tags_t *tags; notmuch_tags_t *tags;
notmuch_messages_t *messages; notmuch_messages_t *messages;
Data_Get_Notmuch_Messages(self, messages); Data_Get_Notmuch_Messages (self, messages);
tags = notmuch_messages_collect_tags(messages); tags = notmuch_messages_collect_tags (messages);
if (!tags) if (!tags)
rb_raise(notmuch_rb_eMemoryError, "Out of memory"); rb_raise (notmuch_rb_eMemoryError, "Out of memory");
return Data_Wrap_Struct(notmuch_rb_cTags, NULL, NULL, tags); return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags);
} }

View file

@ -1,6 +1,6 @@
/* The Ruby interface to the notmuch mail library /* The Ruby interface to the notmuch mail library
* *
* Copyright © 2010 Ali Polatel * Copyright © 2010, 2011 Ali Polatel
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,14 +26,14 @@
* Destroys the query, freeing all resources allocated for it. * Destroys the query, freeing all resources allocated for it.
*/ */
VALUE VALUE
notmuch_rb_query_destroy(VALUE self) notmuch_rb_query_destroy (VALUE self)
{ {
notmuch_query_t *query; notmuch_query_t *query;
Data_Get_Notmuch_Query(self, query); Data_Get_Notmuch_Query (self, query);
notmuch_query_destroy(query); notmuch_query_destroy (query);
DATA_PTR(self) = NULL; DATA_PTR (self) = NULL;
return Qnil; return Qnil;
} }
@ -44,13 +44,13 @@ notmuch_rb_query_destroy(VALUE self)
* Get sort type of the +QUERY+ * Get sort type of the +QUERY+
*/ */
VALUE VALUE
notmuch_rb_query_get_sort(VALUE self) notmuch_rb_query_get_sort (VALUE self)
{ {
notmuch_query_t *query; notmuch_query_t *query;
Data_Get_Notmuch_Query(self, query); Data_Get_Notmuch_Query (self, query);
return FIX2INT(notmuch_query_get_sort(query)); return FIX2INT (notmuch_query_get_sort (query));
} }
/* /*
@ -59,16 +59,16 @@ notmuch_rb_query_get_sort(VALUE self)
* Set sort type of the +QUERY+ * Set sort type of the +QUERY+
*/ */
VALUE VALUE
notmuch_rb_query_set_sort(VALUE self, VALUE sortv) notmuch_rb_query_set_sort (VALUE self, VALUE sortv)
{ {
notmuch_query_t *query; notmuch_query_t *query;
Data_Get_Notmuch_Query(self, query); Data_Get_Notmuch_Query (self, query);
if (!FIXNUM_P(sortv)) if (!FIXNUM_P (sortv))
rb_raise(rb_eTypeError, "Not a Fixnum"); rb_raise (rb_eTypeError, "Not a Fixnum");
notmuch_query_set_sort(query, FIX2UINT(sortv)); notmuch_query_set_sort (query, FIX2UINT (sortv));
return Qnil; return Qnil;
} }
@ -79,13 +79,13 @@ notmuch_rb_query_set_sort(VALUE self, VALUE sortv)
* Get query string of the +QUERY+ * Get query string of the +QUERY+
*/ */
VALUE VALUE
notmuch_rb_query_get_string(VALUE self) notmuch_rb_query_get_string (VALUE self)
{ {
notmuch_query_t *query; notmuch_query_t *query;
Data_Get_Notmuch_Query(self, query); Data_Get_Notmuch_Query (self, query);
return rb_str_new2(notmuch_query_get_query_string(query)); return rb_str_new2 (notmuch_query_get_query_string (query));
} }
/* /*
@ -94,18 +94,18 @@ notmuch_rb_query_get_string(VALUE self)
* Search for threads * Search for threads
*/ */
VALUE VALUE
notmuch_rb_query_search_threads(VALUE self) notmuch_rb_query_search_threads (VALUE self)
{ {
notmuch_query_t *query; notmuch_query_t *query;
notmuch_threads_t *threads; notmuch_threads_t *threads;
Data_Get_Notmuch_Query(self, query); Data_Get_Notmuch_Query (self, query);
threads = notmuch_query_search_threads(query); threads = notmuch_query_search_threads (query);
if (!threads) if (!threads)
rb_raise(notmuch_rb_eMemoryError, "Out of memory"); rb_raise (notmuch_rb_eMemoryError, "Out of memory");
return Data_Wrap_Struct(notmuch_rb_cThreads, NULL, NULL, threads); return Data_Wrap_Struct (notmuch_rb_cThreads, NULL, NULL, threads);
} }
/* /*
@ -114,16 +114,16 @@ notmuch_rb_query_search_threads(VALUE self)
* Search for messages * Search for messages
*/ */
VALUE VALUE
notmuch_rb_query_search_messages(VALUE self) notmuch_rb_query_search_messages (VALUE self)
{ {
notmuch_query_t *query; notmuch_query_t *query;
notmuch_messages_t *messages; notmuch_messages_t *messages;
Data_Get_Notmuch_Query(self, query); Data_Get_Notmuch_Query (self, query);
messages = notmuch_query_search_messages(query); messages = notmuch_query_search_messages (query);
if (!messages) if (!messages)
rb_raise(notmuch_rb_eMemoryError, "Out of memory"); rb_raise (notmuch_rb_eMemoryError, "Out of memory");
return Data_Wrap_Struct(notmuch_rb_cMessages, NULL, NULL, messages); return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages);
} }

View file

@ -1,6 +1,6 @@
/* The Ruby interface to the notmuch mail library /* The Ruby interface to the notmuch mail library
* *
* Copyright © 2010 Ali Polatel * Copyright © 2010, 2011 Ali Polatel
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,31 +21,31 @@
#include "defs.h" #include "defs.h"
void void
notmuch_rb_status_raise(notmuch_status_t status) notmuch_rb_status_raise (notmuch_status_t status)
{ {
switch (status) { switch (status) {
case NOTMUCH_STATUS_SUCCESS: case NOTMUCH_STATUS_SUCCESS:
case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
break; break;
case NOTMUCH_STATUS_OUT_OF_MEMORY: case NOTMUCH_STATUS_OUT_OF_MEMORY:
rb_raise(notmuch_rb_eMemoryError, "out of memory"); rb_raise (notmuch_rb_eMemoryError, "out of memory");
case NOTMUCH_STATUS_READ_ONLY_DATABASE: case NOTMUCH_STATUS_READ_ONLY_DATABASE:
rb_raise(notmuch_rb_eReadOnlyError, "read-only database"); rb_raise (notmuch_rb_eReadOnlyError, "read-only database");
case NOTMUCH_STATUS_XAPIAN_EXCEPTION: case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
rb_raise(notmuch_rb_eXapianError, "xapian exception"); rb_raise (notmuch_rb_eXapianError, "xapian exception");
case NOTMUCH_STATUS_FILE_ERROR: case NOTMUCH_STATUS_FILE_ERROR:
rb_raise(notmuch_rb_eFileError, "failed to read/write file"); rb_raise (notmuch_rb_eFileError, "failed to read/write file");
case NOTMUCH_STATUS_FILE_NOT_EMAIL: case NOTMUCH_STATUS_FILE_NOT_EMAIL:
rb_raise(notmuch_rb_eFileNotEmailError, "file not email"); rb_raise (notmuch_rb_eFileNotEmailError, "file not email");
case NOTMUCH_STATUS_NULL_POINTER: case NOTMUCH_STATUS_NULL_POINTER:
rb_raise(notmuch_rb_eNullPointerError, "null pointer"); rb_raise (notmuch_rb_eNullPointerError, "null pointer");
case NOTMUCH_STATUS_TAG_TOO_LONG: case NOTMUCH_STATUS_TAG_TOO_LONG:
rb_raise(notmuch_rb_eTagTooLongError, "tag too long"); rb_raise (notmuch_rb_eTagTooLongError, "tag too long");
case NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW: case NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW:
rb_raise(notmuch_rb_eUnbalancedFreezeThawError, "unbalanced freeze/thaw"); rb_raise (notmuch_rb_eUnbalancedFreezeThawError, "unbalanced freeze/thaw");
case NOTMUCH_STATUS_UNBALANCED_ATOMIC: case NOTMUCH_STATUS_UNBALANCED_ATOMIC:
rb_raise(notmuch_rb_eUnbalancedAtomicError, "unbalanced atomic"); rb_raise (notmuch_rb_eUnbalancedAtomicError, "unbalanced atomic");
default: default:
rb_raise(notmuch_rb_eBaseError, "unknown notmuch error"); rb_raise (notmuch_rb_eBaseError, "unknown notmuch error");
} }
} }

View file

@ -1,6 +1,6 @@
/* The Ruby interface to the notmuch mail library /* The Ruby interface to the notmuch mail library
* *
* Copyright © 2010 Ali Polatel * Copyright © 2010, 2011 Ali Polatel
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,14 +26,14 @@
* Destroys the tags, freeing all resources allocated for it. * Destroys the tags, freeing all resources allocated for it.
*/ */
VALUE VALUE
notmuch_rb_tags_destroy(VALUE self) notmuch_rb_tags_destroy (VALUE self)
{ {
notmuch_tags_t *tags; notmuch_tags_t *tags;
Data_Get_Notmuch_Tags(self, tags); Data_Get_Notmuch_Tags (self, tags);
notmuch_tags_destroy(tags); notmuch_tags_destroy (tags);
DATA_PTR(self) = NULL; DATA_PTR (self) = NULL;
return Qnil; return Qnil;
} }
@ -45,16 +45,16 @@ notmuch_rb_tags_destroy(VALUE self)
* parameter. * parameter.
*/ */
VALUE VALUE
notmuch_rb_tags_each(VALUE self) notmuch_rb_tags_each (VALUE self)
{ {
const char *tag; const char *tag;
notmuch_tags_t *tags; notmuch_tags_t *tags;
Data_Get_Notmuch_Tags(self, tags); Data_Get_Notmuch_Tags (self, tags);
for (; notmuch_tags_valid(tags); notmuch_tags_move_to_next(tags)) { for (; notmuch_tags_valid (tags); notmuch_tags_move_to_next (tags)) {
tag = notmuch_tags_get(tags); tag = notmuch_tags_get (tags);
rb_yield(rb_str_new2(tag)); rb_yield (rb_str_new2 (tag));
} }
return self; return self;

View file

@ -1,6 +1,6 @@
/* The Ruby interface to the notmuch mail library /* The Ruby interface to the notmuch mail library
* *
* Copyright © 2010 Ali Polatel * Copyright © 2010, 2011 Ali Polatel
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,14 +26,14 @@
* Destroys the thread, freeing all resources allocated for it. * Destroys the thread, freeing all resources allocated for it.
*/ */
VALUE VALUE
notmuch_rb_thread_destroy(VALUE self) notmuch_rb_thread_destroy (VALUE self)
{ {
notmuch_thread_t *thread; notmuch_thread_t *thread;
Data_Get_Notmuch_Thread(self, thread); Data_Get_Notmuch_Thread (self, thread);
notmuch_thread_destroy(thread); notmuch_thread_destroy (thread);
DATA_PTR(self) = NULL; DATA_PTR (self) = NULL;
return Qnil; return Qnil;
} }
@ -44,16 +44,16 @@ notmuch_rb_thread_destroy(VALUE self)
* Returns the thread id * Returns the thread id
*/ */
VALUE VALUE
notmuch_rb_thread_get_thread_id(VALUE self) notmuch_rb_thread_get_thread_id (VALUE self)
{ {
const char *tid; const char *tid;
notmuch_thread_t *thread; notmuch_thread_t *thread;
Data_Get_Notmuch_Thread(self, thread); Data_Get_Notmuch_Thread (self, thread);
tid = notmuch_thread_get_thread_id(thread); tid = notmuch_thread_get_thread_id (thread);
return rb_str_new2(tid); return rb_str_new2 (tid);
} }
/* /*
@ -62,13 +62,13 @@ notmuch_rb_thread_get_thread_id(VALUE self)
* Returns the number of total messages * Returns the number of total messages
*/ */
VALUE VALUE
notmuch_rb_thread_get_total_messages(VALUE self) notmuch_rb_thread_get_total_messages (VALUE self)
{ {
notmuch_thread_t *thread; notmuch_thread_t *thread;
Data_Get_Notmuch_Thread(self, thread); Data_Get_Notmuch_Thread (self, thread);
return INT2FIX(notmuch_thread_get_total_messages(thread)); return INT2FIX (notmuch_thread_get_total_messages (thread));
} }
/* /*
@ -77,18 +77,18 @@ notmuch_rb_thread_get_total_messages(VALUE self)
* Get a Notmuch::Messages iterator for the top level messages in thread. * Get a Notmuch::Messages iterator for the top level messages in thread.
*/ */
VALUE VALUE
notmuch_rb_thread_get_toplevel_messages(VALUE self) notmuch_rb_thread_get_toplevel_messages (VALUE self)
{ {
notmuch_messages_t *messages; notmuch_messages_t *messages;
notmuch_thread_t *thread; notmuch_thread_t *thread;
Data_Get_Notmuch_Thread(self, thread); Data_Get_Notmuch_Thread (self, thread);
messages = notmuch_thread_get_toplevel_messages(thread); messages = notmuch_thread_get_toplevel_messages (thread);
if (!messages) if (!messages)
rb_raise(notmuch_rb_eMemoryError, "Out of memory"); rb_raise (notmuch_rb_eMemoryError, "Out of memory");
return Data_Wrap_Struct(notmuch_rb_cMessages, NULL, NULL, messages); return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages);
} }
/* /*
@ -97,13 +97,13 @@ notmuch_rb_thread_get_toplevel_messages(VALUE self)
* Get the number of messages in thread that matched the search * Get the number of messages in thread that matched the search
*/ */
VALUE VALUE
notmuch_rb_thread_get_matched_messages(VALUE self) notmuch_rb_thread_get_matched_messages (VALUE self)
{ {
notmuch_thread_t *thread; notmuch_thread_t *thread;
Data_Get_Notmuch_Thread(self, thread); Data_Get_Notmuch_Thread (self, thread);
return INT2FIX(notmuch_thread_get_matched_messages(thread)); return INT2FIX (notmuch_thread_get_matched_messages (thread));
} }
/* /*
@ -112,16 +112,16 @@ notmuch_rb_thread_get_matched_messages(VALUE self)
* Get a comma-separated list of the names of the authors. * Get a comma-separated list of the names of the authors.
*/ */
VALUE VALUE
notmuch_rb_thread_get_authors(VALUE self) notmuch_rb_thread_get_authors (VALUE self)
{ {
const char *authors; const char *authors;
notmuch_thread_t *thread; notmuch_thread_t *thread;
Data_Get_Notmuch_Thread(self, thread); Data_Get_Notmuch_Thread (self, thread);
authors = notmuch_thread_get_authors(thread); authors = notmuch_thread_get_authors (thread);
return rb_str_new2(authors); return rb_str_new2 (authors);
} }
/* /*
@ -130,16 +130,16 @@ notmuch_rb_thread_get_authors(VALUE self)
* Returns the subject of the thread * Returns the subject of the thread
*/ */
VALUE VALUE
notmuch_rb_thread_get_subject(VALUE self) notmuch_rb_thread_get_subject (VALUE self)
{ {
const char *subject; const char *subject;
notmuch_thread_t *thread; notmuch_thread_t *thread;
Data_Get_Notmuch_Thread(self, thread); Data_Get_Notmuch_Thread (self, thread);
subject = notmuch_thread_get_subject(thread); subject = notmuch_thread_get_subject (thread);
return rb_str_new2(subject); return rb_str_new2 (subject);
} }
/* /*
@ -148,13 +148,13 @@ notmuch_rb_thread_get_subject(VALUE self)
* Get the date of the oldest message in thread. * Get the date of the oldest message in thread.
*/ */
VALUE VALUE
notmuch_rb_thread_get_oldest_date(VALUE self) notmuch_rb_thread_get_oldest_date (VALUE self)
{ {
notmuch_thread_t *thread; notmuch_thread_t *thread;
Data_Get_Notmuch_Thread(self, thread); Data_Get_Notmuch_Thread (self, thread);
return UINT2NUM(notmuch_thread_get_oldest_date(thread)); return UINT2NUM (notmuch_thread_get_oldest_date (thread));
} }
/* /*
@ -163,13 +163,13 @@ notmuch_rb_thread_get_oldest_date(VALUE self)
* Get the date of the newest message in thread. * Get the date of the newest message in thread.
*/ */
VALUE VALUE
notmuch_rb_thread_get_newest_date(VALUE self) notmuch_rb_thread_get_newest_date (VALUE self)
{ {
notmuch_thread_t *thread; notmuch_thread_t *thread;
Data_Get_Notmuch_Thread(self, thread); Data_Get_Notmuch_Thread (self, thread);
return UINT2NUM(notmuch_thread_get_newest_date(thread)); return UINT2NUM (notmuch_thread_get_newest_date (thread));
} }
/* /*
@ -178,16 +178,16 @@ notmuch_rb_thread_get_newest_date(VALUE self)
* Get a Notmuch::Tags iterator for the tags of the thread * Get a Notmuch::Tags iterator for the tags of the thread
*/ */
VALUE VALUE
notmuch_rb_thread_get_tags(VALUE self) notmuch_rb_thread_get_tags (VALUE self)
{ {
notmuch_thread_t *thread; notmuch_thread_t *thread;
notmuch_tags_t *tags; notmuch_tags_t *tags;
Data_Get_Notmuch_Thread(self, thread); Data_Get_Notmuch_Thread (self, thread);
tags = notmuch_thread_get_tags(thread); tags = notmuch_thread_get_tags (thread);
if (!tags) if (!tags)
rb_raise(notmuch_rb_eMemoryError, "Out of memory"); rb_raise (notmuch_rb_eMemoryError, "Out of memory");
return Data_Wrap_Struct(notmuch_rb_cTags, NULL, NULL, tags); return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags);
} }

View file

@ -1,6 +1,6 @@
/* The Ruby interface to the notmuch mail library /* The Ruby interface to the notmuch mail library
* *
* Copyright © 2010 Ali Polatel * Copyright © 2010, 2011 Ali Polatel
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,14 +26,14 @@
* Destroys the threads, freeing all resources allocated for it. * Destroys the threads, freeing all resources allocated for it.
*/ */
VALUE VALUE
notmuch_rb_threads_destroy(VALUE self) notmuch_rb_threads_destroy (VALUE self)
{ {
notmuch_threads_t *threads; notmuch_threads_t *threads;
Data_Get_Struct(self, notmuch_threads_t, threads); Data_Get_Struct (self, notmuch_threads_t, threads);
notmuch_threads_destroy(threads); notmuch_threads_destroy (threads);
DATA_PTR(self) = NULL; DATA_PTR (self) = NULL;
return Qnil; return Qnil;
} }
@ -44,16 +44,16 @@ notmuch_rb_threads_destroy(VALUE self)
* parameter. * parameter.
*/ */
VALUE VALUE
notmuch_rb_threads_each(VALUE self) notmuch_rb_threads_each (VALUE self)
{ {
notmuch_thread_t *thread; notmuch_thread_t *thread;
notmuch_threads_t *threads; notmuch_threads_t *threads;
Data_Get_Notmuch_Threads(self, threads); Data_Get_Notmuch_Threads (self, threads);
for (; notmuch_threads_valid(threads); notmuch_threads_move_to_next(threads)) { for (; notmuch_threads_valid (threads); notmuch_threads_move_to_next (threads)) {
thread = notmuch_threads_get(threads); thread = notmuch_threads_get (threads);
rb_yield(Data_Wrap_Struct(notmuch_rb_cThread, NULL, NULL, thread)); rb_yield (Data_Wrap_Struct (notmuch_rb_cThread, NULL, NULL, thread));
} }
return self; return self;