3232 * URL.
3333 * RFC for HTCP can be found at http://www.htcp.org/
3434 */
35- static void cache_expire_url (int sock , char * url )
35+ static void cache_expire_url (int sock , char * url )
3636{
37- char * buf ;
37+ char * buf ;
3838
3939 if (sock < 0 ) {
4040 return ;
@@ -44,66 +44,66 @@ static void cache_expire_url(int sock, char * url)
4444 int url_len ;
4545
4646 url_len = strlen (url );
47- buf = (char * ) malloc (12 + 22 + url_len );
47+ buf = (char * )malloc (12 + 22 + url_len );
4848
4949 if (!buf ) {
5050 return ;
5151 }
5252
5353 idx = 0 ;
5454
55- //16 bit: Overall length of the datagram packet, including this header
55+ // 16 bit: Overall length of the datagram packet, including this header
5656 * ((uint16_t * )(& buf [idx ])) = htons (12 + 22 + url_len );
5757 idx += 2 ;
5858
59- //HTCP version. Currently at 0.0
60- buf [idx ++ ] = 0 ; //Major version
61- buf [idx ++ ] = 0 ; //Minor version
59+ // HTCP version. Currently at 0.0
60+ buf [idx ++ ] = 0 ; // Major version
61+ buf [idx ++ ] = 0 ; // Minor version
6262
63- //Length of HTCP data, including this field
63+ // Length of HTCP data, including this field
6464 * ((uint16_t * )(& buf [idx ])) = htons (8 + 22 + url_len );
6565 idx += 2 ;
6666
67- //HTCP opcode CLR=4
67+ // HTCP opcode CLR=4
6868 buf [idx ++ ] = 4 ;
69- //Reserved
69+ // Reserved
7070 buf [idx ++ ] = 0 ;
7171
72- //32 bit transaction id;
72+ // 32 bit transaction id;
7373 * ((uint32_t * )(& buf [idx ])) = htonl (255 );
7474 idx += 4 ;
7575
7676 buf [idx ++ ] = 0 ;
77- buf [idx ++ ] = 0 ; //HTCP reason
77+ buf [idx ++ ] = 0 ; // HTCP reason
7878
79- //Length of the Method string
79+ // Length of the Method string
8080 * ((uint16_t * )(& buf [idx ])) = htons (4 );
8181 idx += 2 ;
8282
83- ///Method string
83+ /// Method string
8484 memcpy (& buf [idx ], "HEAD" , 4 );
8585 idx += 4 ;
8686
87- //Length of the url string
87+ // Length of the url string
8888 * ((uint16_t * )(& buf [idx ])) = htons (url_len );
8989 idx += 2 ;
9090
91- //Url string
91+ // Url string
9292 memcpy (& buf [idx ], url , url_len );
9393 idx += url_len ;
9494
95- //Length of version string
95+ // Length of version string
9696 * ((uint16_t * )(& buf [idx ])) = htons (8 );
9797 idx += 2 ;
9898
99- //version string
99+ // version string
100100 memcpy (& buf [idx ], "HTTP/1.1" , 8 );
101101 idx += 8 ;
102102
103- //Length of request headers. Currently 0 as we don't have any headers to send
103+ // Length of request headers. Currently 0 as we don't have any headers to send
104104 * ((uint16_t * )(& buf [idx ])) = htons (0 );
105105
106- if (send (sock , (void * ) buf , (12 + 22 + url_len ), 0 ) < (12 + 22 + url_len )) {
106+ if (send (sock , (void * )buf , (12 + 22 + url_len ), 0 ) < (12 + 22 + url_len )) {
107107 g_logger (G_LOG_LEVEL_ERROR , "Failed to send HTCP purge for %s" , url );
108108 };
109109
@@ -117,13 +117,13 @@ void cache_expire(int sock, const char *host, const char *uri, int x, int y, int
117117 return ;
118118 }
119119
120- char * url = (char * )malloc (1024 );
120+ char * url = (char * )malloc (1024 );
121121 snprintf (url , 1024 , "http://%s%s%i/%i/%i.png" , host , uri , z , x , y );
122122 cache_expire_url (sock , url );
123123 free (url );
124124}
125125
126- int init_cache_expire (const char * htcphost )
126+ int init_cache_expire (const char * htcphost )
127127{
128128 struct addrinfo hints ;
129129 struct addrinfo * result , * rp ;
@@ -132,7 +132,7 @@ int init_cache_expire(const char * htcphost)
132132 /* Obtain address(es) matching host/port */
133133
134134 memset (& hints , 0 , sizeof (struct addrinfo ));
135- hints .ai_family = AF_UNSPEC ; /* Allow IPv4 or IPv6 */
135+ hints .ai_family = AF_UNSPEC ; /* Allow IPv4 or IPv6 */
136136 hints .ai_socktype = SOCK_DGRAM ; /* Datagram socket */
137137 hints .ai_flags = 0 ;
138138 hints .ai_protocol = 0 ; /* Any protocol */
@@ -157,7 +157,7 @@ int init_cache_expire(const char * htcphost)
157157 }
158158
159159 if (connect (sfd , rp -> ai_addr , rp -> ai_addrlen ) != -1 ) {
160- break ; /* Success */
160+ break ; /* Success */
161161 }
162162
163163 close (sfd );
@@ -171,5 +171,4 @@ int init_cache_expire(const char * htcphost)
171171 freeaddrinfo (result ); /* No longer needed */
172172
173173 return sfd ;
174-
175174}
0 commit comments