#include #include #include #include "identity.h" void read_preferences() { FILE *f; char buffer[1024]; char *fbuf, *p, *s; int len, max; init_parameters(); sprintf(buffer, "%s/." LUI_ID "rc", getenv("HOME")); f = fopen(buffer, "r"); if(!f) { sprintf(buffer, "%s/.luirc", getenv("HOME")); f = fopen(buffer, "r"); if(!f) { //perror(buffer); //perror("couldn't open .yzluirc, using defaults"); return; } } fseek(f, 0, SEEK_END); max = ftell(f); if(!max){fclose(f); return;} rewind(f); fbuf = malloc(max+1); len = fread(fbuf, 1, max, f); if(len>0) { fbuf[len] = 0; s = p = fbuf; while(*p) { if(*p==' ' || *p=='\n') { *p = 0; if(!strchr("/;#%", s[0])) process_complete_command(s); s = p+1; } p++; } } free(fbuf); fclose(f); }