diff --git a/db/mork/src/morkConfig.h b/db/mork/src/morkConfig.h index e7aad50bcbf5..836c21365f67 100644 --- a/db/mork/src/morkConfig.h +++ b/db/mork/src/morkConfig.h @@ -160,7 +160,6 @@ extern void mork_assertion_signal(const char* inMessage); #define MORK_LIB_IMPL(return) return /*implementation return declaration*/ // { %%%%% begin standard c utility methods %%%%% -/*define MORK_USE_XP_STDLIB 1*/ #if defined(MORK_WIN) || defined(MORK_UNIX) || defined(MORK_MAC) || defined(MORK_BEOS) || defined(MORK_OS2) #define MORK_USE_C_STDLIB 1 @@ -197,18 +196,6 @@ MORK_LIB(mork_size) mork_strlen(const void* inString); #define MORK_STRLEN(string) mork_strlen(string) #endif /*MORK_PROVIDE_STDLIB*/ -#ifdef MORK_USE_XP_STDLIB -#define MORK_MEMCMP(src1,src2,size) XP_MEMCMP(src1,src2,size) -#define MORK_MEMCPY(dest,src,size) XP_MEMCPY(dest,src,size) -#define MORK_MEMMOVE(dest,src,size) XP_MEMMOVE(dest,src,size) -#define MORK_MEMSET(dest,byte,size) XP_MEMSET(dest,byte,size) -#define MORK_STRCPY(dest,src) XP_STRCPY(dest,src) -#define MORK_STRCMP(one,two) XP_STRCMP(one,two) -#define MORK_STRNCMP(one,two,length) XP_STRNCMP(one,two,length) -#define MORK_STRLEN(string) XP_STRLEN(string) -#endif /*MORK_USE_XP_STDLIB*/ - - // } %%%%% end standard c utility methods %%%%% //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789 diff --git a/mailnews/base/search/src/nsMsgSearchNews.cpp b/mailnews/base/search/src/nsMsgSearchNews.cpp index bd2ac3141384..ba901dc5638d 100644 --- a/mailnews/base/search/src/nsMsgSearchNews.cpp +++ b/mailnews/base/search/src/nsMsgSearchNews.cpp @@ -600,96 +600,6 @@ nsresult nsMsgSearchNewsEx::SaveProfile (const char *profileName) return err; } #endif // DOING_PROFILES -#if OLDWAY -// Callback from libnet -SEARCH_API void MSG_AddNewsSearchHit (MWContext *context, const char *resultLine) -{ - MSG_SearchFrame *frame = MSG_SearchFrame::FromContext (context); - nsMsgSearchNewsEx *adapter = (nsMsgSearchNewsEx *) frame->GetRunningAdapter(); - if (adapter) - { - MessageHdrStruct hdr; - XP_BZERO(&hdr, sizeof(hdr)); - - // Here we make the SEARCH result compatible with xover conventions. In SEARCH, the - // group name and a ':' precede the article number, so try to skip over this stuff - // before asking NeoMessageHdr to parse it - char *xoverCompatLine = XP_STRCHR(resultLine, ':'); - if (xoverCompatLine) - xoverCompatLine++; - else - xoverCompatLine = (char*) resultLine; //### casting away const - - if (NeoMessageHdr::ParseLine ((char*) xoverCompatLine, &hdr)) //### casting away const - { - if (hdr.m_flags & kHasRe) // hack around which kind of flag we actually got - { - hdr.m_flags &= !kHasRe; - hdr.m_flags |= MSG_FLAG_HAS_RE; - } - adapter->ReportHit (&hdr, XP_STRTOK((char*) resultLine, ":")); //### casting away const - } - } -} - - -SEARCH_API nsresult MSG_SaveProfileStatus (MSG_Pane *searchPane, PRBool *cmdEnabled) -{ - nsresult err = NS_OK; - - NS_ABORT_IF_FALSE(cmdEnabled, "cmdEnabled cannot be NULL"); - if (cmdEnabled) - { - *cmdEnabled = PR_FALSE; - MSG_SearchFrame *frame = MSG_SearchFrame::FromPane (searchPane); - if (frame) - *cmdEnabled = frame->GetSaveProfileStatus(); - } - else - err = NS_ERROR_NULL_POINTER; - - return err; -} - - -SEARCH_API nsresult MSG_SaveProfile (MSG_Pane *searchPane, const char * profileName) -{ - nsresult err = NS_OK; - -#ifdef _DEBUG - PRBool enabled = PR_FALSE; - MSG_SaveProfileStatus (searchPane, &enabled); - NS_ENSURE_TRUE(enabled, SearchError_ScopeAgreement); -#endif - - if (profileName) - { - MSG_SearchFrame *frame = MSG_SearchFrame::FromPane (searchPane); - NS_ASSERTION(frame, "frame cannot be NULL"); - if (frame) - { - nsMsgSearchNewsEx *adapter = frame->GetProfileAdapter(); - NS_ASSERTION(adapter, "adaptor cannot be NULL"); - if (adapter) - err = adapter->SaveProfile (profileName); - } - } - else - err = NS_ERROR_NULL_POINTER; - - return err; -} - - -SEARCH_API int MSG_AddProfileGroup (MSG_Pane *pane, MSG_NewsHost* host, - const char *groupName) -{ - MSG_FolderInfoNews *group = - pane->GetMaster()->AddProfileNewsgroup(host, groupName); - return group ? 0 : -1; -} - -#endif nsresult nsMsgSearchValidityManager::InitNewsTable() { diff --git a/mailnews/compose/src/nsMsgAppleDecode.cpp b/mailnews/compose/src/nsMsgAppleDecode.cpp deleted file mode 100755 index 464b5ebdba71..000000000000 --- a/mailnews/compose/src/nsMsgAppleDecode.cpp +++ /dev/null @@ -1,1783 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org Code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * apple_double_decode.c - * - * --------------------- - * - * Codes for decoding Apple Single/Double object parts. - * - * 05aug95 mym Created. - * 25sep95 mym Add support to write to binhex encoding on non-mac system. - */ - -#include "nscore.h" -#include "msgCore.h" - -#include "nsMsgAppleDouble.h" -#include "nsMsgAppleCodes.h" -#include "nsMsgBinHex.h" -#ifdef XP_MAC -#include -#endif - -extern int MK_UNABLE_TO_OPEN_TMP_FILE; -extern int MK_MIME_ERROR_WRITING_FILE; - -/* -** Static functions. -*/ -PRIVATE int from_decoder(appledouble_decode_object* p_ap_decode_obj, - char *buff, - int buff_size, - PRInt32 *in_count); -PRIVATE int from_64(appledouble_decode_object* p_ap_decode_obj, - char *buff, - int size, - PRInt32 *real_size); -PRIVATE int from_qp(appledouble_decode_object* p_ap_decode_obj, - char *buff, - int size, - PRInt32 *real_size); -PRIVATE int from_uu(appledouble_decode_object* p_ap_decode_obj, - char *buff, - int size, - PRInt32 *real_size); -PRIVATE int from_none(appledouble_decode_object* p_ap_decode_obj, - char *buff, - int size, - PRInt32 *real_size); - -PRIVATE int decoder_seek(appledouble_decode_object* p_ap_decode_obj, - int seek_pos, - int start_pos); - -/* -** fetch_a_line -** ------------- -** -** get a line from the in stream.. -*/ -int fetch_a_line( - appledouble_decode_object* p_ap_decode_obj, - char *buff) -{ - int i, left; - char *p, c = 0; - - if (p_ap_decode_obj->s_leftover == 0 && - p_ap_decode_obj->s_inbuff <= p_ap_decode_obj->pos_inbuff) - { - *buff = '\0'; - return errEOB; - } - - if (p_ap_decode_obj->s_leftover) - { - for (p = p_ap_decode_obj->b_leftover, i = p_ap_decode_obj->s_leftover; i>0; i--) - *buff++ = *p++; - - p_ap_decode_obj->s_leftover = 0; - } - - p = p_ap_decode_obj->inbuff + p_ap_decode_obj->pos_inbuff; - left = p_ap_decode_obj->s_inbuff - p_ap_decode_obj->pos_inbuff; - - for (i = 0; i < left; ) - { - c = *p++; i++; - - if (c == CR && *p == LF) - { - p++; i++; /* make sure skip both LF & CR */ - } - - if (c == LF || c == CR) - break; - - *buff++ = c; - } - p_ap_decode_obj->pos_inbuff += i; - - if (i == left && c != LF && c != CR) - { - /* - ** we meet the buff end before we can terminate the string, - ** save the string to the left_over buff. - */ - p_ap_decode_obj->s_leftover = i; - - for (p = p_ap_decode_obj->b_leftover; i>0; i--) - *p++ = *(buff-i); - - return errEOB; - } - *buff = '\0'; - return NOERR; -} - -void parse_param( - char *p, - char **param, /* the param */ - char **define, /* the defination. */ - char **np) /* next position. */ -{ - while (*p == ' ' || *p == '\"' || *p == ';') p++; - *param = p; - - while (*p != ' ' && *p != '=' ) p++; - if (*p == ' ') - *define = p+1; - else - *define = p+2; - - while (*p && *p != ';') p++; - - if (*p == ';') - *np = p + 1; - else - *np = p; -} - -int ap_seek_part_start( - appledouble_decode_object* p_ap_decode_obj) -{ - int status; - char newline[256]; - - while (1) - { - status = fetch_a_line(p_ap_decode_obj, newline); - if(status != NOERR) - break; - - if (newline[0] == '\0' && p_ap_decode_obj->boundary0 != NULL) - return errDone; - - if (!PL_strncasecmp(newline, "--", 2)) - { - /* we meet the start separator, copy it and it will be our boundary */ - p_ap_decode_obj->boundary0 = nsCRT::strdup(newline+2); - return errDone; - } - } - return status; -} - -int ParseFileHeader( - appledouble_decode_object *p_ap_decode_obj) -{ - int status; - int i; - char newline[256], *p; - char *param, *define; - - while (1) - { - status = fetch_a_line(p_ap_decode_obj, newline); - if (newline[0] == '\0') - break; /* we get the end of a defination section. */ - - p = newline; - while (1) - { - parse_param(p, ¶m, &define, &p); - /* - ** we only care about these params. - */ - if (!PL_strncasecmp(param, "Content-Type:", 13)) - { - if (!PL_strncasecmp(define, MULTIPART_APPLEDOUBLE, - nsCRT::strlen(MULTIPART_APPLEDOUBLE)) || - !PL_strncasecmp(define, MULTIPART_HEADER_SET, - nsCRT::strlen(MULTIPART_HEADER_SET))) - p_ap_decode_obj->messagetype = kAppleDouble; - else - p_ap_decode_obj->messagetype = kGeneralMine; - } - else if (!PL_strncasecmp(param, "boundary=", 9)) - { - for (i = 0; *define && *define != '\"'; ) - p_ap_decode_obj->boundary0[i++] = *define++; - - p_ap_decode_obj->boundary0[i] = '\0'; - } - else if (!PL_strncasecmp(param, "Content-Disposition:", 20)) - { - if (!PL_strncasecmp(define, "inline", 5)) - p_ap_decode_obj->deposition = kInline; - else - p_ap_decode_obj->deposition = kDontCare; - } - else if (!PL_strncasecmp(param, "filename=", 9)) - { - for (i = 0, p=define; *p && *p != '\"'; ) - p_ap_decode_obj->fname[i++] = *p++; - - p_ap_decode_obj->fname[i] = '\0'; - } - - if (*p == '\0') - break; - } - } - - return NOERR; -} - -int ap_seek_to_boundary( - appledouble_decode_object *p_ap_decode_obj, - PRBool firstime) -{ - int status = NOERR; - char buff[256]; - - while (status == NOERR) - { - status = fetch_a_line(p_ap_decode_obj, buff); - if (status != NOERR) - break; - - if ((!PL_strncasecmp(buff, "--", 2) && - !PL_strncasecmp( buff+2, - p_ap_decode_obj->boundary0, - nsCRT::strlen(p_ap_decode_obj->boundary0))) - ||!PL_strncasecmp( buff, - p_ap_decode_obj->boundary0, - nsCRT::strlen(p_ap_decode_obj->boundary0))) - { - TRACEMSG(("Found boundary: %s", p_ap_decode_obj->boundary0)); - status = errDone; - break; - } - } - - if (firstime && status == errEOB) - status = NOERR; /* so we can do it again. */ - - return status; -} - -int ap_parse_header( - appledouble_decode_object *p_ap_decode_obj, - PRBool firstime) -{ - int status, i; - char newline[256], *p; - char *param, *define; - - if (firstime) - { - /* do the clean ups. */ - p_ap_decode_obj->encoding = kEncodeNone; - p_ap_decode_obj->which_part = kFinishing; - } - - while (1) - { - status = fetch_a_line(p_ap_decode_obj, newline); - if (status != NOERR) - return status; /* a possible end of buff happened. */ - - if (newline[0] == '\0') - break; /* we get the end of a defination section. */ - - p = newline; - while (1) - { - parse_param(p, ¶m, &define, &p); - /* - ** we only care about these params. - */ - if (!PL_strncasecmp(param, "Content-Type:", 13)) - { - if (!PL_strncasecmp(define, "application/applefile", 21)) - p_ap_decode_obj->which_part = kHeaderPortion; - else - { - p_ap_decode_obj->which_part = kDataPortion; - if (!PL_strncasecmp(define, "text/plain", 10)) - p_ap_decode_obj->is_binary = FALSE; - else - p_ap_decode_obj->is_binary = TRUE; - } - - /* Broken QuickMail messages */ - if (!PL_strncasecmp(define, "x-uuencode-apple-single", 23)) - p_ap_decode_obj->encoding = kEncodeUU; - } - else if (!PL_strncasecmp(param, "Content-Transfer-Encoding:",26)) - { - if (!PL_strncasecmp(define, "base64", 6)) - p_ap_decode_obj->encoding = kEncodeBase64; - else if (!PL_strncasecmp(define, "quoted-printable", 16)) - p_ap_decode_obj->encoding = kEncodeQP; - else - p_ap_decode_obj->encoding = kEncodeNone; - } - else if (!PL_strncasecmp(param, "Content-Disposition:", 20)) - { - if (!PL_strncasecmp(define, "inline", 5)) - p_ap_decode_obj->deposition = kInline; - else - p_ap_decode_obj->deposition = kDontCare; - } - else if (!PL_strncasecmp(param, "filename=", 9)) - { - if (p_ap_decode_obj->fname[0] == '\0') - { - for (i = 0; *define && *define != '\"'; ) - p_ap_decode_obj->fname[i++] = *define++; - - p_ap_decode_obj->fname[i] = '\0'; - } - } - - if (*p == '\0') - break; - } - } - return errDone; -} - - -/* -** decode the head portion. -*/ - - -int ap_decode_file_infor(appledouble_decode_object *p_ap_decode_obj) -{ - ap_header head; - ap_entry entries[NUM_ENTRIES + 1]; - int i, j; - int st_pt; - PRInt32 in_count; - int status; - char name[256]; - PRBool positionedAtRFork = FALSE; - - st_pt = p_ap_decode_obj->pos_inbuff; - - /* - ** Read & verify header - */ - status = from_decoder( - p_ap_decode_obj, - (char *) &head, - 26, /* sizeof (head), */ - &in_count); - if (status != NOERR) - return status; - - if (p_ap_decode_obj->is_apple_single) - { - if (ntohl(head.magic) != APPLESINGLE_MAGIC) - return errVersion; - } - else - { - if(ntohl(head.magic) != APPLEDOUBLE_MAGIC) - return errVersion; - } - - if (ntohl(head.version) != VERSION) - { - return errVersion; - } - - /* read entries */ - head.entries = ntohs(head.entries); - for (i = j = 0; i < head.entries; ++i) - { - status = from_decoder( - p_ap_decode_obj, - (char *) (entries + j), - sizeof (ap_entry), - &in_count); - if (status != NOERR) - return errDecoding; - - /* - ** correct the byte order now. - */ - entries[j].id = ntohl(entries[j].id); - entries[j].offset = ntohl(entries[j].offset); - entries[j].length = ntohl(entries[j].length); - /* - ** only care about these entries... - */ - if (j < NUM_ENTRIES) - switch (entries[j].id) - { - case ENT_NAME: - case ENT_FINFO: - case ENT_DATES: - case ENT_COMMENT: - case ENT_RFORK: - case ENT_DFORK: - ++j; - break; - } - } - - in_count = nsCRT::strlen(p_ap_decode_obj->fname); - - /* if the user has not provided the output file name, read it - * from the ENT_NAME entry - */ - - if (in_count == 0) - { - /* read name */ - for (i = 0; i < j && entries[i].id != ENT_NAME; ++i) - ; - if (i == j) - return errDecoding; - - status = decoder_seek( - p_ap_decode_obj, - entries[i].offset, - st_pt); - if (status != NOERR) - return status; - - if (entries[i].length > 63) - entries[i].length = 63; - - status = from_decoder( - p_ap_decode_obj, - p_ap_decode_obj->fname, - entries[i].length, - &in_count); - if (status != NOERR) - return status; - - p_ap_decode_obj->fname[in_count] = '\0'; - } - - /* P_String version of the file name. */ - PL_strcpy((char *)name+1, p_ap_decode_obj->fname); - name[0] = (char) in_count; - - if (p_ap_decode_obj->write_as_binhex) - { - /* - ** fill out the simple the binhex head. - */ - binhex_header head; - myFInfo myFInfo; - - status = (*p_ap_decode_obj->binhex_stream->put_block) - (p_ap_decode_obj->binhex_stream->data_object, - name, - name[0] + 2); - if (status != NOERR) - return status; - - /* get finder info */ - for (i = 0; i < j && entries[i].id != ENT_FINFO; ++i) - ; - if (i < j) - { - status = decoder_seek(p_ap_decode_obj, - entries[i].offset, - st_pt); - if (status != NOERR) - return status; - - status = from_decoder(p_ap_decode_obj, - (char *) &myFInfo, - sizeof (myFInfo), - &in_count); - if (status != NOERR) - return status; - } - - head.type = myFInfo.fdType; - head.creator = myFInfo.fdCreator; - head.flags = myFInfo.fdFlags; - - for (i = 0; i < j && entries[i].id != ENT_DFORK; ++i) - ; - if (i < j && entries[i].length != 0) - { - head.dlen = entries[i].length; /* set the data fork length */ - } - else - { - head.dlen = 0; - } - - for (i = 0; i < j && entries[i].id != ENT_RFORK; ++i) - ; - if (i < j && entries[i].length != 0) - { - head.rlen = entries[i].length; /* set the resource fork length */ - } - else - { - head.rlen = 0; - } - - /* - ** and the dlen, rlen is in the host byte order, correct it if needed ... - */ - head.dlen = htonl(head.dlen); - head.rlen = htonl(head.rlen); - /* - ** then encode them in binhex. - */ - status = (*p_ap_decode_obj->binhex_stream->put_block) - (p_ap_decode_obj->binhex_stream->data_object, - (char*)&head, - sizeof(binhex_header)); - if (status != NOERR) - return status; - - /* - ** after we have done with the header, end the binhex header part. - */ - status = (*p_ap_decode_obj->binhex_stream->put_block) - (p_ap_decode_obj->binhex_stream->data_object, - NULL, - 0); - } - else - { - -#ifdef XP_MAC - - ap_dates dates; - HFileInfo *fpb; - CInfoPBRec cipbr; - IOParam vinfo; - GetVolParmsInfoBuffer vp; - DTPBRec dtp; - char comment[256]; - - unsigned char filename[256]; /* this is a pascal string - should be unsigned char. */ - StandardFileReply reply; - - /* convert char* p_ap_decode_obj->fname to a pascal string */ - PL_strcpy((char*)filename + 1, p_ap_decode_obj->fname); - filename[0] = nsCRT::strlen(p_ap_decode_obj->fname); - - if( !p_ap_decode_obj->mSpec ) - { - StandardPutFile("\pSave decoded file as:", - (const unsigned char*)filename, - &reply); - - if (!reply.sfGood) - { - return errUsrCancel; - } - } - else - { - reply.sfFile.vRefNum = p_ap_decode_obj->mSpec->vRefNum; - reply.sfFile.parID = p_ap_decode_obj->mSpec->parID; - memcpy(&reply.sfFile.name, p_ap_decode_obj->mSpec->name , 63 ); - } - - memcpy(p_ap_decode_obj->fname, - reply.sfFile.name+1, - *(reply.sfFile.name)+1); - p_ap_decode_obj->fname[*(reply.sfFile.name)] = '\0'; - - p_ap_decode_obj->vRefNum = reply.sfFile.vRefNum; - p_ap_decode_obj->dirId = reply.sfFile.parID; - - /* create & get info for file */ - HDelete(reply.sfFile.vRefNum, - reply.sfFile.parID, - reply.sfFile.name); - -#define DONT_CARE_TYPE 0x3f3f3f3f - - if (HCreate(reply.sfFile.vRefNum, - reply.sfFile.parID, - reply.sfFile.name, - DONT_CARE_TYPE, - DONT_CARE_TYPE) != NOERR) - { - return errFileOpen; - } - - fpb = (HFileInfo *) &cipbr; - fpb->ioVRefNum = reply.sfFile.vRefNum; - fpb->ioDirID = reply.sfFile.parID; - fpb->ioNamePtr = reply.sfFile.name; - fpb->ioFDirIndex = 0; - PBGetCatInfoSync(&cipbr); - - /* get finder info */ - for (i = 0; i < j && entries[i].id != ENT_FINFO; ++i) - ; - if (i < j) - { - status = decoder_seek(p_ap_decode_obj, - entries[i].offset, - st_pt); - if (status != NOERR) - return status; - - status = from_decoder(p_ap_decode_obj, - (char *) &fpb->ioFlFndrInfo, - sizeof (FInfo), - &in_count); - if (status != NOERR) - return status; - - status = from_decoder(p_ap_decode_obj, - (char *) &fpb->ioFlXFndrInfo, - sizeof (FXInfo), - &in_count); - - if (status != NOERR && status != errEOP ) - return status; - - fpb->ioFlFndrInfo.fdFlags &= 0xfc00; /* clear flags maintained by finder */ - } - - /* - ** get file date info - */ - for (i = 0; i < j && entries[i].id != ENT_DATES; ++i) - ; - if (i < j) - { - status = decoder_seek(p_ap_decode_obj, - entries[i].offset, - st_pt); - if (status != NOERR && status != errEOP ) - return status; - - status = from_decoder(p_ap_decode_obj, - (char *) &dates, - sizeof (dates), - &in_count); - if (status != NOERR) - return status; - - fpb->ioFlCrDat = dates.create - CONVERT_TIME; - fpb->ioFlMdDat = dates.modify - CONVERT_TIME; - fpb->ioFlBkDat = dates.backup - CONVERT_TIME; - } - - /* - ** update info - */ - fpb->ioDirID = fpb->ioFlParID; - PBSetCatInfoSync(&cipbr); - - /* - ** get comment & save it - */ - for (i = 0; i < j && entries[i].id != ENT_COMMENT; ++i) - ; - if (i < j && entries[i].length != 0) - { - memset((void *) &vinfo, '\0', sizeof (vinfo)); - vinfo.ioVRefNum = fpb->ioVRefNum; - vinfo.ioBuffer = (Ptr) &vp; - vinfo.ioReqCount = sizeof (vp); - if (PBHGetVolParmsSync((HParmBlkPtr) &vinfo) == NOERR && - ((vp.vMAttrib >> bHasDesktopMgr) & 1)) - { - memset((void *) &dtp, '\0', sizeof (dtp)); - dtp.ioVRefNum = fpb->ioVRefNum; - if (PBDTGetPath(&dtp) == NOERR) - { - if (entries[i].length > 255) - entries[i].length = 255; - - status = decoder_seek(p_ap_decode_obj, - entries[i].offset, - st_pt); - if (status != NOERR) - return status; - - status = from_decoder(p_ap_decode_obj, - comment, - entries[i].length, - &in_count); - if (status != NOERR) - return status; - - dtp.ioDTBuffer = (Ptr) comment; - dtp.ioNamePtr = fpb->ioNamePtr; - dtp.ioDirID = fpb->ioDirID; - dtp.ioDTReqCount = entries[i].length; - if (PBDTSetCommentSync(&dtp) == NOERR) - { - PBDTFlushSync(&dtp); - } - } - } - } - -#else - /* - ** in non-mac system, creating a data fork file will be it. - */ -#endif - } - - /* - ** Get the size of the resource fork, and (maybe) position to the beginning of it. - */ - for (i = 0; i < j && entries[i].id != ENT_RFORK; ++i) - ; - if (i < j && entries[i].length != 0) - { -#ifdef XP_MAC - /* Seek to the start of the resource fork only if we're on a Mac */ - status = decoder_seek(p_ap_decode_obj, - entries[i].offset, - st_pt); - positionedAtRFork = TRUE; -#endif - p_ap_decode_obj->rksize = entries[i].length; - } - else - p_ap_decode_obj->rksize = 0; - - /* - ** Get the size of the data fork, and (maybe) position to the beginning of it. - */ - for (i = 0; i < j && entries[i].id != ENT_DFORK; ++i) - ; - if (i < j && entries[i].length != 0) - { - if (p_ap_decode_obj->is_apple_single && !positionedAtRFork) - status = decoder_seek(p_ap_decode_obj, - entries[i].offset, - st_pt); - p_ap_decode_obj->dksize = entries[i].length; - } - else - p_ap_decode_obj->dksize = 0; - - /* - ** Prepare a tempfile to hold the resource fork decoded by the decoder, - ** because in binhex, resource fork appears after the data fork!!! - */ - if (p_ap_decode_obj->write_as_binhex) - { - if (p_ap_decode_obj->rksize != 0) - { - /* we need a temp file to hold all the resource data, because the */ - p_ap_decode_obj->tmpFileSpec = nsMsgCreateTempFileSpec("apmail"); - if (!p_ap_decode_obj->tmpFileSpec) - return errFileOpen; - - p_ap_decode_obj->tmpFileStream = new nsIOFileStream(*(p_ap_decode_obj->tmpFileSpec)); - if ( (!p_ap_decode_obj->tmpFileStream) || - (p_ap_decode_obj->tmpFileStream->is_open()) ) - { - delete p_ap_decode_obj->tmpFileSpec; - return errFileOpen; - } - } - } - - return NOERR; -} - -/* -** ap_decode_process_header -** -** -*/ -int ap_decode_process_header( - appledouble_decode_object* p_ap_decode_obj, - PRBool firstime) -{ - PRInt32 in_count; - int status = NOERR; - char wr_buff[1024]; - - if (firstime) - { - status = ap_decode_file_infor(p_ap_decode_obj); - if (status != NOERR) - return status; - - if (p_ap_decode_obj->rksize > 0) - { -#ifdef XP_MAC - if(!p_ap_decode_obj->write_as_binhex) - { - Str63 fname; - short refNum; - - fname[0] = nsCRT::strlen(p_ap_decode_obj->fname); - PL_strcpy((char*)fname+1, p_ap_decode_obj->fname); - - if (HOpenRF(p_ap_decode_obj->vRefNum, - p_ap_decode_obj->dirId, - fname, - fsWrPerm, - &refNum) != NOERR) - { - return (errFileOpen); - } - p_ap_decode_obj->fileId = refNum; - } -#endif - } - else - { - status = errDone; - } - } - - /* - ** Time to continue decoding all the resource data. - */ - while (status == NOERR && p_ap_decode_obj->rksize > 0) - { - in_count = PR_MIN(1024, p_ap_decode_obj->rksize); - - status = from_decoder(p_ap_decode_obj, - wr_buff, - in_count, - &in_count); - - if (p_ap_decode_obj->write_as_binhex) - { - /* - ** Write to the temp file first, because the resource fork appears after - ** the data fork in the binhex encoding. - */ - if (p_ap_decode_obj->tmpFileStream->write(wr_buff, in_count) != in_count) - { - status = errFileWrite; - break; - } - - p_ap_decode_obj->data_size += in_count; - } - else - { -#ifdef XP_MAC - long howMuch = in_count; - - if (FSWrite(p_ap_decode_obj->fileId, &howMuch, wr_buff) != NOERR) - { - status = errFileWrite; - break; - } -#else - /* ====== Write nothing in a non mac file system ============ */ -#endif - } - - p_ap_decode_obj->rksize -= in_count; - } - - if (p_ap_decode_obj->rksize <= 0 || status == errEOP) - { - if (p_ap_decode_obj->write_as_binhex) - { - /* - ** No more resource data, but we are not done - ** with tempfile yet, just seek back to the start point, - ** -- ready for a readback later - */ - if (p_ap_decode_obj->tmpFileStream) - p_ap_decode_obj->tmpFileStream->seek(PR_SEEK_SET, 0); - } - -#ifdef XP_MAC - else if (p_ap_decode_obj->fileId) /* close the resource fork of the macfile */ - { - FSClose(p_ap_decode_obj->fileId); - p_ap_decode_obj->fileId = 0; - } -#endif - if (!p_ap_decode_obj->is_apple_single) - { - p_ap_decode_obj->left = 0; - p_ap_decode_obj->state64 = 0; - } - status = errDone; - } - return status; -} - -int ap_decode_process_data( - appledouble_decode_object* p_ap_decode_obj, - PRBool firstime) -{ - char wr_buff[1024]; - PRInt32 in_count; - int status = NOERR; - int retval = NOERR; - - if (firstime) - { - if (!p_ap_decode_obj->write_as_binhex) - { -#ifdef XP_MAC - char *filename; - FSSpec fspec; - - fspec.vRefNum = p_ap_decode_obj->vRefNum; - fspec.parID = p_ap_decode_obj->dirId; - fspec.name[0] = nsCRT::strlen(p_ap_decode_obj->fname); - PL_strcpy((char*)fspec.name+1, p_ap_decode_obj->fname); - - nsFileSpec tFileSpec(fspec, PR_TRUE); - - if (p_ap_decode_obj->is_binary) - p_ap_decode_obj->fileStream = new nsIOFileStream(tFileSpec, (PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE)); - else - p_ap_decode_obj->fileStream = new nsIOFileStream(tFileSpec, (PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE)); - // RICHIE XP_FileOpen(filename+7, xpURL, XP_FILE_TRUNCATE); - - PR_FREEIF(filename); -#else - nsFileSpec tFileSpec(p_ap_decode_obj->fname); - if (p_ap_decode_obj->is_binary) - p_ap_decode_obj->fileStream = new nsIOFileStream(tFileSpec, (PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE)); - // RICHIE XP_FileOpen(p_ap_decode_obj->fname, xpURL, XP_FILE_TRUNCATE_BIN); - else - p_ap_decode_obj->fileStream = new nsIOFileStream(tFileSpec, (PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE)); - // RICHIE XP_FileOpen(p_ap_decode_obj->fname, xpURL, XP_FILE_TRUNCATE); -#endif - } - else - { - ; /* == don't need do anything to binhex stream, it is ready already == */ - } - } - - if (p_ap_decode_obj->is_apple_single && - p_ap_decode_obj->dksize == 0) - { - /* if no data in apple single, we already done then. */ - status = errDone; - } - - while (status == NOERR && retval == NOERR) - { - retval = from_decoder(p_ap_decode_obj, - wr_buff, - 1024, - &in_count); - - if (p_ap_decode_obj->is_apple_single) /* we know the data fork size in */ - p_ap_decode_obj->dksize -= in_count; /* apple single, use it to decide the end */ - - if (p_ap_decode_obj->write_as_binhex) - status = (*p_ap_decode_obj->binhex_stream->put_block) - (p_ap_decode_obj->binhex_stream->data_object, - wr_buff, - in_count); - else - status = p_ap_decode_obj->fileStream(wr_buff, in_count) == in_count ? NOERR : errFileWrite; - - if (retval == errEOP || /* for apple double, we meet the boundary */ - ( p_ap_decode_obj->is_apple_single && - p_ap_decode_obj->dksize <= 0)) /* for apple single, we know it is ending */ - { - status = errDone; - break; - } - } - - if (status == errDone) - { - if (p_ap_decode_obj->write_as_binhex) - { - /* CALL with data == NULL && size == 0 to end a part object in binhex encoding */ - status = (*p_ap_decode_obj->binhex_stream->put_block) - (p_ap_decode_obj->binhex_stream->data_object, - NULL, - 0); - if (status != NOERR) - return status; - } - else if (p_ap_decode_obj->fileStream) - { - p_ap_decode_obj->fileStream->close(); - delete p_ap_decode_obj->fileStream; - } - - status = errDone; - } - return status; -} - -/* -** Fill the data from the decoder stream. -*/ -PRIVATE int from_decoder( - appledouble_decode_object* p_ap_decode_obj, - char *buff, - int buff_size, - PRInt32 *in_count) -{ - int status; - - switch (p_ap_decode_obj->encoding) - { - case kEncodeQP: - status = from_qp(p_ap_decode_obj, - buff, - buff_size, - in_count); - break; - case kEncodeBase64: - status = from_64(p_ap_decode_obj, - buff, - buff_size, - in_count); - break; - case kEncodeUU: - status = from_uu(p_ap_decode_obj, - buff, - buff_size, - in_count); - break; - case kEncodeNone: - default: - status = from_none(p_ap_decode_obj, - buff, - buff_size, - in_count); - break; - } - return status; -} - -/* -** decoder_seek -** -** simulate a stream seeking on the encoded stream. -*/ -PRIVATE int decoder_seek( - appledouble_decode_object* p_ap_decode_obj, - int seek_pos, - int start_pos) -{ - char tmp[1024]; - int status = NOERR; - PRInt32 in_count; - - /* - ** force a reset on the in buffer. - */ - p_ap_decode_obj->state64 = 0; - p_ap_decode_obj->left = 0; - p_ap_decode_obj->pos_inbuff = start_pos; - p_ap_decode_obj->uu_starts_line = TRUE; - p_ap_decode_obj->uu_bytes_written = p_ap_decode_obj->uu_line_bytes = 0; - p_ap_decode_obj->uu_state = kWaitingForBegin; - - while (seek_pos > 0) - { - status = from_decoder(p_ap_decode_obj, - tmp, - PR_MIN(1024, seek_pos), - &in_count); - if (status != NOERR) - break; - - seek_pos -= in_count; - } - return status; -} - -#define XX 127 -/* - * Table for decoding base64 - */ -static char index_64[256] = { - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,62, XX,XX,XX,63, - 52,53,54,55, 56,57,58,59, 60,61,XX,XX, XX,XX,XX,XX, - XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14, - 15,16,17,18, 19,20,21,22, 23,24,25,XX, XX,XX,XX,XX, - XX,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40, - 41,42,43,44, 45,46,47,48, 49,50,51,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, -}; - -#define CHAR64(c) (index_64[(unsigned char)(c)]) -#define EndOfBuff(p) ((p)->pos_inbuff >= (p)->s_inbuff) - -PRIVATE int fetch_next_char_64( - appledouble_decode_object* p_ap_decode_obj) -{ - char c; - - c = p_ap_decode_obj->inbuff[p_ap_decode_obj->pos_inbuff++]; - if (c == '-') - --p_ap_decode_obj->pos_inbuff; /* put back */ - - while (c == LF || c == CR) /* skip the CR character. */ - { - if (EndOfBuff(p_ap_decode_obj)) - { - c = 0; - break; - } - - c = p_ap_decode_obj->inbuff[p_ap_decode_obj->pos_inbuff++]; - if (c == '-') - { - --p_ap_decode_obj->pos_inbuff; /* put back */ - } - } - return (int)c; -} - - -PRIVATE int from_64( - appledouble_decode_object* p_ap_decode_obj, - char *buff, - int size, - PRInt32 *real_size) -{ - int i, j, buf[4]; - int c1, c2, c3, c4; - - (*real_size) = 0; - - /* - ** decode 4 by 4s characters - */ - for (i = p_ap_decode_obj->state64; i<4; i++) - { - if (EndOfBuff(p_ap_decode_obj)) - { - p_ap_decode_obj->state64 = i; - break; - } - if ((p_ap_decode_obj->c[i] = fetch_next_char_64(p_ap_decode_obj)) == 0) - break; - } - - if (i != 4) - { - /* - ** not enough data to fill the decode buff. - */ - return errEOB; /* end of buff */ - } - - while (size > 0) - { - c1 = p_ap_decode_obj->c[0]; - c2 = p_ap_decode_obj->c[1]; - c3 = p_ap_decode_obj->c[2]; - c4 = p_ap_decode_obj->c[3]; - - if (c1 == '-' || c2 == '-' || c3 == '-' || c4 == '-') - { - return errEOP; /* we meet the part boundary. */ - } - - if (c1 == '=' || c2 == '=') - { - return errDecoding; - } - - c1 = CHAR64(c1); - c2 = CHAR64(c2); - buf[0] = ((c1<<2) | ((c2&0x30)>>4)); - - if (c3 != '=') - { - c3 = CHAR64(c3); - buf[1] = (((c2&0x0F) << 4) | ((c3&0x3C) >> 2)); - - if (c4 != '=') - { - c4 = CHAR64(c4); - buf[2] = (((c3&0x03) << 6) | c4); - } - else - { - if (p_ap_decode_obj->left == 0) - { - *buff++ = buf[0]; (*real_size)++; - } - *buff++ = buf[1]; (*real_size)++; - /* return errEOP; */ /* bug 87784 */ - return EndOfBuff(p_ap_decode_obj) ? errEOP : NOERR; - } - } - else - { - *buff++ = *buf; - (*real_size)++; - /* return errEOP; *bug 87784*/ /* we meet the the end */ - return EndOfBuff(p_ap_decode_obj) ? errEOP : NOERR; - } - /* - ** copy the content - */ - for (j = p_ap_decode_obj->left; j<3; ) - { - *buff++ = buf[j++]; - (*real_size)++; - if (--size <= 0) - break; - } - p_ap_decode_obj->left = j % 3; - - if (size <=0) - { - if (j == 3) - p_ap_decode_obj->state64 = 0; /* See if we used up all data, */ - /* ifnot, keep the data, */ - /* we need it for next time. */ - else - p_ap_decode_obj->state64 = 4; - - break; - } - - /* - ** fetch the next 4 character group. - */ - for (i = 0; i < 4; i++) - { - if (EndOfBuff(p_ap_decode_obj)) - break; - - if ((p_ap_decode_obj->c[i] = fetch_next_char_64(p_ap_decode_obj)) == 0) - break; - } - - p_ap_decode_obj->state64 = i % 4; - - if (i != 4) - break; /* some kind of end of buff met.*/ - } - - /* - ** decide the size and status. - */ - return EndOfBuff(p_ap_decode_obj) ? errEOB : NOERR; -} - -/* - * Table for decoding hexadecimal in quoted-printable - */ -static char index_hex[256] = { - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,XX,XX, XX,XX,XX,XX, - XX,10,11,12, 13,14,15,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,10,11,12, 13,14,15,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, - XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, -}; - -#define HEXCHAR(c) (index_hex[(unsigned char)(c)]) -#define NEXT_CHAR(p) ((int)((p)->inbuff[(p)->pos_inbuff++])) -#define CURRENT_CHAR(p) ((int)((p)->inbuff[(p)->pos_inbuff])) -/* -** quoted printable decode, as defined in RFC 1521, page18 - 20 -*/ -PRIVATE int from_qp( - appledouble_decode_object* p_ap_decode_obj, - char *buff, - int size, - PRInt32 *real_size) -{ - char c; - int c1, c2; - - *real_size = 0; - - if (p_ap_decode_obj->c[0] == '=') - { - /* - ** continue with the last time's left over. - */ - p_ap_decode_obj->c[0] = 0; - - c1 = p_ap_decode_obj->c[1]; p_ap_decode_obj->c[1] = 0; - - if ( c1 == 0) - { - c1 = NEXT_CHAR(p_ap_decode_obj); - c2 = NEXT_CHAR(p_ap_decode_obj); - } - else - { - c2 = NEXT_CHAR(p_ap_decode_obj); - } - c = HEXCHAR(c1) << 4 | HEXCHAR(c2); - - size --; - *buff ++ = c; - (*real_size) ++; - } - - /* - ** Then start to work on the new data - */ - while (size > 0) - { - if (EndOfBuff(p_ap_decode_obj)) - break; - - c1 = NEXT_CHAR(p_ap_decode_obj); - - if (c1 == '=') - { - if (EndOfBuff(p_ap_decode_obj)) - { - p_ap_decode_obj->c[0] = c1; - break; - } - - c1 = NEXT_CHAR(p_ap_decode_obj); - if (c1 != '\n') - { - /* - ** Rule #2 - */ - c1 = HEXCHAR(c1); - if (EndOfBuff(p_ap_decode_obj)) - { - p_ap_decode_obj->c[0] = '='; - p_ap_decode_obj->c[1] = c1; - break; - } - - c2 = NEXT_CHAR(p_ap_decode_obj); - c2 = HEXCHAR(c2); - c = c1 << 4 | c2; - if (c != '\r') - { - size --; - *buff++ = c; - (*real_size)++; - } - } - else - { - /* ignore the line break -- soft line break, rule #5 */ - } - } - else - { - if (c1 == CR || c1 == LF) - { - if (p_ap_decode_obj->pos_inbuff < p_ap_decode_obj->s_inbuff) - { - if (p_ap_decode_obj->boundary0 && - (!PL_strncasecmp(p_ap_decode_obj->pos_inbuff+p_ap_decode_obj->inbuff, - "--", - 2) - && - !PL_strncasecmp(p_ap_decode_obj->pos_inbuff+p_ap_decode_obj->inbuff+2, - p_ap_decode_obj->boundary0, - nsCRT::strlen(p_ap_decode_obj->boundary0)))) - { - return errEOP; - } - } - } - - /* - ** general 8bits case, Rule #1 - */ - size -- ; - *buff++ = c1; - (*real_size) ++; - } - } - return EndOfBuff(p_ap_decode_obj) ? errEOB : NOERR; -} - -#define UUEOL(c) (((c) == CR) || ((c) == LF)) -# undef UUDEC -# define UUDEC(c) (((c) - ' ') & 077) - -/* Check for and skip past the "begin" line of a uuencode body. */ -PRIVATE void ensure_uu_body_state(appledouble_decode_object* p) -{ - char *end = &(p->inbuff[p->s_inbuff]); - char *current = &(p->inbuff[p->pos_inbuff]); - - if (p->uu_state == kMainBody && p->uu_starts_line - && !PL_strncasecmp(current, "end", PR_MIN(3, end - current))) - p->uu_state = kEnd; - - while (p->uu_state != kMainBody && (current < end)) - { - switch(p->uu_state) - { - case kWaitingForBegin: - case kBegin: - /* If we're not at the beginning of a line, move to the next line. */ - if (! p->uu_starts_line) - { - while(current < end && !UUEOL(*current)) - current++; - while(current < end && UUEOL(*current)) - current++; - - p->uu_starts_line = TRUE; /* we reached the start of a line */ - if (p->uu_state == kBegin) - p->uu_state = kMainBody; - - continue; - } - else - { - /* - At the start of a line. Test for "begin". - - ### mwelch: - - There is a potential danger here. If a buffer ends with a line - starting with some substring of "begin", this code will be fooled - into thinking that the uuencode body starts with the following line. - If the message itself contains lines that begin with a substring of - "begin", such as "be", "because", or "bezoar", and if those lines happen - to end a 1024-byte chunk, this becomes Really Bad. However, there is - no good, safe way to overcome this problem. So, for now, I hope and - pray that the 1024 character limit will always incorporate the entire - first line of a uuencode body. - - It should be noted that broken messages that have the body text in - the same MIME part as the uuencode attachment also risk this same - pitfall if any line in the message starts with "begin". - */ - - if ((p->uu_state == kWaitingForBegin) - && !PL_strncasecmp(current, "begin", PR_MIN(5, end - current))) - p->uu_state = kBegin; - p->uu_starts_line = FALSE; /* make us advance to next line */ - } - break; - case kEnd: - /* Run out the buffer. */ - current = end; - } - } - - /* Record where we stopped scanning. */ - p->pos_inbuff = p->s_inbuff - (end - current); -} - -#define UU_VOID_CHAR 0 - -PRIVATE int fetch_next_char_uu(appledouble_decode_object* p, PRBool newBunch) -{ - char c=0; - PRBool gotChar = FALSE; - - if (EndOfBuff(p)) - return 0; - - while(!gotChar) - { - if (EndOfBuff(p)) - { - c = 0; - gotChar = TRUE; - } - else if (p->uu_starts_line) - { - char *end = &(p->inbuff[p->s_inbuff]); - char *current = &(p->inbuff[p->pos_inbuff]); - - /* Look here for 'end' line signifying end of uuencode body. */ - if (!PL_strncasecmp(current, "end", PR_MIN(3, end - current))) - { - p->uu_state = kEnd; /* set the uuencode state to end */ - p->pos_inbuff = p->s_inbuff; /* run out the current buffer */ - - c = 0; /* return a 0 to uudecoder */ - gotChar = TRUE; - } - } - if (gotChar) - continue; - - c = NEXT_CHAR(p); - - if ((c == CR) || (c == LF)) - { - if (newBunch) - { - /* A new line could immediately follow either a CR or an LF. - If we reach the end of a buffer, simply assume the next buffer - will start a line (as it should in the current libmime implementation). - If it starts with CR or LF, that line will be skipped as well. */ - if (EndOfBuff(p) || ((CURRENT_CHAR(p) != CR) && (CURRENT_CHAR(p) != LF))) - p->uu_starts_line = TRUE; - - continue; - } - - /* End of line, but we have to finish a 4-tuple. Stop here. */ - -- p->pos_inbuff; /* give back the end-of-line character */ - c = UU_VOID_CHAR; /* flag as truncated */ - gotChar = TRUE; - } - - /* At this point, we have a valid char. */ - - else if (p->uu_starts_line) - { - /* read length char at start of each line */ - p->uu_line_bytes = UUDEC(c); - p->uu_starts_line = FALSE; - continue; - } - - else if (p->uu_line_bytes <= 0) - /* We ran out of bytes to decode on this line. Skip spare chars until - we reach the end of (line or buffer). */ - continue; - - else - gotChar = TRUE; /* valid returnable char */ - } - - return (int) c; -} - -/* -** uudecode -*/ - -PRIVATE int from_uu( - appledouble_decode_object* p_ap_decode_obj, - char *buff, - int size, - PRInt32 *real_size) -{ - char c; - int i; - int returnVal = NOERR; - int c1, c2, c3, c4; - - *real_size = 0; - - /* Make sure that we're in the uuencode body, or run out the buffer if - we don't have any body text in this buffer. */ - ensure_uu_body_state(p_ap_decode_obj); - - if (p_ap_decode_obj->uu_state == kEnd) - return errEOP; - - /* Continue with what was left over last time. */ - for (i = p_ap_decode_obj->state64; i<4; i++) - { - if (EndOfBuff(p_ap_decode_obj)) - { - p_ap_decode_obj->state64 = i; - break; - } - if ((p_ap_decode_obj->c[i] = fetch_next_char_uu(p_ap_decode_obj, (i==0))) == 0) - break; - } - - if ( (i < p_ap_decode_obj->uu_line_bytes+1) - && (EndOfBuff(p_ap_decode_obj))) - /* not enough data to decode, return here. */ - return errEOB; - - while((size > 0) && (!EndOfBuff(p_ap_decode_obj))) - { - c1 = p_ap_decode_obj->c[0]; - c2 = p_ap_decode_obj->c[1]; - c3 = p_ap_decode_obj->c[2]; - c4 = p_ap_decode_obj->c[3]; - - /* - At this point we have characters ready to decode. - Convert them to binary bytes. - */ - if ((i > 1) - && (p_ap_decode_obj->uu_bytes_written < 1) - && (p_ap_decode_obj->uu_line_bytes > 0)) - { - c = UUDEC(c1) << 2 | UUDEC(c2) >> 4; - size --; - *buff ++ = c; - (*real_size) ++; - p_ap_decode_obj->uu_line_bytes--; - p_ap_decode_obj->uu_bytes_written++; - } - - if ((i > 2) && (size > 0) - && (p_ap_decode_obj->uu_bytes_written < 2) - && (p_ap_decode_obj->uu_line_bytes > 0)) - { - c = UUDEC(c2) << 4 | UUDEC(c3) >> 2; - size --; - *buff ++ = c; - (*real_size) ++; - p_ap_decode_obj->uu_line_bytes--; - p_ap_decode_obj->uu_bytes_written++; - } - - if ((i > 3) && (size > 0) - && (p_ap_decode_obj->uu_line_bytes > 0)) - { - c = UUDEC(c3) << 6 | UUDEC(c4); - size --; - *buff ++ = c; - (*real_size) ++; - p_ap_decode_obj->uu_line_bytes--; - p_ap_decode_obj->uu_bytes_written = 0; - } - - if (p_ap_decode_obj->uu_state == kEnd) - continue; - - /* If this line is finished, this tuple is also finished. */ - if (p_ap_decode_obj->uu_line_bytes <= 0) - p_ap_decode_obj->uu_bytes_written = 0; - - if (p_ap_decode_obj->uu_bytes_written > 0) - { - /* size == 0, but we have bytes left in current tuple */ - p_ap_decode_obj->state64 = i; - continue; - } - - /* - ** fetch the next 4 character group. - */ - - for (i = 0; i < 4; i++) - { - if (EndOfBuff(p_ap_decode_obj)) - break; - - if ((p_ap_decode_obj->c[i] = fetch_next_char_uu(p_ap_decode_obj, (i == 0))) == 0) - break; - } - - p_ap_decode_obj->state64 = i; - - if ( (i < p_ap_decode_obj->uu_line_bytes+1) - && (EndOfBuff(p_ap_decode_obj))) - /* not enough data to decode, return here. */ - continue; - } - - if (p_ap_decode_obj->uu_state == kEnd) - returnVal = errEOP; - else if (EndOfBuff(p_ap_decode_obj)) - returnVal = errEOB; - - return returnVal; -} - -/* -** from_none -** -** plain text transfer. -*/ -PRIVATE int from_none( - appledouble_decode_object* p_ap_decode_obj, - char *buff, - int size, - PRInt32 *real_size) -{ - char c; - int i, status = NOERR; - int left = p_ap_decode_obj->s_inbuff - p_ap_decode_obj->pos_inbuff; - int total = PR_MIN(size, left); - - for (i = 0; i < total; i++) - { - *buff ++ = c = NEXT_CHAR(p_ap_decode_obj); - if (c == CR || c == LF) - { - /* make sure the next thing is not a boundary string */ - if (p_ap_decode_obj->pos_inbuff < p_ap_decode_obj->s_inbuff) - { - if (p_ap_decode_obj->boundary0 && - (!PL_strncasecmp(p_ap_decode_obj->pos_inbuff+p_ap_decode_obj->inbuff, - "--", - 2) - && - !PL_strncasecmp(p_ap_decode_obj->pos_inbuff+p_ap_decode_obj->inbuff+2, - p_ap_decode_obj->boundary0, - nsCRT::strlen(p_ap_decode_obj->boundary0)))) - { - status = errEOP; - break; - } - } - } - } - - *real_size = i; - if (status == NOERR) - status = (left == i) ? errEOB : status; - return status; -} - diff --git a/mailnews/compose/src/nsMsgAppleDecodeStream.cpp b/mailnews/compose/src/nsMsgAppleDecodeStream.cpp deleted file mode 100755 index b8f9c10bfb88..000000000000 --- a/mailnews/compose/src/nsMsgAppleDecodeStream.cpp +++ /dev/null @@ -1,753 +0,0 @@ -DON'T COMPILE ME!!! -RICHIE -RICHIE -RICHIE OLD FE INTERFACES TO APPLEDOUBLE ENCODE/DECODE -RICHIE -RICHIE -RICHIE - -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org Code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/** -* Apple Double encode/decode stream -* ---------------------------------- -* -* 11sep95 mym created. -*/ - -#include "nscore.h" -#include "msgCore.h" -#include "prio.h" - -#include "nsMsgAppleDouble.h" -#include "nsMsgAppleCodes.h" - -#include "nsMsgBinHex.h" -#include "m_cvstrm.h" - -extern int MK_MSG_SAVE_ATTACH_AS; - -#ifdef RICHIE_XP_MAC -#pragma warn_unusedarg off - -extern int MK_UNABLE_TO_OPEN_TMP_FILE; -extern int MK_MIME_ERROR_WRITING_FILE; - -/* --------------------------------------------------------------------------------- -** -** The codes for Apple-double encoding stream. --- it's only useful on Mac OS -** -** --------------------------------------------------------------------------------- -*/ - -#define WORKING_BUFF_SIZE 8192 - -typedef struct _AppledoubleEncodeObject -{ - appledouble_encode_object ap_encode_obj; - - char* buff; /* the working buff. */ - PRInt32 s_buff; /* the working buff size. */ - - RICHIE_XP_File fp; /* file to hold the encoding */ - char *fname; /* and the file name. */ - -} AppleDoubleEncodeObject; - -/* - Let's go "l" characters forward of the encoding for this write. - Note: - "s" is just a dummy paramter. - */ -PRIVATE int -net_AppleDouble_Encode_Write ( - void *stream, const char* s, PRInt32 l) -{ - int status = 0; - AppleDoubleEncodeObject * obj = (AppleDoubleEncodeObject*)stream; - PRInt32 count, size; - - while (l > 0) - { - size = obj->s_buff * 11 / 16; - size = PR_MIN(l, size); - status = ap_encode_next(&(obj->ap_encode_obj), - obj->buff, - size, - &count); - if (status == noErr || status == errDone) - { - /* - * we get the encode data, so call the next stream to write it to the disk. - */ - if (RICHIE_XP_FileWrite(obj->buff, count, obj->fp) != count) - return errFileWrite; - } - - if (status != noErr ) /* abort when error / done? */ - break; - - l -= size; - } - return status; -} - -/* -** is the stream ready for writing? - */ -PRIVATE unsigned int net_AppleDouble_Encode_Ready (void *stream) -{ - return(PR_MAX_WRITE_READY); /* always ready for writing */ -} - - -PRIVATE void net_AppleDouble_Encode_Complete (void *stream) -{ - AppleDoubleEncodeObject * obj = (AppleDoubleEncodeObject*)stream; - - ap_encode_end(&(obj->ap_encode_obj), false); /* this is a normal ending */ - - if (obj->fp) - { - RICHIE_XP_FileClose(obj->fp); /* done with the target file */ - - PR_FREEIF(obj->fname); /* and the file name too */ - } - - PR_FREEIF(obj->buff); /* free the working buff. */ - PR_FREEIF(obj); -} - -PRIVATE void net_AppleDouble_Encode_Abort (void *stream, int status) -{ - AppleDoubleEncodeObject * obj = (AppleDoubleEncodeObject*)stream; - - ap_encode_end(&(obj->ap_encode_obj), true); /* it is an aborting exist... */ - - if (obj->fp) - { - RICHIE_XP_FileClose(obj->fp); - - RICHIE_XP_FileRemove (obj->fname, xpURL); /* remove the partial file. */ - - PR_FREEIF(obj->fname); - } - PR_FREEIF(obj->buff); /* free the working buff. */ - PR_FREEIF(obj); -} - -/* -** fe_MakeAppleDoubleEncodeStream -** ------------------------------ -** -** Will create a apple double encode stream: -** -** -> take the filename as the input source (it needs to be a mac file.) -** -> take a file name for the temp file we are generating. -*/ - -PUBLIC NET_StreamClass * -fe_MakeAppleDoubleEncodeStream (int format_out, - void *data_obj, - URL_Struct *URL_s, - MWContext *window_id, - char* src_filename, - char* dst_filename, - char* separator) -{ - AppleDoubleEncodeObject* obj; - NET_StreamClass* stream; - char* working_buff = NULL; - int bSize = WORKING_BUFF_SIZE; - - TRACEMSG(("Setting up apple encode stream. Have URL: %s\n", URL_s->address)); - - stream = new (NET_StreamClass); - if(stream == NULL) - return(NULL); - - obj = new (AppleDoubleEncodeObject); - if (obj == NULL) - { - PR_FREEIF (stream); - return(NULL); - } - - while (!working_buff && (bSize >= 512)) - { - working_buff = (char *)PR_CALLOC(bSize); - if (!working_buff) - bSize /= 2; - } - if (working_buff == NULL) - { - PR_FREEIF (obj); - PR_FREEIF (stream); - return (NULL); - } - - stream->name = "Apple Double Encode"; - stream->complete = (MKStreamCompleteFunc) net_AppleDouble_Encode_Complete; - stream->abort = (MKStreamAbortFunc) net_AppleDouble_Encode_Abort; - stream->put_block = (MKStreamWriteFunc) net_AppleDouble_Encode_Write; - stream->is_write_ready = (MKStreamWriteReadyFunc) net_AppleDouble_Encode_Ready; - stream->data_object = obj; - stream->window_id = window_id; - - obj->fp = RICHIE_XP_FileOpen(dst_filename, xpFileToPost, RICHIE_XP_FILE_WRITE_BIN); - if (obj->fp == NULL) - { - PR_FREEIF (working_buff); - PR_FREEIF (obj); - PR_FREEIF (stream); - return (NULL); - } - - obj->fname = nsCRT::strdup(dst_filename); - - obj->buff = working_buff; - obj->s_buff = bSize; - - /* - ** setup all the need information on the apple double encoder. - */ - ap_encode_init(&(obj->ap_encode_obj), - src_filename, /* pass the file name of the source. */ - separator); - - TRACEMSG(("Returning stream from NET_AppleDoubleEncoder\n")); - - return stream; -} -#endif - -/* -** --------------------------------------------------------------------------------- -** -** The codes for the Apple sigle/double decoding. -** -** --------------------------------------------------------------------------------- -*/ -typedef struct AppleDoubleDecodeObject -{ - appledouble_decode_object ap_decode_obj; - - char* in_buff; /* the temporary buff to accumulate */ - /* the input, make sure the call to */ - /* the dedcoder engine big enough buff */ - PRInt32 bytes_in_buff; /* the count for the temporary buff. */ - - NET_StreamClass* binhex_stream; /* a binhex encode stream to convert */ - /* the decoded mac file to binhex. */ - -} AppleDoubleDecodeObject; - -PRIVATE int -net_AppleDouble_Decode_Write ( - void *stream, const char* s, PRInt32 l) -{ - int status = NOERR; - AppleDoubleDecodeObject * obj = (AppleDoubleDecodeObject*) stream; - PRInt32 size; - - /* - ** To force an effecient decoding, we should - ** make sure that the buff pass to the decode next is great than 1024 bytes. - */ - if (obj->bytes_in_buff + l > 1024) - { - size = 1024 - obj->bytes_in_buff; - memcpy(obj->in_buff+obj->bytes_in_buff, - s, - size); - s += size; - l -= size; - - status = ap_decode_next(&(obj->ap_decode_obj), - obj->in_buff, - 1024); - obj->bytes_in_buff = 0; - } - - if (l > 1024) - { - /* we are sure that obj->bytes_in_buff == 0 at this point. */ - status = ap_decode_next(&(obj->ap_decode_obj), - (char *)s, - l); - } - else - { - /* and we are sure we will not get overflow with the buff. */ - memcpy(obj->in_buff+obj->bytes_in_buff, - s, - l); - obj->bytes_in_buff += l; - } - return status; -} - -PRIVATE unsigned int -net_AppleDouble_Decode_Ready (NET_StreamClass *stream) -{ - return(PR_MAX_WRITE_READY); /* always ready for writing */ -} - - -PRIVATE void -net_AppleDouble_Decode_Complete (void *stream) -{ - AppleDoubleDecodeObject *obj = (AppleDoubleDecodeObject *)stream; - - if (obj->bytes_in_buff) - { - - ap_decode_next(&(obj->ap_decode_obj), /* do the last calls. */ - (char *)obj->in_buff, - obj->bytes_in_buff); - obj->bytes_in_buff = 0; - } - - ap_decode_end(&(obj->ap_decode_obj), FALSE); /* it is a normal clean up cases.*/ - - if (obj->binhex_stream) - PR_FREEIF(obj->binhex_stream); - - if (obj->in_buff) - PR_FREEIF(obj->in_buff); - - PR_FREEIF(obj); -} - -PRIVATE void -net_AppleDouble_Decode_Abort ( - void *stream, int status) -{ - AppleDoubleDecodeObject *obj = (AppleDoubleDecodeObject *)stream; - - ap_decode_end(&(obj->ap_decode_obj), TRUE); /* it is an abort. */ - - if (obj->binhex_stream) - PR_FREEIF(obj->binhex_stream); - - if (obj->in_buff) - PR_FREEIF(obj->in_buff); - - PR_FREEIF(obj); -} - - -/* -** fe_MakeAppleDoubleDecodeStream_1 -** --------------------------------- -** -** Create the apple double decode stream. -** -** In the Mac OS, it will create a stream to decode to an apple file; -** -** In other OS, the stream will decode apple double object, -** then encode it in binhex format, and save to the file. -*/ -#ifndef RICHIE_XP_MAC -static void -simple_copy(MWContext* context, char* saveName, void* closure) -{ - /* just copy the filename to the closure, so the caller can get it. */ - PL_strcpy(closure, saveName); -} -#endif - -PUBLIC NET_StreamClass * -fe_MakeAppleDoubleDecodeStream_1 (int format_out, - void *data_obj, - URL_Struct *URL_s, - MWContext *window_id) -{ -#ifdef RICHIE_XP_MAC - return fe_MakeAppleDoubleDecodeStream(format_out, - data_obj, - URL_s, - window_id, - false, - NULL); -#else - -#if 0 /* just a test in the mac OS */ - NET_StreamClass *p; - char* url; - StandardFileReply reply; - - StandardPutFile("\pSave binhex encoded file as:", "\pUntitled", &reply); - if (!reply.sfGood) - { - return NULL; - } - url = my_PathnameFromFSSpec(&(reply.sfFile)); - - p = fe_MakeAppleDoubleDecodeStream(format_out, - data_obj, - URL_s, - window_id, - true, - url+7); - PR_FREEIF(url); - return (p); - -#else /* for the none mac-os to get a file name */ - - NET_StreamClass *p; - char* filename; - - filename = PR_CALLOC(1024); - if (filename == NULL) - return NULL; - -/***** RICHIE - CONVERT THIS - if (FE_PromptForFileName(window_id, - RICHIE_XP_GetString(MK_MSG_SAVE_ATTACH_AS), - 0, - FALSE, - FALSE, - simple_copy, - filename) == -1) - { - return NULL; - } -***/ - - p = fe_MakeAppleDoubleDecodeStream(format_out, - data_obj, - URL_s, - window_id, - TRUE, - filename); - PR_FREEIF(filename); - return (p); - -#endif - -#endif -} - - -PUBLIC NET_StreamClass * -fe_MakeAppleDoubleDecodeStream (int format_out, - void *data_obj, - URL_Struct *URL_s, - MWContext *window_id, - PRBool write_as_binhex, - char *dst_filename) -{ - AppleDoubleDecodeObject* obj; - NET_StreamClass* stream; - - TRACEMSG(("Setting up apple double decode stream. Have URL: %s\n", URL_s->address)); - - stream = new (NET_StreamClass); - if(stream == NULL) - return(NULL); - - obj = new (AppleDoubleDecodeObject); - if (obj == NULL) - { - PR_FREEIF(stream); - return(NULL); - } - - stream->name = "AppleDouble Decode"; - stream->complete = (MKStreamCompleteFunc) net_AppleDouble_Decode_Complete; - stream->abort = (MKStreamAbortFunc) net_AppleDouble_Decode_Abort; - stream->put_block = (MKStreamWriteFunc) net_AppleDouble_Decode_Write; - stream->is_write_ready = (MKStreamWriteReadyFunc) net_AppleDouble_Decode_Ready; - stream->data_object = obj; - stream->window_id = window_id; - - /* - ** setup all the need information on the apple double encoder. - */ - obj->in_buff = (char *)PR_CALLOC(1024); - if (obj->in_buff == NULL) - { - PR_FREEIF(obj); - PR_FREEIF(stream); - return (NULL); - } - - obj->bytes_in_buff = 0; - - if (write_as_binhex) - { - obj->binhex_stream = - fe_MakeBinHexEncodeStream(format_out, - data_obj, - URL_s, - window_id, - dst_filename); - if (obj->binhex_stream == NULL) - { - PR_FREEIF(obj); - PR_FREEIF(stream); - PR_FREEIF(obj->in_buff); - return NULL; - } - - ap_decode_init(&(obj->ap_decode_obj), - FALSE, - TRUE, - obj->binhex_stream); - } - else - { - obj->binhex_stream = NULL; - ap_decode_init(&(obj->ap_decode_obj), - FALSE, - FALSE, - window_id); - /* - * jt 8/8/97 -- I think this should be set to true. But' - * let's not touch it for now. - * - * obj->ap_decode_obj.is_binary = TRUE; - */ - } - - if (dst_filename) - { - RICHIE_XP_STRNCPY_SAFE(obj->ap_decode_obj.fname, dst_filename, - sizeof(obj->ap_decode_obj.fname)); - } - #ifdef RICHIE_XP_MAC - obj->ap_decode_obj.mSpec = (FSSpec*)( URL_s->fe_data ); - #endif - TRACEMSG(("Returning stream from NET_AppleDoubleDecode\n")); - - return stream; -} - -/* -** fe_MakeAppleSingleDecodeStream_1 -** -------------------------------- -** -** Create the apple single decode stream. -** -** In the Mac OS, it will create a stream to decode object to an apple file; -** -** In other OS, the stream will decode apple single object, -** then encode context in binhex format, and save to the file. -*/ - -PUBLIC NET_StreamClass * -fe_MakeAppleSingleDecodeStream_1 (int format_out, - void *data_obj, - URL_Struct *URL_s, - MWContext *window_id) -{ -#ifdef RICHIE_XP_MAC - return fe_MakeAppleSingleDecodeStream(format_out, - data_obj, - URL_s, - window_id, - FALSE, - NULL); -#else - -#if 0 /* just a test in the mac OS */ - NET_StreamClass *p; - char* url; - StandardFileReply reply; - - StandardPutFile("\pSave binhex encoded file as:", "\pUntitled", &reply); - if (!reply.sfGood) - { - return NULL; - } - url = my_PathnameFromFSSpec(&(reply.sfFile)); - - p = fe_MakeAppleSingleDecodeStream(format_out, - data_obj, - URL_s, - window_id, - true, - url+7); - PR_FREEIF(url); - return (p); - -#else /* for the none mac-os to get a file name */ - - NET_StreamClass *p; - char* filename; - char* defaultPath = 0; - - defaultPath = URL_s->content_name; - -#ifdef RICHIE_XP_WIN16 - if (RICHIE_XP_FileNameContainsBadChars(defaultPath)) - defaultPath = 0; -#endif - - filename = PR_CALLOC(1024); - if (filename == NULL) - return NULL; - -/***** RICHIE - CONVERT THIS - if (FE_PromptForFileName(window_id, - RICHIE_XP_GetString(MK_MSG_SAVE_ATTACH_AS), - defaultPath, - FALSE, - FALSE, - simple_copy, - filename) == -1) - { - return NULL; - } -*********/ - - p = fe_MakeAppleSingleDecodeStream(format_out, - data_obj, - URL_s, - window_id, - FALSE, - filename); - PR_FREEIF(filename); - return (p); - -#endif - -#endif -} - -/* -** Create the Apple Doube Decode stream. -** -*/ -PUBLIC NET_StreamClass * -fe_MakeAppleSingleDecodeStream (int format_out, - void *data_obj, - URL_Struct *URL_s, - MWContext *window_id, - PRBool write_as_binhex, - char *dst_filename) -{ - AppleDoubleDecodeObject* obj; - NET_StreamClass* stream; - int encoding = kEncodeNone; /* default is that we don't know the encoding */ - - TRACEMSG(("Setting up apple single decode stream. Have URL: %s\n", URL_s->address)); - - stream = RICHIE_XP_NEW(NET_StreamClass); - if(stream == NULL) - return(NULL); - - obj = RICHIE_XP_NEW(AppleDoubleDecodeObject); - if (obj == NULL) - { - PR_FREEIF(stream); - return(NULL); - } - - stream->name = "AppleSingle Decode"; - stream->complete = (MKStreamCompleteFunc) net_AppleDouble_Decode_Complete; - stream->abort = (MKStreamAbortFunc) net_AppleDouble_Decode_Abort; - stream->put_block = (MKStreamWriteFunc) net_AppleDouble_Decode_Write; - stream->is_write_ready = (MKStreamWriteReadyFunc) net_AppleDouble_Decode_Ready; - stream->data_object = obj; - stream->window_id = window_id; - - /* - ** setup all the need information on the apple double encoder. - */ - obj->in_buff = (char *)PR_CALLOC(1024); - if (obj->in_buff == NULL) - { - PR_FREEIF(obj); - PR_FREEIF(stream); - return (NULL); - } - - obj->bytes_in_buff = 0; - - if (write_as_binhex) - { - obj->binhex_stream = - fe_MakeBinHexEncodeStream(format_out, - data_obj, - URL_s, - window_id, - dst_filename); - if (obj->binhex_stream == NULL) - { - PR_FREEIF(obj); - PR_FREEIF(stream); - PR_FREEIF(obj->in_buff); - return NULL; - } - - ap_decode_init(&(obj->ap_decode_obj), - TRUE, - TRUE, - obj->binhex_stream); - } - else - { - obj->binhex_stream = NULL; - ap_decode_init(&(obj->ap_decode_obj), - TRUE, - FALSE, - window_id); -#ifndef RICHIE_XP_MAC - obj->ap_decode_obj.is_binary = TRUE; -#endif - } - - if (dst_filename) - { - RICHIE_XP_STRNCPY_SAFE(obj->ap_decode_obj.fname, dst_filename, - sizeof(obj->ap_decode_obj.fname)); - } - /* If we are of a broken content-type, impose its encoding. */ - if (URL_s->content_type - && !RICHIE_XP_STRNCASECMP(URL_s->content_type, "x-uuencode-apple-single", 23)) - obj->ap_decode_obj.encoding = kEncodeUU; - else - obj->ap_decode_obj.encoding = kEncodeNone; - - TRACEMSG(("Returning stream from NET_AppleSingleDecode\n")); - - return stream; -} diff --git a/mailnews/compose/src/nsMsgAppleDoubleDecode.cpp b/mailnews/compose/src/nsMsgAppleDoubleDecode.cpp deleted file mode 100644 index 2cbe53e51dc9..000000000000 --- a/mailnews/compose/src/nsMsgAppleDoubleDecode.cpp +++ /dev/null @@ -1,376 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org Code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#include "nsID.h" -#include "nsCRT.h" -#include "nscore.h" -#include "msgCore.h" -#include "nsMsgAppleDouble.h" -#include "nsMsgAppleCodes.h" -#include "nsFileSpec.h" -#include "nsMsgCompUtils.h" - -#ifdef XP_MAC - -#pragma warn_unusedarg off -#include "m_cvstrm.h" - -#pragma cplusplus on - -void -DecodingDone( appledouble_decode_object* p_ap_decode_obj ) -{ - FSSpec fspec; - - fspec.vRefNum = p_ap_decode_obj->vRefNum; - fspec.parID = p_ap_decode_obj->dirId; - fspec.name[0] = nsCRT::strlen(p_ap_decode_obj->fname); - strcpy((char*)fspec.name+1, p_ap_decode_obj->fname); - CMimeMapper * mapper = CPrefs::sMimeTypes.FindMimeType(fspec); - if( mapper && (mapper->GetLoadAction() == CMimeMapper::Launch ) ) - { - LFileBufferStream file( fspec ); - LaunchFile( &file ); - } -} - -#pragma cplusplus reset - -#endif /* the ifdef of XP_MAC */ - - -/* -** The initial of the apple double decoder. -** -** Set up the next output stream based on the input. -*/ -int ap_decode_init( - appledouble_decode_object* p_ap_decode_obj, - PRBool is_apple_single, - PRBool write_as_binhex, - void *closure) -{ - memset(p_ap_decode_obj, 0, sizeof(appledouble_decode_object)); - - /* presume first buff starts a line */ - p_ap_decode_obj->uu_starts_line = TRUE; - - if (write_as_binhex) - { - p_ap_decode_obj->write_as_binhex = TRUE; - p_ap_decode_obj->binhex_stream = (NET_StreamClass*)closure; - p_ap_decode_obj->data_size = 0; - } - else - { - p_ap_decode_obj->write_as_binhex = FALSE; - p_ap_decode_obj->binhex_stream = NULL; - - p_ap_decode_obj->context = (MWContext*)closure; - } - - p_ap_decode_obj->is_apple_single = is_apple_single; - - if (is_apple_single) - { - p_ap_decode_obj->encoding = kEncodeNone; - } - - return NOERR; -} - -static int ap_decode_state_machine(appledouble_decode_object* p_ap_decode_obj); -/* -* process the buffer -*/ -int ap_decode_next( - appledouble_decode_object* p_ap_decode_obj, - char *in_buff, - PRInt32 buff_size) -{ - /* - ** install the buff to the decoder. - */ - p_ap_decode_obj->inbuff = in_buff; - p_ap_decode_obj->s_inbuff = buff_size; - p_ap_decode_obj->pos_inbuff = 0; - - /* - ** run off the decode state machine - */ - return ap_decode_state_machine(p_ap_decode_obj); -} - -PRIVATE int ap_decode_state_machine( - appledouble_decode_object* p_ap_decode_obj) -{ - int status = NOERR; - PRInt32 size; - - switch (p_ap_decode_obj->state) - { - case kInit: - /* - ** Make sure that there are stuff in the buff - ** before we can parse the file head . - */ - if (p_ap_decode_obj->s_inbuff <=1 ) - return NOERR; - - if (p_ap_decode_obj->is_apple_single) - { - p_ap_decode_obj->state = kBeginHeaderPortion; - } - else - { - status = ap_seek_part_start(p_ap_decode_obj); - if (status != errDone) - return status; - - p_ap_decode_obj->state = kBeginParseHeader; - } - status = ap_decode_state_machine(p_ap_decode_obj); - break; - - case kBeginSeekBoundary: - p_ap_decode_obj->state = kSeekingBoundary; - status = ap_seek_to_boundary(p_ap_decode_obj, TRUE); - if (status == errDone) - { - p_ap_decode_obj->state = kBeginParseHeader; - status = ap_decode_state_machine(p_ap_decode_obj); - } - break; - - case kSeekingBoundary: - status = ap_seek_to_boundary(p_ap_decode_obj, FALSE); - if (status == errDone) - { - p_ap_decode_obj->state = kBeginParseHeader; - status = ap_decode_state_machine(p_ap_decode_obj); - } - break; - - case kBeginParseHeader: - p_ap_decode_obj->state = kParsingHeader; - status = ap_parse_header(p_ap_decode_obj, TRUE); - if (status == errDone) - { - if (p_ap_decode_obj->which_part == kDataPortion) - p_ap_decode_obj->state = kBeginDataPortion; - else if (p_ap_decode_obj->which_part == kHeaderPortion) - p_ap_decode_obj->state = kBeginHeaderPortion; - else - p_ap_decode_obj->state = kFinishing; - - status = ap_decode_state_machine(p_ap_decode_obj); - } - break; - - case kParsingHeader: - status = ap_parse_header(p_ap_decode_obj, FALSE); - if (status == errDone) - { - if (p_ap_decode_obj->which_part == kDataPortion) - p_ap_decode_obj->state = kBeginDataPortion; - else if (p_ap_decode_obj->which_part == kHeaderPortion) - p_ap_decode_obj->state = kBeginHeaderPortion; - else - p_ap_decode_obj->state = kFinishing; - - status = ap_decode_state_machine(p_ap_decode_obj); - - } - break; - - case kBeginHeaderPortion: - p_ap_decode_obj->state = kProcessingHeaderPortion; - status = ap_decode_process_header(p_ap_decode_obj, TRUE); - if (status == errDone) - { - if (p_ap_decode_obj->is_apple_single) - p_ap_decode_obj->state = kBeginDataPortion; - else - p_ap_decode_obj->state = kBeginSeekBoundary; - - status = ap_decode_state_machine(p_ap_decode_obj); - } - break; - case kProcessingHeaderPortion: - status = ap_decode_process_header(p_ap_decode_obj, FALSE); - if (status == errDone) - { - if (p_ap_decode_obj->is_apple_single) - p_ap_decode_obj->state = kBeginDataPortion; - else - p_ap_decode_obj->state = kBeginSeekBoundary; - - status = ap_decode_state_machine(p_ap_decode_obj); - } - break; - - case kBeginDataPortion: - p_ap_decode_obj->state = kProcessingDataPortion; - status = ap_decode_process_data(p_ap_decode_obj, TRUE); - if (status == errDone) - { - if (p_ap_decode_obj->is_apple_single) - p_ap_decode_obj->state = kFinishing; - else - p_ap_decode_obj->state = kBeginSeekBoundary; - - status = ap_decode_state_machine(p_ap_decode_obj); - } - break; - - case kProcessingDataPortion: - status = ap_decode_process_data(p_ap_decode_obj, FALSE); - if (status == errDone) - { - if (p_ap_decode_obj->is_apple_single) - p_ap_decode_obj->state = kFinishing; - else - p_ap_decode_obj->state = kBeginSeekBoundary; - - status = ap_decode_state_machine(p_ap_decode_obj); - } - break; - - case kFinishing: - if (p_ap_decode_obj->write_as_binhex) - { - if (p_ap_decode_obj->tmpfd) - { - /* - ** It is time to append the data fork to bin hex encoder. - ** - ** The reason behind this dirt work is resource fork is the last - ** piece in the binhex, while it is the first piece in apple double. - */ - p_ap_decode_obj->tmpFileStream->seek(PR_SEEK_SET, 0); - - while (p_ap_decode_obj->data_size > 0) - { - char buff[1024]; - - size = PR_MIN(1024, p_ap_decode_obj->data_size); - p_ap_decode_obj->tmpFileStream->read(buff, size); - status = (*p_ap_decode_obj->binhex_stream->put_block) - (p_ap_decode_obj->binhex_stream->data_object, - buff, - size); - - p_ap_decode_obj->data_size -= size; - } - } - - if (p_ap_decode_obj->data_size <= 0) - { - /* CALL put_block with size == 0 to close a part. */ - status = (*p_ap_decode_obj->binhex_stream->put_block) - (p_ap_decode_obj->binhex_stream->data_object, - NULL, - 0); - if (status != NOERR) - break; - - /* and now we are really done. */ - status = errDone; - } - else - status = NOERR; - } - break; - } - return (status == errEOB) ? NOERR : status; -} - -int ap_decode_end( - appledouble_decode_object* p_ap_decode_obj, - PRBool is_aborting) -{ - /* - ** clear up the apple doubler object. - */ - if (p_ap_decode_obj == NULL) - return NOERR; - - PR_FREEIF(p_ap_decode_obj->boundary0); - -#ifdef XP_MAC - if (p_ap_decode_obj->fileId) - FSClose(p_ap_decode_obj->fileId); - if( p_ap_decode_obj->vRefNum ) - FlushVol(nil, p_ap_decode_obj->vRefNum ); -#endif - - if (p_ap_decode_obj->write_as_binhex) - { - /* - ** make sure close the binhex stream too. - */ - if (is_aborting) - { - (*p_ap_decode_obj->binhex_stream->abort) - (p_ap_decode_obj->binhex_stream->data_object, 0); - } - else - { - (*p_ap_decode_obj->binhex_stream->complete) - (p_ap_decode_obj->binhex_stream->data_object); - } - - if (p_ap_decode_obj->tmpFileStream) - p_ap_decode_obj->tmpFileStream->close(); - - if (p_ap_decode_obj->tmpFileSpec) - { - p_ap_decode_obj->tmpFileSpec->Delete(PR_FALSE); /* remove tmp file if we used it */ - delete p_ap_decode_obj->tmpFileSpec; - } - } - else if (p_ap_decode_obj->fileStream) - { - p_ap_decode_obj->fileStream->close(); - } -#ifdef XP_MAC - if( !is_aborting ) - DecodingDone( p_ap_decode_obj); -#endif - return NOERR; - -} diff --git a/mailnews/compose/src/nsSmtpProtocol.cpp b/mailnews/compose/src/nsSmtpProtocol.cpp index 4031df7385fb..4b5c634a15bd 100644 --- a/mailnews/compose/src/nsSmtpProtocol.cpp +++ b/mailnews/compose/src/nsSmtpProtocol.cpp @@ -1292,44 +1292,6 @@ PRInt32 nsSmtpProtocol::SendDataResponse() m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT; return(NS_ERROR_SENDING_DATA_COMMAND); } -#ifdef UNREADY_CODE -#ifdef XP_UNIX - { - const char * FE_UsersRealMailAddress(void); /* definition */ - const char *real_name; - char *s = 0; - PRBool suppress_sender_header = PR_FALSE; - - PREF_GetBoolPref ("mail.suppress_sender_header", &suppress_sender_header); - if (!suppress_sender_header) - { - real_name = FE_UsersRealMailAddress(); - s = (real_name ? MSG_MakeFullAddress (NULL, real_name) : 0); - if (real_name && !s) - { - m_urlErrorState = NS_ERROR_COULD_NOT_GET_UID; - return(NS_ERROR_COULD_NOT_GET_UID); - } - if(real_name) - { - char buffer[512]; - PR_snprintf(buffer, sizeof(buffer), "Sender: %.256s" CRLF, real_name); - NS_MsgSACat(command, buffer); - if(!command) - { - m_urlErrorState = NS_ERROR_OUT_OF_MEMORY; - return(NS_ERROR_OUT_OF_MEMORY); - } - - status = (int) NET_BlockingWrite(CE_SOCK, command, PL_strlen(command)); - if(status < 0) - { - } - } - } - } -#endif /* XP_UNIX */ -#endif /* UNREADY_CODE */ PR_FREEIF(command); @@ -1338,19 +1300,6 @@ PRInt32 nsSmtpProtocol::SendDataResponse() UpdateStatus(SMTP_DELIV_MAIL); -#ifdef UNREADY_CODE - /* get the size of the message */ - if(CE_URL_S->post_data_is_file) - { - XP_StatStruct stat_entry; - - if(-1 != XP_Stat(CE_URL_S->post_data, - &stat_entry, - xpFileToPost)) - m_totalMessageSize = stat_entry.st_size; - } - else -#endif /* UNREADY_CODE */ { // m_runningURL->GetBodySize(&m_totalMessageSize); } @@ -1406,21 +1355,6 @@ PRInt32 nsSmtpProtocol::SendPostData() "message sent; waiting for reply" status; FE_GraphProgress gets in the way of that. See bug #23414. */ -#ifdef UNREADY_CODE - unsigned long curtime; - curtime = XP_TIME(); - if (curtime != m_LastTime) { - FE_Progress(CE_WINDOW_ID, XP_ProgressText(m_totalMessageSize, - m_totalAmountWritten, - 0, 0)); - m_LastTime = curtime; - } - - if(m_totalMessageSize) - FE_SetProgressBarPercent(CE_WINDOW_ID, - m_totalAmountWritten*100/m_totalMessageSize); -#endif /* UNREADY_CODE */ - return(status); } diff --git a/mailnews/news/src/nsNNTPProtocol.cpp b/mailnews/news/src/nsNNTPProtocol.cpp index 1cd3fd00aebf..0c8a712ba3c8 100644 --- a/mailnews/news/src/nsNNTPProtocol.cpp +++ b/mailnews/news/src/nsNNTPProtocol.cpp @@ -1518,13 +1518,8 @@ PRInt32 nsNNTPProtocol::NewsResponse(nsIInputStream * inputStream, PRUint32 leng /* almost correct */ if(status > 1) { -#ifdef UNREADY_CODE - ce->bytes_received += status; - FE_GraphProgress(ce->window_id, ce->URL_s, ce->bytes_received, status, ce->URL_s->content_length); -#else mBytesReceived += status; mBytesReceivedSinceLastStatusUpdate += status; -#endif } m_previousResponseCode = m_responseCode; @@ -1583,9 +1578,6 @@ PRInt32 nsNNTPProtocol::LoginResponse() AlertError(MK_NNTP_ERROR_MESSAGE, m_responseText); m_nextState = NNTP_ERROR; -#ifdef UNREADY_CODE - cd->control_con->prev_cache = PR_FALSE; /* to keep if from reconnecting */ -#endif return MK_BAD_NNTP_CONNECTION; } @@ -2032,15 +2024,6 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommand(nsIURI * url) } else { -#ifdef UNREADY_CODE -#ifdef BUG_21013 - if(!FE_Confirm(ce->window_id, XP_GetString(XP_CONFIRM_SAVE_NEWSGROUPS))) - { - m_nextState = NEWS_ERROR; - return(MK_INTERRUPTED); - } -#endif /* BUG_21013 */ -#endif PRBool xactive=PR_FALSE; rv = m_nntpServer->QueryExtension("XACTIVE",&xactive); if (NS_SUCCEEDED(rv) && xactive) @@ -2148,11 +2131,6 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommand(nsIURI * url) } } m_nextState = NNTP_RESPONSE; -#ifdef UNREADY_CODE - if (PL_strstr(ce->URL_s->address, "PROFILE NEW")) - m_nextStateAfterResponse = NNTP_PROFILE_ADD_RESPONSE; - else -#endif m_nextStateAfterResponse = NNTP_PROFILE_DELETE_RESPONSE; } else if (m_typeWanted == IDS_WANTED) @@ -2327,15 +2305,8 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommandResponse() /* start the graph progress indicator */ -#ifdef UNREADY_CODE - FE_GraphProgressInit(ce->window_id, ce->URL_s, ce->URL_s->content_length); -#else NNTP_LOG_NOTE("start the graph progress indicator"); -#endif SetFlag(NNTP_DESTROY_PROGRESS_GRAPH); -#ifdef UNREADY_CODE - m_originalContentLength = ce->URL_s->content_length; -#endif return(status); } @@ -2421,41 +2392,11 @@ PRInt32 nsNNTPProtocol::BeginArticle() /* Set up the HTML stream */ -#ifdef UNREADY_CODE - ce->URL_s->content_type = nsCRT::strdup (MESSAGE_RFC822); -#endif #ifdef NO_ARTICLE_CACHEING ce->format_out = CLEAR_CACHE_BIT (ce->format_out); #endif - if (m_typeWanted == CANCEL_WANTED) - { -#ifdef UNREADY_CODE - NS_ASSERTION(ce->format_out == FO_PRESENT, "format_out != FO_PRESENT"); - ce->format_out = FO_PRESENT; -#endif - } - - /* Only put stuff in the fe_data if this URL is going to get - passed to MIME_MessageConverter(), since that's the only - thing that knows what to do with this structure. */ -#ifdef UNREADY_CODE - if (CLEAR_CACHE_BIT(ce->format_out) == FO_PRESENT) - { - status = net_InitializeNewsFeData (ce); - if (status < 0) - { - /* #### what error message? */ - return status; - } - } - - cd->stream = NET_StreamBuilder(ce->format_out, ce->URL_s, ce->window_id); - NS_ASSERTION (cd->stream, "no stream"); - if (!cd->stream) return -1; -#endif - // if we have a channel listener, // create a pipe to pump the message into...the output will go to whoever // is consuming the message display @@ -2930,15 +2871,9 @@ PRInt32 nsNNTPProtocol::BeginNewsgroups() { PRInt32 status = 0; m_nextState = NNTP_NEWGROUPS; -#ifdef UNREADY_CODE - NET_Progress(ce->window_id, XP_GetString(XP_PROGRESS_RECEIVE_NEWSGROUP)); - - ce->bytes_received = 0; -#else mBytesReceived = 0; mBytesReceivedSinceLastStatusUpdate = 0; m_startTime = PR_Now(); -#endif return(status); } @@ -3076,10 +3011,7 @@ PRInt32 nsNNTPProtocol::BeginReadNewsList() m_startTime = PR_Now(); PRInt32 status = 0; -#ifdef UNREADY_CODE - NET_Progress(ce->window_id, XP_GetString(XP_PROGRESS_RECEIVE_NEWSGROUP)); -#endif - + return(status); } @@ -3799,34 +3731,6 @@ PRInt32 nsNNTPProtocol::PostDataResponse() if (m_responseCode != MK_NNTP_RESPONSE_POST_OK) { AlertError(MK_NNTP_ERROR_MESSAGE,m_responseText); -#ifdef UNREADY_CODE - ce->URL_s->error_msg = - NET_ExplainErrorDetails(MK_NNTP_ERROR_MESSAGE, - m_responseText ? m_responseText : ""); - if (m_responseCode == MK_NNTP_RESPONSE_POST_FAILED - && MSG_GetPaneType(cd->pane) == MSG_COMPOSITIONPANE - && MSG_IsDuplicatePost(cd->pane) && - MSG_GetCompositionMessageID(cd->pane)) { - /* The news server won't let us post. We suspect that we're submitting - a duplicate post, and that's why it's failing. So, let's go see - if there really is a message out there with the same message-id. - If so, we'll just silently pretend everything went well. */ - PR_snprintf(cd->output_buffer, OUTPUT_BUFFER_SIZE, "STAT %s" CRLF, - MSG_GetCompositionMessageID(cd->pane)); - m_nextState = NNTP_RESPONSE; - m_nextStateAfterResponse = NNTP_CHECK_FOR_MESSAGE; - NNTP_LOG_WRITE(cd->output_buffer); - return (int) NET_BlockingWrite(ce->socket, cd->output_buffer, - PL_strlen(cd->output_buffer)); - } - - MSG_ClearCompositionMessageID(cd->pane); /* So that if the user tries - to just post again, we - won't immediately decide - that this was a duplicate - message and ignore the - error. */ -#endif m_nextState = NEWS_ERROR; return(MK_NNTP_ERROR_MESSAGE); } @@ -3847,9 +3751,6 @@ PRInt32 nsNNTPProtocol::CheckForArticle() /* The article isn't there, so the failure we had earlier wasn't due to a duplicate message-id. Return the error from that previous posting attempt (which is already in ce->URL_s->error_msg). */ -#ifdef UNREADY_CODE - MSG_ClearCompositionMessageID(cd->pane); -#endif return MK_NNTP_ERROR_MESSAGE; } } diff --git a/xpfe/components/search/src/nsInternetSearchService.cpp b/xpfe/components/search/src/nsInternetSearchService.cpp index ca07a69ab9be..e0f440bd7aaf 100755 --- a/xpfe/components/search/src/nsInternetSearchService.cpp +++ b/xpfe/components/search/src/nsInternetSearchService.cpp @@ -5731,10 +5731,6 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent, nsCOMPtr res; -// #define OLDWAY -#ifdef OLDWAY - rv = gRDFService->GetResource(nsCAutoString(hrefStr), getter_AddRefs(res)); -#else // save HREF attribute as URL if (NS_SUCCEEDED(rv = gRDFService->GetAnonymousResource(getter_AddRefs(res)))) { @@ -5748,7 +5744,7 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent, } } } - #endif + if (NS_FAILED(rv)) continue; // set HTML response chunk @@ -5849,9 +5845,6 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent, // look for Name (if it isn't already set) nsCOMPtr oldNameRes = nsnull; -#ifdef OLDWAY - mInner->GetTarget(res, kNC_Name, PR_TRUE, getter_AddRefs(oldNameRes)); -#endif if (!oldNameRes) { if (!nameStr.IsEmpty()) @@ -6005,9 +5998,6 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent, // look for Relevance (if it isn't already set) nsCOMPtr oldRelRes = nsnull; -#ifdef OLDWAY - mInner->GetTarget(res, kNC_Relevance, PR_TRUE, getter_AddRefs(oldRelRes)); -#endif if (!oldRelRes) { if (!relItem.IsEmpty()) @@ -6100,9 +6090,6 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent, // set reference to engine this came from (if it isn't already set) nsCOMPtr oldEngineRes = nsnull; -#ifdef OLDWAY - mInner->GetTarget(res, kNC_Engine, PR_TRUE, getter_AddRefs(oldEngineRes)); -#endif if (!oldEngineRes) { if (!engineStr.IsEmpty())