"Fossies" - the Fresh Open Source Software Archive

Member "citadel/modules/blog/serv_blog.c" (5 Jun 2021, 2285 Bytes) of package /linux/www/citadel.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "serv_blog.c" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 8.24_vs_9.01.

    1 /*
    2  * Support for blog rooms
    3  *
    4  * Copyright (c) 1999-2011 by the citadel.org team
    5  *
    6  * This program is open source software; you can redistribute it and/or
    7  * modify it under the terms of the GNU General Public License as published
    8  * by the Free Software Foundation; either version 3 of the License, or
    9  * (at your option) any later version.
   10  *
   11  * This program is distributed in the hope that it will be useful,
   12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14  * GNU General Public License for more details.
   15  *
   16  * You should have received a copy of the GNU General Public License
   17  * along with this program; if not, write to the Free Software
   18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   19  */
   20 
   21 #include "sysdep.h"
   22 #include <stdlib.h>
   23 #include <unistd.h>
   24 #include <stdio.h>
   25 #include <fcntl.h>
   26 #include <signal.h>
   27 #include <pwd.h>
   28 #include <errno.h>
   29 #include <ctype.h>
   30 #include <sys/types.h>
   31 #include <time.h>
   32 #include <sys/wait.h>
   33 #include <string.h>
   34 #include <limits.h>
   35 #include <libcitadel.h>
   36 #include "citadel.h"
   37 #include "server.h"
   38 #include "citserver.h"
   39 #include "support.h"
   40 #include "config.h"
   41 #include "control.h"
   42 #include "user_ops.h"
   43 #include "database.h"
   44 #include "msgbase.h"
   45 #include "internet_addressing.h"
   46 #include "serv_vcard.h"
   47 #include "citadel_ldap.h"
   48 #include "ctdl_module.h"
   49 
   50 /*
   51  * Pre-save hook for saving a message in a blog room.
   52  * (Do we want to only do this for top-level messages?)
   53  */
   54 int blog_upload_beforesave(struct CtdlMessage *msg, struct recptypes *recp) {
   55 
   56     /* Only run this hook for blog rooms */
   57     if (CC->room.QRdefaultview != VIEW_BLOG) {
   58         return(0);
   59     }
   60 
   61     /* 
   62      * If the message doesn't have an EUID, give it one.
   63      */
   64     if (CM_IsEmpty(msg, eExclusiveID))
   65     {
   66         char uuid[SIZ];
   67         generate_uuid(uuid);
   68         CM_SetField(msg, eExclusiveID, uuid, strlen(uuid));
   69     }
   70 
   71     /*
   72      * We also want to define a maximum length, whether we generated it or not.
   73      */
   74     CM_CutFieldAt(msg, eExclusiveID, BLOG_EUIDBUF_SIZE - 1);
   75     
   76     /* Now allow the save to complete. */
   77     return(0);
   78 }
   79 
   80 
   81 CTDL_MODULE_INIT(blog)
   82 {
   83     if (!threading)
   84     {
   85         CtdlRegisterMessageHook(blog_upload_beforesave, EVT_BEFORESAVE);
   86     }
   87     
   88     /* return our module id for the Log */
   89     return "blog";
   90 }