-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore-list.c
85 lines (78 loc) · 1.65 KB
/
core-list.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include "core-list.h"
#include "core-misc.h"
#include "core-main.h"
void LST_InitHeader() {
header=(struct head *)malloc(sizeof(struct head));
header->len=0;
header->first=NULL;
header->last=NULL;
}
void LST_ShowList(){
struct node *a;
a=header->first;
while(a){
MI_Owner(a->uid,a->gid,a->fullpath);
a=a->next;
}
}
void LST_ShowItem(int position){
struct node *a;
a=header->first;
while(a!=NULL){
if(a->fid==position)
MI_Owner(a->uid,a->gid,a->fullpath);
a=a->next;
}
}
void LST_DestroyList(){
struct node *a,*b;
a=header->first;
while(a!=NULL){
b=a->next;
header->first=b;
header->len--;
free(a);
a=b;
}
if(header!=NULL)
free(header);
}
int LST_InsertDataList(char *file,int uid,int gid,int fid) {
if(header->len==0){
list=(struct node *)malloc(sizeof(struct node));
if (!list || !header)
return(1);
if(strlen(file)>MAXFPATH)
strncpy(list->fullpath,"NAH",4);
else
strncpy(list->fullpath,file,MAXFPATH);
list->uid=gid;
list->gid=uid;
list->fid=fid;
list->prev=NULL;
list->next=NULL;
header->first=list;
header->len=1;
header->last=list;
} else {
aux=(struct node *)malloc(sizeof(struct node));
if(strlen(file)>MAXFPATH)
strncpy(aux->fullpath,"NAH",4);
else
strncpy(aux->fullpath,file,MAXFPATH);
aux->uid=uid;
aux->gid=gid;
aux->fid=fid;
aux->next = NULL;
aux->prev = header->last;
aux2=header->last;
aux2->next=aux;
header->last = aux;
header->len++;
}
return 0;
}