示例#1
0
long frameTroubleCodes::LoadDTC_OBD(CPtrList* pStorage)
{
	CString sError;
	POSITION pos = NULL;
	LPSTRUCT_LABELITEM lpItem = NULL;

TRYTRY

EXCEPTION_BOOKMARK(__LINE__)
	frameList* lpFrameList = NULL;
	lpFrameList = (frameList*)lpSplitter->GetPane(1,0);

EXCEPTION_BOOKMARK(__LINE__)
	pos = pStorage->GetHeadPosition();
	while(pos != NULL)
	{
		lpItem = (LPSTRUCT_LABELITEM)pStorage->GetNext(pos);
		lpFrameList->lpList->InsertItem(lpFrameList->lpList->GetItemCount(),lpItem->szID);
		lpFrameList->lpList->SetItemText(lpFrameList->lpList->GetItemCount()-1,1,lpItem->szLabel);
	}
	lpFrameList->SortTextItems(0,TRUE,0,-1);

CATCHCATCH("frameTroubleCodes::LoadDTC_OBD()");

	if(bExceptionFlag == EXEPT_CONTINUE)
		return FALSE;
	if(bExceptionFlag == EXEPT_ABORT)
		nuke();

	return TRUE;
}
void frameDTCReader::OnUpdateHistoricDTC(WPARAM wParam,LPARAM lParam)
{
	CString sError;
	LPSTRUCT_DTCITEM lpDTCItem = (LPSTRUCT_DTCITEM)lParam;

TRYTRY

EXCEPTION_BOOKMARK(__LINE__)
	frameList* lpList_historic = NULL;
	lpList_historic = (frameList*)lpSplitter->GetPane(1,0);

EXCEPTION_BOOKMARK(__LINE__)
	LVFINDINFO findInfo;
	findInfo.flags = LVFI_PARTIAL|LVFI_STRING;
	findInfo.psz = lpDTCItem->szID;

	if(lpList_historic->lpList->FindItem(&findInfo) == -1)
	{
		lpList_historic->lpList->InsertItem(lpList_historic->lpList->GetItemCount(),lpDTCItem->szID);
		lpList_historic->lpList->SetItemText(lpList_historic->lpList->GetItemCount()-1,1,lpDTCItem->szLabel);
	}

CATCHCATCH("frameDTCReader::OnUpdateHistoricDTC()");

	if(bExceptionFlag == EXEPT_CONTINUE)
	{}
	if(bExceptionFlag == EXEPT_ABORT)
		nuke();

	return;
}
示例#3
0
void frameTableEditor::OnSize(UINT nType,int cx,int cy)
{
	CString sError;

TRYTRY

EXCEPTION_BOOKMARK(__LINE__)
	CFrameWnd::OnSize(nType,cx,cy);

EXCEPTION_BOOKMARK(__LINE__)
	RECT rect;
	GetClientRect(&rect);

EXCEPTION_BOOKMARK(__LINE__)
//	lpGrid->MoveWindow(rect.left,rect.top,rect.right,rect.bottom,TRUE);

CATCHCATCH("frameTableEditor::OnSize()");

	if(bExceptionFlag == EXEPT_CONTINUE)
	{}
	if(bExceptionFlag == EXEPT_ABORT)
		nuke();

	return;
}
示例#4
0
BOOL frameTableEditor::PreCreateWindow(CREATESTRUCT& cs)
{
	CString sError;

TRYTRY

EXCEPTION_BOOKMARK(__LINE__)
	if(!CFrameWnd::PreCreateWindow(cs))
		return FALSE;

EXCEPTION_BOOKMARK(__LINE__)
	cs.lpszName = "Table Editor";
	cs.style = WS_CAPTION | WS_THICKFRAME | WS_SYSMENU;
	cs.dwExStyle = WS_EX_TOOLWINDOW | WS_EX_CLIENTEDGE;
	cs.hMenu = NULL;
	cs.cx = 350;
	cs.cy = 175;

CATCHCATCH("frameTableEditor::PreCreateWindow()");

	if(bExceptionFlag == EXEPT_CONTINUE)
		return -1;
	if(bExceptionFlag == EXEPT_ABORT)
		nuke();

	return TRUE;
}
示例#5
0
文件: Hero.cpp 项目: Rdbaker/wings
// Take appropriate action according to key pressed.
void Hero::kbd(const df::EventKeyboard *p_keyboard_event) {

  switch(p_keyboard_event->getKey()) {
  case df::Keyboard::W:       // up
    if (p_keyboard_event->getKeyboardAction() == df::KEY_DOWN)
      move(-1);
    break;
  case df::Keyboard::S:       // down
    if (p_keyboard_event->getKeyboardAction() == df::KEY_DOWN)
      move(+1);
    break;
  case df::Keyboard::SPACE:   // nuke!
    if (p_keyboard_event->getKeyboardAction() == df::KEY_PRESSED)
      nuke();
    break;
 case df::Keyboard::Q:        // quit
   if (p_keyboard_event->getKeyboardAction() == df::KEY_PRESSED) {
     df::WorldManager &world_manager = df::WorldManager::getInstance();
     df::NetworkManager &net_mgr = df::NetworkManager::getInstance();
     new GameOver;
     world_manager.markForDelete(this);
    }
    break;
 default:
    break;
  };

  return;
}
示例#6
0
文件: itrash.c 项目: Andiry/xfstests
int main(int argc, char* argv[])
{
	int f;
	loff_t offset;

	if (argc != 3) {
		printf("%s <device> <offset>\n", argv[0]);
		exit(1);
	}

	f = open(argv[1], O_RDWR);
	offset = atoll(argv[2]);

	if (f < 0) die("open");
	if (lseek(f, offset, SEEK_SET) < 0) die("lseek");
	if (read(f, buffer, 32768) != 32768) die("read");
	printf("Starting overwrite\n");
	nuke();
	if (lseek(f, offset, SEEK_SET) < 0) die("lseek");
	if (write(f, buffer, 32768) != 32768) die("write");
	if (!overwrote)
		printf("Did not overwrite any inodes\n");
	printf("Overwrite complete\n");
	close(f);
	return 0;
}
示例#7
0
void IPCEngineHost::readyRead()
{
    QDataStream s(m_device);
    SET_NATIVE_BYTE_ORDER(s);
    if (!m_nextMessagePayloadSize) {
        if (quint64(m_device->bytesAvailable ()) < 3 * sizeof(quint64))
            return;
        s >> m_nextMessageCookie;
        s >> m_nextMessageFunction;
        s >> m_nextMessagePayloadSize;
        m_nextMessagePayloadSize += 1; // Terminator and "got header" marker.
    }

    quint64 ba = m_device->bytesAvailable();
    if (ba < m_nextMessagePayloadSize)
        return;

    QByteArray payload = m_device->read(m_nextMessagePayloadSize - 1);

    char terminator;
    m_device->getChar(&terminator);
    if (terminator != 'T') {
        showStatusMessage(tr("Fatal engine shutdown. Incompatible binary or IPC error."));
        showMessage(QLatin1String("IPC Error: terminator missing"));
        nuke();
        return;
    }
    rpcCallback(m_nextMessageFunction, payload);
    m_nextMessagePayloadSize = 0;
    if (quint64(m_device->bytesAvailable()) >= 3 * sizeof(quint64))
        QTimer::singleShot(0, this, SLOT(readyRead()));
}
示例#8
0
文件: nuke.c 项目: Agochka/klibc
static int nuke_dirent(int len, const char *dir, const char *name)
{
	int bytes = len + strlen(name) + 2;
	char path[bytes];
	int xlen;

	xlen = snprintf(path, bytes, "%s/%s", dir, name);
	assert(xlen < bytes);

	return nuke(path);
}
示例#9
0
文件: nuke.c 项目: Agochka/klibc
int main(int argc, char *argv[])
{
	int i;

	program = argv[0];

	for (i = 1; i < argc; i++)
		nuke(argv[i]);

	return 0;
}
示例#10
0
BOOL frameTableEditor::OnCreateClient(LPCREATESTRUCT lpcs,CCreateContext* pContext)
{
	CString sError;

TRYTRY

EXCEPTION_BOOKMARK(__LINE__)
	if(!CFrameWnd::OnCreateClient(lpcs,pContext))
		return FALSE;

EXCEPTION_BOOKMARK(__LINE__)
	lpFont = new CFont;
	LOGFONT lf;

	memset(&lf, 0, sizeof(LOGFONT));
	lf.lfHeight = 0xfffffff5;
	lf.lfWeight = FW_REGULAR;
	lf.lfOutPrecision = OUT_STROKE_PRECIS;
	lf.lfClipPrecision = CLIP_STROKE_PRECIS;
	lf.lfQuality = DRAFT_QUALITY;
	lf.lfPitchAndFamily = 0x22;
	lf.lfCharSet = 0;
	strcpy(lf.lfFaceName,"Tahoma");

	lpFont->CreateFontIndirect(&lf);

EXCEPTION_BOOKMARK(__LINE__)
	CRect rect;
	GetClientRect(&rect);

EXCEPTION_BOOKMARK(__LINE__)
	frameGrid* lpGrid;
	if((lpGrid = new frameGrid()) == NULL)
	{
		sError.Format("Memory Error - callbackRomTables [lpGrid] : %i [0x%X]",GetLastError()); 
		OutputString(sError,TRUE);
		return F_NO_MEMORY;
	}
	lpGrid->Create(NULL,NULL,WS_CHILD | WS_VISIBLE,rect,this,NULL,0,pContext);

CATCHCATCH("frameTableEditor::OnCreateClient()");

	if(bExceptionFlag == EXEPT_CONTINUE)
		return FALSE;
	if(bExceptionFlag == EXEPT_ABORT)
		nuke();

	return TRUE;
}
示例#11
0
static int nuke_dirent(int len, const char *dir, const char *name, dev_t me)
{
	int bytes = len + strlen(name) + 2;
	char path[bytes];
	int xlen;
	struct stat st;

	xlen = snprintf(path, bytes, "%s/%s", dir, name);
	assert(xlen < bytes);

	if (lstat(path, &st))
		return ENOENT;	/* Return 0 since already gone? */

	if (st.st_dev != me)
		return 0;	/* DO NOT recurse down mount points!!!!! */

	return nuke(path);
}
void frameDTCReader::OnPauseDTC()
{
	CString sError;

TRYTRY

EXCEPTION_BOOKMARK(__LINE__)
	if(lpParent->bThreadDTCQuery == TRUE)
		lpParent->StopDTCQueryThread();
	else
		lpParent->StartDTCQueryThread();

CATCHCATCH("frameRealtime::OnPauseDataCapture()");

	if(bExceptionFlag == EXEPT_CONTINUE)
	{}
	if(bExceptionFlag == EXEPT_ABORT)
		nuke();

	return;
}
void frameDTCReader::ResizeSplitter()
{
	CString sError;

TRYTRY

EXCEPTION_BOOKMARK(__LINE__)
	RECT rect;
	::GetClientRect(lpParent->lpMainFrame->splitterWndLeft.m_hWnd,&rect);
	lpSplitter->SetRowInfo(0,(rect.bottom * lpParent->GetRegistryValue("Settings","splitterDTCReader",50)) / 100,40);
	lpSplitter->RecalcLayout();

CATCHCATCH("frameDTCReader::ResizeSplitter()");

	if(bExceptionFlag == EXEPT_CONTINUE)
	{}
	if(bExceptionFlag == EXEPT_ABORT)
		nuke();

	return;
}
示例#14
0
static int goku_ep_disable(struct usb_ep *_ep)
{
	struct goku_ep	*ep;
	struct goku_udc	*dev;
	unsigned long	flags;

	ep = container_of(_ep, struct goku_ep, ep);
	if (!_ep || !ep->ep.desc)
		return -ENODEV;
	dev = ep->dev;
	if (dev->ep0state == EP0_SUSPEND)
		return -EBUSY;

	VDBG(dev, "disable %s\n", _ep->name);

	spin_lock_irqsave(&dev->lock, flags);
	nuke(ep, -ESHUTDOWN);
	ep_reset(dev->regs, ep);
	spin_unlock_irqrestore(&dev->lock, flags);

	return 0;
}
示例#15
0
// Take appropriate action according to key pressed.
void Hero::kbd(const df::EventKeyboard *p_keyboard_event) {

  switch(p_keyboard_event->getKey()) {
  case df::Keyboard::W:			// up
    if (p_keyboard_event->getKeyboardAction() == df::KEY_DOWN)
      move(-1);
    break;
  case df::Keyboard::S:			// down
    if (p_keyboard_event->getKeyboardAction() == df::KEY_DOWN)
      move(+1);
    break;
  case df::Keyboard::SPACE:		// nuke!
    if (p_keyboard_event->getKeyboardAction() == df::KEY_PRESSED)
      nuke();
    break;
  case df::Keyboard::Q:			// quit
    if (p_keyboard_event->getKeyboardAction() == df::KEY_PRESSED)
      WM.markForDelete(this);
    break;
  };

  return;
}
示例#16
0
void LldbEngineHost::finished(int, QProcess::ExitStatus status)
{
    showMessage(QString(QLatin1String("guest went bye bye. exit status: %1 and code: %2"))
                .arg(status).arg(m_guestProcess->exitCode()), LogError);
    nuke();
}
示例#17
0
void IPCEngineHost::rpcCallback(quint64 f, QByteArray payload)
{
    switch (f) {
        default: {
            showMessage(QLatin1String("IPC Error: unhandled id in guest to host call"));
            const QString logMessage = tr("Fatal engine shutdown. Incompatible binary or IPC error.");
            showMessage(logMessage, LogError);
            showStatusMessage(logMessage);
    }
            nuke();
            break;
        case IPCEngineGuest::NotifyEngineSetupOk:
            notifyEngineSetupOk();
            break;
        case IPCEngineGuest::NotifyEngineSetupFailed:
            notifyEngineSetupFailed();
            break;
        case IPCEngineGuest::NotifyEngineRunFailed:
            notifyEngineRunFailed();
            break;
        case IPCEngineGuest::NotifyInferiorSetupOk:
            attemptBreakpointSynchronization();
            notifyInferiorSetupOk();
            break;
        case IPCEngineGuest::NotifyInferiorSetupFailed:
            notifyInferiorSetupFailed();
            break;
        case IPCEngineGuest::NotifyEngineRunAndInferiorRunOk:
            notifyEngineRunAndInferiorRunOk();
            break;
        case IPCEngineGuest::NotifyEngineRunAndInferiorStopOk:
            notifyEngineRunAndInferiorStopOk();
            break;
        case IPCEngineGuest::NotifyInferiorRunRequested:
            notifyInferiorRunRequested();
            break;
        case IPCEngineGuest::NotifyInferiorRunOk:
            notifyInferiorRunOk();
            break;
        case IPCEngineGuest::NotifyInferiorRunFailed:
            notifyInferiorRunFailed();
            break;
        case IPCEngineGuest::NotifyInferiorStopOk:
            notifyInferiorStopOk();
            break;
        case IPCEngineGuest::NotifyInferiorSpontaneousStop:
            notifyInferiorSpontaneousStop();
            break;
        case IPCEngineGuest::NotifyInferiorStopFailed:
            notifyInferiorStopFailed();
            break;
        case IPCEngineGuest::NotifyInferiorExited:
            notifyInferiorExited();
            break;
        case IPCEngineGuest::NotifyInferiorShutdownOk:
            notifyInferiorShutdownOk();
            break;
        case IPCEngineGuest::NotifyInferiorShutdownFailed:
            notifyInferiorShutdownFailed();
            break;
        case IPCEngineGuest::NotifyEngineSpontaneousShutdown:
            notifyEngineSpontaneousShutdown();
            break;
        case IPCEngineGuest::NotifyEngineShutdownOk:
            notifyEngineShutdownOk();
            break;
        case IPCEngineGuest::NotifyEngineShutdownFailed:
            notifyEngineShutdownFailed();
            break;
        case IPCEngineGuest::NotifyInferiorIll:
            notifyInferiorIll();
            break;
        case IPCEngineGuest::NotifyEngineIll:
            notifyEngineIll();
            break;
        case IPCEngineGuest::NotifyInferiorPid:
            {
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                quint64 pid;
                s >> pid;
                notifyInferiorPid(pid);
            }
            break;
        case IPCEngineGuest::ShowStatusMessage:
            {
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                QString msg;
                qint64 timeout;
                s >> msg;
                s >> timeout;
                showStatusMessage(msg, timeout);
            }
            break;
        case IPCEngineGuest::ShowMessage:
            {
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                QString msg;
                qint16 channel;
                qint64 timeout;
                s >> msg;
                s >> channel;
                s >> timeout;
                showMessage(msg, channel, timeout);
            }
            break;
        case IPCEngineGuest::CurrentFrameChanged:
            {
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                quint64 token;
                s >> token;

                resetLocation();
                StackHandler *sh = stackHandler();
                sh->setCurrentIndex(token);
                if (!sh->currentFrame().isUsable() || QFileInfo(sh->currentFrame().file).exists())
                    gotoLocation(Location(sh->currentFrame(), true));
                else if (!m_sourceAgents.contains(sh->currentFrame().file))
                    fetchFrameSource(token);
                foreach(SourceAgent *agent, m_sourceAgents.values())
                    agent->updateLocationMarker();
            }
            break;
        case IPCEngineGuest::CurrentThreadChanged:
            {
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                quint64 token;
                s >> token;
                threadsHandler()->setCurrentThreadId(token);
            }
            break;
        case IPCEngineGuest::ListFrames:
            {
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                StackFrames frames;
                s >> frames;
                stackHandler()->setFrames(frames);
            }
            break;
        case IPCEngineGuest::ListThreads:
            {
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                Threads threads;
                s >> threads;
                threadsHandler()->setThreads(threads);
            }
            break;
        case IPCEngineGuest::Disassembled:
            {
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                quint64 pc;
                DisassemblerLines lines;
                s >> pc;
                s >> lines;
                DisassemblerAgent *view = m_frameToDisassemblerAgent.take(pc);
                if (view)
                    view->setContents(lines);
            }
            break;
        case IPCEngineGuest::UpdateWatchData:
            {
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                bool fullCycle;
                qint64 count;
                QList<WatchData> wd;
                s >> fullCycle;
                s >> count;
                for (qint64 i = 0; i < count; ++i) {
                    WatchData d;
                    s >> d;
                    wd.append(d);
                }
                WatchHandler *wh = watchHandler();
                if (!wh)
                    break;
                wh->beginCycle(fullCycle);
                wh->insertBulkData(wd);
                wh->endCycle(fullCycle);
            }
            break;
        case IPCEngineGuest::NotifyAddBreakpointOk:
            {
                attemptBreakpointSynchronization();
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                BreakpointId id;
                s >> id;
                breakHandler()->notifyBreakpointInsertOk(id);
            }
            break;
        case IPCEngineGuest::NotifyAddBreakpointFailed:
            {
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                BreakpointId id;
                s >> id;
                breakHandler()->notifyBreakpointInsertFailed(id);
            }
            break;
        case IPCEngineGuest::NotifyRemoveBreakpointOk:
            {
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                BreakpointId id;
                s >> id;
                breakHandler()->notifyBreakpointRemoveOk(id);
            }
            break;
        case IPCEngineGuest::NotifyRemoveBreakpointFailed:
            {
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                BreakpointId id;
                s >> id;
                breakHandler()->notifyBreakpointRemoveFailed(id);
            }
            break;
        case IPCEngineGuest::NotifyChangeBreakpointOk:
            {
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                BreakpointId id;
                s >> id;
                breakHandler()->notifyBreakpointChangeOk(id);
            }
            break;
        case IPCEngineGuest::NotifyChangeBreakpointFailed:
            {
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                BreakpointId id;
                s >> id;
                breakHandler()->notifyBreakpointChangeFailed(id);
            }
            break;
        case IPCEngineGuest::NotifyBreakpointAdjusted:
            {
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                BreakpointId id;
                BreakpointParameters d;
                s >> id >> d;
                breakHandler()->notifyBreakpointAdjusted(id, d);
            }
            break;
        case IPCEngineGuest::FrameSourceFetched:
            {
                QDataStream s(payload);
                SET_NATIVE_BYTE_ORDER(s);
                qint64 token;
                QString path;
                QString source;
                s >> token >> path >> source;
                SourceAgent *agent = new SourceAgent(this);
                agent->setSourceProducerName(startParameters().connParams.host);
                agent->setContent(path, source);
                m_sourceAgents.insert(path, agent);
                agent->updateLocationMarker();
            }
            break;
    }
}
示例#18
0
static Froot *buildTree(
  char  *dirName,
  Froot *subDirs
){

  /**
   | - Opens the required directory;
   | - allocates a structure to hold the names of the TeX-related files,
   |   initialized from the global structure "protoTree";
   | - starts a loop over all the files of the given directory.
  **/

  DIR           *pDir;         /* Pointer returned from opendir()    */
  struct dirent *pDe;          /* Pointer returned from readdir()    */
  Froot         *teXTree;      /* Root node of the TeX-related files */

  if (output_level >= DEBUG) {
    printf("* Scanning directory \"%s\" - confirm = %c, recurse = %c, ",
         dirName, (confirm ? 'Y' : 'N'), (recurse ? 'Y' : 'N')),
    printf("keep = %c\n", (keep ? 'Y' : 'N'));
    printf("* Editor trailer: \"%s\"\n", bExt);
    puts("------------------------------Phase 1: directory scan");
  }

  if ((pDir = opendir(dirName)) == 0) {
    fprintf(stderr,
            "%s: \"%s\" cannot be opened (or is not a directory)\n",
            programName, dirName);
    return 0;
  }

  if ((teXTree = malloc(sizeof(protoTree))) == 0) {
    noMemory();
  }
  memcpy(teXTree, protoTree, sizeof(protoTree));

  while ((pDe = readdir(pDir)) != 0) {
    char    tName[FILENAME_MAX];         /* Fully qualified file name       */
    struct  stat sStat;                  /* To be filled by stat(2)         */
    size_t  len;                         /* Lenght of the current file name */
    size_t  last;                        /* Index of its last character     */
    char   *pFe;                         /* Pointer to file extension       */

    /**
     | - Tests for empty inodes (already removed files);
     | - skips the . and .. (current and previous directory);
     | - tests the trailing part of the file name against the extension of
     |   the backup files, to be always deleted.
    **/

    if (pDe->d_ino == 0)                continue;
    if (strcmp(pDe->d_name, ".")  == 0) continue;
    if (strcmp(pDe->d_name, "..") == 0) continue;

    sprintf(tName, "%s/%s", dirName, pDe->d_name);

    len  = strlen(pDe->d_name);
    last = len - 1;

    if (n_bExt != 0) {                  /* If 0, no backup files to delete */
      int crit;                         /* What exceeds backup extensions  */

      crit = len - n_bExt;
      if (crit > 0   &&   strcmp(pDe->d_name + crit, bExt) == 0) {
        nuke(tName);
        continue;
      }
    }

    /**
     | If the file is a directory and the -r option has been given, stores
     | the directory name in the linked list pointed to by "subDirs", for
     | recursive calls.
     |
     | N.B.: if stat(2) fails, the file is skipped.
    **/

    if (stat(tName, &sStat) != 0) {
      fprintf(stderr, "File \"%s", tName);
      perror("\"");
      continue;
    }

    if (S_ISDIR(sStat.st_mode) != 0) {

      if (output_level >= DEBUG) {
        printf("File %s - is a directory\n", pDe->d_name);
      }

      if (recurse) {
        insertNode(tName, 0, 0, 0, subDirs);
      }
      continue;
    }

    /**
     | If the file has an extension (the rightmost dot followed by at
     | least one character), and if that extension matches one of the
     | entries in teXTree[i].extension: stores the file name (with the
     | extension stripped) in the appropriate linked list, together with
     | its modification time.
    **/

    if ((pFe = strrchr(pDe->d_name, '.')) != 0) {
      size_t nameLen;

      nameLen = pFe - pDe->d_name;
      if (nameLen < last) {
        Froot *pTT;

        if (output_level >= DEBUG) {
          printf("File %s - extension %s", pDe->d_name, pFe);
        }

        /**
         | Loop on recognized TeX-related file extensions
        **/

        for (pTT = teXTree;   pTT->extension != 0;   pTT++) {
          if (strcmp(pFe, pTT->extension) == 0) {
            insertNode(pDe->d_name, nameLen, sStat.st_mtime, access(tName, W_OK), pTT);

            if (output_level >= DEBUG) {
              printf(" - inserted in tree");
            }
            break;
          }
        } /* loop on known extensions */

        if (output_level >= DEBUG) {
          puts("");
        }

      } else {
        if (output_level >= VERBOSE) {
          printf("File %s - empty extension\n", pDe->d_name);
        }
      }

    } else {
      if (output_level >= DEBUG) {
        printf("File %s - without extension\n", pDe->d_name);
      }
    }
  }             /* while (readdir) ... */

  if (closedir(pDir) != 0) {
    fprintf(stderr, "Directory \"%s", dirName);
    perror("\"");
  }

  return teXTree;
}
示例#19
0
static void examineTree(
  Froot *teXTree,
  char  *dirName
){

  /**
   | Examines the linked lists for this directory doing the effective
   | cleanup.
  **/

  Froot *pTT;           /* Pointer over linked list trees      */
  Fnode *pTeX;          /* Running pointer over the .tex files */

  /**
   | Looks, for all the .tex files, if a corresponding entry with the same
   | name exists (with a different extension) in the other lists; if so,
   | and if its modification time is later than the one of the related
   | .tex file, removes it from the file system.
  **/
  putsMessage("------------------------------Phase 3: effective cleanup",
              DEBUG);

  for (pTeX = teXTree->firstNode;   pTeX != 0;   pTeX = pTeX->next) {
    char tName[FILENAME_MAX];

    sprintf(tName, "%s/%s.tex", dirName, pTeX->name);
    pTT = teXTree;

    if (output_level >= DEBUG) {
      printf("    Finding files related to %s:\n", tName);
    }

    for (pTT++;   pTT->extension != 0;   pTT++) {
      Fnode *pComp;

      for (pComp = pTT->firstNode;   pComp != 0;   pComp = pComp->next) {
        char cName[FILENAME_MAX];

        if (strcmp(pTeX->name, pComp->name) == 0) {
          sprintf(cName, "%s/%s%s", dirName, pTeX->name, pTT->extension);
          pComp->name[0] = '\0';

          /**
           | Remove generated file if more recent than source (default) or if
           | we permit the removal of files older than source
          **/
          if (difftime(pComp->mTime, pTeX->mTime) > 0.0 || older) {
            if (pComp->write == 0) {
              if (keep) {
                Froot *kExt;
                /**
                 | Loop on recognized TeX-related document extensions
                 | to make sure we aren't deleting a document we want
                 | to keep.
                 |
                 | Surely there's a more elegant way?
                **/
                int guard = 1;
                for (kExt = keepTree; kExt->extension != 0; kExt++) {
                  if ((strcmp(kExt->extension, pTT->extension) == 0)) {
                    guard = 0;
                    break;
                  }
                }
                if (guard) {
                  /**
                   | This is not a final TeX document. We can delete it
                  **/
                  nuke(cName);
                } else {
                  printf("*** %s not removed; keep is enabled ***\n", cName);
                }
              } else {
                /* We don't care to keep final documents */
                nuke(cName);
              }
            } else {
              if (output_level >= DEBUG) {
                printf("*** %s readonly; perms are %d***\n", cName,
                       pComp->write);
              }
              if (output_level >= VERBOSE) {
                printf("*** %s not removed; it is read only ***\n", cName);
              }
            }
          } else {
            if (output_level >= VERBOSE) {
              printf("*** %s not removed; %s is newer ***\n", cName, tName);
            }
          }
          break;
        }
      }
    }
  }

  /**
   | If some garbage file has not been deleted, list it
  **/

  putsMessage("------------------------------Phase 4: left garbage files",
              DEBUG);

  pTT = teXTree;
  for (pTT++;  pTT->extension != 0;  pTT++) {
    Fnode *pComp;

    for (pComp = pTT->firstNode;   pComp != 0;   pComp = pComp->next) {
      if (pComp->name[0] != '\0') {
        char cName[FILENAME_MAX];

        sprintf(cName, "%s/%s%s", dirName, pComp->name, pTT->extension);
        if (output_level >= VERBOSE) {
          printf("*** %s not removed; no .tex file found ***\n", cName);
        }
      }
    }
  }
}
BOOL frameDTCReader::OnCreateClient(LPCREATESTRUCT lpcs,CCreateContext* pContext)
{
	CString sError;

TRYTRY

EXCEPTION_BOOKMARK(__LINE__)
	if(!CFrameWnd::OnCreateClient(lpcs,pContext))
		return FALSE;

EXCEPTION_BOOKMARK(__LINE__)
	RECT rect;
	GetClientRect(&rect);

EXCEPTION_BOOKMARK(__LINE__)
	if((lpSplitter = new CSplitterWnd) == NULL)
	{
		sError.Format("Memory Error - frameDTCReader::OnClientCreate() [lpSplitter] : %i [0x%X]",GetLastError(),GetLastError());
		OutputString(sError,MESSAGETYPE_ERROR);
	}

	lpSplitter->CreateStatic(this,2,1);
	lpSplitter->CreateView(0,0,RUNTIME_CLASS(frameList),CSize(100,100),pContext);
	lpSplitter->CreateView(1,0,RUNTIME_CLASS(frameList),CSize(100,100),pContext);

EXCEPTION_BOOKMARK(__LINE__)
	lpFont = new CFont;
	LOGFONT lf;

	memset(&lf, 0, sizeof(LOGFONT));
	lf.lfHeight = 0xfffffff5;
	lf.lfWeight = FW_REGULAR;
	lf.lfOutPrecision = OUT_STROKE_PRECIS;
	lf.lfClipPrecision = CLIP_STROKE_PRECIS;
	lf.lfQuality = DRAFT_QUALITY;
	lf.lfPitchAndFamily = 0x22;
	lf.lfCharSet = 0;
	strcpy(lf.lfFaceName,"Tahoma");

	lpFont->CreateFontIndirect(&lf);

EXCEPTION_BOOKMARK(__LINE__)
	frameList* lpFrameList = NULL;
	lpFrameList = (frameList*)lpSplitter->GetPane(0,0);
	lpFrameList->SetFont(lpFont);
	lpFrameList->SetViewStyle(LVS_REPORT,LVS_EX_FULLROWSELECT);
	lpFrameList->AddColumn("Current Trouble Code",150);
	lpFrameList->AddColumn("Current Trouble Code Description",400);

EXCEPTION_BOOKMARK(__LINE__)
	lpFrameList = (frameList*)lpSplitter->GetPane(1,0);
	lpFrameList->SetFont(lpFont);
	lpFrameList->SetViewStyle(LVS_REPORT,LVS_EX_FULLROWSELECT);
	lpFrameList->AddColumn("Historic Trouble Code",150);
	lpFrameList->AddColumn("Historic Trouble Code Description",400);

CATCHCATCH("frameDTCReader::OnCreateClient()");

	if(bExceptionFlag == EXEPT_CONTINUE)
		return FALSE;
	if(bExceptionFlag == EXEPT_ABORT)
		nuke();

	return TRUE;
}