I like this patch. -- ________________________________________________________________ Paul Stevens mailto:[EMAIL PROTECTED] NET FACILITIES GROUP PGP: finger [EMAIL PROTECTED] The Netherlands________________________________http://www.nfg.nl
--- Begin Message --->From [EMAIL PROTECTED] Wed Jan 29 19: 51:57 2003 Return-Path: <[EMAIL PROTECTED]> X-Original-To: [EMAIL PROTECTED] Delivered-To: [EMAIL PROTECTED] Received: from akerpoort.nfg.nl (akerpoort.wice [172.16.1.200]) by shiko.wice (Postfix) with ESMTP id 4003AF9EC for <[EMAIL PROTECTED]>; Wed, 29 Jan 2003 19:51:57 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by akerpoort.nfg.nl (Postfix) with ESMTP id 5BE418247C for <[EMAIL PROTECTED]>; Wed, 29 Jan 2003 19:51:56 +0100 (CET) Received: by akerpoort.nfg.nl (Postfix, from userid 1002) id 60B9E82380; Wed, 29 Jan 2003 19:51:55 +0100 (CET) X-Original-To: [EMAIL PROTECTED] Delivered-To: [EMAIL PROTECTED] Received: from localhost (localhost [127.0.0.1]) by akerpoort.nfg.nl (Postfix) with ESMTP id 16D458247C for <[EMAIL PROTECTED]>; Wed, 29 Jan 2003 19:51:43 +0100 (CET) Received: from banzai.nfg.nl (banzai [194.109.206.156]) by akerpoort.nfg.nl (Postfix) with ESMTP id 7C10882380 for <[EMAIL PROTECTED]>; Wed, 29 Jan 2003 19:51:41 +0100 (CET) Received: from twister.fastxs.net (twister.fastxs.net [62.133.136.9]) by banzai.nfg.nl (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id TAA27619 for <[EMAIL PROTECTED]>; Wed, 29 Jan 2003 19:51:40 +0100 Received: from twister.fastxs.net (localhost [127.0.0.1]) by twister.fastxs.net (Postfix) with ESMTP id 32BB77B662; Wed, 29 Jan 2003 19:50:40 +0100 (CET) Received: from colossus.engr.paly.net (colossus.engr.paly.net [199.80.240.152]) by twister.fastxs.net (Postfix) with ESMTP id 2762A7B65F for <[email protected]>; Wed, 29 Jan 2003 19:47:14 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by colossus.engr.paly.net (Postfix) with ESMTP id 77BF496D for <[email protected]>; Wed, 29 Jan 2003 10:44:34 -0800 (PST) From: Aaron Stone <[EMAIL PROTECTED]> X-X-Sender: [EMAIL PROTECTED] To: [email protected] Message-ID: <[EMAIL PROTECTED]> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: [Dbmail] New db_insert_message with auto-mailbox creation Sender: [EMAIL PROTECTED] Errors-To: [EMAIL PROTECTED] X-BeenThere: [email protected] X-Mailman-Version: 2.0.10 Precedence: bulk Reply-To: [email protected] List-Help: <mailto:[EMAIL PROTECTED]> List-Post: <mailto:[email protected]> List-Subscribe: <https://mailman.fastxs.nl/mailman/listinfo/dbmail>, <mailto:[EMAIL PROTECTED]> List-Id: <dbmail.dbmail.org> List-Unsubscribe: <https://mailman.fastxs.nl/mailman/listinfo/dbmail>, <mailto:[EMAIL PROTECTED]> List-Archive: <https://mailman.fastxs.nl/pipermail/dbmail/> Date: Wed, 29 Jan 2003 10:44:34 -0800 (PST) X-Virus-Scanned: by AMaViS new-20020517 X-Spam-Status: No, hits=0.1 required=5.0 tests=KNOWN_MAILING_LIST,SPAM_PHRASE_00_01,USER_AGENT_PINE version=2.43 X-Spam-Level: X-Virus-Scanned: by AMaViS new-20020517 Status: OBecause users authenticated with an external auth mechanism are not very likely to have an INBOX created for them... and because INBOX, as a hard-coded feature of the IMAP specification, must exist, here's a new db_insert_message function which calls db_createmailbox if needed: Aaron /* * inserts into inbox ! */ u64_t db_insert_message (u64_t useridnr, const char *deliver_to_mailbox, const char *uniqueid) { char timestr[30]; time_t td; struct tm tm; u64_t mailboxid; time(&td); /* get time */ tm = *localtime(&td); /* get components */ strftime(timestr, sizeof(timestr), "%G-%m-%d %H:%M:%S", &tm); /* if there isn't a mailbox specified, default to INBOX */ mailboxid = db_get_mailboxid( useridnr, ( deliver_to_mailbox ? deliver_to_mailbox : "INBOX" ) ); /* check to see if the desired mailbox exists */ if( mailboxid == 0 ) { /* see if we're configured to automatically create mailboxes */ if( 1 ) { trace( TRACE_DEBUG, "db_insert_message(): creating mailbox as it does not exist" ); if( db_createmailbox( ( deliver_to_mailbox ? deliver_to_mailbox : "INBOX" ), useridnr ) != 0 ) { return -1; } else { /* if only db_create_mailbox returned the mailboxid... */ mailboxid = db_get_mailboxid( useridnr, ( deliver_to_mailbox ? deliver_to_mailbox : "INBOX" ) ); } } else { trace( TRACE_ERROR, "db_insert_message(): mailbox does not exist, failing" ); return -1; } } snprintf (query, DEF_QUERYSIZE,"INSERT INTO messages(mailbox_idnr,messagesize,unique_id," "internal_date,recent_flag,status)" " VALUES (%llu, 0, \"%s\", \"%s\", 1, '005')", mailboxid, uniqueid ? uniqueid : "", timestr); if (db_query (query)==-1) { trace(TRACE_STOP,"db_insert_message(): dbquery failed"); } return db_insert_result(""); } _______________________________________________ Dbmail mailing list [email protected] https://mailman.fastxs.nl/mailman/listinfo/dbmail
--- End Message ---
