Changeset 2463 for neercs


Ignore:
Timestamp:
Jun 20, 2008, 1:42:06 PM (12 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Added configuration file and routines
Location:
neercs/trunk/src
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/Makefile.am

    r2458 r2463  
    33
    44neercs_SOURCES = neercs.h mygetopt.c recurrent.c main.c screens.c term.c \
    5                  grab.c effects.c wm.c screensaver.c attach.c
     5                 grab.c effects.c wm.c screensaver.c attach.c configuration.c
    66neercs_CFLAGS = @CACA_CFLAGS@
    77neercs_LDADD = @CACA_LIBS@ @UTIL_LIBS@ @PAM_LIBS@
    8 
  • neercs/trunk/src/main.c

    r2458 r2463  
    7777    int lock_offset = 0;
    7878
     79
    7980    default_shell = getenv("SHELL");
    8081
     
    113114        return -1;
    114115    }
     116
     117
    115118    screen_list->count = 0;
    116119    screen_list->width  = cucul_get_canvas_width(cv);
     
    130133    memset(screen_list->lockmsg, 0, 1024);
    131134    memset(screen_list->lockpass, 0, 1024);
     135
     136
     137    if(!read_configuration_file("neercs.ini", screen_list))
     138    {
     139
     140        if(!read_configuration_file("~/neercs.ini", screen_list))
     141        {
     142                 if(!read_configuration_file("/etc/neercs.ini", screen_list))
     143                 {
     144                     printf("Failed to read configuration file\n");
     145                 }
     146        }
     147    }
     148
    132149
    133150    recurrent_list = (struct recurrent_list*) malloc(sizeof(struct recurrent_list));
     
    449466
    450467    free(screen_list->screen);
     468
     469
     470    struct option *option = screen_list->config;
     471
     472
     473    while(option)
     474    {
     475        struct option *kromeugnon = option;
     476        option = option->next;
     477        free(kromeugnon->key);
     478        free(kromeugnon->value);
     479        free(kromeugnon);
     480    }
     481
    451482    free(screen_list);
    452483
  • neercs/trunk/src/neercs.h

    r2458 r2463  
    2828
    2929
     30struct option
     31{
     32    char *key;
     33    char *value;
     34
     35    struct option *next;
     36};
     37
     38
    3039struct screen
    3140{
     
    8392    int width, height;           /* caca window size */
    8493    struct screen **screen;      /* Windows */
     94
     95    struct option *config;
     96
    8597};
    8698
     
    99111    struct recurrent **recurrent;
    100112};
     113
    101114
    102115
     
    177190
    178191
     192
     193/* Configuration file */
     194int read_configuration_file(char *filename, struct screen_list *screen_list);
     195int parse_conf_line(char *buf, int size, struct screen_list *screen_list);
     196int get_key_value(char *line, struct option *option);
     197int fill_config(struct screen_list *screen_list);
     198
    179199#if 0
    180200#   define debug(f, z...) fprintf(stderr, f "\n", z)
Note: See TracChangeset for help on using the changeset viewer.