diff options
author | louie <lshprung@yahoo.com> | 2020-08-02 18:09:03 -0700 |
---|---|---|
committer | louie <lshprung@yahoo.com> | 2020-08-02 18:09:03 -0700 |
commit | 7cab81c193a01775d804fb037f7d26c6a6806e74 (patch) | |
tree | ba6049ca4c3243496bcd46c1f5639d8f69591e7a /group.c | |
parent | 2ee23565a15bd969828db7442f2f8b4902d5e261 (diff) |
Added option to sort entries
Diffstat (limited to 'group.c')
-rw-r--r-- | group.c | 27 |
1 files changed, 25 insertions, 2 deletions
@@ -6,6 +6,7 @@ #include <unistd.h> #include "entry.h" #include "group.h" +#include "read_cfg.h" #define BUF_LEN 1024 typedef struct group{ @@ -103,8 +104,30 @@ void group_add(char *gname, ENTRY *addme){ //add the entry to the list of entries in the group if(addme != NULL){ - gp->tail = entry_add_last(gp->tail, addme); - if(gp->head == NULL) gp->head = gp->tail; //first element of the new list + if(get_sort()){ + i = entry_add_sorted(gp->head, gp->tail, addme); + switch(i){ + case 1: + gp->head = addme; + break; + + case 2: + gp->tail = addme; + break; + + case 3: + gp->head = addme; + gp->tail = addme; + break; + + } + } + + else{ + gp->tail = entry_add_last(gp->tail, addme); + if(gp->head == NULL) gp->head = gp->tail; //first element of the new list + } + gp->entry_count++; total_count++; } |