bool CompareExt(char *filename, char *ext, bool cs=false) { if (cs) { char *file_ext = Ext(filename); LowerCase(ext); if (strcmp(file_ext, ext) == 0) return true; UpperCase(ext); if (strcmp(file_ext, ext) == 0) return true; return false; } else { return ( strcmp( Ext(filename), ext ) == 0 ); } }
char* Base(char *filename, char *buffer=NULL) { if (filename == NULL) return NULL; if (buffer) strcpy(buffer, filename); else buffer = filename; char *ext = Ext(buffer); if (ext != NULL) *(ext-1) = '\0'; return buffer; }
EXPORT_C TPfkeyExtPrivate::TPfkeyExtPrivate(const TDesC8& aExtensionData) { const TInt byte_len = sizeof(struct sadb_gen_ext) + aExtensionData.Length(); struct sadb_gen_ext& gen_ext = Ext(); gen_ext.sadb_len = (TUint16)((byte_len + 7) / KWordLen); gen_ext.sadb_ext_type = SADB_PRIV_GENERIC_EXT; }
FbImportBook::FbImportBook(FbImportZip & owner, wxZipEntry & entry) : m_parser(NULL) , m_database(owner.GetDatabase()) , m_filename(entry.GetInternalName()) , m_filetype(Ext(m_filename)) , m_message(owner.GetFilename() + wxT(": ") + m_filename) , m_filesize(entry.GetSize()) , m_archive(owner.GetId()) , m_ok(false) { if (m_filetype == wxT("fbd")) return; wxLogMessage(_("Import zip entry %s"), m_filename.c_str()); if (!(m_ok = owner.OpenEntry(entry))) return; if (m_filetype == wxT("fb2")) { m_parser = new FbImportReaderFB2(owner, m_md5sum.IsEmpty()); m_md5sum = m_parser->GetMd5(); } else if (m_filetype == wxT("epub")) { m_md5sum = CalcMd5(owner); if (!owner.OpenEntry(entry)) return; wxString rootfile = FbRootReaderEPUB(owner).GetRoot(); if (!owner.OpenEntry(entry)) return; m_parser = new FbDataReaderEPUB(owner, rootfile); } else { m_md5sum = CalcMd5(owner); wxZipEntry * info = owner.GetInfo(m_filename); if (info && owner.OpenEntry(*info)) { m_parser = new FbImportReaderFB2(owner); } } }
FbImportZip::FbImportZip(FbImportThread & owner, wxInputStream &in, const wxString &filename): m_owner(owner), m_database(*owner.GetDatabase()), m_conv(wxT("cp866")), m_zip(in, m_conv), m_filename(owner.GetRelative(filename)), m_filepath(owner.GetAbsolute(filename)), m_filesize(in.GetLength()), m_ok(m_zip.IsOk()) { if (!m_ok) { wxLogError(_("Zip read error %s"), filename.c_str()); return; } wxLogMessage(_("Import zip %s"), filename.c_str()); while (wxZipEntry * entry = m_zip.GetNextEntry()) { if (entry->GetSize()) { wxString filename = entry->GetInternalName(); if (Ext(filename) == wxT("fbd")) { wxString infoname = filename.BeforeLast(wxT('.')); wxZipEntry*& current = m_map[infoname]; delete current; current = entry; } else { m_list.Add(entry); } } if (m_owner.IsClosed()) break; } }
void QuitDisplayHW(display_hw D_HW) { msgport MsgPort; uldat slot; SaveHW; if (D_HW) { if (D_HW->QuitHW) HW = D_HW, D_HW->QuitHW(); D_HW->Quitted = TRUE; if ((slot = D_HW->AttachSlot) != NOSLOT) { /* avoid KillSlot <-> DeleteDisplayHW infinite recursion */ if ((MsgPort = RemoteGetMsgPort(slot))) MsgPort->AttachHW = (display_hw)0; Ext(Remote,KillSlot)(slot); } if (D_HW->Module) { D_HW->Module->Used--; Delete(D_HW->Module); D_HW->Module = (module)0; } UpdateFlagsHW(); /* this garbles HW... not a problem here */ } RestoreHW; }
FbImportBook::FbImportBook(FbImportThread & owner, wxInputStream & in, const wxString & filename) : m_parser(NULL) , m_database(*owner.GetDatabase()) , m_filename(owner.GetRelative(filename)) , m_filepath(owner.GetAbsolute(filename)) , m_filetype(Ext(m_filename)) , m_message(filename) , m_filesize(in.GetLength()) , m_archive(0) , m_ok(false) { wxLogMessage(_("Import file %s"), m_filename.c_str()); m_ok = in.IsOk(); if (!m_ok) return; if (m_filetype == wxT("fb2")) { m_parser = new FbImportReaderFB2(in, true); m_md5sum = m_parser->GetMd5(); } else if (m_filetype == wxT("epub")) { m_md5sum = CalcMd5(in); in.SeekI(0); wxString rootfile = FbRootReaderEPUB(in).GetRoot(); in.SeekI(0); m_parser = new FbDataReaderEPUB(in, rootfile); } else { m_md5sum = CalcMd5(in); } }
char *ReplaceExt(char *filename, char *new_ext, char *buffer=NULL) { if (filename == NULL) return NULL; if (buffer) strcpy(buffer, filename); else buffer = filename; char *ext = Ext(buffer); if (ext != NULL) sprintf( ext, "%s", new_ext ); return buffer; }
EXPORT_C TPfkeyExtTrafficSelector::TPfkeyExtTrafficSelector(TUint32 aNumsel) { const TInt byte_len = sizeof(struct sadb_x_ts) + aNumsel*sizeof(TSadbSelector); struct sadb_x_ts& x_ts = Ext(); x_ts.sadb_x_ts_len = (TUint16)((byte_len + 7) / KWordLen); x_ts.sadb_x_ts_exttype = SADB_X_EXT_TS; x_ts.sadb_x_ts_numsel = aNumsel; }
EXPORT_C TPfkeyExtSpirange::TPfkeyExtSpirange(TUint32 aMin, TUint32 aMax) { const TInt extLen = sizeof(struct sadb_spirange) / KWordLen; // 31.07 2003 JPS struct sadb_spirange& spirange = Ext(); spirange.sadb_spirange_len = extLen; // 31.07 2003 JPS spirange.sadb_spirange_exttype = SADB_EXT_SPIRANGE; spirange.sadb_spirange_min=aMin; spirange.sadb_spirange_max=aMax; }
EXPORT_C TPfkeyExtKey::TPfkeyExtKey(const TDesC8& aKey, TUint16 aBits, TUint8 aType) { const TInt extLen = (sizeof(struct sadb_key) + aKey.Length() + 7) / KWordLen; struct sadb_key& keyhdr = Ext(); keyhdr.sadb_key_len = (TUint16)extLen; keyhdr.sadb_key_exttype = aType; keyhdr.sadb_key_bits = (TUint16)(aBits ? aBits : aKey.Length() * KWordLen); keyhdr.sadb_key_reserved = 0; }
EXPORT_C TPfkeyExtAddress::TPfkeyExtAddress(const TInetAddr& /*anAddr*/, TUint8 aProtocol, TUint8 aPrefixlen, TUint8 aType) { const TInt byte_len = sizeof(struct sadb_address) + sizeof(TInetAddr); struct sadb_address& address = Ext(); address.sadb_address_len = (byte_len + 7) / KWordLen; address.sadb_address_exttype = aType; address.sadb_address_proto = aProtocol; address.sadb_address_prefixlen = aPrefixlen; address.sadb_address_reserved = 0; }
EXPORT_C TPfkeyExtIdent::TPfkeyExtIdent(const TDesC8& aIdentity, TUint16 aIdType, TUint16 aType) { const TInt byte_len = sizeof(struct sadb_ident) + aIdentity.Length() + 1; //Non-aligned size //(+1 to add a null at the end of the string included in the padding) struct sadb_ident& ident = Ext(); ident.sadb_ident_len = (TUint16)((byte_len + 7) / KWordLen); //Aligned size ident.sadb_ident_exttype = aType; // SA_EXT_IDENTITY_SRC, _DST ident.sadb_ident_type = aIdType; // Type of the following identify information ident.sadb_ident_reserved = 0; // Padding ident.sadb_ident_id = 0; // Not used }
EXPORT_C TPfkeyExtLifetime::TPfkeyExtLifetime( TUint32 aAllocations, const TInt64& aBytes, const TInt64& aAddtime, const TInt64& aUsetime, const TUint16& aType) { const TInt byte_len = sizeof(struct sadb_lifetime); struct sadb_lifetime& lifetime = Ext(); lifetime.sadb_lifetime_len = (TUint16)((byte_len + 7) / KWordLen); lifetime.sadb_lifetime_exttype = aType; lifetime.sadb_lifetime_allocations = aAllocations; lifetime.sadb_lifetime_bytes = aBytes; lifetime.sadb_lifetime_addtime = aAddtime; lifetime.sadb_lifetime_usetime = aUsetime; }
void DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick( wxCommandEvent& event ) { wxFileName fn; wxString wildcard( _( "DRC report files (.rpt)|*.rpt" ) ); wxString Ext( wxT( "rpt" ) ); fn = m_Parent->GetBoard()->GetFileName() + wxT( "-drc" ); fn.SetExt( Ext ); wxFileDialog dlg( this, _( "Save DRC Report File" ), wxEmptyString, fn.GetFullName(), wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR ); if( dlg.ShowModal() == wxID_CANCEL ) return; m_RptFilenameCtrl->SetValue( dlg.GetPath() ); }
EXPORT_C TPfkeyExtSA::TPfkeyExtSA( TUint32 aSPI, TUint8 anAuth, TUint8 anEncrypt, TUint8 aState, TUint8 aReplay, TUint32 aFlags) { const TInt extLen = sizeof(struct sadb_sa) / KWordLen; struct sadb_sa& sa = Ext(); sa.sadb_sa_len = extLen; sa.sadb_sa_exttype = SADB_EXT_SA; sa.sadb_sa_spi = aSPI; sa.sadb_sa_state = aState; sa.sadb_sa_auth = anAuth; sa.sadb_sa_encrypt = anEncrypt; sa.sadb_sa_replay = aReplay; sa.sadb_sa_flags = aFlags; }
DEM read_dem () { int c; DEM f, a, b, d, x; int i; char buf[200]; DEM s; DEM d1; int flags1; DEM used1; extern DEM used; loop: do c = readchar (); while (c==' ' || c=='\t' || c=='\n' || c==0); switch (c) { case 'I': return I; case 'K': return K; case 'S': return S; case 'E': return E; case 'F': return If; case 'O': return Ord; case '-': f = read_dem (); a = read_dem (); return ap (f, a); case '/': a = read_dem (); b = read_dem (); return transym (a, b); case 'T': a = read_dem (); b = read_dem (); return trans (a, b); case 'X': a = read_dem (); return sym (a); case '#': a = read_dem (); b = read_dem (); return Axm (a, b); case 'i': a = read_dem (); return defI (a); case 'k': a = read_dem (); b = read_dem (); return defK (a, b); case 's': a = read_dem (); b = read_dem (); d = read_dem (); return defS (a, b, d); case ')': a = read_dem (); b = read_dem (); return IfNode (a, b); case '1': return Ext1; case '2': return Ext2; case '3': return Ext3; case '4': return Ext4; case '5': return Ext5; case '6': return Ext6; case 'e': return AE; case 'f': return EA0; /* a = read_dem (); return EA (a); */ case 'm': return MP; case 'a': return AI; case 'b': return AK; case 'c': return AS; case 'r': return RPA; case '0': return ZeroIsOrd; case '+': return SucIsOrd; case 'w': return LimIsOrd; case 'p': return PredIsOrd; case 'n': return StepIsOrd; case 'W': return TfI; case '<': a = read_dem (); return left (a); case '>': a = read_dem (); return right (a); case '\'': a = read_dem (); return rep(a); case '%': /*printf ("*1*");*/ a = read_dem (); /*printf ("*2*");*/ trace_dem ("read", a); /*printf ("*3*");*/ b = red (a); /*printf ("*4*");*/ trace_dem ("red", b); return b; /* return red (a); */ case 'R': a = read_dem (); return red1 (a, 0); case '@': a = read_dem (); return reduc (a, 1); case '~': a = read_dem (); return reduc (a, 0); case '$': a = read_dem (); return redu (a); case 'x': a = read_dem (); b = read_dem (); return ext (a, b); case '\\': a = read_dem (); b = read_dem (); trace_dem ("^(0)", a); trace_dem ("^(1)", b); d = exten (a, b); trace_dem ("^(r)", d); return d; case ']': a = read_dem (); b = read_dem (); d = dbextens (a, b); return d; case 'l': a = read_dem (); b = read_dem (); return Ext (a, b); /* return Lambda (a, b); */ case 'L': a = read_dem (); b = read_dem (); return Lambda (a, b); case '.': a = read_dem (); return DBLambda (a); case '!': a = read_dem (); b = read_dem (); return DB_lambda (a, b); /* return DBLambda (DBname (0, a, b)); */ case '?': a = read_dem (); b = read_dem (); return DB_Subst (a, b); case '_': a = read_dem (); b = read_dem (); d = read_dem (); return Subst (a, b, d); case ':': a = read_dem (); b = read_dem (); d = read_dem (); return ap (exten(a,d) ,b); case 'V': x = read_dem (); d = read_dem (); a = mk_dem (node(d), 0, NULL, DB_lambda (x, subdem(0,d)), DB_lambda (x, subdem(1,d)), subdem(2,d) == NULL ? NULL : DB_lambda (x, subdem(2,d)), NULL, NULL, NULL); return a; case 'A': x = read_dem (); d = read_dem (); a = mk_dem (node(d), 0, NULL, ap (x, subdem(0,d)), ap (x, subdem(1,d)), subdem(2,d) == NULL ? NULL : ap (x, subdem(2,d)), NULL, NULL, NULL); return a; case '"': a = read_dem (); /* return NoRed (a); */ no_red[nnr++] = a; return a; case '|': a = read_dem (); no_red[nnr++] = a; b = read_dem (); return b; case 'u': used1 = used; used = read_dem (); a = read_dem (); used = used1; return a; case '(': flags1 = flags; i = 0; for (;;) { c = readchar (); if (c == ')') break; buf[i++] = c; } buf[i] = 0; sscanf (buf, "%x", &flags); a = read_dem (); if ((flags & FLAG_PERM) == 0) flags = flags1; return a; case ',': a = read_dem (); return step (a); case '*': a = read_dem (); return rstep (a); case '`': a = read_dem (); return list_ap (a, nil); case '&': c = readchar (); switch (c) { case '/': return itransym; case 'i': return idefI; case 'k': return idefK; case 's': return idefS; case '<': return ileft; case '>': return iright; case '=': return ieq; case '#': return inode; case '0': return isubdem0; case '1': return isubdem1; case '2': return isubdem2; case '%': return ired; case '$': return iredu; case '\\': return iext; case ',': return istep; case '*': return irstep; default: fprintf (stderr, "Undefined &%c.\n", c); return I; } break; case '[': /* trace_dem ("read symbol", I); */ for (i=0; i<sizeof(buf); i++) { c = readchar(); if (c == ']') { buf[i] = 0; #ifdef TRACE1 printf ("buf=<%s>\n", buf); #endif if (buf[0] >= '0' && buf[0] <= '9') { #ifdef TRACE printf ("\nDBVar <%s>", buf); #endif d1 = DBVar (atoi(buf)); trace_dem ("", d); return d1; } s = Sym(buf); #ifdef TRACE1 trace_dem ("read symbol", s); #endif if (subdem(0,s) == NULL) { #ifdef TRACE1 trace_dem ("return symbol", s); #endif return s; } else { #ifdef TRACE trace_dem ("return value of", s); #endif return subdem(0,s); } } buf[i] = c; } fprintf (stderr, "Symbol too long\n"); return Sym(buf); default: return defined_dems[(unsigned char)c]; /* printf ("Illegal character 0x%02X\n", c); goto loop; */ } }