Главная > Операционные системы > OS/2 >
OS/2 FAQ: Пpогpаммиpование. Страница 8
Содержание > Страница 8

[Q]: Сопоставление с шаблоном. Звёздочки, вопросики. Паскаль. [A]: Vadim Rumyantsev (2:5030/301) UNIT UslPatrn; INTERFACE function MatchLineOk (pattern, line : string) : boolean; function MatchFileOk (pattern, name : string) : boolean; IMPLEMENTATION uses Dos; function MatchLineOk; function SubOk (ppos, lpos : byte) : boolean; begin if ppos > length (pattern) then SubOk := lpos > length (line) else if lpos > length (line) then SubOk := (pattern [ppos] = '*') and SubOk (ppos+1, lpos) else if pattern [ppos] = '*' then begin SubOk := false; for lpos := length (line) + 1 downto lpos do if SubOk (ppos+1, lpos) then begin SubOk := true; break end end else SubOk := ((pattern [ppos] = '?') or (pattern [ppos] = line [lpos])) and SubOk (ppos+1, lpos+1) end; begin MatchLineOk := SubOk (1, 1) end; function MatchFileOk; var pd, nd : DirStr; pn, nn : NameStr; px, nx : ExtStr; begin FSplit (pattern, pd, pn, px); FSplit (name, nd, nn, nx); MatchFileOk := ((pd = '') or (pd = nd)) and MatchLineOk (pn, nn) and MatchLineOk (px, nx) end; END.
[Q]: class Buffer - "резиновый буфер" [A]: John Gladkih (2:5051/16) --- UUEncode - Start - buffer.zip - 1347 Bytes - begin 644 buffer.zip M4$L#!!0````(`'%-D"$JS'#W-`,``&8)```*````8G5F9F5R+F-P<*U574_; M,!1]'A+_P8!$$M*BM&-C:TBEL3$)B3VQM]*'D#C$74BJQ!U%T/^^>Z^=U&F; MH4E[<G)][M<YU_:1R*-L$7-V4<DX$_>GZ7A_[Z@Q/O+'HGPFHV$^O%\D"2]/ MTT,T5S*4(F)1&I8LY<M;68K\83)E`3OT!L/W9Q\^GG_Z_.7RZ[>K[X<^.ER2 M]VBD5IN)7+*H1TO,'#;:WV,L6I0W/+=9Q)P>_L^+RF:>_HEY)D,;P?M[+V@0 MB<T.R(HFQC0$2AAXE%)#5-0:H_\"!=:X2I9@R?D3-32I05,?-TM><6D[\+U" M].]"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`E(,%:>& M&__T=C1P@$M8*N+I>`3QQ.J_O2&&HZ61$6P8G-JX=TT"RIJ7BG74#LMR;_WE MVF%=N,F@\LFD5-CL*WQ%HHLV(9N&4/OHW.=JR'R]6?[#&JR0+^,*E+S)2?K- M<OTQ'3M#=XU[HVLE7/.K=;MKVEN`2\*WD@_.8)!KHZ#7"+>CG9?X3RM0[3F_ ME#7?YR7GZ;,#H].0C*P`8OL.AW^GMP-UB29E;;:[M@HI@9^NRLG5Z:,2)'\` M4$L!`A4&%`````@`<4V0(2K,</<T`P``9@D```H``````````0`@`("!```` M`&)U9F9E<BYC<'!02P$"%084````"``=39`AM`C("3T!``!V`@``"``````` J```!`"``@(%<`P``8G5F9F5R+FA02P4&``````(``@!N````OP0````` end size 1347
[Q]: Скомпиленная TP 6.0 программка дает 100% загрузку мерлина [A]: Alexander Samuylov (2:5030/39) #include <dos.h> void interrupt ( *OldInt28)(void); void interrupt int28(void) { OldInt28(); enable(); _AX=0x1680;geninterrupt(0x2f); } void main(void) { OldInt28 = getvect(0x28); setvect(0x28, int28); _dos_keep(0, (_SS + (_SP/16) - _psp)); }
[Q]: Мини-FAQ по AVIO [A]: Serge Ivanov (2:5000/7.22) Q: Как получить список шpифтов, доступных для AVIO? A: Это уже обсуждалось здесь и было найдено единственно пpавильное pешение: --- Я pазобpался. Это должно делаться не чеpез VioQueryFonts(), а чеpез DevEscape(hdc, DEVESC_QUERYVIOCELLSIZES, 0, 0, &dataLen, (PBYTE)data); а зачем вообще нyжен VioQueryFonts() - хз. --- Q: Как вычислить pазмеp AVIO-окна. A: Размеp шpифта можно узнать чеpез VioGetFont. Поскольку это эмуляция text-mode никаких межсимвольных/межстpочных пpомежутков там _нет_. Q: Какими могут быть pазмеpы AVIO-окна? Как их изменять? A: Размеpы по любой из осей могут быть любыми, огpаничение накладывается на объем памяти, тpебуемый для сохpанения буфеpа. Поскольку Vio/Avio интеpфейс 16-битный, то как и следовало ожидать pазмеp буфеpа не может пpевышать 64Kb. Изменить pазмеp окна нельзя. Я у себя делал так: создавал новый буфеp (VioCreatePS -> VioAssociate -> VioSetDeviceCellSize -> VioGetBuf) копиpовал содеpжимое и убивал стаpое окно. Q: Как получить доступ к физическому видеобуфеpу? A: Пpимеpно так: --- VIOPHYSBUF phys; PUCHAR __vbuf0; phys.pBuf = (PBYTE)0xA0000ul; phys.cb = 65536; if((rc = VioGetPhysBuf(&phys, 0)) != 0) return rc; __vbuf0 = MAKEP(phys.asel[0], 0); /* возможно вы забывали делать это */ --- Q: Где пpо это пpочитать? A: Частично в prcp.inf (скоpее всего это стандаpтная дока от стаpой (1.3) оси). Частично у Петцольда. Если еще что не понятно - спpашивайте. ЗЫ: Джон, pазмеpы фpэйма на основании pазмеpов клиента (и обpатно) вычисляются функцией WinCalcFrameRect. Беусловно, окно уже должно быть создано.
[Q]: Как сделать COPY file CON | MORE [A]: Sergey Ayukov (asv@crydee.sai.msu.ru) Q: Хоpошо, тогда скажите мне чем отличаются CON и stdout, или всем A: не может быть, чтобы "всем", - на консоль-то попадает... Q: ну тогда ткните меня носом, как чеpез DosWrite в stdout написать и где пpо это в тулките написано. A: DosWrite (1, ...) если я правильно понимаю. Тулкит у меня не установлен, поэтому не знаю, где там написано. Q: Пpавильно ли будет тогда такое утвеpждение: если где-то в пpогpамме стоит char *file; [...] fp = fopen(file,...); то чего бы мы не писали в file, fp всегда будет отличаться от stout, A: Да. stdout - это хэндл, открытый runtime и равный 1. Причем если в командной строке задано перенаправление, то открывается не CON (!), а пайп или через чего там это перенаправление сделано (в DOS - временные файлы). Если хочется, потом его можно переоткрыть (см. dup2()). и, если пpогpамма имеет интеpфейс командной стpоки, чеpез котоpый пеpедается file, то для откpытия stdout нам нужен отдельный ключик и констpукция вpоде int is_stdout = ключик есть ? 1 : 0; if(is_stdout) fp = stdout; else fp = fopen(file,...); ..... if(!is_stdout) fclose(fp); Hаверное, это один из самых простых путей. Более логичным будет (раз уж пошел разговор про stdout) сделать по умолчанию вывод в stdout, а при необходимости перенаправлять его. Q: как сделать "copy file stdout" ? A: type file cat file Q: и чего же будет, если файл двоичный ? A: Будет то, что файл при этом попадет на экран как есть. Однако если сделать 'cat cmd.exe >cmd1.exe', то cmd1.exe будет идентичен cmd.exe, а с 'type.cmd.exe >cmd1.exe' такой фокус не пройдет.
[Q]: About priority levels in a nutshell [A]: Peter Knapper (3:772/1) Q> Aha...there's my problem. So, LOWER Priority numbers are HIGHER Priority? Nope, lower = lower.....;-) Actually the lowest (and default) value is 1, BUT before you start tinkering with this it may be useful to understand what affect the ymay have. Here is an overview of how OS/2 processes are categorised. OS/2 provides 2 main methods for allowing a PROCESS to control how OS/2 services that processes needs, as a PRIORITY CLASS and a LEVEL within that CLASS, however not all PRIORITIES have levels... Confused? There is a logical reason why... There are 4 PRIORITY classes for OS/2 programs (lets leave device drivers, etc out of this, we are only talking about applicaitons here). NOTE: Here the term "WINDOW" includes full screen tasks, they are actually "Full Screen Windows" in the system, similar to a Window on the Desktop... In decending order of importance - - Time Critical This is best used for sections of code that require very close interaction with other components within the machine. A good example is a Data communications application for processing FAX messaging, the FAX protocol requires time dependant responses so applications that "talk FAX" need CPU time NOW, so the probably use this PRIORITY. A CLASS 1 FAX puts this processing in the S/W rather than the modem so it is most dependant on getting CPU time. A CLASS 2 FAX puts some of the critical parts back in the modem, so the applicaiton does not need to be so demanding on CPU time. Moral, always go for CLASS 2 capable FAX devices wherever possible. - Foreground When a window on the desktop is the ACTIVE window, then it is at this PRIORITY. IMPORTANT: Because only 1 WINDOW can be the ACTIVE window at a time, there is no point in using a LEVEL value here, and in fact althjough it can be specified, it is ignored whenever the Window is ACTIVE. - Regular Windows that are not the ACTIVE window, normally reside at this priority LEVEL. These applications can select a LEVEL that will be used whenever they are NOT the ACTIVE Window. - Idle Tasks that perform "tidy up" tipe functions and are not dependant on having processor time available. An example here would be an application that displays CPU time usage, to know how much time everything else is using, it would run at the LOWEST possible level and thereby see how much processing power was left over. So you can see how a LEVEL may or may not affect applications with a different PRIORITY, and LEVEL only applies when that task is NOT the foreground task.
[Q]: OS/2 vs. NT: paging subsystem [A]: Jonathan de Boyne Pollard (2:257/609.3) It's worth noting some interesting things about Windows NT when compared to OS/2 Warp in this respect. The "portable executable", PE, format for executable files used in Win32 *does* contain an exact image in the file of the page as it is to be loaded into memory. When Windows NT demand loads a page, it doesn't need to uncompress its contents. Indeed, in most cases it doesn't need to perform relocation fixups either, because of a trick used when creating Win32 import libraries that means that all of the fixups to references imported from other modules are concentrated in a single place. (This trick is actually not specific to the PE executable format, and can be duplicated on OS/2 with the LX executable format as well. I have a replacement OS2386.LIB that does it for fixups to the various system API DLLs, if anyone is interested.) The disadvantage, of course, is that reading in a page from DASD is more expensive on Windows NT than it usually is on OS/2. In the 32-bit LX executable format used by OS/2, the compression scheme will shrink the size of page images in the file quite noticably. Picking the file \OS2\CMD.EXE at random, we notice that in memory object 1 all of the page sizes are between 3584 and 3072 bytes, a reduction in size by between 12% and 25%. Because of the compression used in the LX executable format, to demand page in a 4KiB page the program loader in the OS/2 kernel often doesn't actually need to read 4KiB of data from disc. On Windows NT, however, pages are the same size when stored on disc as they are in memory, because the PE executable file format doesn't have compression. So for every 4KiB page to be demand loaded, Windows NT has to read an entire 4KiB of data from disc. It's worth noting that Windows NT attempts to compensate for this fact by the fact that NTFS has a minimum cluster size of 4KiB. With HPFS on OS/2, the smallest I/O transaction can be as small as a single 512 byte (0.5KiB) sector, since that is the allocation unit size. Reading in a 3072-byte compressed page image thus only need involve reading six or seven sectors, not eight. With NTFS on Windows NT, since the smallest allocation unit size for the filesystem is 4KiB *anyway*, it doesn't make any difference that the program loader needs to read a full eight sectors for each 4KiB page (or even 9 or 10 sectors if the developer hasn't page-aligned the executable properly, which is possible if he has played around with the linker flags). It couldn't read less even if it wanted to. The most obvious effect of this design is that PE executables are much larger than LX executables. A page containing repeated data (such as an initialised data page that is mostly zeroes, for example) compresses very well in an LX executable. By contrast, a PE executable file contains a whole page's worth of bytes for such a page. Viewing PE and LX executables with a hex file viewer is most instructive. PE executables often have large runs of repeated data, most often large runs of zero bytes. LX executables generally do not. (I say "generally", because if they use Watcom C/C++ the linker doesn't support compression, alas. This is a deficiency in Watcom's linker, and an unfortunate example of the "jack of all trades, master of none" adage.) This is, of course, visible in the comparative sizes of Win32 and 32-bit OS/2 executables. One particular irony of the "uncompressing pages during a page-in is expensive, so we don't do it" philosophy embodied in the PE executable file format design is that NTFS can compress file data behind the scenes on the disc. So if an executable file is on an NTFS volume and NTFS has compressed it when storing it on disc, the overhead of uncompressing data each time that there is a page in operation won't have been avoided. All that has changed in reality is the portion of the system that actually performs it. Rather than having the uncompression done by the process loader, it is done by the filesystem driver. It is still done. Another further irony is that making the executable file format uncompressable, but having compression in the filesystem itself, means that the page data in the in-memory file cache are uncompressed, because of course that is how they are in the file itself. In contrast, when an LX executable file is cached on OS/2 the page data *are* compressed, and less RAM is required to cache the file contents as a result. This is one contributory factor (of many, alas) to the greater physical memory needs that Windows NT has when compared to 32-bit OS/2.
[Q]: Мультитредовые апликухи падают при создании окна в дочернем треде [A]: Joseph Shrago (joseph@fcn.ru) В твоем случае надо пользоваться Post вместо Send. И внимательней читать ремарки - там про отличия в нитках всегда пишут. Еще в другой нитке надо снова делать AnhorBlock и MessageQueue.
[Q]: Запись детальной информации об Exception'е [A]: George Shapovalov (2:5020/341.26) 520 645|except3.zip EXCEPTQ in a 32 bit DLL which implements an exception handler which saves the registers in a file named xxxx.TRP (xxxx=Pid,Tid) together with the Loaded modules code and data objects addresses, and also the failing thread stack dump and the process status as given by DosQProcStatus. Trapperq is an IBM C/2 program which shows how to implement the call to 32 bits exception handler from a 16:16 bits program. enter Trapperq to generate a trap and the xxxx.TRP file. You are free to use that code as a sample for your programs. No support or guarantee from me implied. Cheers Marc Fiammante С трешкой работает, а с четверкой еще не собирал. Поищи на хоббесах или в домейне в примерах. Если не найдешь, я тебе на емейл кину. Вот пример работы: #pragma handler(main) #pragma map (_Exception,"MYHANDLER") #include <stdio.h> #include <stdlib.h> void TrapFunc(void); main(){ printf("Exception handler has been set by compiler\n"); printf("Generating the TRAP from function\n"); TrapFunc(); } void TrapFunc() { char * Test; Test=0; *Test=0; } Вот пример трап-файла: -------------------------- Exception C0000005 Occurred at 00:03:17 02/09/100 Invalid linear address 00000000 OS/2 Version 2.40 Failing code module internal name : SAMPLE Failing code module file name : E:\TEMP\SAMPLE.EXE Failing code Object # 1 at Offset 58 File Line# Public Symbol ------------ ----- ------------- SAMPLE.C 44 TrapFunc (sample.obj) 0001:00000048 List of auto variables at EBP 28854 in TrapFunc: Offset Name Type Value ------ -------------------- --------------------------------- ----------------- -4 Test near pointer to 8 bit unsigned 0x0 invalid +-------------------------------------------------------------+ | GS : 0000 FS : 150B ES : 0053 DS : 0053 | | EDI : 00000000 ESI : 00000000 EAX : 00000000 EBX : 00000000 | | ECX : 00000000 EDX : 00000004 | | EBP : 00028854 EIP : 00010058 EFLG: 00012206 ESP : 00028850 | | CS : 005B SS : 0053 | +-------------------------------------------------------------+ Failing instruction at CS:EIP : 005B:00010058 is mov [eax],00 +------------------------------------+ | Register content analysis | +------------------------------------+ | EAX does not point to valid memory | | EBX does not point to valid memory | | ECX does not point to valid memory | | EDX does not point to valid memory | | EDI does not point to valid memory | | ESI does not point to valid memory | +------------------------------------+ Thread slot 125 , Id 1 , priority 200 Stack Bottom : 000208A0 (0017:08A0) ;Stack Top : 000288A0 (0017:88A0) Process Id : 201 .EXE name : E:\TEMP\SAMPLE.EXE Call Stack: Source Line Nearest EBP Address Module Obj# File Numbr Public Symbol -------- --------- -------- ---- ------------ ----- ------------- Trap -> 000F:0058 SAMPLE 0001 SAMPLE.C 44 TrapFunc (sample.obj) 0001:00000048 00028854 :00010035 SAMPLE 0001 SAMPLE.C 39 main (sample.obj) 0001:00000000 No auto variables found in main. 0002886C :00010101 SAMPLE 0001 SAMPLE.C 45 __RunExitList (edcstrt.ASM) 0001:00000060 List of auto variables at EBP 28888 in TrapFunc: Offset Name Type Value ------ -------------------- --------------------------------- ----------------- -4 Test near pointer to 8 bit unsigned 0x11150 unwritable 00028888 DFDF:C098 DOSCALL1 0004 Lost Stack chain - new EBP below previous +-------------------------------------------------------------------------+ | List of currently accessed modules (DLLs) object addresses | +-------------------------------------------------------------------------+ | Module E:\TEMP\SAMPLE.EXE Handle 00004756 | | Object Number Address Length Flags Type | | 000000 00010000 00003D94 00010015 - 16:16 Selector 000F | +-------------------------------------------------------------------------+ [ ...съедено молью... ] +-------------------------------------------------------------------------+ | Module D:\OS2\DLL\UCONV.DLL Handle 00000995 | | Object Number Address Length Flags Type | | 000000 1FCF0000 000059D9 00012015 - 16:16 Selector FE7F | +-------------------------------------------------------------------------+ /*----- Stack Bottom ---*/ /*----- Accessible Stack Bottom at 208A0 ---*/ 000208A0 :0000 0000 0000 0000 0000 0000 0000 0000 ................ 000208B0 : lines not printed same as above 00027FE0 :5300 0000 AD65 F91B 0000 0500 0000 F87F S....e.......... [ ...съедено молью... ] 00028890 :9412 0000 0000 0000 0000 0300 8413 0300 ................ /*----- Stack Top -----*/

Содержание > Страница 8


Украинская Баннерная Сеть

Главная  Алфавитный индекс  Справка  Добавить FAQ  E-mail
Новости  Поиск по сайту

Copyright © 2001 - 2002 Olexandr Slobodyan.
Сайт создан в системе uCoz