зеркало из https://github.com/mozilla/pjs.git
Use MSG_LINEBREAK instead of LINEBREAK.
This commit is contained in:
Родитель
1cded1290c
Коммит
4ac4709ac1
|
@ -476,7 +476,7 @@ nsMsgGroupRecord::GetSaveString()
|
|||
if (!fullname) return NULL; {
|
||||
long nAddTime;
|
||||
LL_L2I(nAddTime, m_addtime);
|
||||
result = PR_smprintf("%s,%s,%lx,%lx,%lx" LINEBREAK,
|
||||
result = PR_smprintf("%s,%s,%lx,%lx,%lx" MSG_LINEBREAK,
|
||||
fullname, pretty ? pretty : "",
|
||||
(long) (m_flags & ~RUNTIMEFLAGS),
|
||||
nAddTime,
|
||||
|
|
|
@ -200,20 +200,20 @@ PRInt32 nsMsgLineBuffer::ConvertAndSendBuffer()
|
|||
if (!m_convertNewlinesP)
|
||||
{
|
||||
}
|
||||
#if (LINEBREAK_LEN == 1)
|
||||
#if (MSG_LINEBREAK_LEN == 1)
|
||||
else if ((newline - buf) >= 2 &&
|
||||
newline[-2] == CR &&
|
||||
newline[-1] == LF)
|
||||
{
|
||||
/* CRLF -> CR or LF */
|
||||
buf [length - 2] = LINEBREAK[0];
|
||||
buf [length - 2] = MSG_LINEBREAK[0];
|
||||
length--;
|
||||
}
|
||||
else if (newline > buf + 1 &&
|
||||
newline[-1] != LINEBREAK[0])
|
||||
newline[-1] != MSG_LINEBREAK[0])
|
||||
{
|
||||
/* CR -> LF or LF -> CR */
|
||||
buf [length - 1] = LINEBREAK[0];
|
||||
buf [length - 1] = MSG_LINEBREAK[0];
|
||||
}
|
||||
#else
|
||||
else if (((newline - buf) >= 2 && newline[-2] != CR) ||
|
||||
|
@ -221,8 +221,8 @@ PRInt32 nsMsgLineBuffer::ConvertAndSendBuffer()
|
|||
{
|
||||
/* LF -> CRLF or CR -> CRLF */
|
||||
length++;
|
||||
buf[length - 2] = LINEBREAK[0];
|
||||
buf[length - 1] = LINEBREAK[1];
|
||||
buf[length - 2] = MSG_LINEBREAK[0];
|
||||
buf[length - 1] = MSG_LINEBREAK[1];
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1151,19 +1151,19 @@ nsMsgCompose::InitializeHeaders(MWContext* old_context, const nsIMsgCompFields*
|
|||
if (body && *body)
|
||||
{
|
||||
m_fields->AppendBody((char *)body);
|
||||
m_fields->AppendBody(LINEBREAK);
|
||||
m_fields->AppendBody(MSG_LINEBREAK);
|
||||
/* m_bodyEdited = PR_TRUE; */
|
||||
}
|
||||
}
|
||||
|
||||
sig = FE_UsersSignature ();
|
||||
if (sig && *sig) {
|
||||
m_fields->AppendBody(LINEBREAK);
|
||||
m_fields->AppendBody(MSG_LINEBREAK);
|
||||
/* If the sig doesn't begin with "--" followed by whitespace or a
|
||||
newline, insert "-- \n" (the pseudo-standard sig delimiter.) */
|
||||
if (sig[0] != '-' || sig[1] != '-' ||
|
||||
(sig[2] != ' ' && sig[2] != CR && sig[2] != LF)) {
|
||||
m_fields->AppendBody("-- " LINEBREAK);
|
||||
m_fields->AppendBody("-- " MSG_LINEBREAK);
|
||||
}
|
||||
m_fields->AppendBody((char *)sig);
|
||||
}
|
||||
|
@ -1362,7 +1362,7 @@ nsMsgCompose::GetUrlDone(PrintSetup* /*pptr*/)
|
|||
PREF_GetIntPref("mailnews.reply_with_extra_lines", &replyWithExtraLines);
|
||||
|
||||
PRInt32 extra = (m_markup ? 0 :
|
||||
(replyWithExtraLines ? LINEBREAK_LEN * replyWithExtraLines
|
||||
(replyWithExtraLines ? MSG_LINEBREAK_LEN * replyWithExtraLines
|
||||
: 0));
|
||||
|
||||
/*JFD
|
||||
|
@ -1376,10 +1376,10 @@ nsMsgCompose::GetUrlDone(PrintSetup* /*pptr*/)
|
|||
|
||||
if (!m_markup && extra && replyOnTop == 1) {
|
||||
for (; replyWithExtraLines > 0; replyWithExtraLines--) {
|
||||
PL_strcpy(curquote, LINEBREAK);
|
||||
curquote += LINEBREAK_LEN;
|
||||
PL_strcpy(curquote, MSG_LINEBREAK);
|
||||
curquote += MSG_LINEBREAK_LEN;
|
||||
if (m_quotefunc)
|
||||
(*m_quotefunc)(m_quoteclosure, LINEBREAK);
|
||||
(*m_quotefunc)(m_quoteclosure, MSG_LINEBREAK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1450,10 +1450,10 @@ nsMsgCompose::GetUrlDone(PrintSetup* /*pptr*/)
|
|||
|
||||
if (!m_markup && extra && replyOnTop == 0) {
|
||||
for (; replyWithExtraLines > 1; replyWithExtraLines--) {
|
||||
PL_strcpy(curquote, LINEBREAK);
|
||||
curquote += LINEBREAK_LEN;
|
||||
PL_strcpy(curquote, MSG_LINEBREAK);
|
||||
curquote += MSG_LINEBREAK_LEN;
|
||||
if (m_quotefunc)
|
||||
(*m_quotefunc)(m_quoteclosure, LINEBREAK);
|
||||
(*m_quotefunc)(m_quoteclosure, MSG_LINEBREAK);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5331,7 +5331,7 @@ mime_do_fcc_1 (MSG_Pane *pane,
|
|||
|
||||
if (file_existed_p && st.st_size > 0)
|
||||
{
|
||||
if (XP_FileWrite (LINEBREAK, LINEBREAK_LEN, out) < LINEBREAK_LEN)
|
||||
if (XP_FileWrite (MSG_LINEBREAK, MSG_LINEBREAK_LEN, out) < MSG_LINEBREAK_LEN)
|
||||
{
|
||||
status = MK_MIME_ERROR_WRITING_FILE;
|
||||
goto FAIL;
|
||||
|
@ -5369,7 +5369,7 @@ mime_do_fcc_1 (MSG_Pane *pane,
|
|||
flags |= MSG_FLAG_READ;
|
||||
if (mode == MSG_QueueForLater )
|
||||
flags |= MSG_FLAG_QUEUED;
|
||||
buf = PR_smprintf(X_MOZILLA_STATUS_FORMAT LINEBREAK, flags);
|
||||
buf = PR_smprintf(X_MOZILLA_STATUS_FORMAT MSG_LINEBREAK, flags);
|
||||
if (buf)
|
||||
{
|
||||
status = msg_do_fcc_handle_line(buf, PL_strlen(buf), outgoingParser);
|
||||
|
@ -5381,7 +5381,7 @@ mime_do_fcc_1 (MSG_Pane *pane,
|
|||
PRUint32 flags2 = 0;
|
||||
if (mode == MSG_SaveAsTemplate)
|
||||
flags2 |= MSG_FLAG_TEMPLATE;
|
||||
buf = PR_smprintf(X_MOZILLA_STATUS2_FORMAT LINEBREAK, flags2);
|
||||
buf = PR_smprintf(X_MOZILLA_STATUS2_FORMAT MSG_LINEBREAK, flags2);
|
||||
if (buf)
|
||||
{
|
||||
status = msg_do_fcc_handle_line(buf, PL_strlen(buf), outgoingParser);
|
||||
|
@ -5430,7 +5430,7 @@ mime_do_fcc_1 (MSG_Pane *pane,
|
|||
status = MK_OUT_OF_MEMORY;
|
||||
goto FAIL;
|
||||
}
|
||||
PR_snprintf(buf, L-1, "FCC: %s" LINEBREAK, fcc_header);
|
||||
PR_snprintf(buf, L-1, "FCC: %s" MSG_LINEBREAK, fcc_header);
|
||||
status = msg_do_fcc_handle_line(buf, PL_strlen(buf), outgoingParser);
|
||||
if (status < 0)
|
||||
goto FAIL;
|
||||
|
@ -5450,7 +5450,7 @@ mime_do_fcc_1 (MSG_Pane *pane,
|
|||
status = MK_OUT_OF_MEMORY;
|
||||
goto FAIL;
|
||||
}
|
||||
PR_snprintf(buf, L-1, "BCC: %s" LINEBREAK, bcc_header);
|
||||
PR_snprintf(buf, L-1, "BCC: %s" MSG_LINEBREAK, bcc_header);
|
||||
status = msg_do_fcc_handle_line(buf, PL_strlen(buf), outgoingParser);
|
||||
if (status < 0)
|
||||
goto FAIL;
|
||||
|
@ -5487,7 +5487,7 @@ mime_do_fcc_1 (MSG_Pane *pane,
|
|||
|
||||
if ((host_and_port && *host_and_port) || !secure_p)
|
||||
{
|
||||
char *line = PR_smprintf(X_MOZILLA_NEWSHOST ": %s%s" LINEBREAK,
|
||||
char *line = PR_smprintf(X_MOZILLA_NEWSHOST ": %s%s" MSG_LINEBREAK,
|
||||
host_and_port ? host_and_port : "",
|
||||
secure_p ? "/secure" : "");
|
||||
PR_FREEIF(orig_hap);
|
||||
|
@ -5548,12 +5548,12 @@ mime_do_fcc_1 (MSG_Pane *pane,
|
|||
msg_do_fcc_handle_line (obuffer, obuffer_fp, outgoingParser);
|
||||
|
||||
/* Terminate with a final newline. */
|
||||
if (XP_FileWrite (LINEBREAK, LINEBREAK_LEN, out) < LINEBREAK_LEN)
|
||||
if (XP_FileWrite (MSG_LINEBREAK, MSG_LINEBREAK_LEN, out) < MSG_LINEBREAK_LEN)
|
||||
{
|
||||
status = MK_MIME_ERROR_WRITING_FILE;
|
||||
}
|
||||
else
|
||||
outgoingParser->AdvanceOutPosition(LINEBREAK_LEN);
|
||||
outgoingParser->AdvanceOutPosition(MSG_LINEBREAK_LEN);
|
||||
|
||||
if (mail_db != NULL && outgoingParser != NULL &&
|
||||
outgoingParser->m_newMsgHdr != NULL)
|
||||
|
|
|
@ -1,889 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "mdb.h"
|
||||
#include "stdio.h"
|
||||
// for LINEBREAK
|
||||
#include "fe_proto.h"
|
||||
|
||||
nsIMdbFactory *NS_NewIMdbFactory()
|
||||
{
|
||||
return new nsIMdbFactory;
|
||||
}
|
||||
|
||||
nsIMdbFactory *MakeMdbFactory()
|
||||
{
|
||||
return NS_NewIMdbFactory();
|
||||
}
|
||||
|
||||
mdb_err nsIMdbFactory::ThumbToOpenStore( // redeem completed thumb from OpenFileStore()
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbThumb* ioThumb, // thumb from OpenFileStore() with done status
|
||||
nsIMdbStore** acqStore) // acquire new db store object
|
||||
{
|
||||
mdb_err ret = 0;
|
||||
nsIMdbStore *resultStore;
|
||||
|
||||
resultStore = new nsIMdbStore;
|
||||
resultStore->m_fileStream = ioThumb->m_fileStream;
|
||||
resultStore->m_backingFile = ioThumb->m_backingFile;
|
||||
*acqStore = resultStore;
|
||||
// this means its an existing store that we have to load.
|
||||
if (resultStore->m_fileStream)
|
||||
{
|
||||
ret = resultStore->ReadAll(ev);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbFactory::CreateNewFileStore( // create a new db with minimal content
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbHeap* ioHeap, // can be nil to cause ev's heap attribute to be used
|
||||
const char* inFilePath, // name of file which should not yet exist
|
||||
const mdbOpenPolicy* inOpenPolicy, // runtime policies for using db
|
||||
nsIMdbStore** acqStore)
|
||||
{
|
||||
printf("new file store for %s\n", inFilePath);
|
||||
nsIMdbStore *resultStore;
|
||||
|
||||
resultStore = new nsIMdbStore;
|
||||
resultStore->m_backingFile = inFilePath;
|
||||
resultStore->m_fileStream = NULL;
|
||||
*acqStore = resultStore;
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbStore::SmallCommit( // save minor changes if convenient and uncostly
|
||||
nsIMdbEnv* ev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbStore::LargeCommit( // save important changes if at all possible
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbThumb** acqThumb)
|
||||
{
|
||||
return WriteAll(ev, acqThumb);
|
||||
}
|
||||
|
||||
mdb_err nsIMdbStore::SessionCommit( // save all changes if large commits delayed
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbThumb** acqThumb)
|
||||
{
|
||||
return WriteAll(ev, acqThumb);
|
||||
}
|
||||
|
||||
mdb_err
|
||||
nsIMdbStore::CompressCommit( // commit and make db physically smaller if possible
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbThumb** acqThumb)
|
||||
{
|
||||
return WriteAll(ev, acqThumb);
|
||||
}
|
||||
|
||||
mdb_err
|
||||
nsIMdbStore::WriteAll(nsIMdbEnv* ev, // context
|
||||
nsIMdbThumb** acqThumb)
|
||||
{
|
||||
*acqThumb = new nsIMdbThumb;
|
||||
|
||||
m_fileStream = new nsIOFileStream(nsFileSpec(m_backingFile));
|
||||
if (m_fileStream == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
WriteTokenList();
|
||||
WriteTableList();
|
||||
delete m_fileStream; // delete closes the stream.
|
||||
m_fileStream = NULL;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mdb_err
|
||||
nsIMdbStore::ReadAll(nsIMdbEnv* ev)
|
||||
{
|
||||
ReadTokenList();
|
||||
ReadTableList();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const char *kStartTokenList = "token list";
|
||||
const char *kEndTokenList = "end token list";
|
||||
|
||||
mdb_err nsIMdbStore::WriteTokenList()
|
||||
{
|
||||
*m_fileStream << kStartTokenList;
|
||||
*m_fileStream << LINEBREAK;
|
||||
PRInt32 i;
|
||||
|
||||
for (i = 0; i < m_tokenStrings.Count(); i++)
|
||||
{
|
||||
nsString outputNSString;
|
||||
char *outputString;
|
||||
m_tokenStrings.StringAt(i, outputNSString);
|
||||
outputString = outputNSString.ToNewCString();
|
||||
|
||||
*m_fileStream << outputString;
|
||||
delete [] outputString;
|
||||
*m_fileStream << LINEBREAK;
|
||||
}
|
||||
*m_fileStream << kEndTokenList;
|
||||
*m_fileStream << LINEBREAK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// read in the token strings.
|
||||
mdb_err nsIMdbStore::ReadTokenList()
|
||||
{
|
||||
char readlineBuffer[100];
|
||||
|
||||
m_tokenStrings.Clear();
|
||||
|
||||
m_fileStream->readline(readlineBuffer, sizeof(readlineBuffer));
|
||||
if (strcmp(readlineBuffer, kStartTokenList))
|
||||
return -1;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
if (m_fileStream->eof())
|
||||
break;
|
||||
|
||||
m_fileStream->readline(readlineBuffer, sizeof(readlineBuffer));
|
||||
|
||||
if (!strcmp(readlineBuffer, kEndTokenList))
|
||||
break;
|
||||
|
||||
nsString unicodeStr(readlineBuffer);
|
||||
m_tokenStrings.AppendString(unicodeStr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *kStartTableList = "table list";
|
||||
const char *kEndTableList = "end table list";
|
||||
|
||||
mdb_err nsIMdbStore::WriteTableList()
|
||||
{
|
||||
*m_fileStream << kStartTableList;
|
||||
*m_fileStream << LINEBREAK;
|
||||
|
||||
PRInt32 i;
|
||||
|
||||
*m_fileStream << (long) m_tables.Count();
|
||||
*m_fileStream << LINEBREAK;
|
||||
for (i = 0; i < m_tables.Count(); i++)
|
||||
{
|
||||
nsIMdbTable *table = (nsIMdbTable *) m_tables.ElementAt(i);
|
||||
table->Write();
|
||||
}
|
||||
*m_fileStream << kEndTableList;
|
||||
*m_fileStream << LINEBREAK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbStore::ReadTableList()
|
||||
{
|
||||
char readlineBuffer[100];
|
||||
|
||||
m_tables.Clear();
|
||||
|
||||
m_fileStream->readline(readlineBuffer, sizeof(readlineBuffer));
|
||||
if (strcmp(readlineBuffer, kStartTableList))
|
||||
return -1;
|
||||
|
||||
m_fileStream->readline(readlineBuffer, sizeof(readlineBuffer));
|
||||
PRInt32 numTables = atoi(readlineBuffer);
|
||||
|
||||
for (PRInt32 i = 0; i < numTables; i++)
|
||||
{
|
||||
nsIMdbTable *table = new nsIMdbTable(this, /* we don't know the kind yet*/ 0);
|
||||
if (table)
|
||||
{
|
||||
m_tables.AppendElement(table);
|
||||
table->Read();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbStore::NewTable( // make one new table of specific type
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_scope inRowScope, // row scope for row ids
|
||||
mdb_kind inTableKind, // the type of table to access
|
||||
mdb_bool inMustBeUnique, // whether store can hold only one of these
|
||||
nsIMdbTable** acqTable) // acquire scoped collection of rows
|
||||
|
||||
{
|
||||
*acqTable = new nsIMdbTable(this, inTableKind);
|
||||
if (*acqTable == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
(*acqTable)->m_Oid.mOid_Id = 1;
|
||||
(*acqTable)->m_Oid.mOid_Scope = inRowScope;
|
||||
PRBool inserted = m_tables.AppendElement(*acqTable);
|
||||
return inserted ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsIMdbPort::nsIMdbPort() : m_backingFile("")
|
||||
{
|
||||
}
|
||||
|
||||
mdb_err nsIMdbPort::GetTable( // access one table with specific oid
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbOid* inOid, // hypothetical table oid
|
||||
nsIMdbTable** acqTable)
|
||||
{
|
||||
mdb_err result = -1;
|
||||
nsIMdbTable *retTable = NULL;
|
||||
*acqTable = NULL;
|
||||
for (PRInt32 i = 0; i < m_tables.Count(); i++)
|
||||
{
|
||||
nsIMdbTable *table = (nsIMdbTable *) m_tables[i];
|
||||
if (table->m_Oid.mOid_Id == inOid->mOid_Id
|
||||
&& table->m_Oid.mOid_Scope == inOid->mOid_Scope)
|
||||
{
|
||||
retTable = table;
|
||||
table->AddRef();
|
||||
*acqTable = table;
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbPort::StringToToken ( nsIMdbEnv* ev, // context
|
||||
const char* inTokenName, // Latin1 string to tokenize if possible
|
||||
mdb_token* outToken)
|
||||
{
|
||||
nsString unicodeStr(inTokenName);
|
||||
PRInt32 tokenPos = m_tokenStrings.IndexOf(unicodeStr);
|
||||
if (tokenPos >= 0)
|
||||
{
|
||||
*outToken = tokenPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_tokenStrings.AppendString(unicodeStr);
|
||||
*outToken = m_tokenStrings.Count() - 1;
|
||||
}
|
||||
// *outToken = (mdb_token) inTokenName;
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbPort::GetTableKind (
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_scope inRowScope, // row scope for row ids
|
||||
mdb_kind inTableKind, // the type of table to access
|
||||
mdb_count* outTableCount, // current number of such tables
|
||||
mdb_bool* outMustBeUnique, // whether port can hold only one of these
|
||||
nsIMdbTable** acqTable)
|
||||
{
|
||||
nsIMdbTable *retTable = NULL;
|
||||
|
||||
mdb_count tableCount = 0;
|
||||
for (PRInt32 i = 0; i < m_tables.Count(); i++)
|
||||
{
|
||||
nsIMdbTable *table = (nsIMdbTable *) m_tables[i];
|
||||
if (table->m_kind == inTableKind)
|
||||
{
|
||||
tableCount++;
|
||||
if (!*acqTable)
|
||||
{
|
||||
retTable = table;
|
||||
table->AddRef();
|
||||
*acqTable = table;
|
||||
}
|
||||
}
|
||||
}
|
||||
*outTableCount = tableCount;
|
||||
|
||||
if (! retTable )
|
||||
*acqTable = new nsIMdbTable (this, inTableKind);
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsIMdbTable::nsIMdbTable(nsIMdbPort* owner, mdb_kind kind)
|
||||
{
|
||||
m_owningPort = owner;
|
||||
m_kind = kind;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbTable::HasOid( // test for the table position of a row member
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbOid* inOid, // row to find in table
|
||||
mdb_pos* outPos)
|
||||
{
|
||||
mdb_pos iteratePos;
|
||||
*outPos = -1;
|
||||
|
||||
for (iteratePos = 0; iteratePos < m_rows.Count(); iteratePos++)
|
||||
{
|
||||
nsIMdbRow *row = (nsIMdbRow *) m_rows.ElementAt(iteratePos);
|
||||
if (row && row->m_oid.mOid_Id == inOid->mOid_Id)
|
||||
{
|
||||
*outPos = iteratePos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbTable::GetTableRowCursor( // make a cursor, starting iteration at inRowPos
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_pos inRowPos, // zero-based ordinal position of row in table
|
||||
nsIMdbTableRowCursor** acqCursor)
|
||||
{
|
||||
*acqCursor = new nsIMdbTableRowCursor;
|
||||
if (*acqCursor == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
(*acqCursor)->SetTable(ev, this);
|
||||
(*acqCursor)->m_pos = inRowPos;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbTable::Write()
|
||||
|
||||
{
|
||||
nsIOFileStream *stream = m_owningPort->m_fileStream;
|
||||
*stream << m_kind;
|
||||
*stream << ",";
|
||||
*stream << m_Oid.mOid_Id;
|
||||
*stream << ",";
|
||||
*stream << m_Oid.mOid_Scope;
|
||||
*stream << ",";
|
||||
*stream << (long) m_rows.Count();
|
||||
*stream << LINEBREAK;
|
||||
|
||||
PRInt32 i;
|
||||
|
||||
for (i = 0; i < m_rows.Count(); i++)
|
||||
{
|
||||
nsIMdbRow *row = (nsIMdbRow *) m_rows.ElementAt(i);
|
||||
if (row)
|
||||
row->Write(stream);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbTable::Read()
|
||||
|
||||
{
|
||||
char lineBuf[100];
|
||||
|
||||
nsIOFileStream *stream = m_owningPort->m_fileStream;
|
||||
|
||||
stream->readline(lineBuf, sizeof(lineBuf));
|
||||
m_kind = atoi(lineBuf);
|
||||
|
||||
char *p;
|
||||
for (p = lineBuf; *p; p++)
|
||||
{
|
||||
if (*p == ',')
|
||||
{
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
PRInt32 oid = atoi(p);
|
||||
m_Oid.mOid_Id = oid;
|
||||
|
||||
for (p; *p; p++)
|
||||
{
|
||||
if (*p == ',')
|
||||
{
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 scope = atoi(p);
|
||||
m_Oid.mOid_Scope = scope;
|
||||
|
||||
for (p; *p; p++)
|
||||
{
|
||||
if (*p == ',')
|
||||
break;
|
||||
}
|
||||
|
||||
PRInt32 numRows = atoi(p + 1);
|
||||
|
||||
for (PRInt32 i = 0; i < numRows; i++)
|
||||
{
|
||||
nsIMdbRow *row = new nsIMdbRow(this, m_owningPort);
|
||||
if (row)
|
||||
{
|
||||
m_rows.AppendElement(row);
|
||||
row->Read(stream);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbTableRowCursor::SetTable(nsIMdbEnv* ev, nsIMdbTable* ioTable)
|
||||
{
|
||||
m_table = ioTable;
|
||||
m_pos = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbTableRowCursor::NextRow( // get row cells from table for cells already in row
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbRow** acqRow, // acquire next row in table
|
||||
mdb_pos* outRowPos)
|
||||
{
|
||||
if (m_pos < 0)
|
||||
m_pos = 0;
|
||||
|
||||
*outRowPos = m_pos;
|
||||
*acqRow = (nsIMdbRow *) m_table->m_rows.ElementAt(m_pos++);
|
||||
return *acqRow != nsnull ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbTable::CutRow ( // make sure the row with inOid is not a member
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbRow* ioRow)
|
||||
{
|
||||
PRBool found = m_rows.RemoveElement(ioRow);
|
||||
if (found)
|
||||
ioRow->Release(); // is this right? Who deletes the row?
|
||||
|
||||
return found ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbStore::NewRowWithOid (nsIMdbEnv* ev, // new row w/ caller assigned oid
|
||||
const mdbOid* inOid, // caller assigned oid
|
||||
nsIMdbRow** acqRow)
|
||||
{
|
||||
*acqRow = new nsIMdbRow (NULL, this);
|
||||
(*acqRow)->m_oid = *inOid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbTable::AddRow ( // make sure the row with inOid is a table member
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbRow* ioRow)
|
||||
{
|
||||
PRBool inserted = m_rows.AppendElement(ioRow);
|
||||
ioRow->m_owningTable = this;
|
||||
return inserted ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsIMdbRow::nsIMdbRow(nsIMdbTable *owningTable, nsIMdbPort *owningPort)
|
||||
{
|
||||
m_owningTable = owningTable;
|
||||
m_owningPort = owningPort;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbRow::AddColumn( // make sure a particular column is inside row
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column inColumn, // column to add
|
||||
const mdbYarn* inYarn)
|
||||
{
|
||||
char *columnName;
|
||||
|
||||
if (m_owningPort)
|
||||
{
|
||||
nsString columnStr;
|
||||
|
||||
m_owningPort->m_tokenStrings.StringAt(inColumn, columnStr);
|
||||
|
||||
columnName = columnStr.ToNewCString();
|
||||
#ifdef DEBUG_DB
|
||||
printf("adding column %s : %s\n", columnName, inYarn->mYarn_Buf);
|
||||
#endif
|
||||
delete [] columnName;
|
||||
}
|
||||
mdbCellImpl newCell;
|
||||
nsIMdbCell *existingCell = NULL;
|
||||
|
||||
newCell.m_column = inColumn;
|
||||
GetCell(ev, inColumn, &existingCell);
|
||||
if (existingCell)
|
||||
{
|
||||
mdbCellImpl *evilCastCell = (mdbCellImpl *) existingCell;
|
||||
PR_FREEIF(evilCastCell->m_cellValue);
|
||||
evilCastCell->m_cellValue = PL_strdup((const char *) inYarn->mYarn_Buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
mdbCellImpl *cellToAdd = new mdbCellImpl;
|
||||
cellToAdd->m_column = inColumn;
|
||||
cellToAdd->m_cellValue = PL_strdup((const char *)inYarn->mYarn_Buf);
|
||||
m_cells.AppendCell(*cellToAdd);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbRow::GetCell( // find a cell in this row
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column inColumn, // column to find
|
||||
nsIMdbCell** acqCell)
|
||||
{
|
||||
mdbCellImpl newCell;
|
||||
|
||||
newCell.m_column = inColumn;
|
||||
PRInt32 cellIndex = m_cells.IndexOf(newCell);
|
||||
if (cellIndex < 0)
|
||||
*acqCell = NULL;
|
||||
else
|
||||
*acqCell = m_cells.CellAt(cellIndex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbRow::Write(nsIOFileStream *stream)
|
||||
{
|
||||
mdb_pos iteratePos;
|
||||
|
||||
// write out the number of cells.
|
||||
*stream << (long) m_cells.Count();
|
||||
*stream << ",";
|
||||
*stream << (long) m_oid.mOid_Id;
|
||||
*stream << LINEBREAK;
|
||||
|
||||
for (iteratePos = 0; iteratePos < m_cells.Count(); iteratePos++)
|
||||
{
|
||||
mdbCellImpl *cell = (mdbCellImpl *) m_cells.ElementAt(iteratePos);
|
||||
if (cell)
|
||||
cell->Write(stream);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbRow::Read(nsIOFileStream *stream)
|
||||
{
|
||||
char line[50];
|
||||
|
||||
stream->readline(line, sizeof(line));
|
||||
|
||||
PRInt32 numCells = atoi(line);
|
||||
|
||||
char *p;
|
||||
for (p = line; *p; p++)
|
||||
{
|
||||
if (*p == ',')
|
||||
break;
|
||||
}
|
||||
|
||||
m_oid.mOid_Id = atoi(p + 1);
|
||||
#ifdef DEBUG_DB
|
||||
printf("reading row id = %d\n", m_oid.mOid_Id);
|
||||
#endif
|
||||
for (PRInt32 i = 0; i < numCells; i++)
|
||||
{
|
||||
mdbCellImpl *cell = new mdbCellImpl;
|
||||
if (cell)
|
||||
{
|
||||
cell->Read(stream);
|
||||
m_cells.AppendCell(*cell);
|
||||
#ifdef DEBUG_DB
|
||||
nsString columnStr;
|
||||
|
||||
m_owningPort->m_tokenStrings.StringAt(cell->m_column, columnStr);
|
||||
char *column = columnStr.ToNewCString();
|
||||
printf("column = %s value = %s\n", (column) ? column : "", cell->m_cellValue);
|
||||
delete [] column;
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbCollection::GetOid (nsIMdbEnv* ev,
|
||||
mdbOid* outOid)
|
||||
{
|
||||
*outOid = m_Oid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbTableRowCursor::NextRowOid ( // get row id of next row in the table
|
||||
nsIMdbEnv* ev, // context
|
||||
mdbOid* outOid, // out row oid
|
||||
mdb_pos* outRowPos)
|
||||
{
|
||||
nsIMdbRow *curRow = NULL;
|
||||
if (m_pos < 0)
|
||||
m_pos = 0;
|
||||
|
||||
*outRowPos = m_pos;
|
||||
if (m_table)
|
||||
curRow = (nsIMdbRow *) m_table->m_rows.ElementAt(m_pos++);
|
||||
if (curRow)
|
||||
*outOid = curRow->m_oid;
|
||||
else
|
||||
*outRowPos = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbBlob::AliasYarn(nsIMdbEnv* ev,
|
||||
mdbYarn* outYarn)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbObject::CutStrongRef(nsIMdbEnv* ev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbFactory::MakeEnv(nsIMdbHeap* ioHeap, nsIMdbEnv** acqEnv)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsIMdbThumb::nsIMdbThumb() : m_backingFile("")
|
||||
{
|
||||
m_fileStream = NULL;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbThumb::DoMore(nsIMdbEnv* ev,
|
||||
mdb_count* outTotal, // total somethings to do in operation
|
||||
mdb_count* outCurrent, // subportion of total completed so far
|
||||
mdb_bool* outDone, // is operation finished?
|
||||
mdb_bool* outBroken // is operation irreparably dead and broken?
|
||||
)
|
||||
{
|
||||
*outDone = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err nsIMdbFactory::OpenFileStore(class nsIMdbEnv *, nsIMdbHeap* , char const *fileName,struct mdbOpenPolicy const *,class nsIMdbThumb **retThumb)
|
||||
{
|
||||
|
||||
*retThumb = new nsIMdbThumb;
|
||||
nsFilePath filePath(fileName);
|
||||
(*retThumb)->m_fileStream = new nsIOFileStream(nsFileSpec(filePath));
|
||||
(*retThumb)->m_backingFile = fileName;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdbCellImpl::mdbCellImpl()
|
||||
{
|
||||
m_cellValue = NULL;
|
||||
m_column = 0;
|
||||
}
|
||||
|
||||
mdbCellImpl::mdbCellImpl(const mdbCellImpl &anotherCell)
|
||||
{
|
||||
m_column = anotherCell.m_column;
|
||||
m_cellValue = anotherCell.m_cellValue;
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
mdbCellImpl&
|
||||
mdbCellImpl::operator=(const mdbCellImpl& other)
|
||||
{
|
||||
m_column = other.m_column;
|
||||
m_cellValue = PL_strdup((const char *) other.m_cellValue);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PRBool mdbCellImpl::Equals(const mdbCellImpl& other)
|
||||
{
|
||||
// I think equality is just whether the columns are the same...
|
||||
return (m_column == other.m_column);
|
||||
}
|
||||
|
||||
mdb_err mdbCellImpl::Write(nsIOFileStream *stream)
|
||||
{
|
||||
*stream << m_column;
|
||||
*stream << "=";
|
||||
if (m_cellValue)
|
||||
*stream << m_cellValue;
|
||||
*stream << LINEBREAK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const int kLineBufLength = 1000;
|
||||
|
||||
mdb_err mdbCellImpl::Read(nsIOFileStream *stream)
|
||||
{
|
||||
char line[kLineBufLength];
|
||||
|
||||
stream->readline(line, kLineBufLength);
|
||||
m_column = atoi(line);
|
||||
|
||||
char *p;
|
||||
for (p = line; *p; p++)
|
||||
{
|
||||
if (*p == '=')
|
||||
break;
|
||||
}
|
||||
m_cellValue = strdup(p + 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdb_err mdbCellImpl::AliasYarn(nsIMdbEnv* ev,
|
||||
mdbYarn* outYarn)
|
||||
{
|
||||
outYarn->mYarn_Buf = m_cellValue;
|
||||
outYarn->mYarn_Size = PL_strlen(m_cellValue) + 1;
|
||||
outYarn->mYarn_Fill = outYarn->mYarn_Size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// MDBCellArray
|
||||
|
||||
MDBCellArray::MDBCellArray(void)
|
||||
: nsVoidArray()
|
||||
{
|
||||
}
|
||||
|
||||
MDBCellArray::~MDBCellArray(void)
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
MDBCellArray&
|
||||
MDBCellArray::operator=(const MDBCellArray& other)
|
||||
{
|
||||
if (nsnull != mArray) {
|
||||
delete mArray;
|
||||
}
|
||||
PRInt32 otherCount = other.mCount;
|
||||
mArraySize = otherCount;
|
||||
mCount = otherCount;
|
||||
if (0 < otherCount) {
|
||||
mArray = new void*[otherCount];
|
||||
while (0 <= --otherCount) {
|
||||
mdbCellImpl* otherCell = (mdbCellImpl*)(other.mArray[otherCount]);
|
||||
mArray[otherCount] = new mdbCellImpl(*otherCell);
|
||||
}
|
||||
} else {
|
||||
mArray = nsnull;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void
|
||||
MDBCellArray::CellAt(PRInt32 aIndex, mdbCellImpl& aCell) const
|
||||
{
|
||||
mdbCellImpl* cell = (mdbCellImpl*)nsVoidArray::ElementAt(aIndex);
|
||||
if (nsnull != cell) {
|
||||
aCell = *cell;
|
||||
}
|
||||
else {
|
||||
aCell.m_cellValue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
mdbCellImpl*
|
||||
MDBCellArray::CellAt(PRInt32 aIndex) const
|
||||
{
|
||||
return (mdbCellImpl*)nsVoidArray::ElementAt(aIndex);
|
||||
}
|
||||
|
||||
PRInt32
|
||||
MDBCellArray::IndexOf(const mdbCellImpl& aPossibleCell) const
|
||||
{
|
||||
void** ap = mArray;
|
||||
void** end = ap + mCount;
|
||||
while (ap < end) {
|
||||
mdbCellImpl* cell = (mdbCellImpl*)*ap;
|
||||
if (cell->Equals(aPossibleCell)) {
|
||||
return ap - mArray;
|
||||
}
|
||||
ap++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
MDBCellArray::InsertCellAt(const mdbCellImpl& aCell, PRInt32 aIndex)
|
||||
{
|
||||
mdbCellImpl* cell = new mdbCellImpl(aCell);
|
||||
if (nsVoidArray::InsertElementAt(cell, aIndex)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
delete cell;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
MDBCellArray::ReplaceCellAt(const mdbCellImpl& aCell, PRInt32 aIndex)
|
||||
{
|
||||
mdbCellImpl* cell = (mdbCellImpl*)nsVoidArray::ElementAt(aIndex);
|
||||
if (nsnull != cell) {
|
||||
*cell = aCell;
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
MDBCellArray::RemoveCell(const mdbCellImpl& aCell)
|
||||
{
|
||||
PRInt32 index = IndexOf(aCell);
|
||||
if (-1 < index) {
|
||||
return RemoveCellAt(index);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool MDBCellArray::RemoveCellAt(PRInt32 aIndex)
|
||||
{
|
||||
mdbCellImpl* cell = CellAt(aIndex);
|
||||
if (nsnull != cell) {
|
||||
nsVoidArray::RemoveElementAt(aIndex);
|
||||
delete cell;
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
MDBCellArray::Clear(void)
|
||||
{
|
||||
PRInt32 index = mCount;
|
||||
while (0 <= --index) {
|
||||
mdbCellImpl* cell = (mdbCellImpl*)mArray[index];
|
||||
delete cell;
|
||||
}
|
||||
nsVoidArray::Clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
MDBCellArray::EnumerateForwards(MDBCellArrayEnumFunc aFunc, void* aData)
|
||||
{
|
||||
PRInt32 index = -1;
|
||||
PRBool running = PR_TRUE;
|
||||
|
||||
while (running && (++index < mCount)) {
|
||||
running = (*aFunc)(*((mdbCellImpl*)mArray[index]), aData);
|
||||
}
|
||||
return running;
|
||||
}
|
||||
|
||||
PRBool
|
||||
MDBCellArray::EnumerateBackwards(MDBCellArrayEnumFunc aFunc, void* aData)
|
||||
{
|
||||
PRInt32 index = mCount;
|
||||
PRBool running = PR_TRUE;
|
||||
|
||||
while (running && (0 <= --index)) {
|
||||
running = (*aFunc)(*((mdbCellImpl*)mArray[index]), aData);
|
||||
}
|
||||
return running;
|
||||
}
|
||||
|
|
@ -290,7 +290,7 @@ void nsMailDatabase::UpdateFolderFlag(nsIMsgDBHdr *mailHdr, PRBool bSet,
|
|||
|
||||
// time to upate x-mozilla-status2
|
||||
position = fileStream->tell();
|
||||
fileStream->seek(position + LINEBREAK_LEN);
|
||||
fileStream->seek(position + MSG_LINEBREAK_LEN);
|
||||
if (fileStream->readline(buf, sizeof(buf)))
|
||||
{
|
||||
if (strncmp(buf, X_MOZILLA_STATUS2, X_MOZILLA_STATUS2_LEN) == 0 &&
|
||||
|
@ -300,7 +300,7 @@ void nsMailDatabase::UpdateFolderFlag(nsIMsgDBHdr *mailHdr, PRBool bSet,
|
|||
PRUint32 dbFlags;
|
||||
(void)mailHdr->GetFlags(&dbFlags);
|
||||
dbFlags &= (MSG_FLAG_MDN_REPORT_NEEDED | MSG_FLAG_MDN_REPORT_SENT | MSG_FLAG_TEMPLATE);
|
||||
fileStream->seek(position + LINEBREAK_LEN);
|
||||
fileStream->seek(position + MSG_LINEBREAK_LEN);
|
||||
PR_snprintf(buf, sizeof(buf), X_MOZILLA_STATUS2_FORMAT, dbFlags);
|
||||
fileStream->write(buf, PL_strlen(buf));
|
||||
}
|
||||
|
|
|
@ -2172,9 +2172,9 @@ void ParseOutgoingMessage::FinishHeader()
|
|||
{
|
||||
if (origPosition > 0 && !m_lastBodyLineEmpty)
|
||||
{
|
||||
len = XP_FileWrite (LINEBREAK, LINEBREAK_LEN, m_out_file);
|
||||
m_bytes_written += LINEBREAK_LEN;
|
||||
m_position += LINEBREAK_LEN;
|
||||
len = XP_FileWrite (MSG_LINEBREAK, MSG_LINEBREAK_LEN, m_out_file);
|
||||
m_bytes_written += MSG_LINEBREAK_LEN;
|
||||
m_position += MSG_LINEBREAK_LEN;
|
||||
}
|
||||
}
|
||||
nsParseMailMessageState::FinishHeader();
|
||||
|
@ -2222,7 +2222,7 @@ PRInt32 ParseOutgoingMessage::ParseFolderLine(const char *line, PRUint32 lineLen
|
|||
|
||||
if (m_newMsgHdr)
|
||||
m_newMsgHdr->SetStatusOffset(m_bytes_written);
|
||||
PR_snprintf(buf, sizeof(buf), X_MOZILLA_STATUS_FORMAT LINEBREAK, (m_newMsgHdr) ? m_newMsgHdr->GetFlags() & ~MSG_FLAG_RUNTIME_ONLY : 0);
|
||||
PR_snprintf(buf, sizeof(buf), X_MOZILLA_STATUS_FORMAT MSG_LINEBREAK, (m_newMsgHdr) ? m_newMsgHdr->GetFlags() & ~MSG_FLAG_RUNTIME_ONLY : 0);
|
||||
len = strlen(buf);
|
||||
res = XP_FileWrite(buf, len, m_out_file);
|
||||
if (res < len)
|
||||
|
@ -2233,7 +2233,7 @@ PRInt32 ParseOutgoingMessage::ParseFolderLine(const char *line, PRUint32 lineLen
|
|||
|
||||
MessageDB::ConvertDBFlagsToPublicFlags(&dbFlags);
|
||||
dbFlags &= (MSG_FLAG_MDN_REPORT_NEEDED | MSG_FLAG_MDN_REPORT_SENT | MSG_FLAG_TEMPLATE);
|
||||
PR_snprintf(buf, sizeof(buf), X_MOZILLA_STATUS2_FORMAT LINEBREAK, dbFlags);
|
||||
PR_snprintf(buf, sizeof(buf), X_MOZILLA_STATUS2_FORMAT MSG_LINEBREAK, dbFlags);
|
||||
len = strlen(buf);
|
||||
res = XP_FileWrite(buf, len, m_out_file);
|
||||
if (res < len)
|
||||
|
|
|
@ -260,7 +260,7 @@ net_pop3_write_mapper(PLHashEntry* he, PRIntn index, void* arg)
|
|||
PR_ASSERT((he->value == ((void *) (int) KEEP)) ||
|
||||
(he->value == ((void *) (int) DELETE_CHAR)) ||
|
||||
(he->value == ((void *) (int) TOO_BIG)));
|
||||
char* tmpBuffer = PR_smprintf("%c %s" LINEBREAK, (char)(long)he->value, (char*)
|
||||
char* tmpBuffer = PR_smprintf("%c %s" MSG_LINEBREAK, (char)(long)he->value, (char*)
|
||||
he->key);
|
||||
PR_ASSERT(tmpBuffer);
|
||||
*file << tmpBuffer;
|
||||
|
@ -278,8 +278,8 @@ net_pop3_write_state(Pop3UidlHost* host, const char* mailDirectory)
|
|||
|
||||
nsOutputFileStream outFileStream(fileSpec, PR_WRONLY | PR_CREATE_FILE |
|
||||
PR_TRUNCATE);
|
||||
char* tmpBuffer = PR_smprintf("%s", "# Netscape POP3 State File" LINEBREAK
|
||||
"# This is a generated file! Do not edit." LINEBREAK LINEBREAK);
|
||||
char* tmpBuffer = PR_smprintf("%s", "# Netscape POP3 State File" MSG_LINEBREAK
|
||||
"# This is a generated file! Do not edit." MSG_LINEBREAK MSG_LINEBREAK);
|
||||
PR_ASSERT(tmpBuffer);
|
||||
|
||||
outFileStream << tmpBuffer;
|
||||
|
@ -294,7 +294,7 @@ net_pop3_write_state(Pop3UidlHost* host, const char* mailDirectory)
|
|||
outFileStream << host->host;
|
||||
outFileStream << " ";
|
||||
outFileStream << host->user;
|
||||
outFileStream << LINEBREAK;
|
||||
outFileStream << MSG_LINEBREAK;
|
||||
PL_HashTableEnumerateEntries(host->hash, net_pop3_write_mapper, (void *)&outFileStream);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,24 +25,6 @@
|
|||
#include <time.h>
|
||||
#include "nsParseMailbox.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
/* ducarroz: we should solve this redefinition problem! */
|
||||
# undef LINEBREAK
|
||||
# undef LINEBREAK_LEN
|
||||
# define LINEBREAK "\015"
|
||||
# define LINEBREAK_LEN 1
|
||||
#else
|
||||
# ifdef XP_WIN
|
||||
# define LINEBREAK "\015\012"
|
||||
# define LINEBREAK_LEN 2
|
||||
# else
|
||||
# ifdef XP_UNIX
|
||||
# define LINEBREAK "\012"
|
||||
# define LINEBREAK_LEN 1
|
||||
# endif /* XP_UNIX */
|
||||
# endif /* XP_WIN */
|
||||
#endif /* XP_MAC */
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsPop3Sink, nsIPop3Sink::GetIID());
|
||||
|
||||
nsPop3Sink::nsPop3Sink()
|
||||
|
@ -229,13 +211,6 @@ nsPop3Sink::GetPopServer(nsIPop3IncomingServer* *server)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifndef CR
|
||||
#define CR '\r'
|
||||
#define LF '\n'
|
||||
#define LINEBREAK "\r\n"
|
||||
#define LINEBREAK_LEN 2
|
||||
#endif
|
||||
|
||||
char*
|
||||
nsPop3Sink::GetDummyEnvelope(void)
|
||||
{
|
||||
|
@ -253,7 +228,7 @@ nsPop3Sink::GetDummyEnvelope(void)
|
|||
strftime("... %c ...") is no good, because it is localized. */
|
||||
PL_strcpy(result, "From - ");
|
||||
PL_strcpy(result + 7, ct);
|
||||
PL_strcpy(result + 7 + 24, LINEBREAK);
|
||||
PL_strcpy(result + 7 + 24, MSG_LINEBREAK);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -312,9 +287,9 @@ nsresult nsPop3Sink::WriteLineToMailbox(char *buffer)
|
|||
nsresult
|
||||
nsPop3Sink::IncorporateComplete(void* closure)
|
||||
{
|
||||
WriteLineToMailbox(LINEBREAK);
|
||||
WriteLineToMailbox(MSG_LINEBREAK);
|
||||
// if (m_outFileStream)
|
||||
// *m_outFileStream << LINEBREAK;
|
||||
// *m_outFileStream << MSG_LINEBREAK;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Incorporate message complete.\n");
|
||||
|
@ -325,7 +300,7 @@ nsPop3Sink::IncorporateComplete(void* closure)
|
|||
nsresult
|
||||
nsPop3Sink::IncorporateAbort(void* closure, PRInt32 status)
|
||||
{
|
||||
WriteLineToMailbox(LINEBREAK);
|
||||
WriteLineToMailbox(MSG_LINEBREAK);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Incorporate message abort.\n");
|
||||
|
|
|
@ -653,7 +653,7 @@ nsNNTPHost::RememberLine(char* line)
|
|||
}
|
||||
if (!new_data) return MK_OUT_OF_MEMORY;
|
||||
PL_strcpy(new_data, line);
|
||||
PL_strcat(new_data, LINEBREAK);
|
||||
PL_strcat(new_data, MSG_LINEBREAK);
|
||||
|
||||
m_optionLines = new_data;
|
||||
|
||||
|
@ -954,7 +954,7 @@ nsNNTPHost::WriteNewsrc()
|
|||
|
||||
PRBool isSubscribed=PR_FALSE;
|
||||
rv = newsgroup->GetSubscribed(&isSubscribed);
|
||||
line = PR_smprintf("%s%s %s" LINEBREAK,
|
||||
line = PR_smprintf("%s%s %s" MSG_LINEBREAK,
|
||||
newsgroupName,
|
||||
isSubscribed ? ":" : "!", str);
|
||||
if (!line) {
|
||||
|
@ -1198,22 +1198,22 @@ int
|
|||
nsNNTPHost::CreateFileHeader()
|
||||
{
|
||||
PR_snprintf(m_block, m_blockSize,
|
||||
"# Netscape newshost information file." LINEBREAK
|
||||
"# This is a generated file! Do not edit." LINEBREAK
|
||||
"" LINEBREAK
|
||||
"version=1" LINEBREAK
|
||||
"newsrcname=%s" LINEBREAK
|
||||
"# Netscape newshost information file." MSG_LINEBREAK
|
||||
"# This is a generated file! Do not edit." MSG_LINEBREAK
|
||||
"" MSG_LINEBREAK
|
||||
"version=1" MSG_LINEBREAK
|
||||
"newsrcname=%s" MSG_LINEBREAK
|
||||
#ifdef OSF1
|
||||
"lastgroupdate=%08x" LINEBREAK
|
||||
"firstnewdate=%08x" LINEBREAK
|
||||
"uniqueid=%08x" LINEBREAK
|
||||
"lastgroupdate=%08x" MSG_LINEBREAK
|
||||
"firstnewdate=%08x" MSG_LINEBREAK
|
||||
"uniqueid=%08x" MSG_LINEBREAK
|
||||
#else
|
||||
"lastgroupdate=%08lx" LINEBREAK
|
||||
"firstnewdate=%08lx" LINEBREAK
|
||||
"uniqueid=%08lx" LINEBREAK
|
||||
"lastgroupdate=%08lx" MSG_LINEBREAK
|
||||
"firstnewdate=%08lx" MSG_LINEBREAK
|
||||
"uniqueid=%08lx" MSG_LINEBREAK
|
||||
#endif
|
||||
"pushauth=%1x" LINEBREAK
|
||||
"" LINEBREAK
|
||||
"pushauth=%1x" MSG_LINEBREAK
|
||||
"" MSG_LINEBREAK
|
||||
"begingroups",
|
||||
m_filename, (long) m_lastGroupUpdate, (long) m_firstnewdate, (long) m_uniqueId,
|
||||
m_pushAuth);
|
||||
|
@ -1326,9 +1326,9 @@ nsNNTPHost::SaveHostInfo()
|
|||
position += length;
|
||||
m_fileStart = position;
|
||||
m_groupTree->SetFileOffset(m_fileStart);
|
||||
status = XP_FileWrite(LINEBREAK, LINEBREAK_LEN, out);
|
||||
status = XP_FileWrite(MSG_LINEBREAK, MSG_LINEBREAK_LEN, out);
|
||||
if (status < 0) goto FAIL;
|
||||
position += LINEBREAK_LEN;
|
||||
position += MSG_LINEBREAK_LEN;
|
||||
|
||||
blockcomma = NULL;
|
||||
if (!m_inhaled) {
|
||||
|
@ -1370,9 +1370,9 @@ nsNNTPHost::SaveHostInfo()
|
|||
status = XP_FileWrite(m_block, length, out);
|
||||
if (status < 0) goto FAIL;
|
||||
position += length;
|
||||
status = XP_FileWrite(LINEBREAK, LINEBREAK_LEN, out);
|
||||
status = XP_FileWrite(MSG_LINEBREAK, MSG_LINEBREAK_LEN, out);
|
||||
if (status < 0) goto FAIL;
|
||||
position += LINEBREAK_LEN;
|
||||
position += MSG_LINEBREAK_LEN;
|
||||
m_block[0] = '\0';
|
||||
XP_FileReadLine(m_block, m_blockSize, in);
|
||||
blockcomma = PL_strchr(m_block, ',');
|
||||
|
@ -1407,9 +1407,9 @@ nsNNTPHost::SaveHostInfo()
|
|||
status = XP_FileWrite(m_block, length, out);
|
||||
if (status < 0) goto FAIL;
|
||||
position += length;
|
||||
status = XP_FileWrite(LINEBREAK, LINEBREAK_LEN, out);
|
||||
status = XP_FileWrite(MSG_LINEBREAK, MSG_LINEBREAK_LEN, out);
|
||||
if (status < 0) goto FAIL;
|
||||
position += LINEBREAK_LEN;
|
||||
position += MSG_LINEBREAK_LEN;
|
||||
m_block[0] = '\0';
|
||||
} while (XP_FileReadLine(m_block, m_blockSize, in) && *m_block);
|
||||
}
|
||||
|
@ -2660,8 +2660,8 @@ RESTART:
|
|||
if (!ptr2) {
|
||||
// What a pain. We found the right place, but the rest of
|
||||
// the line is off the end of the buffer.
|
||||
if (offset > m_blockStart + LINEBREAK_LEN) {
|
||||
m_blockStart = offset - LINEBREAK_LEN;
|
||||
if (offset > m_blockStart + MSG_LINEBREAK_LEN) {
|
||||
m_blockStart = offset - MSG_LINEBREAK_LEN;
|
||||
goto RELOAD;
|
||||
}
|
||||
// We couldn't find it, even though we're at the beginning
|
||||
|
@ -2736,7 +2736,7 @@ nsNNTPHost::LoadSingleEntry(nsMsgGroupRecord* parent, char* groupname,
|
|||
|
||||
while (!result && comp != 0 && min < max) {
|
||||
PRInt32 mid = (min + max) / 2;
|
||||
m_blockStart = mid - LINEBREAK_LEN;
|
||||
m_blockStart = mid - MSG_LINEBREAK_LEN;
|
||||
XP_FileSeek(m_groupFile, m_blockStart, SEEK_SET);
|
||||
int length = XP_FileRead(m_block, m_blockSize, m_groupFile);
|
||||
if (length < 0) length = 0;
|
||||
|
|
|
@ -2038,7 +2038,7 @@ PRInt32 nsNNTPProtocol::ReadArticle(nsIInputStream * inputStream, PRUint32 lengt
|
|||
the local system will convert that to the local line
|
||||
terminator as it is read.
|
||||
*/
|
||||
PL_strcat (outputBuffer, LINEBREAK);
|
||||
PL_strcat (outputBuffer, MSG_LINEBREAK);
|
||||
/* Don't send content-type to mime parser if we're doing a cancel
|
||||
because it confuses mime parser into not parsing.
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче