-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcommon.cpp
More file actions
75 lines (55 loc) · 2.17 KB
/
Copy pathcommon.cpp
File metadata and controls
75 lines (55 loc) · 2.17 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
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
#include "pshare.h"
#include <stdio.h>
#include <time.h>
namespace pshare
{
int get_gmt_date(char* dst,int ndst)
{
time_t timestamp=time(0);
tm* t=gmtime(×tamp);
static const char* wd[7]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
static const char* m[12]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
return snprintf(dst,ndst,"%s, %i %s %.4i %.2i:%.2i:%.2i GMT",wd[t->tm_wday],t->tm_mday,m[t->tm_mon],t->tm_year+1900,
t->tm_hour,t->tm_min,t->tm_sec);
}
// const char xbox360_extra_hdrs[]="X-User-Agent: redsonic\r\n";
int print_http_hdrs(FILE* fp,const char* content_type,int extras)
{
char date[64];
get_gmt_date(date,sizeof(date));
fprintf(fp,
"HTTP/1.1 200 OK\r\nPragma: no-cache\r\nCache-control: no-cache\r\nDate: %s\r\nServer: %s\r\nAccept-Ranges: none\r\n"
"Connection: close\r\nContent-Type: %s\r\nEXT:\r\n",
date,server_name,content_type);
// if(xbox360)
// fprintf(fp,"%s",xbox360_extra_hdrs);
if(!extras)
fprintf(fp,"\r\n");
return 0;
}
int print_http_hdrs_no_content(FILE* fp,int extras)
{
char date[64];
get_gmt_date(date,sizeof(date));
fprintf(fp,
"HTTP/1.1 200 OK\r\nPragma: no-cache\r\nCache-control: no-cache\r\nDate: %s\r\nServer: %s\r\nAccept-Ranges: none\r\n"
"Connection: close\r\nContent-Length: 0\r\nEXT:\r\n",date,server_name);
// if(xbox360)
// fprintf(fp,"%s",xbox360_extra_hdrs);
if(!extras)
fprintf(fp,"\r\n");
return 0;
}
int print_http_error_hdrs(FILE* fp,const char* status,int extras)
{
char date[64];
get_gmt_date(date,sizeof(date));
fprintf(fp,"HTTP/1.1 %s\r\nPragma: no-cache\r\nCache-control: no-cache\r\nDate: %s\r\nServer: %s\r\nConnection: close\r\nEXT:\r\n",
status,date,server_name);
// if(xbox360)
// fprintf(fp,"%s",xbox360_extra_hdrs);
if(!extras)
fprintf(fp,"\r\n");
return 0;
}
}