Changeset 3973 for neercs/trunk


Ignore:
Timestamp:
Nov 20, 2009, 1:20:58 PM (11 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Moved screen list creation / destruction to screen_list.c
Location:
neercs/trunk/src
Files:
1 added
2 edited

Legend:

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

    r3940 r3973  
    55                 term.c grab.c effects.c wm.c screensaver.c attach.c \
    66                 configuration.c mytrace.c mytrace.h input.c lock.c server.c \
    7                  client.c                
     7                 client.c screen_list.c               
    88neercs_CFLAGS = @CACA_CFLAGS@
    99neercs_LDADD = @CACA_LIBS@ @UTIL_LIBS@ @PAM_LIBS@
  • neercs/trunk/src/main.c

    r3969 r3973  
    2828#include <sys/time.h>
    2929#include <time.h>
    30 #include <pwd.h>
     30
    3131
    3232
     
    174174
    175175    return mainret;
    176 }
    177 
    178 void free_screen_list(struct screen_list *screen_list)
    179 {
    180     int i;
    181     struct option *option;
    182 
    183     if (screen_list->dp)
    184         caca_free_display(screen_list->dp);
    185 
    186     if (screen_list->cv)
    187         caca_free_canvas(screen_list->cv);
    188 
    189     for (i = 0; i < screen_list->count; i++)
    190     {
    191         destroy_screen(screen_list->screen[i]);
    192     }
    193 
    194     if (screen_list->socket_path[SOCK_SERVER])
    195         free(screen_list->socket_path[SOCK_SERVER]);
    196 
    197     if (screen_list->socket_path[SOCK_CLIENT])
    198     {
    199         unlink(screen_list->socket_path[SOCK_CLIENT]);
    200         free(screen_list->socket_path[SOCK_CLIENT]);
    201     }
    202 
    203     if (screen_list->socket[SOCK_CLIENT])
    204         close(screen_list->socket[SOCK_CLIENT]);
    205 
    206     if (screen_list->socket[SOCK_SERVER])
    207         close(screen_list->socket[SOCK_SERVER]);
    208 
    209     if (screen_list->screen)
    210         free(screen_list->screen);
    211 
    212     option = screen_list->config;
    213 
    214     while (option)
    215     {
    216         struct option *kromeugnon = option;
    217         option = option->next;
    218         if (kromeugnon->key)
    219             free(kromeugnon->key);
    220         if (kromeugnon->value)
    221             free(kromeugnon->value);
    222         free(kromeugnon);
    223     }
    224 
    225     for (i = 0; i < screen_list->recurrent_list->count; i++)
    226     {
    227         remove_recurrent(screen_list->recurrent_list, i);
    228         i = 0;
    229     }
    230 
    231     if (screen_list->recurrent_list->recurrent)
    232         free(screen_list->recurrent_list->recurrent);
    233     if (screen_list->recurrent_list)
    234         free(screen_list->recurrent_list);
    235 
    236     if (screen_list->session_name)
    237         free(screen_list->session_name);
    238 
    239     if (screen_list->title)
    240         free(screen_list->title);
    241 
    242     free(screen_list);
    243 }
    244 
    245 struct screen_list *create_screen_list(void)
    246 {
    247 
    248     struct screen_list *screen_list = NULL;
    249     struct passwd *user_info;
    250     char *user_dir = NULL;
    251 
    252     /* Create screen list */
    253     screen_list = (struct screen_list *)malloc(sizeof(struct screen_list));
    254     if (!screen_list)
    255     {
    256         fprintf(stderr, "Can't allocate memory at %s:%d\n", __FUNCTION__,
    257                 __LINE__);
    258         return NULL;
    259     }
    260     screen_list->screen =
    261         (struct screen **)malloc(sizeof(sizeof(struct screen *)));
    262     if (!screen_list->screen)
    263     {
    264         fprintf(stderr, "Can't allocate memory at %s:%d\n", __FUNCTION__,
    265                 __LINE__);
    266         free(screen_list);
    267         return NULL;
    268     }
    269 
    270     screen_list->count = 0;
    271     screen_list->mini = 1;
    272     screen_list->help = 0;
    273     screen_list->status = 1;
    274     screen_list->title = NULL;
    275     screen_list->window_list = 0;
    276     screen_list->wm_type = WM_VSPLIT;
    277     screen_list->in_bell = 0;
    278     screen_list->changed = 0;
    279     screen_list->requested_delay = 0;
    280     screen_list->delay = 1000 / 60;     /* Don't refresh more than 60 times
    281                                            per second */
    282     screen_list->pty = screen_list->prevpty = 0;
    283     screen_list->dont_update_coords = 0;
    284     screen_list->screensaver_timeout = (60) * 1000000;
    285     screen_list->screensaver_data = NULL;
    286     screen_list->in_screensaver = 0;
    287     screen_list->locked = 0;
    288     screen_list->lock_offset = 0;
    289     screen_list->lock_on_detach = 0;
    290     screen_list->attached = 1;
    291     screen_list->socket[SOCK_SERVER] = 0;
    292     screen_list->socket[SOCK_CLIENT] = 0;
    293     screen_list->socket_dir = NULL;
    294     screen_list->socket_path[SOCK_SERVER] = NULL;
    295     screen_list->socket_path[SOCK_CLIENT] = NULL;
    296     screen_list->session_name = NULL;
    297     screen_list->default_shell = NULL;
    298     screen_list->user_path = NULL;
    299     screen_list->autolock_timeout = -1;
    300     screen_list->to_grab = NULL;
    301     screen_list->to_start = NULL;
    302     screen_list->nb_to_grab = 0;
    303     screen_list->attach = 0;
    304     screen_list->forceattach = 0;
    305 
    306     screen_list->force_refresh = 0;
    307     screen_list->cube.in_switch = 0;
    308     screen_list->cube.duration = 1000000;
    309 
    310 
    311     screen_list->recurrent_list = NULL;
    312     screen_list->cv = NULL;
    313     screen_list->dp = NULL;
    314 
    315     memset(screen_list->lockmsg, 0, 1024);
    316     memset(screen_list->lockpass, 0, 1024);
    317 
    318 
    319 
    320     /* Build local config file path */
    321     user_dir = getenv("HOME");
    322     if (!user_dir)
    323     {
    324         user_info = getpwuid(getuid());
    325         if (user_info)
    326         {
    327             user_dir = user_info->pw_dir;
    328         }
    329     }
    330     if (user_dir)
    331     {
    332         screen_list->user_path =
    333             malloc(strlen(user_dir) + strlen("/.neercsrc") + 1);
    334         sprintf(screen_list->user_path, "%s/%s", user_dir, ".neercsrc");
    335     }
    336 
    337 
    338     screen_list->recurrent_list =
    339         (struct recurrent_list *)malloc(sizeof(struct recurrent_list));
    340     screen_list->recurrent_list->recurrent =
    341         (struct recurrent **)malloc(sizeof(struct recurrent *));
    342     if (!screen_list->recurrent_list->recurrent)
    343     {
    344         fprintf(stderr, "Can't allocate memory at %s:%d\n", __FUNCTION__,
    345                 __LINE__);
    346         free(screen_list);
    347         free(screen_list->screen);
    348         return NULL;
    349     }
    350     screen_list->recurrent_list->count = 0;
    351 
    352 
    353 
    354     return screen_list;
    355176}
    356177
Note: See TracChangeset for help on using the changeset viewer.