comment style
authorArt Cancro <ajc@citadel.org>
Fri, 20 May 2022 23:47:35 +0000 (00:47 +0100)
committerArt Cancro <ajc@citadel.org>
Fri, 20 May 2022 23:47:35 +0000 (00:47 +0100)
citadel/modules/ctdlproto/serv_messages.c
libcitadel/lib/stringbuf.c
webcit/messages.c

index f48060b14d492999158ec755990ee0892b161d89..480f849952f377411f56e72002d4e16ad0363bc6 100644 (file)
@@ -355,8 +355,7 @@ void cmd_dlat(char *cmdbuf) {
 
        msgid = extract_long(cmdbuf, 0);
        extract_token(desired_section, cmdbuf, 1, '|', sizeof desired_section);
-       safestrncpy(CC->download_desired_section, desired_section,
-               sizeof CC->download_desired_section);
+       safestrncpy(CC->download_desired_section, desired_section, sizeof CC->download_desired_section);
        CtdlOutputMsg(msgid, MT_SPEW_SECTION, 0, 1, 1, NULL, 0, NULL, NULL, NULL);
 }
 
@@ -423,7 +422,7 @@ void cmd_ent0(char *entargs) {
                sizeof errmsg,
                NULL,
                POST_LOGGED_IN,
-               (!IsEmptyStr(references))               /* is this a reply?  or a top-level post? */
+               (!IsEmptyStr(references))               // is this a reply?  or a top-level post?
        );
        if (err) {
                cprintf("%d %s\n", err, errmsg);
@@ -514,7 +513,7 @@ void cmd_ent0(char *entargs) {
                        return;
                }
 
-               /* Recipient required, but none were specified */
+               // Recipient required, but none were specified
                if ( (valid_to->num_error < 0) && (valid_cc->num_error < 0) && (valid_bcc->num_error < 0) ) {
                        free_recipients(valid_to);
                        free_recipients(valid_cc);
@@ -557,13 +556,13 @@ void cmd_ent0(char *entargs) {
 
        }
 
-       /* Is this a room which has anonymous-only or anonymous-option? */
+       // Is this a room which has anonymous-only or anonymous-option?
        anonymous = MES_NORMAL;
        if (CC->room.QRflags & QR_ANONONLY) {
                anonymous = MES_ANONONLY;
        }
        if (CC->room.QRflags & QR_ANONOPT) {
-               if (anon_flag == 1) {   /* only if the user requested it */
+               if (anon_flag == 1) {   // only if the user requested it
                        anonymous = MES_ANONOPT;
                }
        }
@@ -572,18 +571,16 @@ void cmd_ent0(char *entargs) {
                recp[0] = 0;
        }
 
-       /* Recommend to the client that the use of a message subject is
-        * strongly recommended in this room, if either the SUBJECTREQ flag
-        * is set, or if there is one or more Internet email recipients.
-        */
+       // Recommend to the client that the use of a message subject is
+       // strongly recommended in this room, if either the SUBJECTREQ flag
+       // is set, or if there is one or more Internet email recipients.
+
        if (CC->room.QRflags2 & QR2_SUBJECTREQ) subject_required = 1;
        if ((valid_to)  && (valid_to->num_internet > 0))        subject_required = 1;
        if ((valid_cc)  && (valid_cc->num_internet > 0))        subject_required = 1;
        if ((valid_bcc) && (valid_bcc->num_internet > 0))       subject_required = 1;
 
-       /* If we're only checking the validity of the request, return
-        * success without creating the message.
-        */
+       // If we're only checking the validity of the request, return success without creating the message.
        if (post == 0) {
                cprintf("%d %s|%d\n", CIT_OK,
                        ((valid_to != NULL) ? valid_to->display_recp : ""), 
@@ -594,12 +591,12 @@ void cmd_ent0(char *entargs) {
                return;
        }
 
-       /* We don't need these anymore because we'll do it differently below */
+       // We don't need these anymore because we'll do it differently below
        free_recipients(valid_to);
        free_recipients(valid_cc);
        free_recipients(valid_bcc);
 
-       /* Read in the message from the client. */
+       // Read in the message from the client.
        if (do_confirm) {
                cprintf("%d send message\n", START_CHAT_MODE);
        }
@@ -696,9 +693,7 @@ void cmd_dele(char *args) {
                return;
        }
 
-       /*
-        * Build our message set to be moved/copied
-        */
+       // Build our message set to be moved/copied
        msgs = malloc(num_msgs * sizeof(long));
        for (i=0; i<num_msgs; ++i) {
                extract_token(msgtok, msgset, i, ',', sizeof msgtok);
@@ -757,34 +752,36 @@ void cmd_move(char *args) {
        CtdlGetUser(&CC->user, CC->curr_user);
        CtdlRoomAccess(&qtemp, &CC->user, &ra, NULL);
 
-       /* Check for permission to perform this operation.
-        * Remember: "CC->room" is source, "qtemp" is target.
-        */
+       // Check for permission to perform this operation.
+       // Remember: "CC->room" is source, "qtemp" is target.
        permit = 0;
 
-       /* Admins can move/copy */
+       // Admins can move/copy
        if (CC->user.axlevel >= AxAideU) permit = 1;
 
-       /* Room aides can move/copy */
+       // Room aides can move/copy
        if (CC->user.usernum == CC->room.QRroomaide) permit = 1;
 
-       /* Permit move/copy from personal rooms */
+       // Permit move/copy from personal rooms
        if ((CC->room.QRflags & QR_MAILBOX)
            && (qtemp.QRflags & QR_MAILBOX)) permit = 1;
 
-       /* Permit only copy from public to personal room */
-       if ( (is_copy)
-            && (!(CC->room.QRflags & QR_MAILBOX))
-            && (qtemp.QRflags & QR_MAILBOX)) permit = 1;
+       // Permit only copy from public to personal room
+       if (    (is_copy)
+               && (!(CC->room.QRflags & QR_MAILBOX))
+               && (qtemp.QRflags & QR_MAILBOX)
+       ) {
+               permit = 1;
+       }
 
-       /* Permit message removal from collaborative delete rooms */
+       // Permit message removal from collaborative delete rooms
        if (CC->room.QRflags2 & QR2_COLLABDEL) permit = 1;
 
-       /* Users allowed to post into the target room may move into it too. */
+       // Users allowed to post into the target room may move into it too.
        if ((CC->room.QRflags & QR_MAILBOX) && 
            (qtemp.QRflags & UA_POSTALLOWED))  permit = 1;
 
-       /* User must have access to target room */
+       // User must have access to target room
        if (!(ra & UA_KNOWN))  permit = 0;
 
        if (!permit) {
@@ -793,18 +790,14 @@ void cmd_move(char *args) {
                return;
        }
 
-       /*
-        * Build our message set to be moved/copied
-        */
+       // Build our message set to be moved/copied
        msgs = malloc(num_msgs * sizeof(long));
        for (i=0; i<num_msgs; ++i) {
                extract_token(msgtok, msgset, i, ',', sizeof msgtok);
                msgs[i] = atol(msgtok);
        }
 
-       /*
-        * Do the copy
-        */
+       // Do the copy
        err = CtdlSaveMsgPointersInRoom(targ, msgs, num_msgs, 1, NULL, 0);
        if (err != 0) {
                cprintf("%d Cannot store message(s) in %s: error %d\n",
@@ -813,9 +806,7 @@ void cmd_move(char *args) {
                return;
        }
 
-       /* Now delete the message from the source room,
-        * if this is a 'move' rather than a 'copy' operation.
-        */
+       // Now delete the message from the source room, if this is a 'move' rather than a 'copy' operation.
        if (is_copy == 0) {
                CtdlDeleteMessages(CC->room.QRname, msgs, num_msgs, "");
        }
index 8830ffc60c557308cf9f9fb42c3f3e90cb668bd1..ba7b4c1bac98afae6c92dc81eaff62fe285efec2 100644 (file)
@@ -2950,64 +2950,18 @@ int StrBufDestroyStreamContext(eStreamType type, vStreamT **vStream, const char
        return rc;
 }
 
-int StrBufStreamTranscode(eStreamType type, IOBuffer *Target, IOBuffer *In, const char* pIn, long pInLen, vStreamT *vStream, int LastChunk, const char **Err)
-{
+int StrBufStreamTranscode(eStreamType type, IOBuffer *Target, IOBuffer *In, const char* pIn, long pInLen, vStreamT *vStream, int LastChunk, const char **Err) {
        int rc = 0;
        switch (type)
        {
        case eBase64Encode:
        {
-               /// TODO
-/*
-               // base64_decodestate *state = (base64_decodestate*)vStream;
-               long ExpectLen;
-               
-               if (In != NULL)
-               {
-                       pIn = In->buf;
-                       pInLen = In->BufUsed;
-               }
-               if ((In == NULL) || (vStream == NULL))
-                       return;
-               
-               ExpectLen = (pInLen / 4) * 3;
-
-               if (Target->BufSize - Target->BufUsed < ExpectLen)
-               {
-                       IncreaseBuf(Target, 1, Target->BufUsed + ExpectLen + 1);
-               }
-
-               ////    ExpectLen = base64_encode_block(pIn, pInLen, Target->buf + Target->BufUsed, state);
-               Target->BufUsed += ExpectLen;
-               Target->buf[Target->BufUsed] = '\0';
-*/
+               // ???
        }
        break;
        case eBase64Decode:
        {
-/*
-               base64_decodestate *state = (base64_decodestate *)vStream;
-               long ExpectLen;
-               
-               if (In != NULL)
-               {
-                       pIn = In->buf;
-                       pInLen = In->BufUsed;
-               }
-               if ((pIn == NULL) || (vStream == NULL))
-                       return;
-               
-               ExpectLen = (pInLen / 4) * 3;
-
-               if (Target->BufSize - Target->BufUsed < ExpectLen)
-               {
-                       IncreaseBuf(Target, 1, Target->BufUsed + ExpectLen + 1);
-               }
-
-               ExpectLen = base64_decode_block(pIn, pInLen, Target->buf + Target->BufUsed, state);
-               Target->BufUsed += ExpectLen;
-               Target->buf[Target->BufUsed] = '\0';
-*/
+               // ???
        }
        break;
        case eZLibEncode:
@@ -3036,23 +2990,16 @@ int StrBufStreamTranscode(eStreamType type, IOBuffer *Target, IOBuffer *In, cons
 
                stream->OutBuf.BufUsed += (chunkavail - stream->zstream.avail_out);
 
-               if (Target && 
-                   (LastChunk ||
-                    (stream->OutBuf.BufUsed != org_outbuf_len)
-                           ))
-               {
+               if (Target && (LastChunk || (stream->OutBuf.BufUsed != org_outbuf_len))) {
                        iSwapBuffers(Target->Buf, &stream->OutBuf);
                }
 
-               if (stream->zstream.avail_in == 0)
-               {
+               if (stream->zstream.avail_in == 0) {
                        FlushStrBuf(In->Buf);
                        In->ReadWritePointer = NULL;
                }
-               else
-               {
-                       if (stream->zstream.avail_in < 64)
-                       {
+               else {
+                       if (stream->zstream.avail_in < 64) {
                                memmove(In->Buf->buf,
                                        In->Buf->buf + In->Buf->BufUsed - stream->zstream.avail_in,
                                        stream->zstream.avail_in);
@@ -3060,11 +3007,8 @@ int StrBufStreamTranscode(eStreamType type, IOBuffer *Target, IOBuffer *In, cons
                                In->Buf->BufUsed = stream->zstream.avail_in;
                                In->Buf->buf[In->Buf->BufUsed] = '\0';
                        }
-                       else
-                       {
-                               
-                               In->ReadWritePointer = In->Buf->buf + 
-                                       (In->Buf->BufUsed - stream->zstream.avail_in);
+                       else {
+                               In->ReadWritePointer = In->Buf->buf + (In->Buf->BufUsed - stream->zstream.avail_in);
                        }
                }
                rc = (LastChunk && (err != Z_FINISH));
@@ -3080,14 +3024,11 @@ int StrBufStreamTranscode(eStreamType type, IOBuffer *Target, IOBuffer *In, cons
                int err;
 
                if ((stream->zstream.avail_out != 0) && (stream->zstream.next_in != NULL)) {
-                       if (In->ReadWritePointer != NULL)
-                       {
+                       if (In->ReadWritePointer != NULL) {
                                stream->zstream.next_in = (Bytef *) In->ReadWritePointer;
-                               stream->zstream.avail_in = (uInt) In->Buf->BufUsed - 
-                                       (In->ReadWritePointer - In->Buf->buf);
+                               stream->zstream.avail_in = (uInt) In->Buf->BufUsed - (In->ReadWritePointer - In->Buf->buf);
                        }
-                       else
-                       {
+                       else {
                                stream->zstream.next_in = (Bytef *) In->Buf->buf;
                                stream->zstream.avail_in = (uInt) In->Buf->BufUsed;
                        }
@@ -3114,15 +3055,12 @@ int StrBufStreamTranscode(eStreamType type, IOBuffer *Target, IOBuffer *In, cons
 
                if (Target) iSwapBuffers(Target->Buf, &stream->OutBuf);
 
-               if (stream->zstream.avail_in == 0)
-               {
+               if (stream->zstream.avail_in == 0) {
                        FlushStrBuf(In->Buf);
                        In->ReadWritePointer = NULL;
                }
-               else
-               {
-                       if (stream->zstream.avail_in < 64)
-                       {
+               else {
+                       if (stream->zstream.avail_in < 64) {
                                memmove(In->Buf->buf,
                                        In->Buf->buf + In->Buf->BufUsed - stream->zstream.avail_in,
                                        stream->zstream.avail_in);
@@ -3130,11 +3068,9 @@ int StrBufStreamTranscode(eStreamType type, IOBuffer *Target, IOBuffer *In, cons
                                In->Buf->BufUsed = stream->zstream.avail_in;
                                In->Buf->buf[In->Buf->BufUsed] = '\0';
                        }
-                       else
-                       {
+                       else {
                                
-                               In->ReadWritePointer = In->Buf->buf + 
-                                       (In->Buf->BufUsed - stream->zstream.avail_in);
+                               In->ReadWritePointer = In->Buf->buf + (In->Buf->BufUsed - stream->zstream.avail_in);
                        }
                }
        }
@@ -3152,8 +3088,7 @@ int StrBufStreamTranscode(eStreamType type, IOBuffer *Target, IOBuffer *In, cons
  * @brief decode a buffer from base 64 encoding; destroys original
  * @param Buf Buffor to transform
  */
-int StrBufDecodeHex(StrBuf *Buf)
-{
+int StrBufDecodeHex(StrBuf *Buf) {
        unsigned int ch;
        char *pch, *pche, *pchi;
 
index d713aaea9a91df089caece3368b43ab49cd8b74d..e474a7a06d0b909c1259a737931d9d76f1b5ed56 100644 (file)
@@ -1799,14 +1799,13 @@ void postpart(StrBuf *partnum, StrBuf *filename, int force_download) {
 }
 
 
-/*
- * Generic function to output an arbitrary MIME part from an arbitrary
- * message number on the server.
- *
- * msgnum              message number on the citadel server
- * partnum             MIME part number to be output
- * force_download      Nonzero to force set the Content-Type: header to "application/octet-stream"
- */
+// Generic function to output an arbitrary MIME part from an arbitrary
+// message number on the server.
+//
+// msgnum              message number on the citadel server
+// partnum             MIME part number to be output
+// force_download      Nonzero to force set the Content-Type: header to "application/octet-stream"
+
 void view_or_download_mimepart(int force_download) {
        long msgnum;
        off_t bytes;
@@ -1840,6 +1839,9 @@ void view_or_download_mimepart(int force_download) {
        StrBufCutLeft(Buf, 4);
        bytes = StrBufExtract_long(Buf, 0, '|');
 
+       syslog(LOG_DEBUG, "\033[31mview or download %ld bytes\033[0m", bytes);
+
+
        if (force_download) {
                ContentType = NewStrBufPlain(HKEY("application/octet-stream"));
        }