Exemplo n.º 1
0
CStdString MythProgramInfo::ProgramID()
{
    char* progId = cmyth_proginfo_programid(*m_proginfo_t);
    CStdString retval(progId);
    ref_release(progId);
    return retval;
}
Exemplo n.º 2
0
void
cmyth_recordingrule_set_subtitle(cmyth_recordingrule_t rr, char *subtitle)
{
	if (rr->subtitle)
		ref_release(rr->subtitle);
	rr->subtitle = ref_strdup(subtitle);
}
Exemplo n.º 3
0
void
cmyth_recordingrule_set_storagegroup(cmyth_recordingrule_t rr, char *storagegroup)
{
	if (rr->storagegroup)
		ref_release(rr->storagegroup);
	rr->storagegroup = ref_strdup(storagegroup);
}
Exemplo n.º 4
0
void
cmyth_recordingrule_set_starttime(cmyth_recordingrule_t rr, time_t starttime)
{
	if (rr->starttime)
		ref_release(rr->starttime);
	rr->starttime = cmyth_timestamp_from_unixtime(starttime);
}
Exemplo n.º 5
0
void
cmyth_recordingrule_set_description(cmyth_recordingrule_t rr, char *description)
{
	if (rr->description)
		ref_release(rr->description);
	rr->description = ref_strdup(description);
}
Exemplo n.º 6
0
CStdString MythRecordingRule::Callsign() const
{
  char *buf = cmyth_recordingrule_callsign(*m_recordingrule_t);
  CStdString retval(buf);
  ref_release(buf);
  return retval;
}
Exemplo n.º 7
0
void run(char *conf_file) {
  struct running rr;
  struct event *sig1_ev,*sig2_ev,*sig_hup;

  evthread_use_pthreads();
  setup_running(&rr);
  register_interface_types(&rr);
  register_source_types(&rr);
  run_config(&rr,conf_file);
  start_stats_timer(&rr);
  
  ref_release(&(rr.ic_running));

  event_add(sq_consumer(rr.sq),0);
  event_add(si_consumer(rr.si),0);
  sq_release(rr.sq);
  evsignal_add(sig1_ev=evsignal_new(rr.eb,SIGINT,user_quit,&rr),0);
  evsignal_add(sig2_ev=evsignal_new(rr.eb,SIGTERM,user_quit,&rr),0);
  evsignal_add(sig_hup=evsignal_new(rr.eb,SIGHUP,hupev,&rr),0);
  rr.sigkill_timer = event_new(rr.eb,-1,EV_PERSIST,sigkill_self,&rr);
  log_info(("Starting event loop"));
  event_base_loop(rr.eb,0);
  log_info(("Event loop finished"));
  event_del(sig1_ev);
  event_del(sig2_ev);
  event_del(sig_hup);
  event_free(sig1_ev);
  event_free(sig2_ev);
  event_free(sig_hup);
  closedown(&rr);
  log_info(("Bye!"));
  config_finished();
}
Exemplo n.º 8
0
/**
 * Allocate a dynamic query string to have parameters added to it
 * \param db database connection object
 * \param query_string Query string with ? placemarks for all dynamic
 * 			parameters, this is NOT copied and must therefore
 * 			remain valid for the life of the query.
 */
cmyth_mysql_query_t * 
cmyth_mysql_query_create(cmyth_database_t db, const char * query_string)
{
    cmyth_mysql_query_t * out;
    out = ref_alloc(sizeof(*out));
    if(out != NULL)
    {
	ref_set_destroy(out,query_destroy);
	out->source = out->source_pos = query_string;
	out->source_len = strlen(out->source);
	out->buf_size = out->source_len *2;
	out->buf_used = 0;
	out->db = ref_hold(db);
	out->buf = ref_alloc(out->buf_size);
	if(out->buf == NULL)
	{
	    ref_release(out);
	    out = NULL;
	}
	else
	{
	    out->buf[0] = '\0';
	}

    }
    return out;
}
Exemplo n.º 9
0
void
cmyth_recordingrule_set_profile(cmyth_recordingrule_t rr, char *profile)
{
	if (rr->profile)
		ref_release(rr->profile);
	rr->profile = ref_strdup(profile);
}
Exemplo n.º 10
0
MYSQL_RES *
cmyth_mysql_query_result(cmyth_mysql_query_t * query)
{
    MYSQL_RES * retval = NULL;
    int ret;
    char * query_str;
    MYSQL *mysql = cmyth_db_get_connection(query->db);
    if(mysql == NULL)
	return NULL;
    query_str = cmyth_mysql_query_string(query);
    if(query_str == NULL)
	return NULL;
    ret = mysql_query(mysql,query_str);
    ref_release(query_str);
    if(ret != 0)
    {
	 cmyth_dbg(CMYTH_DBG_ERROR, "%s: mysql_query(%s) Failed: %s\n",
				__FUNCTION__, query_str, mysql_error(mysql));
	 return NULL;
    }
    retval = mysql_store_result(mysql);
    if(retval == NULL)
    {
	 cmyth_dbg(CMYTH_DBG_ERROR, "%s: mysql_use_result Failed: %s\n",
				__FUNCTION__, query_str, mysql_error(mysql));
    }
    return retval;
}
Exemplo n.º 11
0
/**
 * Internal only! Registered as callback to de-allocate actual buffer if
 * the query is de-allocated
 * \param p pointer to the query data structure
 */
