[机房环境动力运维工作总结]工作总结的写法 (一)基本情况。 1.总结必须有情况的概述和叙述,有的比较简单,有的比较详细。这部分内容主要是对工作的主客观条件、有利和不利条件以及工作的环境和基础等进行分...+阅读
#include #include #include #include #include #define ACC_PASS_DELIMITER '|'#define IMAX_PASS_TRY_TIMES 3#define IMAX_BUFF_SIZE 4096#define ACC_FILE "account.txt"#define REC_FILE "record.txt"/* 功能函数,可以自定功能 */ int do_something(void) { char buf[IMAX_BUFF_SIZE]; while
(1) { memset(buf, 0x0, sizeof(buf)); if (scanf("%s", buf) == EOF) break; if (strcmp(buf, "exit") == 0) break; printf("您输入的是[%s]\n", buf); } return 0; } int write_something_to_record(const char *v) { FILE *fp = NULL; fp = fopen(REC_FILE, "a+"); if (fp == NULL) { printf("打开记录文件失败:%s", strerror(errno)); return -1; } fputs(v, fp); fclose(fp); return 0; }/* 上机 */ int online(char *pacc) { FILE *fp = NULL; char buf[IMAX_BUFF_SIZE]; char rbuf[IMAX_BUFF_SIZE]; int i, j, iLen; int iCount = 0; int isFound = 0; time_t my_time; struct tm *rtime; char *acc = NULL; char *pass = NULL; char *tmp = NULL; fp = fopen(ACC_FILE, "r"); if (fp == NULL) { printf("打开账号文件失败: %s\n", strerror(errno)); return -1; } while
(1) { memset(buf, 0x0, sizeof(buf)); printf("请输入账号(长度不要超过%d): ", IMAX_BUFF_SIZE); if (scanf("%s", buf) == EOF) { printf("输入结束,欢迎使用xx系统\n"); fclose(fp); return 0; } while
(1) { if (fgets(rbuf, sizeof(rbuf), fp) == NULL) { break; } iLen = strlen(rbuf); for (i = 0; i if (rbuf[i] == ACC_PASS_DELIMITER) { break; } if (rbuf[i] != buf[i]) break; } if (rbuf[i] == ACC_PASS_DELIMITER) { isFound = 1; break; } } if (!isFound) { printf("账号[%s]不存在\n", buf); fclose(fp); return -1; } /* 删除回车换行 */ j = 0; for (i = 0; i if ((rbuf[i] != '\r') & (rbuf[i] != '\n')) { rbuf[j++] = rbuf[i]; } } rbuf[j] = '\0'; /* 取账号密码 */ sprintf(buf, "%c", ACC_PASS_DELIMITER); tmp = strtok(rbuf, buf); acc = calloc(strlen(tmp)+1, 1); if (acc == NULL) { return -1; } strcpy(acc, tmp); tmp =strtok(NULL, buf); pass = calloc(strlen(tmp)+1, 1); if (pass == NULL) { free(acc); return -1; } iLen = sprintf(pass, "%s", tmp); err_pass: if (iCount memset(buf, 0x0, sizeof(buf)); printf("请输入密码(长度不要超过%d): ", IMAX_BUFF_SIZE); if (scanf("%s", buf) == EOF) { printf("输入结束,欢迎使用xx系统\n"); fclose(fp); free(acc); free(pass); return 0; } if (strcmp(pass, buf) == 0) { /* 成功登录 todo */ printf("time is %s\n", "Time"); my_time = time(NULL); rtime = localtime(&my_time); sprintf(buf, "用户[%s]在%d年%d月%d日-%d时%d分秒%d登录\n", acc, rtime->tm_year+1900, rtime->tm_mon+1, rtime->tm_mday, rtime->tm_hour, rtime->tm_min, rtime->tm_sec); write_something_to_record(buf); strcpy(pacc, acc); fclose(fp); free(acc); free(pass); return 0; } iCount++; goto err_pass; } else { break; } } printf("密码错误次数超限,请联系管理员\n"); free(acc); free(pass); fclose(fp); return -1; }/* 下机 */ int offline(const char *acc) { char buf[IMAX_BUFF_SIZE]; time_t my_time; struct tm *rtime; my_time = time(NULL); rtime = localtime(&my_time); sprintf(buf, "用户[%s]在%d年%d月%d日-%d时%d分秒%d退出\n", acc, rtime->tm_year+1900, rtime->tm_mon+1, rtime->tm_mday, rtime->tm_hour, rtime->tm_min, rtime->tm_sec); write_something_to_record(buf); return 0; } int main(int argc, char **argv) { char buf[IMAX_BUFF_SIZE]; printf("欢迎使用xx系统\n"); while
(1) { memset(buf, 0x0, sizeof(buf)); if (online(buf) == -1) { continue; } do_something(); offline(buf); } return 0; }
以下为关联文档:
电信机房的维护工作都有哪些中国电信IDC业务包括主机托管类、资源出租类、增值服务类等业务。 1、主机托管类业务:指用户的主机托管在电信部门的标准机房环境中(包括:空调、照明、湿度、不间断电源、防静...
求助 c语言课设某机房上机管理系统#define SIZE 6 #include#includestruct student /*定义student结构体*/ { char num[20]; char name[10]; char xibie[10]; char leibie[10]; float jishi; int shangji; }s...
管理系统中计算机应用上机去文库,查看完整内容> 内容来自用户:wj118220 1.数据库特点:数据结构化 2.修改表结构的SQL命令是ALTERTABLE 3.SQL语言中,修改表结构的命令是ALTER 4.从划分范围上看,企业信息系...