Porting to OS/2: Case #2 wildcards

When wildcards(*, ?) are provided as arguments, OS/2 accepts them as is, but Unix-like systems expand them to real entires. In fact, who do this is a shell. Fortunately, OS/2 shells such as CMD and 4OS2, do not this task.

So this became the task of applications. You can do this by yourself. But kLIBC provides a function and a link flag for this. The function is _wildcard() and the flag is -Zargs-wild.

If you add -Zargs-wild to your linker flag, then _wildcard() is called automatically on startup. Or do like this.

1
2
3
4
5
6
7
8
9
10
int main( int argc, char *argv[])
{
#ifdef __OS2__
    _wildcard(&argc, &argv);
#endif
 
    /* some codes */
    
    return 0;
}


By this, you can expand wildcards in arguments to real file entries. For examples, if you call a program with "*.cmd", then original argc will be 2 and argv[0] will be a program name, argv[1] will be "*.cmd". But _wildcard() modifies them. If you have a.cmd and b.cmd in the directory, then argc will be 3, argv[1] and argv[2] will be a.cmd and b.cmd, respectively.

댓글

이 블로그의 인기 게시물

토렌트: < 왕좌의 게임 > 시즌 1 ~ 시즌 8 완결편 마그넷

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

토렌트: < 스타워즈 > Ep.1 ~ Ep.6 마그넷