|
[code:1]
#include <stdio.h>
#include <string.h>
int *strcmp(const char *s1, const char *s2);
int main(int argc, char *argv[])
{
char *CommandHelpLong="--help";
char *CommandHelpShort="-h";
char * CheckHelpLong;
char *CheckHelpShort;
int *HelpCompareLong;
int *HelpCompareShort;
char *CommandOpen="--open";
char *CheckOpen;
int *OpenCompare;
char *CommandClose="--close";
char *CheckClose;
int *CloseCompare;
CheckClose = argv[1];
CheckOpen = argv[1];
CheckHelpShort = argv[1];
CheckHelpLong = argv[1];
if ((CheckHelpLong != NULL) ||
(CheckHelpShort != NULL) ||
(CheckOpen !=NULL) ||
(CheckClose !=NULL))
{
if(((HelpCompareLong = strcmp(CheckHelpLong, CommandHelpLong)) == 0)
||
((HelpCompareShort = strcmp(CheckHelpShort, CommandHelpShort)) == 0))
printf("%s\n%s\n%s\n%s\n%s\n%s\n",
"Com version 1.0.01 by lluct ([email protected])",
"使用:",
"com -h --help --帮助",
"com --open --打开光驱",
"com --close --关闭光驱",
"--open和--close参数都已经加上了&参数,所以不同再加. ");
else if ((OpenCompare = strcmp(CheckOpen, CommandOpen)) == 0)
system("eject -r&");
else if ((CloseCompare = strcmp(CheckClose, CommandClose)) == 0)
system("eject -t&");
else
printf("com: %s: 非法参数!!请键入参数--help查看帮助.\n", argv[1]);
}
else
printf("请键入参数--help查看帮助!\n");
return 0;
}
[/code:1]
|
|