📄 main.c
字号:
/*********************************************************************
Filename: main.c
Revised: $Date: 2007-12-11 09:48:27 -0800 $
Revision: $Revision: 10194 $
Description:
Notes:
*********************************************************************/
/*********************************************************************
* INCLUDES
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
/*
#include <semaphore.h>
#include <pthread.h>
*/
#include "analyseframe.h"
#include "uart.h"
#include "web.h"
/*********************************************************************
* GLOBAL VARIABLES
*/
/*
/*********************************************************************
* LOCAL VARIABLES
*/
/*********************************************************************
* EXTERNAL VARIABLES
*/
/*********************************************************************
* FUNCTIONS
*/
int main(void)
{
char *data;
int value;
unsigned short int p = 1;
unsigned short int i = 0x1234;
display_web_head();
if ((data = getenv("QUERY_STRING")) == NULL)
{
printf("<p>data error</p>");
exit(1);
}
else
{
strcpy(query_string_data, data);
operate_query_string(query_string_data);
}
display_web_tail();
if ((sem_id = semget(ftok("/tmp", 'a'), 1, IPC_CREAT | IPC_EXCL | 0666)) < 0)
{
perror("semget");
if ((sem_id = semget(ftok("/tmp", 'a'), 1, IPC_CREAT | 0666)) < 0)
{
perror("semget");
exit(1);
}
else
{
#ifdef DEBUG_MODE
printf("<p>exist semaphore success!\n");
#endif
}
}
else
{
#ifdef DEBUG_MODE
printf("<p>creat semaphore success!\n");
#endif
port_sem.val = 1;
semctl(sem_id, 0, SETVAL, port_sem);
}
#ifdef DEBUG_MODE
value = semctl(sem_id, 0, GETVAL, 0);
printf("value of semaphore is: %d\n", value);
#endif
if (port_open() < 0)
{
printf("<p>Failed to open ttyS0...\n");
exit(1);
}
#ifdef DEBUG_MODE
printf("<p>Succeed to open ttyS0...\n");
#endif
frame_process();
port_close();
#ifdef DEBUG_MODE
printf("<p>p = %d\n", *(char *)&p);
#endif
exit(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -