Commit 5571d66a authored by 马伊齐's avatar 马伊齐

自动格式化

parent 41a4b49e
...@@ -16,14 +16,11 @@ ...@@ -16,14 +16,11 @@
#include <sys/shm.h> #include <sys/shm.h>
#define SHM_KEY 1234 #define SHM_KEY 1234
int msgid = -1; // 全局变量,用于存储消息队列ID
int msgid = -1; // 全局变量,用于存储消息队列ID
int shmid; int shmid;
messageQueue *queue; messageQueue *queue;
// 全局数组来保存socket信息 // 全局数组来保存socket信息
socket_info_t sockets[MAX_CLIENTS + 1] = {0}; socket_info_t sockets[MAX_CLIENTS + 1] = {0};
...@@ -284,9 +281,10 @@ int msg_local_send(uint16_t type, uint32_t code, void *pad, int len) ...@@ -284,9 +281,10 @@ int msg_local_send(uint16_t type, uint32_t code, void *pad, int len)
int msg_local_ssignal_init(void) int msg_local_ssignal_init(void)
{ {
// 获取已存在的共享内存 // 获取已存在的共享内存
if ((shmid = shmget(SHM_KEY, sizeof(int), IPC_CREAT | 0666)) < 0) { if ((shmid = shmget(SHM_KEY, sizeof(int), IPC_CREAT | 0666)) < 0)
{
perror("shmget"); perror("shmget");
return -1; return -1;
} }
...@@ -304,7 +302,8 @@ int msg_local_rsignal_init(void) ...@@ -304,7 +302,8 @@ int msg_local_rsignal_init(void)
{ {
shmid = shmget(SHM_KEY, sizeof(int), 0666); shmid = shmget(SHM_KEY, sizeof(int), 0666);
// 获取已存在的共享内存 // 获取已存在的共享内存
if ((shmid = shmget(SHM_KEY, sizeof(int), 0666)) < 0) { if ((shmid = shmget(SHM_KEY, sizeof(int), 0666)) < 0)
{
perror("shmget"); perror("shmget");
return -1; return -1;
} }
...@@ -316,7 +315,8 @@ int msg_local_rsignal_init(void) ...@@ -316,7 +315,8 @@ int msg_local_rsignal_init(void)
} }
} }
int msg_local_send_pulse(uint16_t type, uint32_t code) { int msg_local_send_pulse(uint16_t type, uint32_t code)
{
if (queue->rear == queue->front) if (queue->rear == queue->front)
{ {
...@@ -335,13 +335,14 @@ int msg_local_send_pulse(uint16_t type, uint32_t code) { ...@@ -335,13 +335,14 @@ int msg_local_send_pulse(uint16_t type, uint32_t code) {
{ {
queue->mQueue[queue->front].type = type; queue->mQueue[queue->front].type = type;
queue->mQueue[queue->front].code = code; queue->mQueue[queue->front].code = code;
queue->front = (queue->front + 1) % MAX_QSIZE; queue->front = (queue->front + 1) % MAX_QSIZE;
return 0; return 0;
} }
} }
int msg_local_recv_pulse(uint16_t *type, uint32_t *code) { int msg_local_recv_pulse(uint16_t *type, uint32_t *code)
{
if (queue->rear == -1) if (queue->rear == -1)
{ {
printf("Null signal queue\n"); printf("Null signal queue\n");
...@@ -360,8 +361,7 @@ int msg_local_recv_pulse(uint16_t *type, uint32_t *code) { ...@@ -360,8 +361,7 @@ int msg_local_recv_pulse(uint16_t *type, uint32_t *code) {
*code = queue->mQueue[queue->rear].code; *code = queue->mQueue[queue->rear].code;
queue->rear = (queue->rear + 1) % MAX_QSIZE; queue->rear = (queue->rear + 1) % MAX_QSIZE;
return 0; return 0;
} }
} }
int msg_recv(int channel, msg_data_t *msg) int msg_recv(int channel, msg_data_t *msg)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment