PProjectWindow::PProjectWindow(const entry_ref *doc, const char* mimetype) : inherited(doc) , fPrjFile(NULL) , fToolBar(NULL) , fButtonBar(NULL) , fPanel(NULL) { SetMimeType(mimetype, false); SetupSizeAndLayout(); } /* PProjectWindow::PProjectWindow */
void CAgnAttachment::InternalizeL(RReadStream& aStream) { // don't read in type as assume already read HBufC8* mimeType = HBufC8::NewL(aStream, KCalAttachmentMaxMimeTypeLength); SetMimeType(mimeType); iUid = aStream.ReadUint32L(); iAttributes = static_cast<CCalAttachment::TAttributes>(aStream.ReadUint16L()); iFlags = aStream.ReadUint16L(); iSize = aStream.ReadInt32L(); delete iLabel; iLabel = NULL; iLabel = HBufC::NewL(aStream, KCalAttachmentMaxLabelLength); }
// Used when an entry is copied void CAgnAttachment::CopyL(const CAgnAttachment& aSource) { __ASSERT_ALWAYS(Type() == aSource.Type(), Panic(EAgmErrBadAttachmentType)); HBufC8* content = NULL; if (aSource.Content().Length()) { content = aSource.Content().AllocL(); } SetContent(content); HBufC8* mimeType = NULL; if (aSource.MimeType().Length()) { mimeType = aSource.MimeType().AllocL(); } SetMimeType(mimeType); SetUid(aSource.Uid()); iAttributes = aSource.iAttributes; iFlags = aSource.iFlags; SetSize(aSource.Size()); SetLabelL(aSource.Label()); }
int main(int argc, char *argv[]) { DistillerStatus st; UINT32 len; int i; char nextfile[MAX_FILENAME]; char logFile[MAX_FILENAME]; char *timeStr; TestRun runs[MAX_TESTRUNS]; FILE *f; time_t t; int numRuns; int repeatCount; DistillerInput in; DistillerOutput out; C_DistillerType distType; sprintf(distType.string, "test " INPUT_MIME_TYPE); if (argc < 3) { usage(); exit(1); } if (!(numRuns = readInputFile(argv[1],runs))) { fprintf(stderr, "Error reading input file %s.\n", argv[1]); exit(1); } repeatCount = atoi(argv[2]); if (repeatCount <=0) { fprintf(stderr, "Invaild count value.\n"); exit(1); } if ((st = DistillerInit(distType, 0, NULL)) != distOk) { fprintf(stderr, "DistillerInit failed: error %d\n", (int)st); exit(1); } sprintf(logFile,"harness.log"); t = time(NULL); timeStr = ctime(&t); printf("%s\n",logFile); if ((f = fopen(logFile, "a")) == NULL) { fprintf(stderr, "Can't open log file %s\n", logFile); return 0; } SetMimeType(&in, INPUT_MIME_TYPE); for (i=0;i<numRuns;i++) { int fd; int count; int ii; fprintf(stdout,"Test run for case %s:\n",runs[i].inputFileName); fprintf(f,"Test run for case %s:\n",runs[i].inputFileName); printArguments(f,*(runs[i].argList)); fd = open(runs[i].inputFileName, O_RDONLY); if (fd == -1) { fprintf(stderr, "Can't read %s, skipping\n", runs[i].inputFileName); fprintf(f, "Can't read %s, skipping\n", runs[i].inputFileName); continue; } for (len = 0; (count = read(fd, (void*)(buf+len), (sizeof(buf)-len))) > 0; len += count) ; fprintf(stderr, "Read %lu bytes from %s\n", len, runs[i].inputFileName); fprintf(f, "Read %lu bytes from %s\n", len, runs[i].inputFileName); SetData(&in, (void *)buf); SetDataLength(&in, len); SetMetadata(&in, NULL); SetMetadataLength(&in, 0); for (ii= 0; ii<repeatCount; ii++) { fprintf(stderr,"Calling distiller main\n"); fprintf(f,"Calling distiller main\n"); /* Distiller status */ st = DistillerMain(runs[i].argList->arg,runs[i].argList->nargs,&in,&out); if (st != distOk) { fprintf(stderr, "DistillerMain failed: error %d\n", (int)st); fprintf(f, "DistillerMain failed: error %d\n", (int)st); } close(fd); strcpy(nextfile,runs[i].inputFileName); strcat(nextfile, ".OUT"); fd = open(nextfile, O_CREAT | O_WRONLY | O_TRUNC, 0666); if (fd == -1) { fprintf(stderr, "Can't write %s, using stdout\n", nextfile); fprintf(f, "Can't write %s, using stdout\n", nextfile); fd = fileno(stdout); } len = write(fd, (const void *)DataPtr(&out), (size_t)(DataLength(&out))); if (fd != fileno(stdout)) close(fd); fprintf(stderr, "Wrote %lu of %lu bytes to %s\n", len, DataLength(&out), nextfile); fprintf(f, "Wrote %lu of %lu bytes to %s\n", len, DataLength(&out), nextfile); if (out.data.freeMe == gm_True) DistillerFree(DataPtr(&out)); if (out.metadata.freeMe == gm_True) DistillerFree(MetadataPtr(&out)); } } fclose(f); return(1); }
int main(int argc, char *argv[]) { DistillerStatus st; UINT32 len; Argument args[12]; int nargs = 0; int i; char *k; FILE *f; char nextfile[255]; DistillerInput in; DistillerOutput out; C_DistillerType distType; sprintf(distType.string, "test " INPUT_MIME_TYPE); if ((argc < 2) || (argc >= 2 && strncmp(argv[1], "-h", 2) == 0)) { usage(); exit(1); } if ((f = fopen(argv[1], "r")) == NULL) { fprintf(stderr, "Can't open input file %s\n", argv[1]); exit(1); } for (i=2; i<argc-1; i += 2, nargs++) { SET_ARG_ID(args[nargs], strtoul(&argv[i][1], (char**)NULL, 0)); switch (argv[i][0]) { case 'i': SET_ARG_INT(args[nargs], strtol(argv[i+1], (char**)NULL, 0)); fprintf(stderr, "Arg id %lu is %ld\n", ARG_ID(args[nargs]), ARG_INT(args[nargs])); break; case 'f': SET_ARG_DOUBLE(args[nargs], strtod(argv[i+1], (char**)NULL)); fprintf(stderr, "Arg id %lu is %f\n", ARG_ID(args[nargs]), (float)ARG_DOUBLE(args[nargs])); break; case 's': default: SET_ARG_STRING(args[nargs], argv[i+1]); fprintf(stderr, "Arg id %lu is \"%s\"\n", ARG_ID(args[nargs]), ARG_STRING(args[nargs])); } } if ((st = DistillerInit(distType, 0, NULL)) != distOk) { fprintf(stderr, "DistillerInit failed: error %d\n", (int)st); exit(1); } SetMimeType(&in, INPUT_MIME_TYPE); while (fgets(nextfile, 254, f) != NULL) { char nextfile2[255]; int fd; int count; int ii; nextfile[strlen(nextfile)-1] = 0; fd = open(nextfile, O_RDONLY); if (fd == -1) { fprintf(stderr, "Can't read %s, skipping\n", nextfile); continue; } for (len = 0; (count = read(fd, (void*)(buf+len), (sizeof(buf)-len))) > 0; len += count) ; fprintf(stderr, "Read %lu bytes from %s\n", len, nextfile); SetData(&in, (void *)buf); SetDataLength(&in, len); SetMetadata(&in, NULL); SetMetadataLength(&in, 0); for (ii= 0; ii<REPEAT_COUNT; ii++) { fprintf(stderr,"Calling distiller main\n"); st = DistillerMain(args,nargs,&in,&out); if (st != distOk) { fprintf(stderr, "DistillerMain failed: error %d\n", (int)st); } close(fd); strcpy(nextfile2, argv[argc-1]); if (nextfile2[strlen(nextfile2)-1] != '/') strcat(nextfile2,"/"); k = strrchr(nextfile, '/'); if (k) strcat(nextfile2, k+1); else strcat(nextfile2, nextfile); strcat(nextfile2, ".OUT"); fd = open(nextfile2, O_CREAT | O_WRONLY | O_TRUNC, 0666); if (fd == -1) { fprintf(stderr, "Can't write %s, using stdout\n", nextfile2); fd = fileno(stdout); } len = write(fd, (const void *)DataPtr(&out), (size_t)(DataLength(&out))); if (fd != fileno(stdout)) close(fd); fprintf(stderr, "Wrote %lu of %lu bytes to %s\n", len, DataLength(&out), nextfile2); if (out.data.freeMe == gm_True) DistillerFree(DataPtr(&out)); if (out.metadata.freeMe == gm_True) DistillerFree(MetadataPtr(&out)); } } return(1); }
EXPORT_C void CAgnAttachment::SetMimeTypeL(const TDesC8& aMimeType) { SetMimeType(aMimeType.AllocL()); }