Changeset 4071


Ignore:
Timestamp:
11/30/09 11:03:47 (3 years ago)
Author:
jylam
Message:
  • Moved system stuff (user_path, shell, grab stuff, etc) to struct sys
Location:
neercs/trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/attach.c

    r4061 r4071  
    415415            free(screen_list->comm.socket_path[SOCK_SERVER]); 
    416416            screen_list->comm.socket_path[SOCK_SERVER] = NULL; 
    417             screen_list->attach = 0; 
     417            screen_list->sys.attach = 0; 
    418418        } 
    419419    } 
     
    421421    { 
    422422        fprintf(stderr, "No socket found!\n"); 
    423         screen_list->attach = 0; 
    424     } 
    425 } 
    426  
     423        screen_list->sys.attach = 0; 
     424    } 
     425} 
     426 
  • neercs/trunk/src/input.c

    r4064 r4071  
    140140                       create_screen(screen_list->width, 
    141141                                     screen_list->height, 
    142                                      screen_list->default_shell)); 
     142                                     screen_list->sys.default_shell)); 
    143143        refresh = 1; 
    144144        break; 
  • neercs/trunk/src/main.c

    r4060 r4071  
    9191 
    9292    screen_list = create_screen_list(); 
    93     screen_list->default_shell = getenv("SHELL"); 
     93    screen_list->sys.default_shell = getenv("SHELL"); 
    9494 
    9595    args = argc - 1; 
    96     if (screen_list->default_shell == NULL && args <= 0) 
     96    if (screen_list->sys.default_shell == NULL && args <= 0) 
    9797    { 
    9898        fprintf(stderr, 
     
    108108 
    109109    /* Then local one */ 
    110     if (screen_list->user_path) 
    111     { 
    112         read_configuration_file(screen_list->user_path, screen_list); 
    113         free(screen_list->user_path); 
    114     } 
    115  
    116     if (screen_list->attach) 
    117     { 
    118         if (screen_list->nb_to_grab || screen_list->to_start) 
     110    if (screen_list->sys.user_path) 
     111    { 
     112        read_configuration_file(screen_list->sys.user_path, screen_list); 
     113        free(screen_list->sys.user_path); 
     114    } 
     115 
     116    if (screen_list->sys.attach) 
     117    { 
     118        if (screen_list->sys.nb_to_grab || screen_list->sys.to_start) 
    119119        { 
    120120            fprintf(stderr, 
     
    125125        attach(screen_list); 
    126126 
    127         if (screen_list->forceattach && !screen_list->attach) 
     127        if (screen_list->sys.forceattach && !screen_list->sys.attach) 
    128128            goto end; 
    129129    } 
     
    154154 
    155155    /* Fork the server if needed */ 
    156     if (!screen_list->attach) 
     156    if (!screen_list->sys.attach) 
    157157    { 
    158158        debug("Spawning a new server"); 
     
    213213        { 
    214214        case 'c':              /* --config */ 
    215             if (screen_list->user_path) 
    216                 free(screen_list->user_path); 
    217             screen_list->user_path = strdup(myoptarg); 
     215            if (screen_list->sys.user_path) 
     216                free(screen_list->sys.user_path); 
     217            screen_list->sys.user_path = strdup(myoptarg); 
    218218            s += 2; 
    219219            break; 
     
    230230                { 
    231231                    fprintf(stderr, "Invalid pid %d\n", pidopt); 
    232                     if (screen_list->to_grab) 
    233                         free(screen_list->to_grab); 
     232                    if (screen_list->sys.to_grab) 
     233                        free(screen_list->sys.to_grab); 
    234234                    return -1; 
    235235                } 
     
    242242                break; 
    243243            } 
    244             if (!screen_list->to_grab) 
     244            if (!screen_list->sys.to_grab) 
    245245            { 
    246246                /* At most argc-1-s times -P <pid> + final 0 */ 
    247                 screen_list->to_grab = 
     247                screen_list->sys.to_grab = 
    248248                    (int *)malloc(((argc - 1 - s) / 2 + 1) * sizeof(int)); 
    249                 if (!screen_list->to_grab) 
     249                if (!screen_list->sys.to_grab) 
    250250                { 
    251251                    fprintf(stderr, "Can't allocate memory at %s:%d\n", 
     
    254254                } 
    255255            } 
    256             screen_list->to_grab[screen_list->nb_to_grab++] = pidopt; 
    257             screen_list->to_grab[screen_list->nb_to_grab] = 0; 
     256            screen_list->sys.to_grab[screen_list->sys.nb_to_grab++] = pidopt; 
     257            screen_list->sys.to_grab[screen_list->sys.nb_to_grab] = 0; 
    258258            s += 2; 
    259259            break; 
     
    264264            break; 
    265265        case 'r': 
    266             screen_list->forceattach = 1; 
     266            screen_list->sys.forceattach = 1; 
    267267        case 'R': 
    268             if (screen_list->attach) 
     268            if (screen_list->sys.attach) 
    269269            { 
    270270                fprintf(stderr, "Attaching can only be requested once\n"); 
     
    278278                s += 1; 
    279279            } 
    280             screen_list->attach = 1; 
     280            screen_list->sys.attach = 1; 
    281281            s += 1; 
    282282            break; 
     
    299299    if (s >= 0 && s < argc - 1) 
    300300    { 
    301         screen_list->to_start = (char **)malloc((argc - s) * sizeof(char *)); 
    302         if (!screen_list->to_start) 
     301        screen_list->sys.to_start = (char **)malloc((argc - s) * sizeof(char *)); 
     302        if (!screen_list->sys.to_start) 
    303303        { 
    304304            fprintf(stderr, "Can't allocate memory at %s:%d\n", __FUNCTION__, 
     
    308308        for (i = 0; i < (argc - 1) - s; i++) 
    309309        { 
    310             screen_list->to_start[i] = strdup(argv[i + s + 1]); 
    311         } 
    312         screen_list->to_start[argc - 1 - s] = NULL; 
     310            screen_list->sys.to_start[i] = strdup(argv[i + s + 1]); 
     311        } 
     312        screen_list->sys.to_start[argc - 1 - s] = NULL; 
    313313    } 
    314314    return s; 
  • neercs/trunk/src/neercs.h

    r4063 r4071  
    196196}; 
    197197 
     198struct sys 
     199{ 
     200    char *default_shell; 
     201    char *user_path; 
     202    int  *to_grab; 
     203    char **to_start; 
     204    int  nb_to_grab; 
     205    int  attach, forceattach;     
     206}; 
     207 
    198208struct screen_list 
    199209{ 
     
    204214    int changed;                 /* Global redraw needed (e.g. adding a screen) */ 
    205215    int delay;                   /* Minimal time between two refresh (ms) */ 
     216    int  requested_delay; 
    206217    int force_refresh; 
    207218    int need_refresh;            /* If we skipped a refresh, do it next time */ 
     
    239250    /* Option parsing and configuration */ 
    240251    struct option *config; 
    241     char *default_shell; 
    242     char *user_path; 
    243     int *to_grab; 
    244     char **to_start; 
    245     int nb_to_grab; 
    246     int attach, forceattach; 
    247     int requested_delay; 
     252     
     253    struct sys sys; 
    248254 
    249255    struct recurrent_list *recurrent_list; 
  • neercs/trunk/src/python/interpreter.c

    r4064 r4071  
    7171        debug("py Init %p\n", screen_list->interpreter_props.box); 
    7272    } 
    73     debug("py Drawing !\n"); 
    7473    widget_ibox_draw(screen_list->interpreter_props.box); 
    7574} 
  • neercs/trunk/src/screen_list.c

    r4063 r4071  
    8686    screen_list->comm.socket_path[SOCK_CLIENT] = NULL; 
    8787    screen_list->comm.session_name = NULL; 
    88     screen_list->default_shell = NULL; 
    89     screen_list->user_path = NULL; 
    90     screen_list->to_grab = NULL; 
    91     screen_list->to_start = NULL; 
    92     screen_list->nb_to_grab = 0; 
    93     screen_list->attach = 0; 
    94     screen_list->forceattach = 0; 
     88    screen_list->sys.default_shell = NULL; 
     89    screen_list->sys.user_path = NULL; 
     90    screen_list->sys.to_grab = NULL; 
     91    screen_list->sys.to_start = NULL; 
     92    screen_list->sys.nb_to_grab = 0; 
     93    screen_list->sys.attach = 0; 
     94    screen_list->sys.forceattach = 0; 
    9595    screen_list->need_refresh = 0; 
    9696 
     
    120120    if (user_dir) 
    121121    { 
    122         screen_list->user_path = 
     122        screen_list->sys.user_path = 
    123123        malloc(strlen(user_dir) + strlen("/.neercsrc") + 1); 
    124         sprintf(screen_list->user_path, "%s/%s", user_dir, ".neercsrc"); 
     124        sprintf(screen_list->sys.user_path, "%s/%s", user_dir, ".neercsrc"); 
    125125    } 
    126126     
  • neercs/trunk/src/server.c

    r4063 r4071  
    418418                                         + screen_list->modals.status); 
    419419 
    420     if (!screen_list->to_grab && !screen_list->to_start) 
     420    if (!screen_list->sys.to_grab && !screen_list->sys.to_start) 
    421421    { 
    422422        add_screen(screen_list, 
    423423                   create_screen(screen_list->width, 
    424424                                 screen_list->height, 
    425                                  screen_list->default_shell)); 
     425                                 screen_list->sys.default_shell)); 
    426426    } 
    427427 
    428428    /* Attach processes */ 
    429     if (screen_list->to_grab) 
    430     { 
    431         for (i = 0; screen_list->to_grab[i]; i++) 
     429    if (screen_list->sys.to_grab) 
     430    { 
     431        for (i = 0; screen_list->sys.to_grab[i]; i++) 
    432432        { 
    433433            add_screen(screen_list, 
    434434                       create_screen_grab(screen_list->width, 
    435435                                          screen_list->height, 
    436                                           screen_list->to_grab[i])); 
    437         } 
    438         free(screen_list->to_grab); 
    439         screen_list->to_grab = NULL; 
     436                                          screen_list->sys.to_grab[i])); 
     437        } 
     438        free(screen_list->sys.to_grab); 
     439        screen_list->sys.to_grab = NULL; 
    440440    } 
    441441 
    442442    /* Launch command line processes */ 
    443     if (screen_list->to_start) 
    444     { 
    445         for (i = 0; screen_list->to_start[i]; i++) 
     443    if (screen_list->sys.to_start) 
     444    { 
     445        for (i = 0; screen_list->sys.to_start[i]; i++) 
    446446        { 
    447447            add_screen(screen_list, 
    448448                       create_screen(screen_list->width, 
    449449                                     screen_list->height, 
    450                                      screen_list->to_start[i])); 
    451             free(screen_list->to_start[i]); 
    452         } 
    453         free(screen_list->to_start); 
    454         screen_list->to_start = NULL; 
     450                                     screen_list->sys.to_start[i])); 
     451            free(screen_list->sys.to_start[i]); 
     452        } 
     453        free(screen_list->sys.to_start); 
     454        screen_list->sys.to_start = NULL; 
    455455    } 
    456456 
  • neercs/trunk/src/widgets.c

    r4048 r4071  
    8080void widget_ibox_destroy(struct input_box *box) 
    8181{ 
     82    if(!box) return; 
    8283    if (box->command) 
    8384        free(box->command); 
Note: See TracChangeset for help on using the changeset viewer.