⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client.c

📁 多用户银行系统
💻 C
字号:
#include <setjmp.h>#include <stdlib.h> // malloc#include <signal.h>#include <unistd.h>#include "../include/tools.h"#include "../include/structs.h"#include "../include/stddef.h"#include "../include/clientlib.h"void sig_client(int sig);SHM *shm;char *oper;int shmid;int main(){	USER user;	char *guibuf;	int index;	shmid = shmget(KEY , SHM_SIZE , 0600);	shm = shmat(shmid , 0 , 0);	printf("shm address : %p\n" , shm);		// to ignal Ctrl+C//	signal(SIGINT , SIG_IGN); 	signal(SIGRSPN , sig_client);	oper = (char *)malloc(sizeof(char) * (OPER_SIZE + 1));	guibuf = (char *)malloc(sizeof(char) * (GUI_BUF_SIZE + 1));	if(!oper || !guibuf){		printf("malloc error !\n");		exit(1);		}/*	do{		getInput(&user);	}while(identify(&user) < OK); // can't work if use : while(! identify(&user)) !!*/	readFile(guibuf);/*	key = ftok("/root/test.c" , 0);	shmid = shmget(key , SHM_SIZE , 0600);	shm = shmat(shmid , 0 , 0);	*/	index = getSHM();		(shm->swap_arr)[index].swap.cpid = getpid();	sigset_t mask , omask;	sigemptyset(&mask);	while(1){		showGUI(guibuf);		getChoice(oper);		strcpy( (shm->swap_arr)[index].swap.mark , oper);			execute(index , oper);		while((shm->swap_arr)[index].swap.over != DONE){}		(shm->swap_arr)[index].swap.over = NODONE;				showResult(oper , index);		//sigsuspend(&mask);		//pause();			}};void sig_client(int signo){	printf("################################\n");	printf("        server returned\n");	printf("################################\n");	printf("sig handle in client returned ....\n");	return ;};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -