-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocketHelper.c
59 lines (50 loc) · 1.56 KB
/
socketHelper.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
#include "socketHelper.h"
//////////////////////////////////////////////////////////////////////////////
// This code block construct_udp_to_send is a helper function used to clean //
// up some code. It uses a port number send empty udp port init. it returns //
// the socket desc. and the a filled in server_addr_in type //
//////////////////////////////////////////////////////////////////////////////
int construct_udp_to_send(int portNumber, struct sockaddr_in * server_addr){
(*server_addr).sin_family = AF_INET;
(*server_addr).sin_port = htons(portNumber);
(*server_addr).sin_addr.s_addr = INADDR_ANY;
//(*server_addr).sin_addr.s_addr = inet_addr("0.0.0.0");
int socket_desc = socket(AF_INET,SOCK_DGRAM,0);
return socket_desc;
}
int containsWallet(char * msg, char **username){
char checking_wallet_text[] =" WALLET";
char*loc;
loc=strstr(msg,checking_wallet_text);
if(loc ==NULL){
return 0;
}
else{
*username= strtok(msg, " ");
//printf("username :%s\n",*username);
return 1;
}
}
int containsTXLIST(char * input){
char txList[]= "TXLIST" ;
if( strstr(txList, input)){
return 1;
}else{
return 0;
}
}
//////////////////////////////////////////////////////////////////////////////
// This code block defines and a map to be used and init with 1000 alicoins //
//////////////////////////////////////////////////////////////////////////////
//typedef struct Key{
// char name[100];
//}Key;
//
//typedef struct Value{
// int aliCoins;
//}Value;
//
//typedef struct Map{
// Key key;
// Value value;
//}Map;