2016의 게시물 표시

OS/2 codes: How to control CD-ROM drives

OS/2 provides ioctl commands to control CD-ROM drives and discs. And some commands have been added with new OS2CDROM.DMD. In this article, let's research the ways to control CD-ROM drives and to utilize new commands. 1. Opening or Closing a Tray The most strange thing of OS/2 ioctl commands are CDROMDISK_CLOSETRAY . It's not possible to issue the command. Because a handle for a disc is required to issue, but there is no way to open a handle for the opened drives. This is applied to CDROMDISK_EJECTDISK . It's not possible to issue the command if a disc is not in a drive. To open and/or to close a tray, another way should be used. OS/2 provides general ioctl commands to eject and to load a media for a removable media . Ejecting is used to open a tray. Loading is used to close a tray. These commands can be issued without a handle. Therefore, it's possible to open and to close a tray even if a disc is not in the drive. Codes are like this: Colored By Color Scri

OS/2 codes: How to manipulate FAT32 paritions

On OS/2, in general, it's possible to access to any partitions in DASD mode. This is true for FAT32 partitions. Unfortunately, however, accessing in DASD mode may not work on FAT32 partitions, especially writing to them. Instead, FAT32.IFS provides special ioctl commands. Let's see the way accessing to FAT32 partitions. 1. Accessing FAT32 partitions in DASD mode Accessing in DASD mode is the general ways on OS/2. Unfortunately, however, FAT32.IFS does not allow to access the areas beyond 2GB by default. This is true for HPFS.IFS. To overcome this problem, FAT32.IFS provides a special mode, SECTOR IO mode, like HPFS.IFS. If the sector io mode is enabled, accessing in DASD mode is performed in sectors not in bytes. To enable sector io mode, you should call DosFSCtl() , and pass 0xDEADFACE as a parameter list like this: Colored By Color Scripter ™ 1 2 3 4 5 6 7 ULONG cbData     = 0; ULONG ulDeadFace = 0xDEADFACE; ULONG cbParam    =  sizeof ( ulDeadFace );

OS/2 codes: How to get information about CPUs

OS/2 provides various APIs to get information of CPU, from number of CPUs to CPU time snapshot. 1. Number of CPUs 1.1 DosQuerySysInfo( QSV_NUMPROCESSORS ) DosQuerySysInfo() returns the requested system information. If passing QSV_NUMPROCESSORS , number of CPUs are returned to the buffer. Look: DosQuerySysInfo( QSV_NUMPROCESSORS, QSV_NUMPROCESSORS,                  &ulCpus, sizeof( ulCpus )) 1.2 DosGetProcessorStatus() DosGetProcessorStatus() returns the status of the given CPU ID starting from 1. If CPU ID is valid, that is, ID-th CPU exists, it returns PROC_ONLINE or PROC_OFFLINE according to the status of that CPU. PROC_ONLINE means that the given CPU is available for running work. PROC_OFFLINE means that the given CPU is not available. Whereas the given CPU does not exist, it returns an error, ERROR_INVALID_PARAMETER . After all, number of CPUs can be caculated if counting from 1 until an error is returned.   for( ulProcId = 1, ulCpuCount = 0; ; ulProcId++ )

OS/2 codes: How to check if IFS was loaded

IFS stands for Installable File System. With IFS, OS/2 can support various file systems even if they are not supported by default. What should we do to check if a specific IFS was loaded ? First of all, we can iterate all drives from A to Z, and check the attached IFS to them. However, this method cannot check IFS which is loaded but not attached yet. In addition, same IFS may be attached to the different drives. This causes extra cost when programming. To solve the above unconveniences is to check IFS directly. How ? DosFSCtl() provides such functions. DosFSCtl() provides the communication between an application and a specific IFS. If the given IFS was not loaded, it returns ERROR_INVALID_FSD_NAME , otherwise any other error codes. Using this, it's possible to check if a specific IFS was loaded. However, note that the IFS name passed to DosFSCtl() is neither the filename of the IFS nor the file-system name in the boot sector. It's the exported name by IFS. For examp

OS/2 codes: How to emulate COPY-ON-WRITE #4 Epilogue

