-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cx
More file actions
executable file
·132 lines (132 loc) · 3.52 KB
/
Copy pathmain.cx
File metadata and controls
executable file
·132 lines (132 loc) · 3.52 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//-*-C-*-
/*******************************************************************************
* ___ workplace
* ¦OUX¦ C+
* ¦/C+¦ server
* --- web server
* entry and raw labels
* ©overcq on ‟Gentoo Linux 17.1” “x86_64” 2020‒4‒10 S
*******************************************************************************/
#define S_as_user "www-data"
Pc E_main_S_conf_file[] =
{ "oux-web-srv.conf"
, "/etc/oux-web-srv.conf"
};
//==============================================================================
N
E_main_I_read_conf( void
){ for_n( file_i, sizeof( E_main_S_conf_file ) / sizeof( E_main_S_conf_file[0] ))
{ I conf_file = E_mem_Q_file_M( E_main_S_conf_file[ file_i ], yes, 0 );
if( !~conf_file )
continue;
if( (S)conf_file < 0 )
return (N)conf_file;
N r = E_conf_I_read( conf_file );
if(r)
return r;
r = E_mem_Q_file_W( conf_file );
if(r)
return r;
break;
}
return 0;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int
main(
int argc
, Pc *argv
){ N r = E_base_M( argc, argv );
if(r)
return (int)r;
X_M( main, loop );
if( _X_var( main, loop ) < 0 )
return (int)_X_var( main, loop );
Mt_( E_conf_S_bind, 0 );
if( !E_conf_S_bind )
{ GV_(NA); V();
}
Mt_( E_srv_S_srv, 0 );
if( !E_srv_S_srv )
{ GV_(NA); V();
}
Mt_( E_http_srv_S_accept, 0 );
if( !E_http_srv_S_accept )
{ GV_(NA); V();
}
Mt_( E_http2_srv_S_accept, 0 );
if( !E_http2_srv_S_accept )
{ GV_(NA); V();
}
if( E_main_I_read_conf() )
{ G_(); Gs0_( "error: reading config file" ); V();
}
if( E_http2_push_M() )
{ G_(); Gs0_( "error: initializing HTTP/2 push" ); V();
}
if( E_srv_M() )
{ G_(); Gs0_( "error: initializing server" ); V();
}
struct passwd *pw = getpwnam( S_as_user );
if( !pw )
{ G_(); V();
}
V0_( setgid( pw->pw_gid ));
V0_( setuid( pw->pw_uid ));
r = Dh_M( srv, srv, 0, 0 );
if(r)
return (int)r;
O{ X_B( main, loop, 0 )
break;
}
r = Dh_W( srv, srv, 0 );
if(r)
return (int)r;
r = E_text_syntax_W( E_http2_push_Z_syntax_html );
if(r)
return (int)r;
r = W( E_http2_srv_S_accept );
if(r)
return (int)r;
r = W( E_http_srv_S_accept );
if(r)
return (int)r;
r = W( E_srv_S_srv );
if(r)
return (int)r;
for_n( i, E_conf_S_bind_n )
{ if( W( E_conf_S_bind[i].ip ))
return 0;
if( E_conf_S_bind[i].ssl )
{ r = W( E_conf_S_bind[i].certificate_path );
if(r)
return (int)r;
r = W( E_conf_S_bind[i].private_key_path );
if(r)
return (int)r;
}
for_n( j, E_conf_S_bind[i].virtualhost_n )
{ r = W( E_conf_S_bind[i].virtualhost[j].root_path );
if(r)
return (int)r;
r = W( E_conf_S_bind[i].virtualhost[j].host );
if(r)
return (int)r;
}
}
r = W( E_conf_S_bind );
if(r)
return (int)r;
r = X_W( main, loop );
if(r)
return (int)r;
r = E_base_W();
return r ? (int)r : EXIT_SUCCESS;
}
//==============================================================================
void
E_flow_Q_process_call_I_func( pid_t pid
, P data
){
}
/******************************************************************************/