static void
query_destroy(void *p)
{
    cmyth_mysql_query_t * query = (cmyth_mysql_query_t *)p;
    if(query->buf != NULL)
    {
	ref_release(query->buf);
	query->buf = NULL;
	query->buf_size = 0;
    }
    if(query->db != NULL)
    {
	ref_release(query->db);
	query->db = NULL;
    }
}
Exemplo n.º 12
0
static int
get_event(char *host)
{
	struct timeval tv;
	cmyth_conn_t event;

	if ((event=cmyth_conn_connect_event(host, 6543,
					    16*1024, 4096)) == NULL) {
		return -1;
	}

	tv.tv_sec = 1;
	tv.tv_usec = 0;

	if (cmyth_event_select(event, &tv) > 0) {
		cmyth_event_t e;
		char data[128];

		memset(data, 0, sizeof(data));

		e = cmyth_event_get(event, data, sizeof(data));

		printf("Event: %d '%s'\n", e, data);
	}

	ref_release(event);

	return 0;
}
Exemplo n.º 13
0
CStdString MythProgramInfo::Path()
{
    char* path = cmyth_proginfo_pathname(*m_proginfo_t);
    CStdString retval(path);
    ref_release(path);
    return retval;
}
Exemplo n.º 14
0
CStdString MythProgramInfo::Subtitle()
{
    char* subtitle = cmyth_proginfo_subtitle(*m_proginfo_t);
    CStdString retval(subtitle);
    ref_release(subtitle);
    return retval;
}
Exemplo n.º 15
0
CStdString  MythRecordingRule::StorageGroup() const
{
  char *buf = cmyth_recordingrule_storagegroup(*m_recordingrule_t);
  CStdString retval(buf);
  ref_release(buf);
  return retval;
}
Exemplo n.º 16
0
void
cmyth_recordingrule_set_programid(cmyth_recordingrule_t rr, char *programid)
{
	if (rr->programid)
		ref_release(rr->programid);
	rr->programid = ref_strdup(programid);
}
Exemplo n.º 17
0
CStdString  MythRecordingRule::PlaybackGroup() const
{
  char *buf = cmyth_recordingrule_playgroup(*m_recordingrule_t);
  CStdString retval(buf);
  ref_release(buf);
  return retval;
}
Exemplo n.º 18
0
void
cmyth_recordingrule_set_seriesid(cmyth_recordingrule_t rr, char *seriesid)
{
	if (rr->seriesid)
		ref_release(rr->seriesid);
	rr->seriesid = ref_strdup(seriesid);
}
Exemplo n.º 19
0
int
cmyth_chain_set_current(cmyth_chain_t chain, cmyth_proginfo_t prog)
{
	unsigned int i;
	int rc = -1;
	void (*callback)(cmyth_proginfo_t prog) = NULL;
	cmyth_proginfo_t cb_prog = NULL;

	if ((chain == NULL) || (prog == NULL)) {
		return -1;
	}

	pthread_mutex_lock(&chain->chain_mutex);

	for (i=0; i<chain->chain_count; i++) {
		if (cmyth_proginfo_compare(prog,
					   chain->chain_list[i]->prog) == 0) {
			chain->chain_current = i;
			callback = chain->chain_callback;
			if (callback) {
				cb_prog = ref_hold(chain->chain_list[i]->prog);
			}
			break;
		}
	}

	pthread_mutex_unlock(&chain->chain_mutex);

	if (callback && cb_prog) {
		callback(cb_prog);
		ref_release(cb_prog);
	}

	return rc;
}
Exemplo n.º 20
0
void
cmyth_recordingrule_set_inetref(cmyth_recordingrule_t rr, char *inetref)
{
	if (rr->inetref)
		ref_release(rr->inetref);
	rr->inetref = ref_strdup(inetref);
}
Exemplo n.º 21
0
void
cmyth_recordingrule_set_callsign(cmyth_recordingrule_t rr, char *callsign)
{
	if (rr->callsign)
		ref_release(rr->callsign);
	rr->callsign = ref_strdup(callsign);
}
Exemplo n.º 22
0
/*
 * cmyth_recorder_get_next_proginfo(cmyth_recorder_t rec,
 *                                  cmyth_proginfo_t current,
 *                                  cmyth_browsedir_t direction)
 *
 * Scope: PUBLIC
 *
 * Description:
 *
 * Request program information from the recorder 'rec' for the next
 * program in the program guide from the current program (i.e. current
 * channel and time slot) in the direction specified by 'direction'
 * which may have any of the following values:
 *
 *     BROWSE_DIRECTION_SAME        - Stay in the same place
 *     BROWSE_DIRECTION_UP          - Move up one slot (down one channel)
 *     BROWSE_DIRECTION_DOWN        - Move down one slot (up one channel)
 *     BROWSE_DIRECTION_LEFT        - Move left one slot (down one time slot)
 *     BROWSE_DIRECTION_RIGHT       - Move right one slot (up one time slot)
 *     BROWSE_DIRECTION_FAVORITE    - Move to the next favorite slot
 *
 * This does not affect the current recording.
 *
 * Return Value:
 *
 * Success: A held non-NULL cmyth_proginfo_t
 * Failure: A NULL pointer
 */
