-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.c
More file actions
44 lines (31 loc) · 1 KB
/
Copy pathtest.c
File metadata and controls
44 lines (31 loc) · 1 KB
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
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include"list.h"
int addClientToPeer(char* hostname){
peernode *temp = (peernode *)malloc(sizeof(peernode));
temp->hostname = hostname;
insertFrontPeerList(temp);
}
int main(){
char *ch;
char field[256],*hostname;
int field2;
char *buf = (char *)malloc(sizeof(512));
hostname = (char *)malloc(sizeof(256));
memset(hostname,'\0',strlen(hostname));
buf="Host: nom0061218.nomadic.ncsu.edusfsdfs\n";
int i=0;
ch = strstr(buf,"Host:");
sscanf(ch,"%[^' '] %[^\n]",field,hostname);
printf("Substring =>%s,%s\n",field,hostname);
addClientToPeer(hostname);
buf = (char *)malloc(sizeof(512));
hostname = (char *)malloc(sizeof(256));
buf="Host: sfsdsssssadadasdasdadasdadfssdfsdfsdfsf\n";
ch = strstr(buf,"Host:");
sscanf(ch,"%[^' '] %[^\n]",field,hostname);
printf("Substring =>%s,%s\n",field,hostname);
addClientToPeer(hostname);
printAll();
}