So far, we've researched the basic strucutre of the implementation of the copy-on-write feature. As well as, we've looked into the ways to enable copy-on-write in all threads including a main thread. Nevertheless, this approach has some limitations. Copy-on-write will not work if it is used in a thread started by custom codes using DosCreateThread() not _beginthread() it is used in an alien thread created in DLLs not linked with copy-on-write module source memory blocks are allocated malloc() not DosAllocMem() In the above first two cases, installing/uninstalling an exception handler in the context using copy-on-write manually is needed. In case of malloc(), it may be succeeded, but it's not recommended. Failure possibility is higher. Finally, copy-on-write not supported by Kernel is not optimal and may not be useful due to its efficiency. However, the fact itself that implementation of copy-on-write is possible is meaningful even if it is not actually usefu

OS/2 codes: How to emulate COPY-ON-WRITE #3 Install exception handler

To activate the exception handler, it's needed to install it. By the way, the handler works only on the thread on which it is installed. After, we should install the handler on every threads. Let's see the way to install a handler first: EXCEPTIONREGISTRATIONRECORD regRec = { 0 }; /* Register an exception handler for SIGSEGV */ regRec.ExceptionHandler = ( ERR )sigsegv; DosSetExceptionHandler( &regRec ); EXCEPTIONREGISTRATIONRECORD is a type to register handler. Generally, it should be initialized to 0 except ExceptionHandler field. ExceptionHandler should be set to the handler to be registered. Finally, register the handler with DosSetExceptionHandler() . Here, note that EXCEPTIONREGISTRATIONRECORD variables should be placed in the stack . Uninstalling the installed handler is simple: /* Deregister an exception handler */ DosUnsetExceptionHandler( &regRec ); regRec is the variable which was used when installing the handler. DosUnsetExceptionHandler()

OS/2 codes: How to emulate COPY-ON-WRITE #2 Exception handler

In the previous article, we looked into a basic structure of a main function. In that, the last question was how to catch write access to the registered memory blocks. Here is the answer. It's the exception. We removed WRITE permission of the memory blocks. Because of this, writing to those blocks causes an exception, so called SIGSEGV. To catch such exceptions, we should implement exception handlers. Exception handler is like this: ULONG _System sigsegv( PEXCEPTIONREPORTRECORD p1,                        PEXCEPTIONREGISTRATIONRECORD p2,                        PCONTEXTRECORD p3,                        PVOID pv ); Out of the above parameters, p1 is the most important. p1->ExceptionNum is the exception code. Here 0xc0000005( XCPT_ACCESS_VIOLATION ). p1->ExceptionInfo[0] contains flags for the cause of the exception. For example, XCPT_READ_ACCESS for READ acess and XCPT_WRITE_ACCESS for WRITE access. p1->Exceptioninfo[1] is the fault address. Return value is X

OS/2 codes: How to emulate COPY-ON-WRITE #1 main function

A basic principle of copy-on-write is the following. Remove WRITE permission of source memory blocks Create an alias memory without WRITE permission for source memory blocks Register information for these Let's see the ways to implement the above sentences. 1. Remove WRITE permission / Alter access protections of memory blocks To do this, all you have to do is calling DosSetMem() like this: DosSetMem ( p, cb, flSrc & ~PAG_WRITE )) Where p is the pointer to the source memory block, cb is the size of the blocks, flSrc is the access protection flags of those. Then, how can we get the protection flags of the source blocks ? Use DosQueryMem(): DosQueryMem ( p, &cbSrc, &flSrc ); Where p is the pointer to the memory block, cbSrc is the size to be queried. flSrc is the place where to store access flags. 2. Create an alias memory An alias memory is an memory sharing same contents with the original memory. For details, see < DosAliasMem(), ma

OS/2 codes: How to emulate COPY-ON-WRITE #0 Prologue

Copy-On-Write is a feature to improve copy performance. That is, memory blocks share the same contents until copy operation to those blocks really occur. By postponing copy-operations until it is needed really, it's possible to remove initial overheads of copy operation. This was needed to implement mmap(). Espeically, MAP_PRIVATE. On Linux( http://man7.org/linux/man-pages/man2/mmap.2.html ), copy-on-write feature is used. I thought it's not possible without kernel supports. However, Dave Yeo suggested DosAliasMem(). I thought it may be possible. I did implement such a feature. A series of the following articles are records of implementing copy-on-write on OS/2.

