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.
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.
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.
댓글
댓글 쓰기