Beispiel #1
0
void GmUifApp::RemoveById (ubyte4 LogId)
{
	wxString tmpfile = GetTmpFile (GetAppName ());
	try {
		GmUnitedIndexFile uif (tmpfile, 0);
		const vector<GmUifRootEntry*> & roots = m_app.GetAllRootEntries ();
		GmSetDeleteFlagHandler handler (LogId);
		for (size_t index = 0; index < roots.size (); ++index) {
			GmUifRootPairT tree;
			GmAutoClearRootPairTree act (tree);
			m_app.GetUifRootTree (*roots[index], tree);
			for (size_t tindex = 0; tindex < tree.second->size (); ++tindex) {
				GmUifSourcePairT * pNode = (*tree.second)[tindex];
				TraverseTree (pNode->second, &handler, pNode->first->SourceName, GmUifAppHanldeFileType ());
			}

			ClearEmptyRootTreePair (tree);
			const GmUifRootEntry & entry = *tree.first;
			AddTheseTreeToUifFile (*tree.second, uif, (GmRootEntryType)entry.EntryType
									, entry.EntryDataType, entry.TraverseMtd, entry.EntryTime);
		}

		uif.Close ();
		m_app.Close ();
		if (wxRemoveFile (GetAppName ()))
			wxRenameFile (tmpfile, GetAppName ());
	}
	catch (...) {
		wxRemoveFile (tmpfile);
		throw;
	}
}
Beispiel #2
0
bool CMapiMessage::CopyMsgAttachToFile(LPATTACH lpAttach, /*out*/ nsIFile **tmp_file)
{
  bool bResult = true;
  LPMESSAGE  lpMsg;
  HRESULT hr = lpAttach->OpenProperty(PR_ATTACH_DATA_OBJ, &IID_IMessage, 0, 0,
                                      reinterpret_cast<LPUNKNOWN *>(&lpMsg));
  NS_ENSURE_SUCCESS(hr, false);

  if (!GetTmpFile(tmp_file))
    return false;

  nsCOMPtr<nsIOutputStream> destOutputStream;
  nsresult rv = MsgNewBufferedFileOutputStream(getter_AddRefs(destOutputStream), *tmp_file, -1, 0600);
  if (NS_SUCCEEDED(rv))
    rv = nsOutlookMail::ImportMessage(lpMsg, destOutputStream, nsIMsgSend::nsMsgSaveAsDraft);

  if (NS_FAILED(rv)) {
    (*tmp_file)->Remove(false);
    (*tmp_file)->Release();
    *tmp_file = 0;
  }

  return NS_SUCCEEDED(rv);
}
Beispiel #3
0
static void make_freq_file(char *str, int make_marks, double f1, double f2)
{
    int i = 0, njoin, image = 0;
    FILE *fpr, *fpw, *fopen();
    string f_file, t_file, foo;
    char buf[MAXBUFSIZE];
    double offset, fl, fu, f0, f2LO=0.0;
    SLAIM data;
    
    void XS_system(), send_line();
    double SpecUnitConv();
    char *GetTmpFile();
    
    fl = f1; fu = f2;
    
    if ((make_marks == 2 || make_marks == -1) && vP->s) {
        f2LO = 2.0 * vP->s->lofreq;
        fl = f2LO - f2;
        fu = f2LO - f1;
	image = 1;
    }
    f0 = (fl + fu)/2.0;

    if (strncmp(str, "SLAIM", 5)==0) {
        if (f0 > 200.0 && f0 < 300.0) {
            sprintf(f_file, "%s/%s2", pP->slaimDir, pP->slaimFile);
        } else if (f0 >= 300.0) {
            sprintf(f_file, "%s/%s3", pP->slaimDir, pP->slaimFile);
        } else {
            sprintf(f_file, "%s/%s1", pP->slaimDir, pP->slaimFile);
        }
        strcpy(t_file, GetTmpFile("slaim"));
        offset = 0.1 + image*0.1;
    } else if (strncmp(str, "JPL", 3)==0) {
        if (f0 > 15.0 && f0 < 70.0) {
            sprintf(f_file, "%s/jpl.015-070", pP->jplDir);
        } else if (f0 >=  70.0 && f0 < 120.0) {
            sprintf(f_file, "%s/jpl.070-120", pP->jplDir);
        } else if (f0 >= 120.0 && f0 < 200.0) {
            sprintf(f_file, "%s/jpl.120-200", pP->jplDir);
        } else if (f0 >= 200.0 && f0 < 300.0) {
            sprintf(f_file, "%s/jpl.200-300", pP->jplDir);
        } else if (f0 >= 300.0 && f0 < 400.0) {
            sprintf(f_file, "%s/jpl.300-400", pP->jplDir);
        } else if (f0 >= 400.0 && f0 < 500.0) {
            sprintf(f_file, "%s/jpl.400-500", pP->jplDir);
        } else if (f0 >= 500.0 && f0 < 600.0) {
            sprintf(f_file, "%s/jpl.500-600", pP->jplDir);
        } else {
            sprintf(f_file, "Don't have a JPL file for f=%f GHz.", f0);
            send_line(f_file);
            return;
        }
        strcpy(t_file, GetTmpFile("jpl"));
        offset = 0.2 + image*0.1;
    } else if (strncmp(str, "IDENT", 5)==0) {
        sprintf(f_file, "%s/%s", pP->identDir, pP->identFile);
        strcpy(t_file, GetTmpFile("ident"));
        offset = 0.3;
    } else if (strncmp(str, "sgrb2", 5)==0) {
        sprintf(f_file, "%s/%s", pP->identDir, str);
        strcpy(t_file, GetTmpFile(str));
        offset = 0.1;
    } else if (strncmp(str, "orion", 5)==0) {
        sprintf(f_file, "%s/%s", pP->identDir, str);
        strcpy(t_file, GetTmpFile(str));
        offset = 0.0;
    } else if (strncmp(str, "LOVAS", 5)==0) {
        sprintf(f_file, "%s/%s", pP->lovasDir, pP->lovasFile);
        strcpy(t_file, GetTmpFile("lovas"));
        offset = 0.4 + image*0.1;
    } else {
        return;
    }
    if ((fpr = fopen(f_file, "r")) == NULL) {
        sprintf(foo, "Unable to open %s for reading.", f_file);
        PostErrorDialog(NULL, foo);
        return;
    }
    sprintf(foo, "%s %s", pP->unixRmCmd, t_file);
    XS_system(foo, 0);
    if ((fpw = fopen(t_file, "w")) == NULL) {
        sprintf(foo, "Unable to open %s for writing.", t_file);
        PostErrorDialog(NULL, foo);
        if (fpr) fclose(fpr);
        return;
    }

    while((fgets(buf, MAXBUFSIZE, fpr)) != NULL) {
        buf[strlen(buf)-1] = '\0';
        if (strncmp(str, "SLAIM", 5)==0) { 
            obtain_slaim_data(buf, &data);
        } 
        if (strncmp(str, "JPL", 3)==0) {
            obtain_jpl_data(buf, &data);
        } 
        if (strncmp(str, "IDENT", 5)==0) {
            if (buf[0] != ' ') continue;
            obtain_ident_data(buf, &data);
        }
        if (strncmp(str, "sgrb2", 5)==0 || strncmp(str, "orion", 5)==0) {
            if (str[0] == '#' || str[0] == '!') continue;
            obtain_sgrb2_data(buf, &data);
        }
        if (strncmp(str, "LOVAS", 5)==0) {
            obtain_lovas_data(buf, &data);
        }
        if (data.fre_cal >= 1000.0*fl && data.fre_cal <= 1000.0*fu) {
            fprintf(fpw, "%s\n", buf);
            if (make_marks >= 1 && nmark < MAXMARK) {
                mark_xunit = vP->xunit;
		if (image) {
                  f0 = SpecUnitConv(mark_xunit, UNIT_FRE,
		                     f2LO - data.fre_cal/1000.0);
		} else {
                  f0 = SpecUnitConv(mark_xunit, UNIT_FRE, data.fre_cal/1000.0);
		}
                marks[nmark].mode = 0;
                marks[nmark].x = f0;
                if (offset == 0.0) {
                    marks[nmark].y = data.line_str;
                    marks[nmark].align = 0.0;
                    marks[nmark].type  = MARK_TYPE_LINE;
                } else {
                    marks[nmark].y = vP->yupper - offset*vP->yrange;
                    marks[nmark].align = 0.5;
                    marks[nmark].type  = MARK_TYPE_ARROW;
                }
                marks[nmark].angle = 90.0;
                marks[nmark].xlength = 20;
                marks[nmark].ylength = 20;
                marks[nmark].tagged = 0;
                njoin = nmark + data.joined;
                if (njoin != nmark && njoin >= 0 && njoin < MAXMARK)
                    marks[nmark].mark = &marks[njoin];
                else
                    marks[nmark].mark = NULL;
                marks[nmark].dir = MARK_DIR_DOWN;
                strcpy(marks[nmark].label, data.mol);
                nmark++;
            }
            i++;
        }
    }
    fclose(fpw);
    fclose(fpr);
    if (make_marks <= 0) {
        sprintf(foo, "%s %s &", pP->editor, t_file);
        XS_system(foo, 1);
    }
}
Beispiel #4
0
/*** zPrint - <print> editor function
*
*   Prints file(s) or designated area
*
*   Input:
*	NOARG	    Print current file
*	TEXTARG     List of files to print
*	STREAMARG   Print designated area
*	BOXARG	    Print designated area
*	LINEARG     Print designated area
*
*   Output:
*	Returns TRUE if the printing has been successful, FALSE otherwise
*
*************************************************************************/
flagType
zPrint (
    CMDDATA argData,
    ARG * pArg,
    flagType fMeta
    )
{
    flagType	fOK;		    /* Holds the return value		*/
    PFILE       pFile;              /* general file pointer             */

    /*
     * The following is used only when we scan a list of files (TEXTARG)
     */
    flagType	fNewFile;	    /* Did we open a new file ? 	*/
    buffer	pNameList;	    /* Holds the list of file names	*/
    char	*pName, *pEndName;  /* Begining and end of file names	*/
    flagType	fDone = FALSE;	    /* Did we finish with the list ?	*/

    /*
     *	If we can flush the files, that's the moment
     */
    AutoSave ();

    switch (pArg->argType) {

	case NOARG:
	    return (DoPrint (pFileHead, FALSE));

	case TEXTARG:
	    /*
	     * Get the list in a buffer
	     */
	    strcpy ((char *) pNameList, pArg->arg.textarg.pText);

	    /*
	     * Empty list = no work
	     */
            if (!*(pName = whiteskip (pNameList))) {
                return FALSE;
            }

	    /*
	     * For each name:
	     *	     - pName points at the begining
	     *	     - Make pEndName pointing just past its ends
	     *	     - If it's already the end of the string
	     *		then we're done with the list
	     *		else put a zero terminator there
	     *	     - Do the job with the name we've found :
	     *		. Get the file handle (if it doen't exist yet,
	     *		  create one and switch fNewFile on
	     *		. Call DoPrint
	     *	     - Let pName point to the next name
	     */
	    fOK = TRUE;

	    do {
		pEndName = whitescan (pName);
                if (*pEndName) {
		    *pEndName = 0;
                } else {
                    fDone = TRUE;
                }

		if ((pFile = FileNameToHandle (pName, pName)) == NULL) {
		    pFile = AddFile (pName);
		    FileRead (pName, pFile, FALSE);
		    fNewFile = TRUE;
                } else  {
                    fNewFile = FALSE;
                }

		fOK &= DoPrint (pFile, FALSE);

                if (fNewFile) {
                    RemoveFile (pFile);
                }

		pName = whiteskip (++pEndName);

            } while (!fDone && *pName);

	    /*
	     * Just in case we would change the behaviour to stopping all
	     * things at the first error :
	     *
	     *	} while (fOK && !fDone && *pName);
	     */
            return (fOK);

	case STREAMARG:
	case BOXARG:
	case LINEARG:
	    /*
	     *	If we print an area, we'll put the text in a temporary file,
	     *	call DoPrint with this file and then destroy it.
	     */
	    pFile = GetTmpFile ();

	    switch (pArg->argType) {
		case STREAMARG:
		    CopyStream (pFileHead, pFile,
				pArg->arg.streamarg.xStart, pArg->arg.streamarg.yStart,
				pArg->arg.streamarg.xEnd, pArg->arg.streamarg.yEnd,
				0L,0L);
                    break;

		case BOXARG:
		    CopyBox (pFileHead, pFile,
			     pArg->arg.boxarg.xLeft, pArg->arg.boxarg.yTop,
			     pArg->arg.boxarg.xRight, pArg->arg.boxarg.yBottom,
			     0L,0L);
                    break;

		case LINEARG:
		    CopyLine (pFileHead, pFile,
			      pArg->arg.linearg.yStart, pArg->arg.linearg.yEnd,
			      0L);
		    break;
            }

	    /*
	     * If we have to spawn a print command, then we need to make a real
	     * disk file
	     */
            if (pPrintCmd && (!FileWrite (pFile->pName, pFile))) {
		fOK = FALSE;
            } else {
                fOK = DoPrint (pFile, TRUE);
            }
	    RemoveFile (pFile);
	    return (fOK);
    }
    argData; fMeta;
}