토렌트: < 하이큐 > 3기 < 카라스노 고교 vs 시라토리자와 학원 고교 > 완결(1화~10화) 마그넷

 소년 스포츠물의 명작 <하이큐> 3기 <카라스노 고교 vs 시라토리자와 학원 고교> 입니다. <하이큐> 3기 <카라스노 고교 vs 시라토리자와 학원 고교> 마그넷 주소: magnet:?xt=urn:btih:E61A7B439C939DA8857FE35690FF7E5FFF54A022 마그넷 주소로 토렌트 다운 받기 uTorrent 다운 받기 마그넷 주소 클릭하기 uTorrent 가 자동으로 실행되면 그대로 토렌트 다운 받기 uTorrent 가 자동으로 실행되지 않으면 마그넷 링크 주소 복사 uTorrent 실행 [파일] - [주소에서 토렌트 추가] 클립보드에 저장한 주소가 입력 창에 입력 되어 있음 복사한 주소가 아니면 마그넷 링크 주소 복사 토렌트 다운 받기

uTorrent 광고 없애기

토렌트를 애용하는 사람이라면 토렌트의 대명사 uTorrent 를 알고 있을 것이다. uTorrent 는 무료로 사용할 수 있지만, 대신에 윗쪽과 왼쪽에 광고를 노출한다. 크게 문제는 없지만, 간혹 19금스러운 광고들이 나올 때면 깜짝 놀라기도 한다. 그리고 광고 때문인지는 모르지만, uTorrent 를 처음 실행할 때 느려지는 현상도 있다. 이런 저런 이유로 광고를 없애고 싶은 사람들은 이렇게 하자. <uTorrent> 실행 [옵션] - [설정] 선택 왼쪽 패널에서 [고급 설정] 선택 [필터] 입력 필드에 "offers" 입력 나열된 키 중에서 [offers.left_offer_enabled] 와 [offers.sponsored_torrent_offer_enabled] 에서 "false" 로 바꿈( 더블 클릭 하면바뀜) [확인] 버튼 누른 후 재시작 이렇게 하면 윗쪽과 왼쪽에 광고가 더이상 나타나지 않는다. * 출처: http://clien.net/cs2/bbs/board.php?bo_table=lecture&wr_id=341928

요즘 쓸만한 공개 뉴스 서버

유선 인터넷은 SK 브로드밴드(SKB) 를 이용하고 있다. 옛날 옛적 하나로의 후신이다. 하나로 시절만해도 뉴스서버를 이용하는 데 문제가 없었다. SKB 로 바뀐 이후에도 뉴스 서버는 잘 작동하였는데, 2015년 말이었던 듯하다. 갑자기 뉴스 서버에서 기사들을 읽어오지 못하는 현상이 발생했다. 다른 뉴스 그룹들의 기사는 잘 보였는데, 유독 OS/2 관련 뉴스그룹에서만 기사를 가져오지 못했다. 잠시 오류가 있는 것뿐이겠거니 했는데, 지금까지도 되지 않고 있다. 그 사이 구글 뉴스 그룹 서비스를 간간이 이용하였는데, 전용 프로그램에 비해 많이 불편하였다. 그래서 공개 뉴스 서버가 없는지 찾아보았다. 사실 아주 오래전 파워콤을 썼던 적이 있었다. 파워콤은 뉴스 서버를 제공하지 않았다. 어쩔 수 없이 공개 뉴스 서버를 써야 했는데, 그 당시 널리 알려졌던 뉴스 서버는 kreonet 의 뉴스 서버였다. 하지만, 관리자가 바뀐 것인지 꽤 오래전부터 뉴스 서버를 제공하지 않는다. 인터넷을 검색해봐도 아주 오래전 글들 뿐이라 요즘에 쓸 수 있는 공개 뉴스 서버들은 없었다. 그러던 중 우연찮게 아주 쓸만한 뉴스 서버 하나를 찾았다. 지금 잘 쓰고 있다. Aioe.org 공개 뉴스 서버이다. 홈페이지는 http://www.aioe.org 이다. 몇 가지 제약이 있지만, 사용에 지장을 줄 정도는 아니다. IP 주소당 하루에 최대 25 개의 메세지를 작성할 수 있다 하루에 세 개 이상의 메세지가 거절되면, 24 시간동안 글을 작성할 수 없다 각 글은 세 개 미만의 그룹(크로스포스트)에만 보낼 수 있다. 각 글은 최대 세 개의 후속 그룹을 포함할 수 있다 기사는 최대 32KB, 헤더는 최대 2KB 까지 허용된다 nntp.aioe.org 에는 최대 4 개의 동시 접속이 허용된다 news.aioe.org 에는 최대 2 개의 동시 접속이 허용된다 IP 주소당 하루에 400 번의 접속을 허락한다 스팸, 포르노, 소아성애 및 어떤 형태의 욕설도 용납되지

