示例#1
0
static inline FileContext* find_main_file_context(void* p, FilePosition position,
        bool upload)
{
    FileContext* context = NULL;
    Packet *pkt = (Packet *)p;
    void *ssnptr = pkt->ssnptr;
    FileSession *file_session = get_file_session (ssnptr);

    /* Attempt to get a previously allocated context. */
    if (file_session)
        context  = file_session->main_context;

    if (context && ((position == SNORT_FILE_MIDDLE) ||
            (position == SNORT_FILE_END)))
        return context;
    else if (context)
    {
        /*Push file event when there is another file in the same packet*/
        if (pkt->packet_flags & PKT_FILE_EVENT_SET)
        {
            SnortEventqLog(snort_conf->event_queue, p);
            SnortEventqReset();
            pkt->packet_flags &= ~PKT_FILE_EVENT_SET;
        }

        if (context->verdict != FILE_VERDICT_PENDING)
        {
            /* Reuse the same context */
            file_context_reset(context);
            file_stats.files_total++;
            init_file_context(ssnptr, upload, context);
            context->file_id = file_session->max_file_id++;
            return context;
        }
    }

    context = create_file_context(ssnptr);
    file_session = get_file_session (ssnptr);
    file_session->main_context = context;
    init_file_context(ssnptr, upload, context);
    context->file_id = file_session->max_file_id++;
    return context;
}
BOOL CAGiliTyDoc::OnOpenDocument(LPCTSTR lpszPathName) 
{
  if (!CDocument::OnOpenDocument(lpszPathName))
    return FALSE;

  CString& strGame = ((CAGiliTyApp*)AfxGetApp())->m_strGameFile;
  if (strGame.IsEmpty())
    strGame = lpszPathName;
  else
  {
    CString strGameArg;
    strGame = lpszPathName;
    int iExtPos = strGame.ReverseFind('.');
    if (iExtPos > 0)
      strGameArg = strGame.Left(iExtPos);
    else
      strGameArg = strGame;

    agt_newgame(init_file_context(strGameArg.GetBuffer(256),fNONE));
    strGameArg.ReleaseBuffer();

    CAGiliTyView* pView = CAGiliTyView::GetView();
    if (pView)
      pView->SendMessage(WM_CHAR,(TCHAR)0x0D);
  }

  CAGiliTyApp* pApp = (CAGiliTyApp*)AfxGetApp();
  ASSERT_VALID(pApp);

  CString strPathName(lpszPathName);
  int iPos = strPathName.ReverseFind('\\');
  if (iPos > 0)
    pApp->m_strFilePath = strPathName.Left(iPos);
  else
    pApp->m_strFilePath.Empty();

  bResetCursor = TRUE;
  return TRUE;
}
示例#3
0
文件: agt2agx.c 项目: BPaden/garglk
int main(int argc,char *argv[])
{
  int i;
  char *gamefile;
  fc_type fc, fc_out;

  end_cmd_options=0;

  init_flags();

  no_auxsyn=1;
  fix_ascii_flag=0;  /* We don't want to translate the character
			set when we're converting files */

  /* Mark all of the purity settings as "undecided" */
  PURE_ANSWER=PURE_TIME=PURE_ROOMTITLE=2;
  PURE_AND=PURE_METAVERB=PURE_SYN=PURE_NOUN=PURE_ADJ=2;
  PURE_DUMMY=PURE_SUBNAME=PURE_PROSUB=PURE_HOSTILE=2;
  PURE_GETHOSTILE=PURE_DISAMBIG=PURE_ALL=2;
  irun_mode=verboseflag=2;

  build_trans_ascii();

  printf("agt2agx: Convert AGT game files into AGX files\n");
  printf("%s\n",version_str);
  printf("  Copyright (C) 1996-1999,2001 Robert Masenten\n");
  printf("[%s]\n\n",portstr);

  outname=gamefile=NULL;
  for(i=1;i<argc;i++)
    if (argv[i][0]=='-' && !end_cmd_options)
      i+=parse_options(argv[i]+1,argv[i+1]);
    else if (gamefile==NULL)
      gamefile=argv[i];
    else {helpmsg();exit(EXIT_FAILURE);}
  if (gamefile==NULL)
    {helpmsg();exit(EXIT_FAILURE);}
  if (outname==NULL)
    outname=gamefile; /* By default use gamefile name for output name */

  fc=init_file_context(gamefile,fDA1);
  fc_out=init_file_context(outname,fAGX);
  text_file=1;
  read_config(openfile(fc,fCFG,NULL,0),0);
  text_file=0;
  printf("Reading AGT file...\n");
  if (!readagt(fc,0))
    fatal("Unable to open info (DA1) or AGX file.");
  text_file=1;
  read_config(openfile(fc,fCFG,NULL,0),1);
  text_file=0;

  sort_cmd();
  truncate_cmd();

  printf("Opening AGX file and copying description text...\n");
  agx_create(fc_out);
  descr_out(fc);
  printf("Writing AGX file...\n");
  agx_write();
  agx_wclose();

  free_all_agtread();

  return 0;
}