login_assist.c_bak
来自「多用户银行系统」· C_BAK 代码 · 共 196 行
C_BAK
196 行
#include <sys/types.h>#include <signal.h>#include <stdio.h>#include "../include/stddef.h"#include "../include/structs.h"extern SHM *shm;int getInput(USER *user){ char *s; char c; char *p; int i = 0; p = user->name; while(1){ system("clear"); printf("Name :"); while(1){ if( ((c = getchar()) != '\n') && ((p - user->name) < MAX_SIZE) ){ *p ++ = c; continue; } break; } *p = '\0'; s = getpass("Password:"); p = user->pwd; while(1){ if( i < strlen(s) && ((p - user->pwd) < MAX_SIZE)){ *(p + i) = *(s + i); i ++; continue; } break; } *(p + i + 1) = '\0'; break; } return OK;};int readFile(char *guibuf){ FILE *fp; char c; int i = 0; fp = fopen(GUIFILE , "r"); if(!fp){ printf("file error!\n"); return EFILE; } while((c = fgetc(fp)) != EOF){ *(guibuf + i) = c; i ++; } *(guibuf + i + 1) = '\0'; return OK;};int showGUI(char *guibuf){ printf("%s\n" , guibuf); return OK;};int getChoice(char *oper){ char *s = oper; char c; printf("please intput your choice : "); while(1){ c = getchar(); if( c != '\n' && ((s - oper) < OPER_SIZE)){ *s ++ = c; continue; }else{ if(c == '\n'){ break; } else { continue; } } } *s = '\0'; return OK;};int execute_(char *oper){ extern SHM *shm; char *s; s = (char *)malloc(sizeof(char) * 11); char c; int i = 0; if(strcmp(oper , "save") == 0){ strcpy(shm->mark , "save"); printf("input your name :"); while(1){ c = getchar(); if( c != '\n' && i < 10){ *s ++ = c; continue; }else{ if(c == '\n')break; else continue; } } *s = '\0'; //scanf("%s" , s); strcpy(shm->chara , s); printf("input your password :"); // scanf("%s" , s); i = 0; while(1){ c = getchar(); if( c != '\n' && i < 10){ *s ++ = c; continue; }else{ if(c == '\n')break; else continue; } } *s = '\0'; strcpy(shm->charb , s); printf("shm->spid : %d\n" , shm->spid); //kill(28543 , SIGRQST); kill(shm->spid , SIGRQST); //sigqueue(shm->spid , SIGRQST , sv.sival_int); printf("have send signal to server ...\n"); } };int getStr(char *str , int max){ char *s; char c; int i = 0; s = str; while(1){ c = getchar(); if(c != '\n' && i < max - 1){ *s ++ = c; continue; }else{ if(c == '\n')break; else continue; } *s = '\0'; } return OK;};int execute(void *handle , char *oper){ return OK; };/*int identify(USER *user){ USER usr; FILE *fp; if((fp = fopen("../pwdfile", "r")) == -1) { printf("open error.\n"); exit(0); } while(1) { if(fread(&usr, sizeof(USER), 1, fp) != 0) { if(strcmp(usr.name, user->name) ==0 ); { if(strcmp(usr.pwd, user->pwd) == 0) { return OK; } else { return EPWD; } } else { continue; } } return ENAME; }}*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?