cmyth_proginfo_t
cmyth_recorder_get_next_proginfo(cmyth_recorder_t rec,
				 cmyth_proginfo_t current,
				 cmyth_browsedir_t direction)
{
	cmyth_proginfo_t ret;

        if (!rec || !current) {
                cmyth_dbg(CMYTH_DBG_ERROR, "%s: invalid args "
			  "rec =%p, current = %p\n",
                          __FUNCTION__, rec, current);
                return NULL;
        }
	ret = cmyth_proginfo_create();
	if (ret == NULL) {
		cmyth_dbg(CMYTH_DBG_ERROR,
			  "%s: cmyth_proginfo_create() failed\n",
			  __FUNCTION__);
		return NULL;
	}
	if (cmyth_recorder_get_next_program_info(rec, current,
						 ret, direction) < 0) {
		cmyth_dbg(CMYTH_DBG_ERROR,
			  "%s: cmyth_recorder_get_next_program_info()\n",
			  __FUNCTION__);
		ref_release(ret);
		return NULL;
	}
	return ret;
}
Exemplo n.º 23
0
void
cmyth_recordingrule_set_endtime(cmyth_recordingrule_t rr, time_t endtime)
{
	if (rr->endtime)
		ref_release(rr->endtime);
	rr->endtime = cmyth_timestamp_from_unixtime(endtime);
}
Exemplo n.º 24
0
int
cmyth_conn_connect_recorder(cmyth_recorder_t rec, unsigned buflen,
			    int tcp_rcvbuf)
{
	cmyth_conn_t conn;
	char *server;
	unsigned short port;

	if (!rec) {
		cmyth_dbg(CMYTH_DBG_ERROR, "%s: rec is NULL\n", __FUNCTION__);
		return -1;
	}

	server = rec->rec_server;
	port = rec->rec_port;

	cmyth_dbg(CMYTH_DBG_PROTO, "%s: connecting recorder control\n",
		  __FUNCTION__);
	conn = cmyth_conn_connect_ctrl(server, port, buflen, tcp_rcvbuf);
	cmyth_dbg(CMYTH_DBG_PROTO,
		  "%s: done connecting recorder control, conn = %p\n",
		  __FUNCTION__, conn);
	if (!conn) {
		cmyth_dbg(CMYTH_DBG_ERROR,
			  "%s: cmyth_connect(%s, %d, %d) failed\n",
			  __FUNCTION__, server, port, buflen);
		return -1;
	}

	if (rec->rec_conn)
		ref_release(rec->rec_conn);
	rec->rec_conn = conn;

	return 0;
}
Exemplo n.º 25
0
void
cmyth_recordingrule_set_category(cmyth_recordingrule_t rr, char *category)
{
	if (rr->category)
		ref_release(rr->category);
	rr->category = ref_strdup(category);
}
Exemplo n.º 26
0
CStdString MythRecordingRule::Subtitle() const
{
  char *buf = cmyth_recordingrule_subtitle(*m_recordingrule_t);
  CStdString retval(buf);
  ref_release(buf);
  return retval;
}
Exemplo n.º 27
0
void
cmyth_recordingrule_set_recgroup(cmyth_recordingrule_t rr, char *recgroup)
{
	if (rr->recgroup)
		ref_release(rr->recgroup);
	rr->recgroup = ref_strdup(recgroup);
}
Exemplo n.º 28
0
CStdString MythRecordingRule::Description() const
{
  char *buf = cmyth_recordingrule_description(*m_recordingrule_t);
  CStdString retval(buf);
  ref_release(buf);
  return retval;
}
Exemplo n.º 29
0
void
cmyth_recordingrule_set_playgroup(cmyth_recordingrule_t rr, char *playgroup)
{
	if (rr->playgroup)
		ref_release(rr->playgroup);
	rr->playgroup = ref_strdup(playgroup);
}
Exemplo n.º 30
0
CStdString MythProgramInfo::RecordingGroup()
{
    char* recgroup = cmyth_proginfo_recgroup(*m_proginfo_t);
    CStdString retval(recgroup);
    ref_release(recgroup);
    return retval;
}