Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 6601B431FB6 for ; Wed, 18 Jul 2012 11:41:06 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TSS4m52QqxwL for ; Wed, 18 Jul 2012 11:41:05 -0700 (PDT) Received: from mail.bustany.org (bustany.org [176.31.244.208]) by olra.theworths.org (Postfix) with ESMTP id DF4DE431FBF for ; Wed, 18 Jul 2012 11:41:04 -0700 (PDT) Received: from localhost.localdomain (91-158-2-79.elisa-laajakaista.fi [91.158.2.79]) by mail.bustany.org (Postfix) with ESMTPSA id 7A71E1400D9 for ; Wed, 18 Jul 2012 20:37:09 +0200 (CEST) From: Adrien Bustany To: notmuch@notmuchmail.org Subject: [PATCH 6/7] go: Bind notmuch_database_find_message_by_filename Date: Wed, 18 Jul 2012 21:34:34 +0300 Message-Id: <1342636475-16057-7-git-send-email-adrien@bustany.org> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1342636475-16057-1-git-send-email-adrien@bustany.org> References: <1342636475-16057-1-git-send-email-adrien@bustany.org> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2012 18:41:06 -0000 --- bindings/go/src/notmuch/notmuch.go | 39 ++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-) diff --git a/bindings/go/src/notmuch/notmuch.go b/bindings/go/src/notmuch/notmuch.go index 384d5a5..be4cb8c 100644 --- a/bindings/go/src/notmuch/notmuch.go +++ b/bindings/go/src/notmuch/notmuch.go @@ -453,6 +453,45 @@ func (self *Database) FindMessage(message_id string) (*Message, Status) { return createMessage(msg, nil), st } +/* Find a message with the given filename. + * + * If the database contains a message with the given filename then, on + * successful return (NOTMUCH_STATUS_SUCCESS) '*message' will be initialized to + * a message object. The caller should call notmuch_message_destroy when done + * with the message. + * + * On any failure or when the message is not found, this function initializes + * '*message' to NULL. This means, when NOTMUCH_STATUS_SUCCESS is returned, the + * caller is supposed to check '*message' for NULL to find out whether the + * message with the given filename is found. + * + * Return value: + * + * NOTMUCH_STATUS_SUCCESS: Successful return, check '*message' + * + * NOTMUCH_STATUS_NULL_POINTER: The given 'message' argument is NULL + * + * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory, creating the message object + * + * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred + */ +func (self *Database) FindMessageByFilename(filename string) (*Message, Status) { + + var c_msg_filename *C.char = C.CString(filename) + defer C.free(unsafe.Pointer(c_msg_filename)) + + if c_msg_filename == nil { + return nil, STATUS_OUT_OF_MEMORY + } + + var msg *C.notmuch_message_t + st := Status(C.notmuch_database_find_message_by_filename(self.db, c_msg_filename, &msg)) + if st != STATUS_SUCCESS { + return nil, st + } + return createMessage(msg, nil), st +} + /* Return a list of all tags found in the database. * * This function creates a list of all tags found in the database. The -- 1.7.7.6