/******************************************************************* * Function Name: ReadProgramPath * Return Type : int * Created On : Feb 23, 2013 * Created By : hrushi * Comments : Reads the program path. This is the zero-th argument * Arguments : int argc, char* argv[] *******************************************************************/ int Args::ReadProgramPath( int argc, char* argv[]) { string ProgramPath( argv[0]); m_ProgramPath = ProgramPath; return EXIT_SUCCESS; }
Int2 Main (void) { AsnIoPtr aop = NULL; AsnModulePtr amp; AsnTypePtr atp_bss, atp_ss, atp_se; BioseqSet bss; FILE *fp; ValNodePtr head, vnp; Char path [PATH_MAX]; CharPtr progname, str, subfile; ErrSetFatalLevel (SEV_MAX); ErrClearOptFlags (EO_SHOW_USERSTR); UseLocalAsnloadDataAndErrMsg (); ErrPathReset (); if (! AllObjLoad ()) { Message (MSG_FATAL, "AllObjLoad failed"); return 1; } if (! SubmitAsnLoad ()) { Message (MSG_FATAL, "SubmitAsnLoad failed"); return 1; } if (! SeqCodeSetLoad ()) { Message (MSG_FATAL, "SeqCodeSetLoad failed"); return 1; } if (! GeneticCodeTableLoad ()) { Message (MSG_FATAL, "GeneticCodeTableLoad failed"); return 1; } MemSet ((Pointer) &bss, 0, sizeof (BioseqSet)); amp = AsnAllModPtr (); if (amp == NULL) { Message (MSG_FATAL, "Unable to load AsnAllModPtr"); return 1; } atp_bss = AsnFind ("Bioseq-set"); if (atp_bss == NULL) { Message (MSG_FATAL, "Unable to find ASN.1 type Bioseq-set"); return 1; } atp_ss = AsnFind ("Bioseq-set.seq-set"); if (atp_ss == NULL) { Message (MSG_FATAL, "Unable to find ASN.1 type Bioseq-set.seq-set"); return 1; } atp_se = AsnFind ("Bioseq-set.seq-set.E"); if (atp_se == NULL) { Message (MSG_FATAL, "Unable to find ASN.1 type Bioseq-set.seq-set.E"); return 1; } ProgramPath (path, sizeof (path)); progname = StringRChr (path, DIRDELIMCHR); if (progname != NULL) { progname++; } else { progname = "idcleanscan"; } if (! GetArgs (progname, sizeof (myargs) / sizeof (Args), myargs)) { return 0; } fp = FileOpen (myargs [o_argOutputFile].strvalue, "a"); if (fp == NULL) { Message (MSG_FATAL, "FileOpen failed"); return 1; } if (StringHasNoText (myargs [p_argInputPath].strvalue)) { str = myargs [i_argInputFile].strvalue; if (! StringHasNoText (str)) { DoReleaseFile (str, myargs [b_argBinaryFile].intvalue, myargs [c_argCompressed].intvalue, fp, aop, NULL); } } else { head = DirCatalog (myargs [p_argInputPath].strvalue); if (! StringHasNoText (myargs [s_argSubset].strvalue)) { aop = AsnIoOpen (myargs [s_argSubset].strvalue, /* "wb" */ "w"); AsnOpenStruct (aop, atp_bss, (Pointer) &bss); AsnOpenStruct (aop, atp_ss, (Pointer) bss.seq_set); /* av.intvalue = BioseqseqSet_class_genbank; AsnWrite (aop, atp_cls, &av); */ } for (vnp = head; vnp != NULL; vnp = vnp->next) { if (vnp->choice == 0) { str = (CharPtr) vnp->data.ptrvalue; if (! StringHasNoText (str)) { subfile = myargs [x_argFileSelect].strvalue; if (StringHasNoText (subfile) || StringStr (str, subfile) != NULL) { #ifdef OS_UNIX /* printf ("%s\n", str); */ #endif DoReleaseFile (str, myargs [b_argBinaryFile].intvalue, myargs [c_argCompressed].intvalue, fp, aop, atp_se); } } } } if (aop != NULL) { AsnCloseStruct (aop, atp_ss, (Pointer) bss.seq_set); AsnCloseStruct (aop, atp_bss, (Pointer) &bss); AsnIoClose (aop); } ValNodeFreeData (head); } FileClose (fp); return 0; }
/******************************************************************************************* > BOOL BitmapPreviewData::GenerateHTMLStub(BrowserPreviewOptions BrowserOptions) Author: Stefan_Stoykov (Xara Group Ltd) <*****@*****.**> Created: 24/6/97 Inputs: BrowserOptions - the options for generating the html page Purpose: Generate a html file which includes our bitmap, together with some other optional stuff. Used for browser preview. *******************************************************************************************/ BOOL BitmapPreviewData::GenerateHTMLStub(BrowserPreviewOptions BrowserOptions) { PORTNOTE("other","Removed _R(IDD_TIMAPOPTIONS) - isn't wanted yet") #ifndef EXCLUDE_FROM_XARALX // sanity checks // check for export options ERROR3IF(m_pOptions == NULL, "BitmapPreviewData::GenerateHTMLStub - need export options"); if (m_pOptions == NULL) // we need export options return FALSE; // get the path for the exported bitmap from the options PathName TempPath = m_pOptions->GetPathName(); // check for exported bitmap ERROR3IF((m_pOptions->HasTempFile() == FALSE) || (TempPath.IsValid() == FALSE), "BitmapPreviewData::GenerateHTMLStub - need exported bitmap"); if ((m_pOptions->HasTempFile() == FALSE) || (TempPath.IsValid() == FALSE)) return FALSE; // delete the previous temp file, if any if (m_pTempHTMLPath != NULL) FileUtil::DeleteFile(m_pTempHTMLPath); else m_pTempHTMLPath = new PathName; // safety check if (m_pTempHTMLPath == NULL) return FALSE; // create a new temp file if (FileUtil::GetTemporaryPathName( _T("htm"),m_pTempHTMLPath) == FALSE) { delete m_pTempHTMLPath; m_pTempHTMLPath = NULL; return FALSE; } // start creating the html page // create a disk file CCDiskFile TempDiskFile(1024, FALSE, TRUE); // get path name to server, so we can find the logo bitmaps CString str; AfxGetModuleShortFileName(AfxGetInstanceHandle(), str); String_256 strPathName(str.GetBuffer(0)); // create a path name object from the program name PathName ProgramPath(strPathName); try { // open it for reading if (!TempDiskFile.open(*m_pTempHTMLPath, ios::out)) return FALSE; // output header String_256 s(_R(IDS_HTML_HEAD)); TempDiskFile.write(s); // set the background attributes switch (BrowserOptions.m_Background) { case BROWSER_BGR_DOC: { // set the background from the document page if (!SetBackgroundFromPage(TempDiskFile, BrowserOptions.m_pSpread)) ERROR3("Setting the html background from the document page failed\n"); } break; case BROWSER_BGR_CHECKER: { // display the checkered bitmap as background // get the checkered bitmap name String_256 Checker(_R(IDS_HTML_CHECKER)); // set it in the path ProgramPath.SetFileNameAndType(Checker); // set the checkered bitmap as background image s.MakeMsg(_R(IDS_CHECK_BACK), (TCHAR *)ProgramPath.GetWebAddress()); TempDiskFile.write(s); } break; case BROWSER_BGR_BITMAP: { // set our bitmap as background image s.MakeMsg(_R(IDS_BITMAPED_BACKGROUND), (TCHAR *)TempPath.GetWebAddress()); TempDiskFile.write(s); } break; case BROWSER_BGR_NONE: { String_256 background(_R(IDS_PLAIN_BACKGROUND)); TempDiskFile.write(background); } break; default: ERROR3("Unknown type of BrowserOptions.m_Background"); break; } // end of switch(BrowserOptions.m_Background) block // Get a pointer to the actual bitmap so that we can get some details from it. // OILBitmap *pOilBitmap = m_pBitmap->ActualBitmap; // ERROR3IF(pOilBitmap == NULL,"BitmapPreviewData::GenerateBitmapInfoStrings NULL oil bitmap pointer"); // Get the details from the specified bitmap // BitmapInfo BmInfo; // pOilBitmap->GetInfo(&BmInfo); // output our bitmap, but only if it wasn't already set as background String_256 s2(_R(IDS_PAGE_TITLE)); TempDiskFile.write(s2); if (BrowserOptions.m_Background != BROWSER_BGR_BITMAP) { // output the bitmap if (m_pOptions->GetFilterType() == MAKE_BITMAP_FILTER) { // GIF animation s.MakeMsg(_R(IDS_DISPLAY_PIC), (const TCHAR *)TempPath.GetFileName()); } else { if( m_pOptions->GetFilterNameStrID() == _R(IDN_FILTERNAME_GIF) || m_pOptions->GetFilterNameStrID() == _R(IDS_JPG_EXP_FILTERNAME) || m_pOptions->GetFilterNameStrID() == _R(IDT_FILTERNAME_BMP) ) { s.MakeMsg(_R(IDS_DISPLAY_BMP), (const TCHAR *)TempPath.GetFileName()); } else if( m_pOptions->GetFilterNameStrID() == _R(IDS_FILTERNAME_PNG) ) s.MakeMsg(_R(IDS_DISPLAY_PNG), (const TCHAR *)TempPath.GetFileName()); } TempDiskFile.write(s); } else { s.MakeMsg(_R(IDS_EMPTY_BOX)); TempDiskFile.write(s); } switch (m_pOptions->GetFilterNameStrID()) { case _R(IDT_FILTERNAME_BMP): s2.MakeMsg(_R(IDS_BMP_MESSAGE)); s.MakeMsg(_R(IDS_WARNING_BOX), (TCHAR *)s2); TempDiskFile.write(s); break; case _R(IDS_FILTERNAME_PNG): s2.MakeMsg(_R(IDS_PNG_MESSAGE)); s.MakeMsg(_R(IDS_WARNING_BOX), (TCHAR *)s2); TempDiskFile.write(s); break; } // end of switch(m_pOptions->GetFilterNameStrID()) s.MakeMsg(_R(IDS_DETAILS_BUILD)); TempDiskFile.write(s); // output the bitmap info, if requested if (BrowserOptions.m_bInfo != FALSE) { String_64 ImageSize; String_64 FileSize; BOOL m_bTransparent = FALSE; INT32 count; count=0; // generate the info strings if (m_pOptions->GetFilterType() == MAKE_BITMAP_FILTER) { // This is actually the export animated GIF using the frame gallery system MakeBitmapExportOptions* pMkBOptions = (MakeBitmapExportOptions*)m_pOptions; ERROR3IF(!pMkBOptions->IS_KIND_OF(MakeBitmapExportOptions), "pMkBOptions isn't"); PALETTE Palette = PAL_OPTIMISED; DITHER DitherType; UINT32 colDepth; String_64 sPalette; String_64 Dither; UINT32 NoOfColours; NoOfColours=m_pOptions->GetNumColsInPalette(); // Palette = pMkBOptions->GetPalette(); DitherType = pMkBOptions->GetDither(); colDepth = pMkBOptions->GetDepth(); s2.MakeMsg(_R(IDS_ANIMATED_GIF)); if (pMkBOptions->WantTransparent()) { s2.MakeMsg(_R(IDS_TRANSPARENT),"animated GIF"); } s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2); TempDiskFile.write(s); switch (Palette) { case PAL_OPTIMISED: sPalette.MakeMsg(_R(IDS_OPTIMISED_PAL)); break; case PAL_BROWSER: case PAL_STANDARD: sPalette.MakeMsg(_R(IDS_BROWSER_PAL)); break; case PAL_GLOBALOPTIMISED: sPalette.MakeMsg(_R(IDS_GLOBAL_OPT)); break; } if (colDepth == 8 && (Palette == PAL_STANDARD || Palette == PAL_BROWSER) ) { NoOfColours = 216; } switch (colDepth) { case 32: case 24: s2.MakeMsg(_R(IDS_TRUECOLOUR),colDepth); break; case 8: { // Include the transparent colour in the colour depth check UINT32 RealNumberOfColours = NoOfColours; if (colDepth <= 8 && pMkBOptions->WantTransparent()) { UINT32 MaxColours = UINT32(pow(2,colDepth)); RealNumberOfColours++; if (RealNumberOfColours > MaxColours) RealNumberOfColours = MaxColours; } // We say 8 but we really mean the number of colours deep // We cannot say 2 colours = 2bpp as we save it as 10 colours due // to having 1 transparent colour and the usual lets pick 10 as the // transparent colour. Cannot allow the user to choose 1 as the code // then outputs 8bpp as GRenderOptPalette::GetOptimisedPalette has the // test if (ReservedColours < NumColours), which fails. /* if (RealNumberOfColours <= 2) s2.MakeMsg(_R(IDS_PALETTEINFO),2,NoOfColours,(const TCHAR*)sPalette); else */ if (RealNumberOfColours <= 16) s2.MakeMsg(_R(IDS_PALETTEINFO),4,NoOfColours,(const TCHAR*)sPalette); else s2.MakeMsg(_R(IDS_AN_PALINFO),colDepth,NoOfColours,(const TCHAR*)sPalette); break; } case 1: s2.MakeMsg(_R(IDS_MONO),colDepth); break; case 4: default: s2.MakeMsg(_R(IDS_PALETTEINFO),colDepth,NoOfColours,(const TCHAR*)sPalette); break; } TempDiskFile.write(s2); s.MakeMsg(_R(IDS_NODITHER)); switch (DitherType) { case XARADITHER_ORDERED: case XARADITHER_ORDERED_GREY: Dither.MakeMsg(_R(IDS_DITH_ORDER)); s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither); break; case XARADITHER_ERROR_DIFFUSION: case XARADITHER_SIMPLE: Dither.MakeMsg(_R(IDS_DITH_ERROR)); s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither); break; case XARADITHER_NONE: s.MakeMsg(_R(IDS_NODITHER)); break; } TempDiskFile.write(s); } // if (m_pOptions->GetFilterType() == MAKE_BITMAP_FILTER) block ends else { switch (m_pOptions->GetFilterNameStrID()) { case _R(IDN_FILTERNAME_GIF): { GIFExportOptions* pGIFOptions = (GIFExportOptions*)m_pOptions; ERROR3IF(!pGIFOptions->IS_KIND_OF(GIFExportOptions), "pGIFOptions isn't"); PALETTE Palette = PAL_OPTIMISED; DITHER DitherType; UINT32 colDepth; String_64 sPalette; String_64 Dither; UINT32 NoOfColours; NoOfColours=m_pOptions->GetNumColsInPalette(); // Palette = pGIFOptions->GetPalette(); DitherType = pGIFOptions->GetDither(); colDepth = pGIFOptions->GetDepth(); if (pGIFOptions->WantTransparent()) count=count+1; if (pGIFOptions->WantInterlaced()) count=count+2; s.MakeMsg(_R(IDS_GIF)); s2.MakeMsg(_R(IDS_A), (const TCHAR*)s); switch (count) { case 1: s2.MakeMsg(_R(IDS_TRANSPARENT),"GIF"); break; case 2: s2.MakeMsg(_R(IDS_INTERLACED),"GIF"); break; case 3: s2.MakeMsg(_R(IDS_INTER_TRANS),"GIF"); break; case 0: break; } s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2); TempDiskFile.write(s); switch (Palette) { case PAL_OPTIMISED: sPalette.MakeMsg(_R(IDS_OPTIMISED_PAL)); break; case PAL_BROWSER: case PAL_STANDARD: sPalette.MakeMsg(_R(IDS_BROWSER_PAL)); break; case PAL_GLOBALOPTIMISED: sPalette.MakeMsg(_R(IDS_GLOBAL_OPT)); break; } if (colDepth == 8 && (Palette == PAL_STANDARD || Palette == PAL_BROWSER) ) { NoOfColours = 216; } s2.MakeMsg(_R(IDS_PALETTEINFO),colDepth,NoOfColours,(const TCHAR*)sPalette); if (colDepth == 8) s2.MakeMsg(_R(IDS_AN_PALINFO),colDepth,NoOfColours,(const TCHAR*)sPalette); if (colDepth == 1) s2.MakeMsg(_R(IDS_MONO),colDepth); if (colDepth > 8) s2.MakeMsg(_R(IDS_TRUECOLOUR),colDepth); TempDiskFile.write(s2); s.MakeMsg(_R(IDS_NODITHER)); switch (DitherType) { case XARADITHER_ORDERED: case XARADITHER_ORDERED_GREY: Dither.MakeMsg(_R(IDS_DITH_ORDER)); s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither); break; case XARADITHER_ERROR_DIFFUSION: case XARADITHER_SIMPLE: Dither.MakeMsg(_R(IDS_DITH_ERROR)); s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither); break; case XARADITHER_NONE: s.MakeMsg(_R(IDS_NODITHER)); break; } TempDiskFile.write(s); } // end case _R(IDN_FILTERNAME_GIF) break; case _R(IDS_JPG_EXP_FILTERNAME): { JPEGExportOptions* pJPEGOptions = (JPEGExportOptions *)m_pOptions; ERROR3IF(!pJPEGOptions->IS_KIND_OF(JPEGExportOptions), "pJPEGOptions isn't"); INT32 Quality = pJPEGOptions->GetQuality(); // Default Quality BOOL Progressive = pJPEGOptions->DoAsProgressive(); if (Quality > 100) Quality = 100; s.MakeMsg(_R(IDS_JPEG)); s2.MakeMsg(_R(IDS_A), (const TCHAR*)s); if (Progressive) s2.MakeMsg(_R(IDS_PROGRESSIVE)); s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2); TempDiskFile.write(s); s.MakeMsg(_R(IDS_JCOMPRESSION),Quality); TempDiskFile.write(s); } // end case _R(IDS_JPG_EXP_FILTERNAME) break; case _R(IDT_FILTERNAME_BMP): { BMPExportOptions* pBMPOptions = (BMPExportOptions*)m_pOptions; ERROR3IF(!pBMPOptions->IS_KIND_OF(BMPExportOptions), "pBMPOptions isn't"); PALETTE Palette; DITHER DitherType; UINT32 colDepth; String_64 sPalette; String_64 Dither; UINT32 NoOfColours; NoOfColours=m_pOptions->GetNumColsInPalette(); Palette = pBMPOptions->GetPalette(); DitherType = pBMPOptions->GetDither(); colDepth = pBMPOptions->GetDepth(); s.MakeMsg(_R(IDS_BMP)); s2.MakeMsg(_R(IDS_A), (const TCHAR*)s); s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2); TempDiskFile.write(s); switch (Palette) { case PAL_OPTIMISED: sPalette.MakeMsg(_R(IDS_OPTIMISED_PAL)); break; case PAL_BROWSER: case PAL_STANDARD: sPalette.MakeMsg(_R(IDS_BROWSER_PAL)); break; case PAL_GLOBALOPTIMISED: sPalette.MakeMsg(_R(IDS_GLOBAL_OPT)); break; } if (colDepth == 8 && (Palette == PAL_STANDARD || Palette == PAL_BROWSER) ) { NoOfColours = 216; } if (colDepth == 8 && NoOfColours > 256) NoOfColours = 256; s2.MakeMsg(_R(IDS_PALETTEINFO),colDepth,NoOfColours,(const TCHAR*)sPalette); if (colDepth == 8) s2.MakeMsg(_R(IDS_AN_PALINFO),colDepth,NoOfColours,(const TCHAR*)sPalette); if (colDepth == 1) s2.MakeMsg(_R(IDS_MONO),colDepth); if (colDepth > 8) s2.MakeMsg(_R(IDS_TRUECOLOUR),colDepth); TempDiskFile.write(s2); s.MakeMsg(_R(IDS_NODITHER)); switch (DitherType) { case XARADITHER_ORDERED: case XARADITHER_ORDERED_GREY: Dither.MakeMsg(_R(IDS_DITH_ORDER)); s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither); break; case XARADITHER_ERROR_DIFFUSION: case XARADITHER_SIMPLE: Dither.MakeMsg(_R(IDS_DITH_ERROR)); s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither); break; case XARADITHER_NONE: s.MakeMsg(_R(IDS_NODITHER)); break; } TempDiskFile.write(s); } // end case _R(IDT_FILTERNAME_BMP) break; case _R(IDS_FILTERNAME_PNG): { PNGExportOptions* pPNGOptions = (PNGExportOptions*)m_pOptions; ERROR3IF(!pPNGOptions->IS_KIND_OF(PNGExportOptions), "pPNGOptions isn't"); PALETTE Palette = PAL_OPTIMISED; DITHER DitherType; UINT32 colDepth; String_64 sPalette; String_64 Dither; UINT32 NoOfColours; NoOfColours=m_pOptions->GetNumColsInPalette(); // Palette = pPNGOptions->GetPalette(); DitherType = pPNGOptions->GetDither(); colDepth = pPNGOptions->GetDepth(); if (pPNGOptions->WantTransparent()) count=count+1; if (pPNGOptions->WantInterlaced()) count=count+2; s.MakeMsg(_R(IDS_PNG)); s2.MakeMsg(_R(IDS_A), (const TCHAR*)s); switch (count) { case 1: s2.MakeMsg(_R(IDS_TRANSPARENT),"PNG"); break; case 2: s2.MakeMsg(_R(IDS_INTERLACED),"PNG"); break; case 3: s2.MakeMsg(_R(IDS_INTER_TRANS),"PNG"); break; case 0: break; } s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2); TempDiskFile.write(s); switch (Palette) { case PAL_OPTIMISED: sPalette.MakeMsg(_R(IDS_OPTIMISED_PAL)); break; case PAL_BROWSER: case PAL_STANDARD: sPalette.MakeMsg(_R(IDS_BROWSER_PAL)); break; case PAL_GLOBALOPTIMISED: sPalette.MakeMsg(_R(IDS_GLOBAL_OPT)); break; } if (colDepth == 8 && (Palette == PAL_STANDARD || Palette == PAL_BROWSER) ) { NoOfColours = 216; } s2.MakeMsg(_R(IDS_PALETTEINFO),colDepth,NoOfColours,(const TCHAR*)sPalette); if (colDepth == 8) s2.MakeMsg(_R(IDS_AN_PALINFO),colDepth,NoOfColours,(const TCHAR*)sPalette); if (colDepth == 1) s2.MakeMsg(_R(IDS_MONO),colDepth); if (colDepth > 8) s2.MakeMsg(_R(IDS_TRUECOLOUR),colDepth); TempDiskFile.write(s2); s.MakeMsg(_R(IDS_NODITHER)); switch (DitherType) { case XARADITHER_ORDERED: case XARADITHER_ORDERED_GREY: Dither.MakeMsg(_R(IDS_DITH_ORDER)); s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither); break; case XARADITHER_ERROR_DIFFUSION: case XARADITHER_SIMPLE: Dither.MakeMsg(_R(IDS_DITH_ERROR)); s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither); break; case XARADITHER_NONE: s.MakeMsg(_R(IDS_NODITHER)); break; } TempDiskFile.write(s); } // end case _R(IDS_FILTERNAME_PNG) break; } // end switch (m_pOptions->GetFilterNameStrID()) } // end else block GenerateBitmapInfoStrings(ImageSize, FileSize); // output the bitmap info s.MakeMsg(_R(IDS_HTML_INFO1), (TCHAR *)ImageSize); TempDiskFile.write(s); // output the bitmap file size info s.MakeMsg(_R(IDS_HTML_INFO2), (TCHAR *)FileSize); TempDiskFile.write(s); s.MakeMsg(_R(IDS_CLOSE_CENTER)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_TDTR_CLOSE)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_BANNER_BOX)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_SPEED_BUILD)); TempDiskFile.write(s); // s.MakeMsg(_R(IDS_SPEED_BUILD2)); // TempDiskFile.write(s); s.MakeMsg(_R(IDS_ES_TR)); TempDiskFile.write(s); String_64 times; s.MakeMsg(_R(IDS_TIME_ENTRY),"14.4k"); TempDiskFile.write(s); CalculateTime(times,14400.0); TempDiskFile.write(times); s.MakeMsg(_R(IDS_ES_TR)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_TIME_ENTRY),"28.8k"); TempDiskFile.write(s); CalculateTime(times,28800.0); TempDiskFile.write(times); s.MakeMsg(_R(IDS_ES_TR)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_TIME_ENTRY),"33.6k"); TempDiskFile.write(s); CalculateTime(times,33600.0); TempDiskFile.write(times); s.MakeMsg(_R(IDS_ES_TR)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_TIME_ENTRY),"57.6k"); TempDiskFile.write(s); CalculateTime(times,57600.0); TempDiskFile.write(times); s.MakeMsg(_R(IDS_ES_TR)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_TIME_ENTRY),"64k"); TempDiskFile.write(s); CalculateTime(times,65536.0); TempDiskFile.write(times); s.MakeMsg(_R(IDS_ES_TR)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_TIME_ENTRY),"128k"); TempDiskFile.write(s); CalculateTime(times,131072.0); TempDiskFile.write(times); // s.MakeMsg(_R(IDS_ES_TR)); // TempDiskFile.write(s); s.MakeMsg(_R(IDS_SPEED_END)); TempDiskFile.write(s); TRACE( _T("m_FileSize = %d"), m_FileSize); } // end of if (BrowserOptions.m_bInfo != FALSE) String_64 webaddy(_R(IDS_HTML_URL_PROGRAM)); //Mark Howitt, 29/10/97. Setup the _R(IDS_HTML_URL_VISITMSG) To be a TCHAR* Also. It likes it that way! String_64 webvmess(_R(IDS_HTML_URL_VISITMSG)); s.MakeMsg(_R(IDS_LINK_BOX),(TCHAR *)webaddy,(TCHAR *)webvmess); TempDiskFile.write(s); //end of my stuff s.MakeMsg(_R(IDS_END_TABLE)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_CLOSE_CENTER)); TempDiskFile.write(s); // output the "Exported from" string // get the xara logo file name String_256 Logo(_R(IDS_HTML_XARALOGO)); // set it in the path ProgramPath.SetFileNameAndType(Logo); // get the xara link String_256 URL(_R(IDS_HTML_URL_XARA)); // output the xara link and the xara logo s.MakeMsg(_R(IDS_HTML_XARA), (TCHAR *)URL, (TCHAR *)ProgramPath.GetWebAddress()); TempDiskFile.write(s); // Do not display the Xara X logo bottom right... /* // get the program logo file name Logo.Load(_R(IDS_HTML_PROGRAMLOGO)); // set it in the path ProgramPath.SetFileNameAndType(Logo); // output the program link URL.Load(_R(IDS_HTML_URL_PROGRAM)); s.MakeMsg(_R(IDS_HTML_PROGRAM), (TCHAR *)URL, (TCHAR *)ProgramPath.GetWebAddress()); TempDiskFile.write(s); */ // output the end of the file s.Load(_R(IDS_HTML_END)); TempDiskFile.write(s); // close the file TempDiskFile.close(); // now export the image map, if the option for that is set if (BrowserOptions.m_bImagemap != FALSE) { // export the image map ExportImagemap( TempDiskFile, m_pTempHTMLPath, m_pOptions->GetSelectionType(), m_pOptions->GetDPI(), BrowserOptions.m_ifoImagemapOptions); } TCHAR *FileWebAddress = m_pTempHTMLPath->GetWebAddress(); //Graham 17/9/97 ProgramPath.SetFileNameAndType(PRODUCT_WEBLINKEXENAME); const TCHAR *PathToWebLink = (const TCHAR *)ProgramPath.GetPath(); String_256 CmdLine = PathToWebLink + String_256(" -f ") + FileWebAddress; //TCHAR *CommandLine = (TCHAR *)CmdLine; if (!InvokeWeblink(CmdLine)) return FALSE; } // end of TRY block catch( CFileException ) { // any disk problems - come here // not much we can do really - just close the file and return FALSE if (TempDiskFile.isOpen()) TempDiskFile.close(); return FALSE; } #endif return TRUE; }
PCSAN LIBCALL LoadCSAN(CharPtr pcFile) { FILE *f; Char fullpath [PATH_MAX]; CharPtr ptr; PCSAN pcsanHead = NULL; PCSAN pcsanTemp = NULL; Char pcBuf[250]; CharPtr ppcParse[125]; CharPtr pcTemp = NULL; CharPtr pcTest = NULL; CharPtr pcSeqPart = NULL; ValNodePtr pvn = NULL; long int val = 0; Int4 i = 0; Int4 iString = 0; Int4 iLen =0; Int4 iWC =0; Int4 iWL = 0; Int4 iGi = 0; if (!pcFile) return(NULL); ProgramPath (fullpath, sizeof (fullpath) - 1); ptr = StringRChr (fullpath, DIRDELIMCHR); if (ptr != NULL) { *ptr = '\0'; } /* printf("FULLPATH[%s]\n",IsNullStr(fullpath)); */ FileBuildPath (fullpath, NULL, pcFile); /* printf("FULLPATH[%s]\n",IsNullStr(fullpath)); */ if ((f = FileOpen (fullpath, "r")) == NULL) { if (FindPath ("NCBI", "NCBI", "DATA", fullpath, sizeof (fullpath) - 1)) { FileBuildPath (fullpath, NULL, pcFile); f = FileOpen (fullpath, "r"); if (f == NULL) { ErrPost(CTX_NCBIOBJ, 1, "Couldn't open [%s] in LoadCSA", IsNullStr(fullpath)); return (NULL); } } else { ErrPost(CTX_NCBIOBJ, 1, "FindPath failed in LoadNeighbors"); return (NULL); } } do /* get each line, tokenize into ppcParse */ { pcBuf[0] = '\0'; pcTest = fgets(pcBuf, (size_t)250, f); /* printf("[%s]\n",IsNullStr(pcTest)); */ if (pcTest) { iLen = StringLen(pcTest); /* Break into words delimited by whitespace or "|" */ /* gi|123456| */ /* printf("LineLength %d\n",(int) iLen); */ for (i=0; i < 125; i++) ppcParse[i] = NULL; pcTemp = pcTest; ppcParse[0] = pcTest; iWC = 1; while ((*pcTemp != '\0') && (iWC < 125)) { if ((*pcTemp == '|') || (*pcTemp == ' ') || (*pcTemp == '\t') || (*pcTemp == '\n')) { *pcTemp = '\0'; /* terminate current word */ do { pcTemp++; /* skip whitespace to next word */ } while ((*pcTemp == '|') || (*pcTemp == ' ') || (*pcTemp == '\t') || (*pcTemp == '\n')); ppcParse[iWC] = pcTemp; /* start next word */ iWC++; } else pcTemp++; } /* DEBUG TEST */ /* for (i=0; i<125; i++) if (ppcParse[i] != NULL) { printf("%ld/%ld [%s]\n",i,iWC, IsNullStr(ppcParse[i])); } */ /* If ppcParse[0] is "gi" then this is a VALID sequence line and the last word parsed is the sequence */ if (ppcParse[0][0] != '\0') { iWL = StringLen(ppcParse[0]); if (iWL == 2) if (((ppcParse[0][0] == 'g') || (ppcParse[0][0] == 'G')) && ((ppcParse[0][1] == 'i') || (ppcParse[0][1] == 'I'))) { /* next word should be GI */ iGi = 0; if (StrToInt4 (ppcParse[1], &iGi)) { /* printf("GI is (%ld)\n",iGi); */ if (iGi == 0) goto parserr; /* find the 2nd last string = sequence */ /* last string is stripped off line terminator, by the way... */ iString=2; /* start after GI */ while (ppcParse[iString+1] != NULL) { /* iString is the LAST sting - line terminator */ iString++; } pcsanTemp = pcsanHead; while (pcsanTemp) { /* look for existing pcsan */ if (iGi == pcsanTemp->iGi) { break; } pcsanTemp = pcsanTemp->next; } if (!pcsanTemp) /* otherwise add a new one */ { pcsanTemp = NewCSAN(); pcsanTemp->next = pcsanHead; pcsanHead = pcsanTemp; /* put at head of list */ pcsanTemp->iGi = iGi; } /* Initialize fields */ pcSeqPart = NULL; pcSeqPart = StringSave(ppcParse[iString-1]); /* printf("SEQ [%ld]= [%s]\n",(long) iString-1, IsNullStr(pcSeqPart)); */ ValNodeAddStr(&pcsanTemp->pvnSeqAlnPart, 0, pcSeqPart); } /* if GI */ } /* if line starts with GI */ } /* if line starts with a word */ } /* if pcTest */ } while (pcTest); printf("REPORT\n"); pcsanTemp = pcsanHead; while (pcsanTemp) { printf("GI = [%ld]\n", (long) pcsanTemp->iGi); pvn = pcsanTemp->pvnSeqAlnPart; while (pvn) { printf(">%s<\n",(char *) IsNullStr(pvn->data.ptrvalue)); pvn = pvn->next; } pcsanTemp = pcsanTemp->next; } FileClose(f); return pcsanHead; parserr: FileClose(f); ErrPostEx(SEV_FATAL,0,0, "Error in input format \n"); FreeCSAN(pcsanHead); return NULL; }
Int2 Main (void) { Int2 db = -1; Int2 i; Boolean makeCDS; Char path [PATH_MAX]; CharPtr progname; FILE *fp; Int2 rsult; ErrSetFatalLevel (SEV_MAX); ErrClearOptFlags (EO_SHOW_USERSTR); UseLocalAsnloadDataAndErrMsg (); ErrPathReset (); if (! AllObjLoad ()) { Message (MSG_FATAL, "AllObjLoad failed"); return 1; } if (! SeqCodeSetLoad ()) { Message (MSG_FATAL, "SeqCodeSetLoad failed"); return 1; } if (! GeneticCodeTableLoad ()) { Message (MSG_FATAL, "GeneticCodeTableLoad failed"); return 1; } ProgramPath (path, sizeof (path)); progname = StringRChr (path, DIRDELIMCHR); if (progname != NULL) { progname++; } else { progname = "fetchent"; } /* GetArgs is a portable way of obtaining arguments */ if (! GetArgs (progname, NUMARG, myargs)) { Message (MSG_FATAL, "GetArgs failed"); return 1; } /* Map database argument to TYP_XX value */ for (i = 0; databases [i] != NULL; i++) { if (StringICmp (myargs [0].strvalue, databases [i]) == 0) { db = i; } } /* Convert M, P, or N alternative database symbols to proper code */ if (db >= 3 && db <= 5) { db -= 3; } if (db < 0 || db > 2) { Message (MSG_FATAL, "Database must be ML, AA, or NT"); return 1; } if (! EntrezInit (progname, FALSE, NULL)) { Message (MSG_FATAL, "EntrezInit failed"); return 1; } fp = FileOpen (myargs [2].strvalue, "w"); if (fp == NULL) { Message (MSG_FATAL, "FileOpen failed"); return 1; } makeCDS = (Boolean) myargs [3].intvalue; if (makeCDS && db != TYP_NT) { Message (MSG_ERROR, "Coding region extraction inappropriate"); makeCDS = FALSE; } rsult = ProcessQuery (db, myargs [1].strvalue, makeCDS, fp); FileClose (fp); EntrezFini (); return rsult; }
/***************************************************************************** * * PrintTemplateSetPtr PrintTemplateSetLoad() * loads PrintTemplates * If path== NULL, looks for "prt.prt" in the "data" directory * *****************************************************************************/ static Boolean PrintTemplateSetLoadInt ( CharPtr path, Boolean verbose ) { AsnIoPtr aip; FILE *f; Boolean retval; Char filename [80]; Char fullpath [PATH_MAX]; CharPtr ptr; ErrSev lastLevel; aip = NULL; if (path != NULL && *path != '\0' && StringRChr (path, DIRDELIMCHR) != NULL) { StringNCpy (fullpath, path, sizeof (fullpath) - 1); if ((aip = AsnIoOpen (fullpath, "r")) == NULL) { if (verbose) { ErrPost(CTX_NCBIOBJ, 1, "Couldn't open [%s]", fullpath); } return FALSE; } } else { if (path != NULL && *path != '\0') { StringNCpy (filename, path, sizeof (filename) - 1); } else { StringCpy (filename, "prt.prt"); } ProgramPath (fullpath, sizeof (fullpath) - 1); ptr = StringRChr (fullpath, DIRDELIMCHR); if (ptr != NULL) { *ptr = '\0'; } FileBuildPath (fullpath, NULL, filename); /* silence SEV_INFO errors from FileOpen() */ if ((lastLevel = ErrGetMessageLevel()) < SEV_WARNING) ErrSetMessageLevel (SEV_WARNING); if ((f = FileOpen (fullpath, "r")) == NULL) { ErrSetMessageLevel (lastLevel); if (FindPath ("NCBI", "NCBI", "DATA", fullpath, sizeof (fullpath) - 1)) { FileBuildPath (fullpath, NULL, filename); if ((aip = AsnIoOpen (fullpath, "r")) == NULL) { if (verbose) { ErrPost(CTX_NCBIOBJ, 1, "Couldn't open [%s]", fullpath); } return FALSE; } } else { if (verbose) { ErrPost(CTX_NCBIOBJ, 1, "FindPath failed in PrintTemplateSetLoad - ncbi configuration file missing or incorrect"); } return FALSE; } } else { ErrSetMessageLevel (lastLevel); FileClose (f); if ((aip = AsnIoOpen(fullpath, "r")) == NULL) { if (verbose) { ErrPost(CTX_NCBIOBJ, 1, "Couldn't open [%s]", fullpath); } return FALSE; } } } retval = PrintTemplateSetAsnRead(aip); AsnIoClose(aip); return retval; }