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 86 87 88 89 90 91 92 93 94 95
|
void split_on_ur_users(char* cache,int clas,int len)
{
int i,j,k;
int totals,new_len;
char* rest;
char** temp;
char* copy1;
char* copy2;
totals=0;
temp=NULL;
for(i=0;i<len;i++)
{
if(cache[i]==SEP)
{
cache[i]=0;
rest=&cache[i+1];
break;
}
}
totals=atoi(cache);
if(totals!=0)
{
temp=(char**)malloc(totals);
if(!temp)
{
..
}
new_len=len-strlen(cache);
j=0;
k=0;
temp[0]=rest;
for(i=0;i<new_len;i++)
{
if(rest[i]==SEP)
{
if(j==1)
{
k++;
rest[i]=0;
temp[k]=&rest[i+1];
j=0;
}
else
{
j++;
}
}
}for(i=0;i<totals;i++)
{
copy1=NULL;
copy2=NULL;
copy1=temp[i];
k=0;
for(j=0;j<new_len;j++)
{
if(temp[i][j]==SEP)
{
copy2=&temp[i][j+1];
temp[i][j]=0;
break;
}
}
if(l_user==NULL)
{
l_user=add_user(NULL,atoi(copy1),0,copy2,"",FALSE,TRUE);
}
else
{
l_user=add_user(l_user,atoi(copy1),0,copy2,"",FALSE,TRUE);
}
}
}
}
et
llist add_user(llist linked_user,int indx,int t_indx,char* ipad,char* nam,BOOL prtcd,BOOL cnntd)
{
user* new_user=malloc(sizeof(user));
if(!new_user)
{
...
}
(*new_user).index=indx;
(*new_user).t_index=t_indx;
(*new_user).connected=cnntd;
(*new_user).ip=ipad;
(*new_user).p_protected=prtcd;
(*new_user).u_name=nam;
(*new_user).next=linked_user;
return new_user;
} |
Partager