OS/2 tricks: How to set up DBCS environment on SBCS OS/2 #4 Epilogue

So far, we've researched the ways to enable DBCS environment on SBCS OS/2. First was how to configure OS/2. Second was how to display DBCS characters. Third was how to input DBCS characters. Neverthless, however, it is not possible to set DBCS environment up on SBCS OS/2, perfectly. Of course, the best and perfect way is to provide DBCS OS/2. However, if it's not possible, then resource corruption of eWP on DBCS code pages should be fixed , at least. eCo Software has been working on the Language Interface Pack project( http://en.ecomstation.ru/projects/lip/ ) which enables to switch messages and texts of eComStation to the localized messages and texts. Support for this project will be also helpful to DBCS users as well as SBCS users. I wish DBCS users use the latest OS/2 without any restrictions.

OS/2 tricks: How to set up DBCS environment on SBCS OS/2 #3 Input DBCS characters

The last step is to enable input DBCS characters. DBCS OS/2 provides a special program, IME(Input Method Editor), to input DBCS characters. Of course, SBCS OS/2 does not. But, there are several ways to input DBCS characters. 1. Web IME Web IME is the web service provides IME. In this case, it's not possible to input DBCS characters to a window directly. Instead, you should use COPY-AND-PASTE. 1.1 InputKing ( http://www.inputking.com/ ) This web IME supports various languages such as European, Russian and Indian as well as Chinese, Japan, Korean and Vietnamese. 2. Native IME Native IME is an OS/2 program to provide IME. But not all IMEs support to input DBCS characters directly. 2.1.Chinese 2.1.1 Bridge2-Hi ( https://www.arcanoae.com/shop/bridge2-hi/ ) This program supports to input Chinese characters, Hanzi. This is not free. 2.2. Japanese 2.2.1 IMERJ ( http://www.altsan.org/programming/os2/index.html#imerj ) This program supports to input Japanese char

OS/2 announce: pkg-config v0.29.1 for OS/2 released

pkg-config v0.29.1 for OS/2 have been released. OS/2 용 pkg-config v0.29.1 를 발표하였습니다. They can be downloaded from : 다음 링크를 클릭하면 받을 수 있습니다 : http://hobbes.nmsu.edu/h-search.php?key=pkg-config-0.29.1.zip&pushbutton=Search Enjoy Warping !!! Korean OS/2 User Community : http://www.ecomstation.co.kr

OS/2 tricks: How to set up DBCS environment on SBCS OS/2 #2 Display DBCS characters

Displaying DBCS characters on SBCS requires at least two things. First is a font driver supporting UNICODE fonts correctly, second is fonts themselves for DBCS. Other than these, there are some other things needed. 1. Font Driver Nowadays, most of fonts are True Type Font. OS/2 also supports it. However, default true type font driver does not support unicode fonts correctly. Especially, DBCS fonts. So if you want to use DBCS fonts, you should install another font driver for a true type font. It's <FreeType/2> . FreeType/2 has several versions. 1.0.x and 1.1.x released by Michael Necasek, 1.2.x released by me, 1.3.x and 2.x released by Alex Taylor. Out of these, you should use 1.2.x or later. You can get them here. FreeType/2 1.2.x: http://www.ecomstation.co.kr/komh/os2factory/#freetype2 FreeType/2 IFI 1.3.x and 2.x: http://www.altsan.org/programming/os2/index.html#ft2 For installations, see their README. 2. Font IBM provided fonts containing CJK glyphs by

OS/2 tricks: How to set up DBCS environment on SBCS OS/2 #1 Configuration

이미지
The first step to enable DBCS environment is to configure your system. 1. CODEPAGE statement OS/2 is a system based on a code page. You can specify two code pages.  For example, you can see the line like following in config.sys CODEPAGE=850,437 First is a primary code page, which is used by processes by default. Second is a secondary code page, which is an auxiliary code page used by some processes on demand. To enable DBCS environment, you should add a DBCS code page which you want to use to CODEPAGE as a primary or a secondary. For example, CODEPAGE=850,949 949 is a Korean code page. Like this, adding a DBCS code page as a secondary code page is most safe. Because if a DBCS code page is used as a primary code page, 1. You will see an error like this on every boot. SYS1729: The code page 949 is not acceptable for the display. Press Enter to continue... 2. Some programs may conflict with DBCS code pages. For example, some resources of eWP is corrupted like this.

토렌트: NGC < 코스모스 > 우리말 더빙 전편(1편~13편) 마그넷

1980년에 제작된 칼 세이건의 <코스모스>를 2014년에 리메이크한 작품을 내셔널 지오그래픽 채널(NGC)에서방영한 우리말 더빙판 <코스모스> 입니다. 과학에, 특히 천문에 관심있는 분들이라면 필히 보아야 하는 작품입니다. DVD 나 Blu-Ray 로도 따로 하나 장만해야겠습니다. NGC <코스모스> 우리말 더빙 마그넷 주소: magnet:?xt=urn:btih:776043FDFACF88F5073D7B8FC3CEDC0B7B3F3F6B 마그넷 주소로 토렌트 다운 받기 uTorrent 다운 받기 마그넷 주소 클릭하기 uTorrent 가 자동으로 실행되면 그대로 토렌트 다운 받기 uTorrent 가 자동으로 실행되지 않으면 마그넷 링크 주소 복사 uTorrent 실행 [파일] - [주소에서 토렌트 추가] 클립보드에 저장한 주소가 입력 창에 입력 되어 있음 복사한 주소가 아니면 마그넷 링크 주소 복사 토렌트 다운 받기

OS/2 tricks: How to set up DBCS environment on SBCS OS/2 #0 Prologue

There are two versions on OS/2 according to the locale. One is SBCS version, and the other one is DBCS version. Still OS/2 does not support unicode as a base system character set. This separation is also inherited by OEM versions such as eComStation and ArcaOS. However, those OEMs lacks DBCS version. Although it was known that beta versions of DBCS eComstation was there, I know, GA version has not been released at all. So if you want to use DBCS version of OS/2, then you should use old-good OS/2 up to MCP2. Even MCP2 of DBCS OS/2 does not support some countries such as Korea. As a result, DBCS users who want to use the latest OS/2 including OEMs, should use SBCS OS/2. Then, is it possible to use DBCS features on SBCS OS/2 ? Yes, but partially. Afterwards, let's find the ways.

OS/2 codes: How to get a module name from a symbol

Sometimes it's needed to know the module where a symbol is. For example, it's needed to know the location of a DLL where I am. To do this, two APIs are required. One is DosQueryModFromEIP() and the other one is DosQueryModuleName(). 1. DosQueryModFromEIP() Here is the description. Purpose DosQueryModFromEIP queries a module handle and name from a given flat address. It takes a flat 32 bit address as a parameter and returns information about the module (a protect mode application currently executing) owning the storage. Syntax #define INCL_DOSMODULEMGR #include os2.h> APIRET APIENTRY DosQueryModFromEIP (HMODULE *phMod, ULONG *pObjNum, ULONG BuffLen, PCHAR pBuff, ULONG *pOffset, ULONG Address) Parameters phMod (PHMODULE) output Address of a location in which the module handle is returned. pObjNum (PULONG) output Address of a ULONG where the module object number corresponding to the Address is returned. The object is zero based. BuffLen (ULONG) i

Bash 쉘 스크립트 가이드 1.0

kldp 에서 눈팅만 하다가, 좋은 자료가 있어 소개한다. 대부분의 리눅스에서 기본 쉘로 쓰이는 BASH 에 대한 안내서이다. gitbook 과 github 에서 진행되고 있다. 가장 큰 장점은 한글로 작성되어 있어 읽기 편하다는 것이고, BASH 를 체계적으로 설명하고있다는 것이다. 지속적으로 업데이트를 한다고 하니, 수시로 방문해 보는 것도 좋을 듯 하다. gitbook 주소 : https://mug896.gitbooks.io/shell-script/content/   github 주소 : http://mug896.github.io/bash-shell/   * 출처: https://kldp.org/node/154415

OS/2 codes: How to get a network interface name from an index and a description of struct ifmib

OS/2 socket call, os2_ioctl( SIOSTATIF42 ), provides the informations about network interfaces available on a machine through struct ifmib . However, struct ifmib does not have a member for a canonical network interface name such as 'lan0'. Instead of, it has an index and a description of a network interface. Fortunately, with those informations it's possible to get a canonical network interface name. An algorithm for this can be found in ODIN sources. See http://trac.netlabs.org/odin32/browser/trunk/src/iphlpapi/iphlpapi.cpp#L169   Based on the above codes, I've made an utility function to get a canonical network name from an index and a description of struct ifmib . See source: https://github.com/komh/os2codes/blob/master/network/getifname.c header: https://github.com/komh/os2codes/blob/master/network/getifname.h test: https://github.com/komh/os2codes/blob/master/network/getifname-test.c

OS/2 codes: How to get MAC address of network interfaces

MAC address is an 48-bits unique hardware address of a network adapter. OS/2 provides socket calls to retrive MAC address from network adapters. First way is to use os2_ioctl( SIOSTATIF42 ) . It returns the informations about all network interfaces available on a machine into struct ifmib . struct ifmib is based on an index of a network interface. That is, it does not provides canonical name of a network interface such as lan0. You should mangle a canonical name from a description field and an index field. For details, see the following ODIN sources. http://trac.netlabs.org/odin32/browser/trunk/src/iphlpapi/iphlpapi.cpp#L169 Second is ioctl( SIOCGIFCONF ) . It returns the information about all network interfaces available on a machine into struct ifconf . On TCP/IP v4.21 or later, struct ifconf may contain AF_LINK address storage. In this case, strcut ifconf contains a canonical name of a network interface, its index and its MAC address. Here is the implementation to re

Porting to OS/2: Case #26 getrusage()

getrusage() provides measure of resource used by the current process or its child processes. See for details. http://pubs.opengroup.org/onlinepubs/9699919799/functions/getrusage.html OS/2 kLIBC has a declaration of getrusage(), but not implemented it actually. Instead, OS/2 kLIBC provides a minimal information for getrusage(). Here is the implementation using it. source: https://github.com/komh/os2compat/blob/master/process/getrusage.c test: https://github.com/komh/os2compat/blob/master/testcase/getrusage-1.c

Porting to OS/2: Case #25 POSIX semaphores

POSIX semaphores are used to control the execution of threads. There are unnamed semaphores and named semaphores. Although named semaphores are always shareable between processes, unnamed semaphores may be private or shareable between processes. Out of these, implementation of unnamed private semaphore is here. source: https://github.com/komh/os2compat/blob/master/thread/semaphore.c header: https://github.com/komh/os2compat/blob/master/thread/semaphore.h test: https://github.com/komh/os2compat/blob/master/testcase/semaphore-1.c  

내 맘대로 비교하기: <자바스크립트 완벽 가이드> 와 <프론트엔드 개발자를 위한 자바스크립트 프로그래밍>

이미지
예전에 Qt 로 <환율 계산기>( http://lvzuufx.blogspot.com/2015/08/qt_11.html ) 를 만들면서 느낀 것이지만, 웹 관련 프로그래밍을 하려면 결국 자바스크립트를 해야만 한다. 떡본 김에 제사 지낸다고 했던가 ? 자바스크립트를 공부하기로 마음 먹고, 많은 분들이 추천하고 있는 책이 무엇인지 살펴보니, 대략 두 권 정도가 공통적으로 나왔다. 하나는 소위 코뿔소 책으로 유명한 <자바스크립트 완벽 가이드> 였고, 다른 하나는 <프론트엔드 개발자를 위한 자바스크립트 프로그래밍> 이었다. 1. <프론트엔드 개발자를 위한 자바스크립트 프로그래밍> 니콜라스 자카스 지음, 한선용 옮김, 인사이트 출판사 출처: http://www.yes24.com/ 전체 분량이 1100 쪽을 넘어간다. 게다가 아주 꼼꼼하게 자바스크립트 설명으로 채워져 있다. 한꺼번에 다 읽을 생각보다는 쉬엄 쉬엄 읽어가야지 하는 마음으로 천천히 다 읽었다. 이 책의 특징이라면 자바스크립트를 엄격하게 사용할 것을 요구한다는 것이다. 예를 들어, 배열과 객체의 차이점을 강조하고 있다. 배열은 숫자를 인덱스로 받아들이고, 객체는 문자열을 인덱스로 받아들이니, 이 둘을 혼용하지 말라고 말한다. 아울러 HTML 요소의 id, name 속성을 자바스크립트에서 변수로 사용하지 말라고도 한다. 과거의 유산(legacy) 이기에 지금도 허용되고 있지만 언제라도 바뀔 수 있기 때문이다. 대신에 document.getElementById() 같은 메쏘드를 꼭 이용하라고 한다. 엄격 모드(strict mode) 와 비엄격 모드(non-strict mode) 의 차이점에 대해서도 꾸준히 언급하는데, 같은 이유인 듯하다. 이 책을 읽으면서 꽤 인상깊었던 부분이 있었는데, 객체의 생성과 상속에 관한 부분이었다. 그 당시 알려진 여러 방법을 소개하고 장단점을 살피는데, 그 연구의 깊이가 느껴진다고 할까 ? 자바스크립트의 객체

Porting to OS/2: Case #24 scandir() and alphsort()

scandir() scans a directory, and alphsort() is provided to scandir() as a comparison function to sort directory entries into alphabetical order. OS/2 kLIBC has a declaration for scandir(), but has not implemented it. In case of alphsort(), OS/2 kLIBC has no even the declaration for it. Here is the implementation and a test for them. source: https://github.com/komh/os2compat/blob/master/io/scandir.c header: https://github.com/komh/os2compat/blob/master/io/scandir.h test: https://github.com/komh/os2compat/blob/master/testcase/scandir-1.c This implementation follows OS/2 kLIBC declaration. However, notice that OS/2 kLIBC declaration is slightly different from POSIX specs. See the comments for details.

Porting to OS/2: Case #23 if_nameindex() family

if_nameindex() is used to retrive all network interface names and indexes. if_freenameindex() is used to free internal storages allocated by if_nameindex(). And there is a family which maps a network inteface name to its corresponding index, and vice versa. They are if_nametoindex() and if_indextoname() . OS/2 has no them. Fortunately, however, OS/2 provides socket calls to implement them. First, you can use os2_ioctl( SIOSTATIF42 ) . This call provides interface statistics for all interfaces up to 42 via struct ifmib which includes a index and a description of a network interface. A index is 0-based. However, if_nameindex() family accepts 0-index as the last entry of network interfaces or an invalid index. So it's needed to increase the index by 1. A description is a long description not a short description. For example, Ethernet-Csmacd not lan0. So you should generate a canonical name from a description and an index. For details, see the following ODIN source. htt

Porting to OS/2: Case #22 _response()

OS/2 kLIBC provides _response() to expand arguments from a response file. And this enables to pass a very long command line. Because OS/2 itself has the limit of a command line length up to 32K. By the way, _response() has a problem. It limits characters per line up to 8192 characters. So if a line has characters more than 8192, then the line is splitted into two or more lines. This is not an expected behavior. To overcome this, I've reimplemented _response() without a line length limit. Here it is. _response(): https://github.com/komh/os2compat/blob/master/process/_response.c   test: https://github.com/komh/os2compat/blob/master/testcase/_response-1.c

Porting to OS/2: Case #21 setmode()

setmode() is used to change the text/binary mode of a file handle. By the way, these modes exists on DOS-like OSes such as OS/2, Windows and DOS. Whereas, UNIX-like OSes such as Linux don't distinguish these modes. They treats all the file handles as a binary mode. In addition, they uses pipes actively via standard handles such as stdin, stdout and stderr. By the way, on OS/2, they are opened in a text mode by default. So it is general to call setmode() in order to change standard handles to a binary mode at the beginning. Because -Zbin-files does not affect on standard handles. This is a good strategy. However, standard handles are used to input from keyboard and to output to a screen, too. As a result, if you change standard handles to binary mode when they are not connected to pipes, then you would encounter unexpected behaviors. For example, if you output two lines, "Hello," and "World", then you expect like this. Hello, World Instead, howver, yo

Porting to OS/2: Case #20 CMSG_ALIGN, CMSG_SPACE and CMSG_LEN macros

OS/2 kLIBC has been missing some control message such as CMSG_ALIGN , CMSG_SPACE and CMSG_LEN macros until 0.6.6. They should be like this, Colored By Color Scripter ™ 1 2 3 4 #define  CMSG_ALIGN( len ) _ALIGN( len ) #define  CMSG_SPACE( len ) ( CMSG_ALIGN(  sizeof (  struct  cmsghdr )) + \                             CMSG_ALIGN( len )) #define  CMSG_LEN( len ) ( CMSG_ALIGN(  sizeof (  struct  cmsghdr )) + ( len )) Here, struct msghdr is in sys/socket.h . See the following link for a detail. https://github.com/komh/os2compat/blob/master/network/cmsg.h