mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 132180 eliminate nsFileSpec in address book. Patch 4 - remove unused code from vcard functions that also happens to include file spec related code. r=dmose,sr=bienvenu
This commit is contained in:
parent
38754de3cc
commit
2dfddb5beb
@ -93,8 +93,10 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
|
||||
*/
|
||||
#include "nsVCard.h"
|
||||
#include "nsVCardObj.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "prprf.h"
|
||||
#include "nscore.h"
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef lint
|
||||
char yysccsid[] = "@(#)yaccpar 1.4 (Berkeley) 02/25/90";
|
||||
@ -223,7 +225,6 @@ static void lexPushMode(enum LexMode mode);
|
||||
static void enterProps(const char *s);
|
||||
static void enterAttr(const char *s1, const char *s2);
|
||||
static void enterValues(const char *value);
|
||||
static void mime_error_(char *s);
|
||||
|
||||
/*#line 250 "vcc.y" */
|
||||
typedef union {
|
||||
@ -533,7 +534,6 @@ static void enterAttr(const char *s1, const char *s2)
|
||||
|
||||
struct LexBuf {
|
||||
/* input */
|
||||
nsInputFileStream *inputFile;
|
||||
char *inputString;
|
||||
unsigned long curPos;
|
||||
unsigned long inputLen;
|
||||
@ -586,17 +586,8 @@ static int lexGetc_()
|
||||
return EOF;
|
||||
else if (lexBuf.inputString)
|
||||
return *(lexBuf.inputString + lexBuf.curPos++);
|
||||
else
|
||||
{
|
||||
char c;
|
||||
nsresult status;
|
||||
|
||||
status = lexBuf.inputFile->read(&c, 1);
|
||||
if (status != 1)
|
||||
return -1;
|
||||
else
|
||||
return c;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int lexGeta()
|
||||
@ -883,7 +874,7 @@ static int match_begin_name(int end) {
|
||||
#pragma require_prototypes off
|
||||
#endif
|
||||
|
||||
void initLex(const char *inputstring, unsigned long inputlen, nsInputFileStream *inputFile)
|
||||
void initLex(const char *inputstring, unsigned long inputlen)
|
||||
{
|
||||
/* initialize lex mode stack */
|
||||
lexBuf.lexModeStack[lexBuf.lexModeStackTop=0] = L_NORMAL;
|
||||
@ -892,7 +883,6 @@ void initLex(const char *inputstring, unsigned long inputlen, nsInputFileStream
|
||||
lexBuf.inputString = (char*) inputstring;
|
||||
lexBuf.inputLen = inputlen;
|
||||
lexBuf.curPos = 0;
|
||||
lexBuf.inputFile = inputFile;
|
||||
|
||||
lexBuf.len = 0;
|
||||
lexBuf.getPtr = 0;
|
||||
@ -1238,46 +1228,10 @@ static VObject* parse_MIMEHelper()
|
||||
/******************************************************************************/
|
||||
VObject* parse_MIME(const char *input, unsigned long len)
|
||||
{
|
||||
initLex(input, len, 0);
|
||||
initLex(input, len);
|
||||
return parse_MIMEHelper();
|
||||
}
|
||||
|
||||
|
||||
VObject* parse_MIME_FromFile(nsInputFileStream *file)
|
||||
{
|
||||
VObject *result;
|
||||
long startPos;
|
||||
|
||||
initLex(0,(unsigned long)-1,file);
|
||||
startPos = file->tell();
|
||||
if (!(result = parse_MIMEHelper())) {
|
||||
file->seek(startPos);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
VObject* parse_MIME_FromFileName(nsFileSpec *fname)
|
||||
{
|
||||
#if !defined(MOZADDRSTANDALONE)
|
||||
nsInputFileStream *fp = new nsInputFileStream(*fname);
|
||||
if (fp)
|
||||
{
|
||||
VObject* o = parse_MIME_FromFile(fp);
|
||||
fp->close();
|
||||
return o;
|
||||
}
|
||||
else {
|
||||
char msg[80];
|
||||
PR_snprintf(msg, sizeof(msg), "Can't open file for reading\n");
|
||||
mime_error_(msg);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
NS_ASSERTION(FALSE, "1.5 <rhp@netscape.com> 06 Jan 2000 08:00");
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static MimeErrorHandler mimeErrorHandler;
|
||||
|
||||
void registerMimeErrorHandler(MimeErrorHandler me)
|
||||
@ -1294,13 +1248,6 @@ void mime_error(char *s)
|
||||
}
|
||||
}
|
||||
|
||||
void mime_error_(char *s)
|
||||
{
|
||||
if (mimeErrorHandler) {
|
||||
mimeErrorHandler(s);
|
||||
}
|
||||
}
|
||||
|
||||
/*#line 1221 "y_tab.c"*/
|
||||
#define YYABORT goto yyabort
|
||||
#define YYACCEPT goto yyaccept
|
||||
|
@ -78,18 +78,12 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
|
||||
#define __VCC_H__ 1
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsVCardObj.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
VObject* parse_MIME(const char *input, unsigned long len);
|
||||
|
||||
VObject* parse_MIME_FromFile(nsInputFileStream *file);
|
||||
|
||||
VObject* parse_MIME_FromFileName(nsFileSpec * fname);
|
||||
|
||||
typedef void (*MimeErrorHandler)(char *);
|
||||
|
||||
void registerMimeErrorHandler(MimeErrorHandler);
|
||||
|
@ -496,166 +496,6 @@ VObject* addPropSizedValue(VObject *o, const char *p, const char *v,
|
||||
return addPropSizedValue_(o,p,dupStr(v,size),size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
The following pretty print a VObject
|
||||
----------------------------------------------------------------------*/
|
||||
|
||||
static void indent(nsOutputFileStream *fp, int level)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<level*4;i++) {
|
||||
fp->write(" ", 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void printValue(nsOutputFileStream *fp, VObject *o, int level)
|
||||
{
|
||||
char *buf = nsnull;
|
||||
|
||||
switch (VALUE_TYPE(o)) {
|
||||
case VCVT_USTRINGZ: {
|
||||
char c;
|
||||
char *t,*s;
|
||||
s = t = fakeCString(USTRINGZ_VALUE_OF(o));
|
||||
fp->write("'",1);
|
||||
while (c=*t,c) {
|
||||
fp->write(&c,1);
|
||||
if (c == '\n') indent(fp,level+2);
|
||||
t++;
|
||||
}
|
||||
fp->write("'",1);
|
||||
deleteString(s);
|
||||
break;
|
||||
}
|
||||
case VCVT_STRINGZ: {
|
||||
char c;
|
||||
char *str = &c;
|
||||
const char *s = STRINGZ_VALUE_OF(o);
|
||||
fp->write("'",1);
|
||||
while (c=*s,c) {
|
||||
fp->write(str,1);
|
||||
if (c == '\n') indent(fp,level+2);
|
||||
s++;
|
||||
}
|
||||
fp->write("'",1);
|
||||
break;
|
||||
}
|
||||
case VCVT_UINT:
|
||||
buf = PR_smprintf("%d", INTEGER_VALUE_OF(o));
|
||||
if (buf)
|
||||
{
|
||||
fp->write(buf, strlen(buf));
|
||||
PR_FREEIF(buf);
|
||||
}
|
||||
break;
|
||||
|
||||
case VCVT_ULONG:
|
||||
buf = PR_smprintf("%ld", LONG_VALUE_OF(o));
|
||||
if (buf)
|
||||
{
|
||||
fp->write(buf, strlen(buf));
|
||||
PR_FREEIF(buf);
|
||||
}
|
||||
break;
|
||||
|
||||
case VCVT_RAW:
|
||||
fp->write("[raw data]", 10);
|
||||
break;
|
||||
|
||||
case VCVT_VOBJECT:
|
||||
fp->write("[vobject]\n", 11);
|
||||
printVObject_(fp,VOBJECT_VALUE_OF(o),level+1);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
fp->write("[none]", 6);
|
||||
break;
|
||||
default:
|
||||
fp->write("[unknown]", 9);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void printNameValue(nsOutputFileStream *fp,VObject *o, int level)
|
||||
{
|
||||
char *buf;
|
||||
|
||||
indent(fp,level);
|
||||
if (NAME_OF(o))
|
||||
{
|
||||
buf = PR_smprintf("%s", NAME_OF(o));
|
||||
if (buf)
|
||||
{
|
||||
fp->write(buf, strlen(buf));
|
||||
PR_FREEIF(buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (VALUE_TYPE(o))
|
||||
{
|
||||
fp->write("=",1);
|
||||
printValue(fp,o, level);
|
||||
}
|
||||
|
||||
fp->write("\n", 1);
|
||||
}
|
||||
|
||||
void printVObject_(nsOutputFileStream *fp, VObject *o, int level)
|
||||
{
|
||||
VObjectIterator t;
|
||||
if (o == 0) {
|
||||
fp->write("[NULL]\n", 7);
|
||||
return;
|
||||
}
|
||||
|
||||
printNameValue(fp,o,level);
|
||||
initPropIterator(&t,o);
|
||||
|
||||
while (moreIteration(&t))
|
||||
{
|
||||
VObject *eachProp = nextVObject(&t);
|
||||
printVObject_(fp,eachProp,level+1);
|
||||
}
|
||||
}
|
||||
|
||||
void printVObject(nsOutputFileStream *fp,VObject *o)
|
||||
{
|
||||
printVObject_(fp,o,0);
|
||||
}
|
||||
|
||||
void printVObjectToFile(nsFileSpec *fname, VObject *o)
|
||||
{
|
||||
#if !defined(MOZADDRSTANDALONE)
|
||||
nsOutputFileStream *fp = new nsOutputFileStream(*fname, PR_WRONLY | PR_CREATE_FILE, 00600);
|
||||
|
||||
if (fp) {
|
||||
printVObject(fp,o);
|
||||
fp->close();
|
||||
}
|
||||
#else
|
||||
NS_ASSERTION(PR_FALSE, "1.10 <rhp@netscape.com> 06 Jan 2000 08:01");
|
||||
#endif
|
||||
}
|
||||
|
||||
void printVObjectsToFile(nsFileSpec *fname,VObject *list)
|
||||
{
|
||||
#if !defined(MOZADDRSTANDALONE)
|
||||
nsOutputFileStream *fp = new nsOutputFileStream(*fname, PR_WRONLY | PR_CREATE_FILE, 00600);
|
||||
if (fp) {
|
||||
while (list) {
|
||||
printVObject(fp,list);
|
||||
list = nextVObjectInList(list);
|
||||
}
|
||||
fp->close();
|
||||
}
|
||||
#else
|
||||
NS_ASSERTION(PR_FALSE, "1.10 <rhp@netscape.com> 06 Jan 2000 08:01");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void cleanVObject(VObject *o)
|
||||
{
|
||||
if (o == 0) return;
|
||||
@ -1042,23 +882,11 @@ const char* lookupProp(const char* str)
|
||||
APIs to Output text form.
|
||||
----------------------------------------------------------------------*/
|
||||
#define OFILE_REALLOC_SIZE 256
|
||||
/* typedef struct OFile {
|
||||
nsOutputFileStream *fp;
|
||||
char *s;
|
||||
int len;
|
||||
int limit;
|
||||
int alloc:1;
|
||||
int fail:1;
|
||||
} OFile; */
|
||||
|
||||
static void appendcOFile_(OFile *fp, char c)
|
||||
{
|
||||
if (fp->fail)
|
||||
return;
|
||||
if (fp->fp) {
|
||||
fp->fp->write(&c,1);
|
||||
}
|
||||
else {
|
||||
stuff:
|
||||
if (fp->len+1 < fp->limit) {
|
||||
fp->s[fp->len] = c;
|
||||
@ -1074,7 +902,6 @@ stuff:
|
||||
PR_FREEIF(fp->s);
|
||||
fp->s = 0;
|
||||
fp->fail = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void appendcOFile(OFile *fp, char c)
|
||||
@ -1100,19 +927,8 @@ static void appendsOFile(OFile *fp, const char *s)
|
||||
}
|
||||
}
|
||||
|
||||
static void initOFile(OFile *fp, nsOutputFileStream *ofp)
|
||||
{
|
||||
fp->fp = ofp;
|
||||
fp->s = 0;
|
||||
fp->len = 0;
|
||||
fp->limit = 0;
|
||||
fp->alloc = 0;
|
||||
fp->fail = 0;
|
||||
}
|
||||
|
||||
static void initMemOFile(OFile *fp, char *s, int len)
|
||||
{
|
||||
fp->fp = 0;
|
||||
fp->s = s;
|
||||
fp->len = 0;
|
||||
fp->limit = s?len:0;
|
||||
@ -1445,43 +1261,6 @@ void writeVObject_(OFile *fp, VObject *o)
|
||||
}
|
||||
}
|
||||
|
||||
void writeVObject(nsOutputFileStream *fp, VObject *o)
|
||||
{
|
||||
OFile ofp;
|
||||
initOFile(&ofp,fp);
|
||||
writeVObject_(&ofp,o);
|
||||
}
|
||||
|
||||
void writeVObjectToFile(nsFileSpec *fname, VObject *o)
|
||||
{
|
||||
#if !defined(MOZADDRSTANDALONE)
|
||||
nsOutputFileStream *fp = new nsOutputFileStream(*fname, PR_WRONLY | PR_CREATE_FILE, 00600);
|
||||
|
||||
if (fp) {
|
||||
writeVObject(fp,o);
|
||||
fp->close();
|
||||
}
|
||||
#else
|
||||
NS_ASSERTION(PR_FALSE, "1.10 <rhp@netscape.com> 06 Jan 2000 08:01");
|
||||
#endif
|
||||
}
|
||||
|
||||
void writeVObjectsToFile(nsFileSpec *fname, VObject *list)
|
||||
{
|
||||
#if !defined(MOZADDRSTANDALONE)
|
||||
nsOutputFileStream *fp = new nsOutputFileStream(*fname, PR_WRONLY | PR_CREATE_FILE, 00600);
|
||||
if (fp) {
|
||||
while (list) {
|
||||
writeVObject(fp,list);
|
||||
list = nextVObjectInList(list);
|
||||
}
|
||||
fp->close();
|
||||
}
|
||||
#else
|
||||
NS_ASSERTION(PR_FALSE, "1.10 <rhp@netscape.com> 06 Jan 2000 08:01");
|
||||
#endif
|
||||
}
|
||||
|
||||
char* writeMemVObject(char *s, int *len, VObject *o)
|
||||
{
|
||||
OFile ofp;
|
||||
|
@ -133,9 +133,6 @@ they will use an appropriately defined local type |vwchar_t|.
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
class nsFileSpec;
|
||||
class nsOutputFileStream;
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
#define VC7bitProp "7bit"
|
||||
@ -354,7 +351,6 @@ struct StrItem {
|
||||
};
|
||||
|
||||
typedef struct OFile {
|
||||
nsOutputFileStream *fp;
|
||||
char *s;
|
||||
int len;
|
||||
int limit;
|
||||
@ -409,10 +405,6 @@ void initPropIterator(VObjectIterator *i, VObject *o);
|
||||
int moreIteration(VObjectIterator *i);
|
||||
VObject* nextVObject(VObjectIterator *i);
|
||||
|
||||
extern void printVObject(nsOutputFileStream *fp,VObject *o);
|
||||
void printVObject_(nsOutputFileStream *fp, VObject *o, int level);
|
||||
extern void writeVObject(nsOutputFileStream *fp, VObject *o);
|
||||
|
||||
void writeVObject_(OFile *fp, VObject *o);
|
||||
char* writeMemVObject(char *s, int *len, VObject *o);
|
||||
extern "C" char* writeMemoryVObjects(char *s, int *len, VObject *list, PRBool expandSpaces);
|
||||
@ -429,11 +421,6 @@ vwchar_t* fakeUnicode(const char *ps, int *bytes);
|
||||
int uStrLen(const vwchar_t *u);
|
||||
char* fakeCString(const vwchar_t *u);
|
||||
|
||||
void printVObjectToFile(nsFileSpec *fname,VObject *o);
|
||||
void printVObjectsToFile(nsFileSpec *fname,VObject *list);
|
||||
void writeVObjectToFile(nsFileSpec *fname, VObject *o);
|
||||
void writeVObjectsToFile(nsFileSpec *fname, VObject *list);
|
||||
|
||||
#define MAXPROPNAMESIZE 256
|
||||
#define MAXMOZPROPNAMESIZE 16
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user