?? configfile.c
字號:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include "configfile.h"void read_config(char* cfgfile, char* ip, char* ip2, char* initrd, char* kernel, char* cmdline, int* mem_mb, int* maxmem_mb, int* console, int* vif, int* num_vbds,struct vbd* vbds){ char key[256]; char value[256]; struct vbd* vbd = vbds; FILE* f = fopen(cfgfile,"r"); *num_vbds=0; if(!f) { printf("error opening cfg file %s\n", cfgfile); exit(-1); } while( fscanf(f, "%[^=] = %[^\n]\n", key, value)!= EOF) { if(!strcmp(key, "kernel")) { strcpy(kernel,value); } else if(!strcmp(key, "initrd")) { strcpy(initrd,value); } else if(!strcmp(key, "ip")) { strcpy(ip,value); } else if(!strcmp(key, "ip2")) { strcpy(ip2,value); } else if(!strcmp(key, "cmdline")) { strcpy(cmdline,value); } else if(vbd && !strcmp(key, "vbd")) { strcpy(vbd->mode,"r"); sscanf(value, "%x,%x,%s\n", &vbd->pdev,&vbd->vdev,vbd->mode); vbd++; ++(*num_vbds); } else if(!strcmp(key, "mem")) { sscanf(value, "%dM", mem_mb); } else if(!strcmp(key, "maxmem")) { sscanf(value, "%dM", maxmem_mb); } else if(!strcmp(key, "console")) { sscanf(value, "%d", console); } else if(!strcmp(key, "vif")) { sscanf(value, "%d", vif); } } fclose(f);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -