fixup spaces/tabs
This commit is contained in:
parent
f23ee8441f
commit
d63df84c98
634
src/zms.cpp
634
src/zms.cpp
|
@ -28,339 +28,339 @@
|
||||||
|
|
||||||
bool ValidateAccess( User *user, int mon_id )
|
bool ValidateAccess( User *user, int mon_id )
|
||||||
{
|
{
|
||||||
bool allowed = true;
|
bool allowed = true;
|
||||||
|
|
||||||
if ( mon_id > 0 )
|
if ( mon_id > 0 )
|
||||||
{
|
{
|
||||||
if ( user->getStream() < User::PERM_VIEW )
|
if ( user->getStream() < User::PERM_VIEW )
|
||||||
allowed = false;
|
allowed = false;
|
||||||
if ( !user->canAccess( mon_id ) )
|
if ( !user->canAccess( mon_id ) )
|
||||||
allowed = false;
|
allowed = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( user->getEvents() < User::PERM_VIEW )
|
if ( user->getEvents() < User::PERM_VIEW )
|
||||||
allowed = false;
|
allowed = false;
|
||||||
}
|
}
|
||||||
if ( !allowed )
|
if ( !allowed )
|
||||||
{
|
{
|
||||||
Error( "Error, insufficient privileges for requested action" );
|
Error( "Error, insufficient privileges for requested action" );
|
||||||
exit( -1 );
|
exit( -1 );
|
||||||
}
|
}
|
||||||
return( allowed );
|
return( allowed );
|
||||||
}
|
}
|
||||||
|
|
||||||
int main( int argc, const char *argv[] )
|
int main( int argc, const char *argv[] )
|
||||||
{
|
{
|
||||||
self = argv[0];
|
self = argv[0];
|
||||||
|
|
||||||
srand( getpid() * time( 0 ) );
|
srand( getpid() * time( 0 ) );
|
||||||
|
|
||||||
enum { ZMS_MONITOR, ZMS_EVENT } source = ZMS_MONITOR;
|
enum { ZMS_MONITOR, ZMS_EVENT } source = ZMS_MONITOR;
|
||||||
StreamBase::StreamMode mode; // When streaming a live view or event, default to STREAM. If a frame is specified then default to SINGLE>
|
StreamBase::StreamMode mode; // When streaming a live view or event, default to STREAM. If a frame is specified then default to SINGLE>
|
||||||
StreamBase::StreamType type = StreamBase::JPEG;
|
StreamBase::StreamType type = StreamBase::JPEG;
|
||||||
char format[32] = ""; //used to specify format to ffmpeg libs
|
char format[32] = ""; //used to specify format to ffmpeg libs
|
||||||
int monitor_id = 0;
|
int monitor_id = 0;
|
||||||
time_t event_time = 0;
|
time_t event_time = 0;
|
||||||
int event_id = 0;
|
int event_id = 0;
|
||||||
int frame_id = 1;
|
int frame_id = 1;
|
||||||
unsigned int scale = 100;
|
unsigned int scale = 100;
|
||||||
unsigned int rate = 100;
|
unsigned int rate = 100;
|
||||||
double maxfps = 10.0;
|
double maxfps = 10.0;
|
||||||
unsigned int bitrate = 100000;
|
unsigned int bitrate = 100000;
|
||||||
unsigned int ttl = 0;
|
unsigned int ttl = 0;
|
||||||
EventStream::StreamMode replay = EventStream::SINGLE;
|
EventStream::StreamMode replay = EventStream::SINGLE;
|
||||||
char username[64] = "";
|
char username[64] = "";
|
||||||
char password[64] = "";
|
char password[64] = "";
|
||||||
char auth[64] = "";
|
char auth[64] = "";
|
||||||
unsigned int connkey = 0;
|
unsigned int connkey = 0;
|
||||||
unsigned int playback_buffer = 0;
|
unsigned int playback_buffer = 0;
|
||||||
|
|
||||||
bool nph = false;
|
bool nph = false;
|
||||||
const char *basename = strrchr( argv[0], '/' );
|
const char *basename = strrchr( argv[0], '/' );
|
||||||
if (basename) //if we found a / lets skip past it
|
if (basename) //if we found a / lets skip past it
|
||||||
basename++;
|
basename++;
|
||||||
else //argv[0] will not always contain the full path, but rather just the script name
|
else //argv[0] will not always contain the full path, but rather just the script name
|
||||||
basename = argv[0];
|
basename = argv[0];
|
||||||
const char *nph_prefix = "nph-";
|
const char *nph_prefix = "nph-";
|
||||||
if ( basename && !strncmp( basename, nph_prefix, strlen(nph_prefix) ) )
|
if ( basename && !strncmp( basename, nph_prefix, strlen(nph_prefix) ) )
|
||||||
{
|
{
|
||||||
nph = true;
|
nph = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
zmLoadConfig();
|
|
||||||
|
|
||||||
logInit( "zms" );
|
zmLoadConfig();
|
||||||
|
|
||||||
ssedetect();
|
|
||||||
|
|
||||||
zmSetDefaultTermHandler();
|
logInit( "zms" );
|
||||||
zmSetDefaultDieHandler();
|
|
||||||
|
|
||||||
const char *query = getenv( "QUERY_STRING" );
|
ssedetect();
|
||||||
if ( query )
|
|
||||||
{
|
|
||||||
Debug( 1, "Query: %s", query );
|
|
||||||
|
|
||||||
char temp_query[1024];
|
|
||||||
strncpy( temp_query, query, sizeof(temp_query) );
|
|
||||||
char *q_ptr = temp_query;
|
|
||||||
char *parms[16]; // Shouldn't be more than this
|
|
||||||
int parm_no = 0;
|
|
||||||
while( (parm_no < 16) && (parms[parm_no] = strtok( q_ptr, "&" )) )
|
|
||||||
{
|
|
||||||
parm_no++;
|
|
||||||
q_ptr = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( int p = 0; p < parm_no; p++ )
|
|
||||||
{
|
|
||||||
char *name = strtok( parms[p], "=" );
|
|
||||||
char *value = strtok( NULL, "=" );
|
|
||||||
if ( !value )
|
|
||||||
value = (char *)"";
|
|
||||||
if ( !strcmp( name, "source" ) )
|
|
||||||
{
|
|
||||||
source = !strcmp( value, "event" )?ZMS_EVENT:ZMS_MONITOR;
|
|
||||||
}
|
|
||||||
else if ( !strcmp( name, "mode" ) )
|
|
||||||
{
|
|
||||||
if ( !strcmp( value, "single" ) ) {
|
|
||||||
mode = StreamBase::SINGLE;
|
|
||||||
} else if ( !strcmp( value, "stream" ) ) {
|
|
||||||
mode = StreamBase::STREAM;
|
|
||||||
} else if ( !strcmp( value, "jpeg" ) ) {
|
|
||||||
type = StreamBase::JPEG;
|
|
||||||
// code for STREAM/SINGLE comes later.
|
|
||||||
} else if ( !strcmp( value, "raw" ) ) {
|
|
||||||
type = StreamBase::RAW;
|
|
||||||
|
|
||||||
} else if ( !strcmp( value, "zip" ) ) {
|
|
||||||
type = StreamBase::ZIP;
|
|
||||||
} else {
|
|
||||||
Warning( "Unsupported mode: (%s) defaulting to ", value );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( !strcmp( name, "format" ) )
|
|
||||||
if ( !strcmp( value, "jpeg" ) ) {
|
|
||||||
type = StreamBase::JPEG;
|
|
||||||
} else if ( !strcmp( value, "raw" ) ) {
|
|
||||||
type = StreamBase::RAW;
|
|
||||||
} else if ( !strcmp( value, "zip" ) ) {
|
|
||||||
type = StreamBase::ZIP;
|
|
||||||
} else if ( !strcmp( value, "mpeg" ) ) {
|
|
||||||
type = StreamBase::MPEG;
|
|
||||||
strncpy( format, value, sizeof(format) );
|
|
||||||
} else {
|
|
||||||
Warning( "Unsupported format: (%s) defaulting to ", value );
|
|
||||||
strncpy( format, value, sizeof(format) );
|
|
||||||
}
|
|
||||||
else if ( !strcmp( name, "monitor" ) )
|
|
||||||
monitor_id = atoi( value );
|
|
||||||
else if ( !strcmp( name, "time" ) )
|
|
||||||
event_time = atoi( value );
|
|
||||||
else if ( !strcmp( name, "event" ) )
|
|
||||||
event_id = strtoull( value, (char **)NULL, 10 );
|
|
||||||
else if ( !strcmp( name, "frame" ) )
|
|
||||||
frame_id = strtoull( value, (char **)NULL, 10 );
|
|
||||||
else if ( !strcmp( name, "scale" ) )
|
|
||||||
scale = atoi( value );
|
|
||||||
else if ( !strcmp( name, "rate" ) )
|
|
||||||
rate = atoi( value );
|
|
||||||
else if ( !strcmp( name, "maxfps" ) )
|
|
||||||
maxfps = atof( value );
|
|
||||||
else if ( !strcmp( name, "bitrate" ) )
|
|
||||||
bitrate = atoi( value );
|
|
||||||
else if ( !strcmp( name, "ttl" ) )
|
|
||||||
ttl = atoi(value);
|
|
||||||
else if ( !strcmp( name, "replay" ) )
|
|
||||||
{
|
|
||||||
replay = !strcmp( value, "gapless" )?StreamBase::ALL_GAPLESS:StreamBase::SINGLE;
|
|
||||||
replay = !strcmp( value, "all" )?StreamBase::ALL:replay;
|
|
||||||
}
|
|
||||||
else if ( !strcmp( name, "connkey" ) )
|
|
||||||
connkey = atoi(value);
|
|
||||||
else if ( !strcmp( name, "buffer" ) )
|
|
||||||
playback_buffer = atoi(value);
|
|
||||||
else if ( config.opt_use_auth )
|
|
||||||
{
|
|
||||||
if ( strcmp( config.auth_relay, "none" ) == 0 )
|
|
||||||
{
|
|
||||||
if ( !strcmp( name, "user" ) )
|
|
||||||
{
|
|
||||||
strncpy( username, value, sizeof(username) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//if ( strcmp( config.auth_relay, "hashed" ) == 0 )
|
|
||||||
{
|
|
||||||
if ( !strcmp( name, "auth" ) )
|
|
||||||
{
|
|
||||||
strncpy( auth, value, sizeof(auth) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//else if ( strcmp( config.auth_relay, "plain" ) == 0 )
|
|
||||||
{
|
|
||||||
if ( !strcmp( name, "user" ) )
|
|
||||||
{
|
|
||||||
strncpy( username, value, sizeof(username) );
|
|
||||||
}
|
|
||||||
if ( !strcmp( name, "pass" ) )
|
|
||||||
{
|
|
||||||
strncpy( password, value, sizeof(password) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( config.opt_use_auth )
|
zmSetDefaultTermHandler();
|
||||||
{
|
zmSetDefaultDieHandler();
|
||||||
User *user = 0;
|
|
||||||
|
|
||||||
if ( strcmp( config.auth_relay, "none" ) == 0 )
|
const char *query = getenv( "QUERY_STRING" );
|
||||||
{
|
if ( query )
|
||||||
if ( *username )
|
{
|
||||||
{
|
Debug( 1, "Query: %s", query );
|
||||||
user = zmLoadUser( username );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//if ( strcmp( config.auth_relay, "hashed" ) == 0 )
|
|
||||||
{
|
|
||||||
if ( *auth )
|
|
||||||
{
|
|
||||||
user = zmLoadAuthUser( auth, config.auth_hash_ips );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//else if ( strcmp( config.auth_relay, "plain" ) == 0 )
|
|
||||||
{
|
|
||||||
if ( *username && *password )
|
|
||||||
{
|
|
||||||
user = zmLoadUser( username, password );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( !user )
|
|
||||||
{
|
|
||||||
Error( "Unable to authenticate user" );
|
|
||||||
logTerm();
|
|
||||||
zmDbClose();
|
|
||||||
return( -1 );
|
|
||||||
}
|
|
||||||
ValidateAccess( user, monitor_id );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! mode ) {
|
char temp_query[1024];
|
||||||
if ( source == ZMS_MONITOR ) {
|
strncpy( temp_query, query, sizeof(temp_query) );
|
||||||
mode = StreamBase::STREAM;
|
char *q_ptr = temp_query;
|
||||||
} else {
|
char *parms[16]; // Shouldn't be more than this
|
||||||
// when getting from an event, if a frame_id is specified, then default to single, otherwise stream
|
int parm_no = 0;
|
||||||
if ( frame_id ) {
|
while( (parm_no < 16) && (parms[parm_no] = strtok( q_ptr, "&" )) )
|
||||||
mode = StreamBase::SINGLE;
|
|
||||||
} else {
|
|
||||||
mode = StreamBase::STREAM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setbuf( stdout, 0 );
|
|
||||||
if ( nph )
|
|
||||||
{
|
|
||||||
fprintf( stdout, "HTTP/1.0 200 OK\r\n" );
|
|
||||||
}
|
|
||||||
fprintf( stdout, "Server: ZoneMinder Video Server/%s\r\n", ZM_VERSION );
|
|
||||||
|
|
||||||
time_t now = time( 0 );
|
|
||||||
char date_string[64];
|
|
||||||
strftime( date_string, sizeof(date_string)-1, "%a, %d %b %Y %H:%M:%S GMT", gmtime( &now ) );
|
|
||||||
|
|
||||||
fprintf( stdout, "Expires: Mon, 26 Jul 1997 05:00:00 GMT\r\n" );
|
|
||||||
fprintf( stdout, "Last-Modified: %s\r\n", date_string );
|
|
||||||
fprintf( stdout, "Cache-Control: no-store, no-cache, must-revalidate\r\n" );
|
|
||||||
fprintf( stdout, "Cache-Control: post-check=0, pre-check=0\r\n" );
|
|
||||||
fprintf( stdout, "Pragma: no-cache\r\n");
|
|
||||||
// Removed as causing more problems than it fixed.
|
|
||||||
//if ( !nph )
|
|
||||||
//{
|
|
||||||
//fprintf( stdout, "Content-Length: 0\r\n");
|
|
||||||
//}
|
|
||||||
|
|
||||||
if ( source == ZMS_MONITOR )
|
|
||||||
{
|
|
||||||
MonitorStream stream;
|
|
||||||
stream.setStreamScale( scale );
|
|
||||||
stream.setStreamReplayRate( rate );
|
|
||||||
stream.setStreamMaxFPS( maxfps );
|
|
||||||
stream.setStreamTTL( ttl );
|
|
||||||
stream.setStreamQueue( connkey );
|
|
||||||
stream.setStreamBuffer( playback_buffer );
|
|
||||||
if ( ! stream.setStreamStart( monitor_id ) ) {
|
|
||||||
Error( "Unable to connect to zmc process for monitor %d", monitor_id );
|
|
||||||
fprintf( stderr, "Unable to connect to zmc process. Please ensure that it is running." );
|
|
||||||
logTerm();
|
|
||||||
zmDbClose();
|
|
||||||
return( -1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
stream.setStreamMode( mode );
|
|
||||||
stream.setStreamType( type );
|
|
||||||
|
|
||||||
if ( type == StreamBase::MPEG )
|
|
||||||
{
|
|
||||||
#if HAVE_LIBAVCODEC
|
|
||||||
stream.setStreamFormat( format );
|
|
||||||
stream.setStreamBitrate( bitrate );
|
|
||||||
stream.setStreamType( type );
|
|
||||||
#else // HAVE_LIBAVCODEC
|
|
||||||
Error( "MPEG streaming of '%s' attempted while disabled", query );
|
|
||||||
fprintf( stderr, "MPEG streaming is disabled.\nYou should configure with the --with-ffmpeg option and rebuild to use this functionality.\n" );
|
|
||||||
logTerm();
|
|
||||||
zmDbClose();
|
|
||||||
return( -1 );
|
|
||||||
#endif // HAVE_LIBAVCODEC
|
|
||||||
}
|
|
||||||
stream.runStream();
|
|
||||||
}
|
|
||||||
else if ( source == ZMS_EVENT )
|
|
||||||
{
|
{
|
||||||
EventStream stream;
|
parm_no++;
|
||||||
stream.setStreamScale( scale );
|
q_ptr = NULL;
|
||||||
stream.setStreamReplayRate( rate );
|
|
||||||
stream.setStreamMaxFPS( maxfps );
|
|
||||||
stream.setStreamMode( replay );
|
|
||||||
stream.setStreamQueue( connkey );
|
|
||||||
if ( monitor_id && event_time )
|
|
||||||
{
|
|
||||||
stream.setStreamStart( monitor_id, event_time );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stream.setStreamStart( event_id, frame_id );
|
|
||||||
}
|
|
||||||
stream.setStreamMode( mode );
|
|
||||||
stream.setStreamType( type );
|
|
||||||
if ( type == StreamBase::MPEG )
|
|
||||||
{
|
|
||||||
#if HAVE_LIBAVCODEC
|
|
||||||
stream.setStreamFormat( format );
|
|
||||||
stream.setStreamBitrate( bitrate );
|
|
||||||
#else // HAVE_LIBAVCODEC
|
|
||||||
Error( "MPEG streaming of '%s' attempted while disabled", query );
|
|
||||||
fprintf( stderr, "MPEG streaming is disabled.\nYou should ensure the ffmpeg libraries are installed and detected and rebuild to use this functionality.\n" );
|
|
||||||
logTerm();
|
|
||||||
zmDbClose();
|
|
||||||
return( -1 );
|
|
||||||
#endif // HAVE_LIBAVCODEC
|
|
||||||
}
|
|
||||||
stream.runStream();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logTerm();
|
for ( int p = 0; p < parm_no; p++ )
|
||||||
zmDbClose();
|
{
|
||||||
|
char *name = strtok( parms[p], "=" );
|
||||||
|
char *value = strtok( NULL, "=" );
|
||||||
|
if ( !value )
|
||||||
|
value = (char *)"";
|
||||||
|
if ( !strcmp( name, "source" ) )
|
||||||
|
{
|
||||||
|
source = !strcmp( value, "event" )?ZMS_EVENT:ZMS_MONITOR;
|
||||||
|
}
|
||||||
|
else if ( !strcmp( name, "mode" ) )
|
||||||
|
{
|
||||||
|
if ( !strcmp( value, "single" ) ) {
|
||||||
|
mode = StreamBase::SINGLE;
|
||||||
|
} else if ( !strcmp( value, "stream" ) ) {
|
||||||
|
mode = StreamBase::STREAM;
|
||||||
|
} else if ( !strcmp( value, "jpeg" ) ) {
|
||||||
|
type = StreamBase::JPEG;
|
||||||
|
// code for STREAM/SINGLE comes later.
|
||||||
|
} else if ( !strcmp( value, "raw" ) ) {
|
||||||
|
type = StreamBase::RAW;
|
||||||
|
|
||||||
return( 0 );
|
} else if ( !strcmp( value, "zip" ) ) {
|
||||||
|
type = StreamBase::ZIP;
|
||||||
|
} else {
|
||||||
|
Warning( "Unsupported mode: (%s) defaulting to ", value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( !strcmp( name, "format" ) )
|
||||||
|
if ( !strcmp( value, "jpeg" ) ) {
|
||||||
|
type = StreamBase::JPEG;
|
||||||
|
} else if ( !strcmp( value, "raw" ) ) {
|
||||||
|
type = StreamBase::RAW;
|
||||||
|
} else if ( !strcmp( value, "zip" ) ) {
|
||||||
|
type = StreamBase::ZIP;
|
||||||
|
} else if ( !strcmp( value, "mpeg" ) ) {
|
||||||
|
type = StreamBase::MPEG;
|
||||||
|
strncpy( format, value, sizeof(format) );
|
||||||
|
} else {
|
||||||
|
Warning( "Unsupported format: (%s) defaulting to ", value );
|
||||||
|
strncpy( format, value, sizeof(format) );
|
||||||
|
}
|
||||||
|
else if ( !strcmp( name, "monitor" ) )
|
||||||
|
monitor_id = atoi( value );
|
||||||
|
else if ( !strcmp( name, "time" ) )
|
||||||
|
event_time = atoi( value );
|
||||||
|
else if ( !strcmp( name, "event" ) )
|
||||||
|
event_id = strtoull( value, (char **)NULL, 10 );
|
||||||
|
else if ( !strcmp( name, "frame" ) )
|
||||||
|
frame_id = strtoull( value, (char **)NULL, 10 );
|
||||||
|
else if ( !strcmp( name, "scale" ) )
|
||||||
|
scale = atoi( value );
|
||||||
|
else if ( !strcmp( name, "rate" ) )
|
||||||
|
rate = atoi( value );
|
||||||
|
else if ( !strcmp( name, "maxfps" ) )
|
||||||
|
maxfps = atof( value );
|
||||||
|
else if ( !strcmp( name, "bitrate" ) )
|
||||||
|
bitrate = atoi( value );
|
||||||
|
else if ( !strcmp( name, "ttl" ) )
|
||||||
|
ttl = atoi(value);
|
||||||
|
else if ( !strcmp( name, "replay" ) )
|
||||||
|
{
|
||||||
|
replay = !strcmp( value, "gapless" )?StreamBase::ALL_GAPLESS:StreamBase::SINGLE;
|
||||||
|
replay = !strcmp( value, "all" )?StreamBase::ALL:replay;
|
||||||
|
}
|
||||||
|
else if ( !strcmp( name, "connkey" ) )
|
||||||
|
connkey = atoi(value);
|
||||||
|
else if ( !strcmp( name, "buffer" ) )
|
||||||
|
playback_buffer = atoi(value);
|
||||||
|
else if ( config.opt_use_auth )
|
||||||
|
{
|
||||||
|
if ( strcmp( config.auth_relay, "none" ) == 0 )
|
||||||
|
{
|
||||||
|
if ( !strcmp( name, "user" ) )
|
||||||
|
{
|
||||||
|
strncpy( username, value, sizeof(username) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//if ( strcmp( config.auth_relay, "hashed" ) == 0 )
|
||||||
|
{
|
||||||
|
if ( !strcmp( name, "auth" ) )
|
||||||
|
{
|
||||||
|
strncpy( auth, value, sizeof(auth) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//else if ( strcmp( config.auth_relay, "plain" ) == 0 )
|
||||||
|
{
|
||||||
|
if ( !strcmp( name, "user" ) )
|
||||||
|
{
|
||||||
|
strncpy( username, value, sizeof(username) );
|
||||||
|
}
|
||||||
|
if ( !strcmp( name, "pass" ) )
|
||||||
|
{
|
||||||
|
strncpy( password, value, sizeof(password) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( config.opt_use_auth )
|
||||||
|
{
|
||||||
|
User *user = 0;
|
||||||
|
|
||||||
|
if ( strcmp( config.auth_relay, "none" ) == 0 )
|
||||||
|
{
|
||||||
|
if ( *username )
|
||||||
|
{
|
||||||
|
user = zmLoadUser( username );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//if ( strcmp( config.auth_relay, "hashed" ) == 0 )
|
||||||
|
{
|
||||||
|
if ( *auth )
|
||||||
|
{
|
||||||
|
user = zmLoadAuthUser( auth, config.auth_hash_ips );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//else if ( strcmp( config.auth_relay, "plain" ) == 0 )
|
||||||
|
{
|
||||||
|
if ( *username && *password )
|
||||||
|
{
|
||||||
|
user = zmLoadUser( username, password );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !user )
|
||||||
|
{
|
||||||
|
Error( "Unable to authenticate user" );
|
||||||
|
logTerm();
|
||||||
|
zmDbClose();
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
ValidateAccess( user, monitor_id );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! mode ) {
|
||||||
|
if ( source == ZMS_MONITOR ) {
|
||||||
|
mode = StreamBase::STREAM;
|
||||||
|
} else {
|
||||||
|
// when getting from an event, if a frame_id is specified, then default to single, otherwise stream
|
||||||
|
if ( frame_id ) {
|
||||||
|
mode = StreamBase::SINGLE;
|
||||||
|
} else {
|
||||||
|
mode = StreamBase::STREAM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setbuf( stdout, 0 );
|
||||||
|
if ( nph )
|
||||||
|
{
|
||||||
|
fprintf( stdout, "HTTP/1.0 200 OK\r\n" );
|
||||||
|
}
|
||||||
|
fprintf( stdout, "Server: ZoneMinder Video Server/%s\r\n", ZM_VERSION );
|
||||||
|
|
||||||
|
time_t now = time( 0 );
|
||||||
|
char date_string[64];
|
||||||
|
strftime( date_string, sizeof(date_string)-1, "%a, %d %b %Y %H:%M:%S GMT", gmtime( &now ) );
|
||||||
|
|
||||||
|
fprintf( stdout, "Expires: Mon, 26 Jul 1997 05:00:00 GMT\r\n" );
|
||||||
|
fprintf( stdout, "Last-Modified: %s\r\n", date_string );
|
||||||
|
fprintf( stdout, "Cache-Control: no-store, no-cache, must-revalidate\r\n" );
|
||||||
|
fprintf( stdout, "Cache-Control: post-check=0, pre-check=0\r\n" );
|
||||||
|
fprintf( stdout, "Pragma: no-cache\r\n");
|
||||||
|
// Removed as causing more problems than it fixed.
|
||||||
|
//if ( !nph )
|
||||||
|
//{
|
||||||
|
//fprintf( stdout, "Content-Length: 0\r\n");
|
||||||
|
//}
|
||||||
|
|
||||||
|
if ( source == ZMS_MONITOR )
|
||||||
|
{
|
||||||
|
MonitorStream stream;
|
||||||
|
stream.setStreamScale( scale );
|
||||||
|
stream.setStreamReplayRate( rate );
|
||||||
|
stream.setStreamMaxFPS( maxfps );
|
||||||
|
stream.setStreamTTL( ttl );
|
||||||
|
stream.setStreamQueue( connkey );
|
||||||
|
stream.setStreamBuffer( playback_buffer );
|
||||||
|
if ( ! stream.setStreamStart( monitor_id ) ) {
|
||||||
|
Error( "Unable to connect to zmc process for monitor %d", monitor_id );
|
||||||
|
fprintf( stderr, "Unable to connect to zmc process. Please ensure that it is running." );
|
||||||
|
logTerm();
|
||||||
|
zmDbClose();
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.setStreamMode( mode );
|
||||||
|
stream.setStreamType( type );
|
||||||
|
|
||||||
|
if ( type == StreamBase::MPEG )
|
||||||
|
{
|
||||||
|
#if HAVE_LIBAVCODEC
|
||||||
|
stream.setStreamFormat( format );
|
||||||
|
stream.setStreamBitrate( bitrate );
|
||||||
|
stream.setStreamType( type );
|
||||||
|
#else // HAVE_LIBAVCODEC
|
||||||
|
Error( "MPEG streaming of '%s' attempted while disabled", query );
|
||||||
|
fprintf( stderr, "MPEG streaming is disabled.\nYou should configure with the --with-ffmpeg option and rebuild to use this functionality.\n" );
|
||||||
|
logTerm();
|
||||||
|
zmDbClose();
|
||||||
|
return( -1 );
|
||||||
|
#endif // HAVE_LIBAVCODEC
|
||||||
|
}
|
||||||
|
stream.runStream();
|
||||||
|
}
|
||||||
|
else if ( source == ZMS_EVENT )
|
||||||
|
{
|
||||||
|
EventStream stream;
|
||||||
|
stream.setStreamScale( scale );
|
||||||
|
stream.setStreamReplayRate( rate );
|
||||||
|
stream.setStreamMaxFPS( maxfps );
|
||||||
|
stream.setStreamMode( replay );
|
||||||
|
stream.setStreamQueue( connkey );
|
||||||
|
if ( monitor_id && event_time )
|
||||||
|
{
|
||||||
|
stream.setStreamStart( monitor_id, event_time );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stream.setStreamStart( event_id, frame_id );
|
||||||
|
}
|
||||||
|
stream.setStreamMode( mode );
|
||||||
|
stream.setStreamType( type );
|
||||||
|
if ( type == StreamBase::MPEG )
|
||||||
|
{
|
||||||
|
#if HAVE_LIBAVCODEC
|
||||||
|
stream.setStreamFormat( format );
|
||||||
|
stream.setStreamBitrate( bitrate );
|
||||||
|
#else // HAVE_LIBAVCODEC
|
||||||
|
Error( "MPEG streaming of '%s' attempted while disabled", query );
|
||||||
|
fprintf( stderr, "MPEG streaming is disabled.\nYou should ensure the ffmpeg libraries are installed and detected and rebuild to use this functionality.\n" );
|
||||||
|
logTerm();
|
||||||
|
zmDbClose();
|
||||||
|
return( -1 );
|
||||||
|
#endif // HAVE_LIBAVCODEC
|
||||||
|
}
|
||||||
|
stream.runStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
logTerm();
|
||||||
|
zmDbClose();
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,34 +21,34 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
zmstreamer - eyeZM video streamer
|
zmstreamer - eyeZM video streamer
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
zmstreamer -e <mode>
|
zmstreamer -e <mode>
|
||||||
zmstreamer -o <format>
|
zmstreamer -o <format>
|
||||||
zmstreamer -u <buffer size>
|
zmstreamer -u <buffer size>
|
||||||
zmstreamer -f <maximum fps>
|
zmstreamer -f <maximum fps>
|
||||||
zmstreamer -s <scale>
|
zmstreamer -s <scale>
|
||||||
zmstreamer -b <bitrate in bps>
|
zmstreamer -b <bitrate in bps>
|
||||||
zmstreamer -m <monitor id>
|
zmstreamer -m <monitor id>
|
||||||
zmstreamer -d <debug mode>
|
zmstreamer -d <debug mode>
|
||||||
zmstreamer -i
|
zmstreamer -i
|
||||||
zmstreamer -?
|
zmstreamer -?
|
||||||
zmstreamer -h
|
zmstreamer -h
|
||||||
zmstreamer -v
|
zmstreamer -v
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
*DEPRECIATED* The xml skin and all files associated with the xml skin are now
|
*DEPRECIATED* The xml skin and all files associated with the xml skin are now
|
||||||
depreciated. Please use the ZoneMinder API instead.
|
depreciated. Please use the ZoneMinder API instead.
|
||||||
|
|
||||||
This binary works in conjunction with the XML skin to stream video to iPhones
|
This binary works in conjunction with the XML skin to stream video to iPhones
|
||||||
running the eyeZm app.
|
running the eyeZm app.
|
||||||
|
|
||||||
=head1 OPTIONS
|
=head1 OPTIONS
|
||||||
|
|
||||||
-e <mode> - Specify output mode: mpeg/jpg/zip/single/raw.
|
-e <mode> - Specify output mode: mpeg/jpg/zip/single/raw.
|
||||||
-o <format> - Specify output format.
|
-o <format> - Specify output format.
|
||||||
|
@ -61,9 +61,9 @@ running the eyeZm app.
|
||||||
-i, -?, -h - Display usage information
|
-i, -?, -h - Display usage information
|
||||||
-v - Print the installed version of ZoneMinder
|
-v - Print the installed version of ZoneMinder
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -92,165 +92,165 @@ running the eyeZm app.
|
||||||
#define ZMS_DEFAULT_BUFFER 1000
|
#define ZMS_DEFAULT_BUFFER 1000
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
self = argv[0];
|
self = argv[0];
|
||||||
// Set initial values to the default values
|
// Set initial values to the default values
|
||||||
int debug = ZMS_DEFAULT_DEBUG;
|
int debug = ZMS_DEFAULT_DEBUG;
|
||||||
int id = ZMS_DEFAULT_ID;
|
int id = ZMS_DEFAULT_ID;
|
||||||
int bitrate = ZMS_DEFAULT_BITRATE;
|
int bitrate = ZMS_DEFAULT_BITRATE;
|
||||||
int scale = ZMS_DEFAULT_SCALE;
|
int scale = ZMS_DEFAULT_SCALE;
|
||||||
char mode[32];
|
char mode[32];
|
||||||
sprintf(mode, "%s", ZMS_DEFAULT_MODE);
|
sprintf(mode, "%s", ZMS_DEFAULT_MODE);
|
||||||
char format[32];
|
char format[32];
|
||||||
sprintf(format, "%s", ZMS_DEFAULT_FORMAT);
|
sprintf(format, "%s", ZMS_DEFAULT_FORMAT);
|
||||||
double maxfps = ZMS_DEFAULT_FPS;
|
double maxfps = ZMS_DEFAULT_FPS;
|
||||||
int buffer = ZMS_DEFAULT_BUFFER;
|
int buffer = ZMS_DEFAULT_BUFFER;
|
||||||
|
|
||||||
// Parse command-line options
|
// Parse command-line options
|
||||||
int arg;
|
int arg;
|
||||||
while ((arg = getopt(argc, argv, OPTIONS)) != -1) {
|
while ((arg = getopt(argc, argv, OPTIONS)) != -1) {
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case 'e':
|
case 'e':
|
||||||
sprintf(mode, "%s", optarg);
|
sprintf(mode, "%s", optarg);
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
sprintf(format, "%s", optarg);
|
sprintf(format, "%s", optarg);
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
buffer = atoi(optarg);
|
buffer = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
maxfps = atof(optarg);
|
maxfps = atof(optarg);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
scale = atoi(optarg);
|
scale = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
bitrate = atoi(optarg);
|
bitrate = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
id = atoi(optarg);
|
id = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
debug = atoi(optarg);
|
debug = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
case 'i':
|
case 'i':
|
||||||
case '?':
|
case '?':
|
||||||
printf("-e <mode> : Specify output mode: mpeg/jpg/zip/single/raw. Default = %s\n", ZMS_DEFAULT_MODE);
|
printf("-e <mode> : Specify output mode: mpeg/jpg/zip/single/raw. Default = %s\n", ZMS_DEFAULT_MODE);
|
||||||
printf("-o <format> : Specify output format. Default = %s\n", ZMS_DEFAULT_FORMAT);
|
printf("-o <format> : Specify output format. Default = %s\n", ZMS_DEFAULT_FORMAT);
|
||||||
printf("-u <buffer size> : Specify buffer size in ms. Default = %d\n", ZMS_DEFAULT_BUFFER);
|
printf("-u <buffer size> : Specify buffer size in ms. Default = %d\n", ZMS_DEFAULT_BUFFER);
|
||||||
printf("-f <maximum fps> : Specify maximum framerate. Default = %lf\n", ZMS_DEFAULT_FPS);
|
printf("-f <maximum fps> : Specify maximum framerate. Default = %lf\n", ZMS_DEFAULT_FPS);
|
||||||
printf("-s <scale> : Specify scale. Default = %d\n", ZMS_DEFAULT_SCALE);
|
printf("-s <scale> : Specify scale. Default = %d\n", ZMS_DEFAULT_SCALE);
|
||||||
printf("-b <bitrate in bps> : Specify bitrate. Default = %d\n", ZMS_DEFAULT_BITRATE);
|
printf("-b <bitrate in bps> : Specify bitrate. Default = %d\n", ZMS_DEFAULT_BITRATE);
|
||||||
printf("-m <monitor id> : Specify monitor id. Default = %d\n", ZMS_DEFAULT_ID);
|
printf("-m <monitor id> : Specify monitor id. Default = %d\n", ZMS_DEFAULT_ID);
|
||||||
printf("-d <debug mode> : 0 = off, 1 = no streaming, 2 = with streaming. Default = 0\n");
|
printf("-d <debug mode> : 0 = off, 1 = no streaming, 2 = with streaming. Default = 0\n");
|
||||||
printf("-i or -? or -h: This information\n");
|
printf("-i or -? or -h: This information\n");
|
||||||
printf("-v : This installed version of ZoneMinder\n");
|
printf("-v : This installed version of ZoneMinder\n");
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
case 'v':
|
case 'v':
|
||||||
std::cout << ZM_VERSION << "\n";
|
std::cout << ZM_VERSION << "\n";
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set stream type
|
// Set stream type
|
||||||
StreamBase::StreamType streamtype;
|
StreamBase::StreamType streamtype;
|
||||||
StreamBase::StreamMode streammode = StreamBase::STREAM;
|
StreamBase::StreamMode streammode = StreamBase::STREAM;
|
||||||
|
|
||||||
if (!strcasecmp("raw", mode))
|
if (!strcasecmp("raw", mode))
|
||||||
streamtype = StreamBase::RAW;
|
streamtype = StreamBase::RAW;
|
||||||
else if (!strcasecmp("mpeg", mode))
|
else if (!strcasecmp("mpeg", mode))
|
||||||
streamtype = StreamBase::MPEG;
|
streamtype = StreamBase::MPEG;
|
||||||
else if (!strcasecmp("jpg", mode))
|
else if (!strcasecmp("jpg", mode))
|
||||||
streamtype = StreamBase::JPEG;
|
streamtype = StreamBase::JPEG;
|
||||||
else if (!strcasecmp("single", mode))
|
else if (!strcasecmp("single", mode))
|
||||||
streammode = StreamBase::SINGLE;
|
streammode = StreamBase::SINGLE;
|
||||||
else if (!strcasecmp("zip", mode))
|
else if (!strcasecmp("zip", mode))
|
||||||
streamtype = StreamBase::ZIP;
|
streamtype = StreamBase::ZIP;
|
||||||
else if (!strcasecmp("mpeg", mode))
|
else if (!strcasecmp("mpeg", mode))
|
||||||
streamtype = StreamBase::MPEG;
|
streamtype = StreamBase::MPEG;
|
||||||
else
|
else
|
||||||
streamtype = StreamBase::MPEG;
|
streamtype = StreamBase::MPEG;
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
// Show stream parameters
|
// Show stream parameters
|
||||||
printf("Stream parameters:\n");
|
printf("Stream parameters:\n");
|
||||||
switch (streamtype) {
|
switch (streamtype) {
|
||||||
case StreamBase::MPEG:
|
case StreamBase::MPEG:
|
||||||
printf("Output mode (-e) = %s\n", "mpeg");
|
printf("Output mode (-e) = %s\n", "mpeg");
|
||||||
printf("Output format (-o) = %s\n", format);
|
printf("Output format (-o) = %s\n", format);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("Output mode (-e) = %s\n", mode);
|
printf("Output mode (-e) = %s\n", mode);
|
||||||
}
|
|
||||||
printf("Buffer size (-u) = %d ms\n", buffer);
|
|
||||||
printf("Maximum FPS (-f) = %lf FPS\n", maxfps);
|
|
||||||
printf("Scale (-s) = %d%%\n", scale);
|
|
||||||
printf("Bitrate (-b) = %d bps\n", bitrate);
|
|
||||||
printf("Monitor Id (-m) = %d\n", id);
|
|
||||||
}
|
}
|
||||||
|
printf("Buffer size (-u) = %d ms\n", buffer);
|
||||||
|
printf("Maximum FPS (-f) = %lf FPS\n", maxfps);
|
||||||
|
printf("Scale (-s) = %d%%\n", scale);
|
||||||
|
printf("Bitrate (-b) = %d bps\n", bitrate);
|
||||||
|
printf("Monitor Id (-m) = %d\n", id);
|
||||||
|
}
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
// Set ZM debugger to print to stdout
|
// Set ZM debugger to print to stdout
|
||||||
printf("Setting up ZoneMinder debugger to print to stdout...");
|
printf("Setting up ZoneMinder debugger to print to stdout...");
|
||||||
setenv("ZM_DBG_PRINT", "1", 1);
|
setenv("ZM_DBG_PRINT", "1", 1);
|
||||||
printf("Done.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loading ZM configurations
|
|
||||||
printf("Loading ZoneMinder configurations...");
|
|
||||||
zmLoadConfig();
|
|
||||||
printf("Done.\n");
|
printf("Done.\n");
|
||||||
|
}
|
||||||
|
|
||||||
logInit("zmstreamer");
|
// Loading ZM configurations
|
||||||
|
printf("Loading ZoneMinder configurations...");
|
||||||
ssedetect();
|
zmLoadConfig();
|
||||||
|
printf("Done.\n");
|
||||||
|
|
||||||
// Setting stream parameters
|
logInit("zmstreamer");
|
||||||
MonitorStream stream;
|
|
||||||
stream.setStreamScale(scale); // default = 100 (scale)
|
ssedetect();
|
||||||
stream.setStreamReplayRate(100); // default = 100 (rate)
|
|
||||||
stream.setStreamMaxFPS(maxfps); // default = 10 (maxfps)
|
// Setting stream parameters
|
||||||
if (debug) stream.setStreamTTL(1);
|
MonitorStream stream;
|
||||||
else stream.setStreamTTL(0); // default = 0 (ttl)
|
stream.setStreamScale(scale); // default = 100 (scale)
|
||||||
stream.setStreamQueue(0); // default = 0 (connkey)
|
stream.setStreamReplayRate(100); // default = 100 (rate)
|
||||||
stream.setStreamBuffer(buffer); // default = 0 (buffer)
|
stream.setStreamMaxFPS(maxfps); // default = 10 (maxfps)
|
||||||
stream.setStreamStart(id); // default = 0 (monitor_id)
|
if (debug) stream.setStreamTTL(1);
|
||||||
stream.setStreamType(streamtype);
|
else stream.setStreamTTL(0); // default = 0 (ttl)
|
||||||
if (streamtype == StreamBase::MPEG) {
|
stream.setStreamQueue(0); // default = 0 (connkey)
|
||||||
|
stream.setStreamBuffer(buffer); // default = 0 (buffer)
|
||||||
|
stream.setStreamStart(id); // default = 0 (monitor_id)
|
||||||
|
stream.setStreamType(streamtype);
|
||||||
|
if (streamtype == StreamBase::MPEG) {
|
||||||
#if HAVE_LIBAVCODEC
|
#if HAVE_LIBAVCODEC
|
||||||
if (debug) printf("HAVE_LIBAVCODEC is set\n");
|
if (debug) printf("HAVE_LIBAVCODEC is set\n");
|
||||||
stream.setStreamFormat(format); // default = "" (format)
|
stream.setStreamFormat(format); // default = "" (format)
|
||||||
stream.setStreamBitrate(bitrate); // default = 100000 (bitrate)
|
stream.setStreamBitrate(bitrate); // default = 100000 (bitrate)
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, "MPEG streaming is disabled.\nYou should configure with the --with-ffmpeg option and rebuild to use this functionality.\n");
|
fprintf(stderr, "MPEG streaming is disabled.\nYou should configure with the --with-ffmpeg option and rebuild to use this functionality.\n");
|
||||||
logTerm();
|
|
||||||
zmDbClose();
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debug != 1) {
|
|
||||||
if (debug) printf("Running stream...");
|
|
||||||
|
|
||||||
// Output headers
|
|
||||||
fprintf(stdout, "Server: ZoneMinder Video Server/%s\r\n", ZM_VERSION);
|
|
||||||
time_t now = time(0);
|
|
||||||
char date_string[64];
|
|
||||||
strftime(date_string, sizeof (date_string) - 1, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&now));
|
|
||||||
fprintf(stdout, "Expires: Mon, 26 Jul 1997 05:00:00 GMT\r\n");
|
|
||||||
fprintf(stdout, "Last-Modified: %s\r\n", date_string);
|
|
||||||
fprintf(stdout, "Cache-Control: no-store, no-cache, must-revalidate\r\n");
|
|
||||||
fprintf(stdout, "Cache-Control: post-check=0, pre-check=0\r\n");
|
|
||||||
fprintf(stdout, "Pragma: no-cache\r\n");
|
|
||||||
|
|
||||||
// Run stream
|
|
||||||
stream.runStream();
|
|
||||||
}
|
|
||||||
if (debug) printf("Done.\n");
|
|
||||||
|
|
||||||
logTerm();
|
logTerm();
|
||||||
zmDbClose();
|
zmDbClose();
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
return (EXIT_SUCCESS);
|
if (debug != 1) {
|
||||||
|
if (debug) printf("Running stream...");
|
||||||
|
|
||||||
|
// Output headers
|
||||||
|
fprintf(stdout, "Server: ZoneMinder Video Server/%s\r\n", ZM_VERSION);
|
||||||
|
time_t now = time(0);
|
||||||
|
char date_string[64];
|
||||||
|
strftime(date_string, sizeof (date_string) - 1, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&now));
|
||||||
|
fprintf(stdout, "Expires: Mon, 26 Jul 1997 05:00:00 GMT\r\n");
|
||||||
|
fprintf(stdout, "Last-Modified: %s\r\n", date_string);
|
||||||
|
fprintf(stdout, "Cache-Control: no-store, no-cache, must-revalidate\r\n");
|
||||||
|
fprintf(stdout, "Cache-Control: post-check=0, pre-check=0\r\n");
|
||||||
|
fprintf(stdout, "Pragma: no-cache\r\n");
|
||||||
|
|
||||||
|
// Run stream
|
||||||
|
stream.runStream();
|
||||||
|
}
|
||||||
|
if (debug) printf("Done.\n");
|
||||||
|
|
||||||
|
logTerm();
|
||||||
|
zmDbClose();
|
||||||
|
|
||||||
|
return (EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue