#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int narg,char **args)
{
int fd;
int val = 0;
printf("jiangdou\n");
printf("jiangdou\n");
printf("jiangdou\n");
printf("jiangdou\n");
printf("jiangdou\n");
//printf("the input parameter 0 is %s\n",args[0]);
//printf("the input parameter 1 is %s\n",args[1]);
if(narg != 2)
{
printf("error,the input parameter must be one!\n");
return -1;
}
char *str = args[1];
//printf("the input parameter is %s\n",str);
char *temp;
char tmp1[512];
temp = strstr(args[1],"=");
if(temp!=NULL)
{
sprintf(tmp1,"%s",(temp + 1));
}
printf("%s\n",tmp1);
//是否ledon命令
if (strcasecmp(tmp1, "ledon") == 0)
{
printf("jiangdou -> ledon\n");
fd = open("/dev/jiangdou_led",0666);
write(fd,&val,sizeof(int));
close(fd);
}
//是否ledoff命令
if (strcasecmp(tmp1, "ledoff") == 0)
{
printf("jiangdou -> ledoff\n");
val = 1;
fd = open("/dev/jiangdou_led",0666);
write(fd,&val,sizeof(int));
close(fd);
}
return;
}
网页程序ledon_cgi
最新推荐文章于 2024-06-01 00:11:39 发布