コード例 #1
0
ファイル: proginfo.c プロジェクト: Ferdiand/cmyth
/*
 * cmyth_proginfo_compare(cmyth_proginfo_t a, cmyth_proginfo_t b)
 *
 * Scope: PUBLIC
 *
 * Description
 *
 * Compare two program info's and indicate whether they are the same program.
 *
 * Return Value:
 *
 * Same: 0
 *
 * Different: -1
 */
int
cmyth_proginfo_compare(cmyth_proginfo_t a, cmyth_proginfo_t b)
{
	if (a == b)
		return 0;

	if ((a == NULL) || (b == NULL))
		return -1;

#define STRCMP(a, b) ( (a && b && (strcmp(a,b) == 0)) ? 0 : \
		       ((a == NULL) && (b == NULL) ? 0 : -1) )

	if (STRCMP(a->proginfo_title, b->proginfo_title) != 0)
		return -1;
	if (STRCMP(a->proginfo_subtitle, b->proginfo_subtitle) != 0)
		return -1;
	if (STRCMP(a->proginfo_description, b->proginfo_description) != 0)
		return -1;

	if (STRCMP(a->proginfo_url, b->proginfo_url) != 0)
		return -1;

	if (cmyth_timestamp_compare(a->proginfo_start_ts,
				    b->proginfo_start_ts) != 0)
		return -1;
	if (cmyth_timestamp_compare(a->proginfo_end_ts,
				    b->proginfo_end_ts) != 0)
		return -1;

	return 0;
}
コード例 #2
0
ファイル: proginfo.c プロジェクト: EricV/xbmc-pvr-addons
/*
 * cmyth_proginfo_compare()
 *
 * Scope: PUBLIC
 *
 * Description
 *
 * Compare two program info's and indicate whether they are the same program.
 *
 * Return Value:
 *
 * Same: 0
 *
 * Different: -1
 */
int
cmyth_proginfo_compare(cmyth_proginfo_t a, cmyth_proginfo_t b)
{
	if (a == b)
		return 0;

	if ((a == NULL) || (b == NULL))
		return -1;

#define STRCMP(a, b) ( (a && b && (strcmp(a,b) == 0)) ? 0 : \
		       ((a == NULL) && (b == NULL) ? 0 : -1) )

	if (STRCMP(a->proginfo_title, b->proginfo_title) != 0)
		return -1;
	if (STRCMP(a->proginfo_subtitle, b->proginfo_subtitle) != 0)
		return -1;
	if (STRCMP(a->proginfo_description, b->proginfo_description) != 0)
		return -1;
	if (STRCMP(a->proginfo_chanstr, b->proginfo_chanstr) != 0)
		return -1;

	if (a->proginfo_url && b->proginfo_url) {
          char* aa = strrchr(a->proginfo_url, '/');
          char* bb = strrchr(b->proginfo_url, '/');
          if (strcmp(aa ? aa+1 : a->proginfo_url, bb ? bb+1 : b->proginfo_url) != 0)
		return -1;
	} else if(!a->proginfo_url != !b->proginfo_url)
		return -1;

	if (cmyth_timestamp_compare(a->proginfo_start_ts,
				    b->proginfo_start_ts) != 0)
		return -1;
	if (cmyth_timestamp_compare(a->proginfo_end_ts,
				    b->proginfo_end_ts) != 0)
		return -1;

	return 0;
}
コード例 #3
0
ファイル: proginfo.c プロジェクト: EricV/xbmc-pvr-addons
cmyth_proginfo_t
cmyth_proginfo_get_from_timeslot(cmyth_conn_t control, uint32_t chanid, const cmyth_timestamp_t recstartts)
{
	int err = 0;
	int count, i;
	char msg[4096];
	cmyth_proginfo_t prog = NULL;
	cmyth_proglist_t list = NULL;
	char time[15];

	if (!control) {
		cmyth_dbg(CMYTH_DBG_ERROR, "%s: no connection\n",
			  __FUNCTION__);
		return NULL;
	}

	if ((err = cmyth_timestamp_to_numstring(time, recstartts)) < 0) {
		cmyth_dbg(CMYTH_DBG_ERROR, "%s: cmyth_timestamp_to_numstring() failed (%d)\n",
			  __FUNCTION__, err);
		return NULL;
	}

	if(control->conn_version >= 32) {
		pthread_mutex_lock(&control->conn_mutex);

		snprintf(msg, sizeof(msg), "QUERY_RECORDING TIMESLOT %"PRIu32" %s",
			chanid, time);

		if ((err=cmyth_send_message(control, msg)) < 0) {
			cmyth_dbg(CMYTH_DBG_ERROR,
				  "%s: cmyth_send_message() failed (%d)\n",
				  __FUNCTION__, err);
			goto out;
		}

		count = cmyth_rcv_length(control);
		if (count < 0) {
			cmyth_dbg(CMYTH_DBG_ERROR,
				  "%s: cmyth_rcv_length() failed (%d)\n",
				  __FUNCTION__, count);
			goto out;
		}

		i = cmyth_rcv_string(control, &err, msg, sizeof(msg), count);
		if (err) {
			cmyth_dbg(CMYTH_DBG_ERROR, "%s: cmyth_rcv_string() failed\n",
				  __FUNCTION__);
			goto out;
		}
		count -= i;

		if (strcmp(msg, "OK") != 0) {
			cmyth_dbg(CMYTH_DBG_ERROR, "%s: didn't recieve OK as response\n",
				  __FUNCTION__);
			goto out;
		}

		prog = cmyth_proginfo_create();
		if (cmyth_rcv_proginfo(control, &err, prog, count) != count) {
			cmyth_dbg(CMYTH_DBG_ERROR,
				  "%s: cmyth_rcv_proginfo() < count\n", __FUNCTION__);
			goto out;
		}

		pthread_mutex_unlock(&control->conn_mutex);
		return prog;
		out:
		pthread_mutex_unlock(&control->conn_mutex);
		if(prog)
			ref_release(prog);
		return NULL;

	} else {

		list = cmyth_proglist_get_all_recorded(control);
		if (!list) {
			cmyth_dbg(CMYTH_DBG_ERROR, "%s: no program list\n",
				  __FUNCTION__);
		}

		count = cmyth_proglist_get_count(list);
		for (i = 0;i < count; i++) {
			prog = cmyth_proglist_get_item(list, i);
			if (!prog) {
				cmyth_dbg(CMYTH_DBG_DEBUG, "%s: no program info\n",
					  __FUNCTION__);
				continue;
			}
			if (cmyth_timestamp_compare(prog->proginfo_rec_start_ts, recstartts) != 0 ||
					prog->proginfo_chanId != chanid) {
				ref_release(prog);
				prog = NULL;
				continue;
			}
			break;
		}
		ref_release(list);
		return prog;
	}

}