当前位置: 首页>>代码示例>>C++>>正文


C++ DSFYDEBUG函数代码示例

本文整理汇总了C++中DSFYDEBUG函数的典型用法代码示例。如果您正苦于以下问题:C++ DSFYDEBUG函数的具体用法?C++ DSFYDEBUG怎么用?C++ DSFYDEBUG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DSFYDEBUG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cache_get_meta_playlist_revision

unsigned int cache_get_meta_playlist_revision(){
    unsigned int revision;

    /* Build cache filename. */
    snprintf(cache_filename, PATH_MAX, "%s/meta_playlist_revision", cache_directory);

    /* Try to open file for reading. */
    FILE *file = fopen(cache_filename, "r");

    if(!file){
        DSFYDEBUG("Error opening file in read-mode.\n");

        return 0;
    }

    /* Write data to file. */
    if(fread(&revision, sizeof(unsigned int), 1, file) != 1){
        DSFYDEBUG("Error reading meta playlist revision.\n");

        return 0;
    }

    fclose(file);

    return revision;
}
开发者ID:FauxFaux,项目名称:despotify,代码行数:26,代码来源:cache.c

示例2: read_server_auth_response

int read_server_auth_response (SESSION * session)
{
	unsigned char buf[256];
	unsigned char payload_len;
	int ret;

	ret = block_read(session->ap_sock, buf, 2);
	if (ret != 2) {
		DSFYDEBUG("Failed to read 'status' + length byte, got %d bytes\n", ret);
		return -1;
	}

	if (buf[0] != 0x00) {
		DSFYDEBUG("Authentication failed with error 0x%02x, bad password?\n", buf[1]);
		return -1;
	}

	/* Payload length + this byte must not be zero(?) */
	assert (buf[1] > 0);

	payload_len = buf[1];

	ret = block_read (session->ap_sock, buf, payload_len);
	if (ret != payload_len) {
		DSFYDEBUG("Failed to read 'payload', got %d of %u bytes\n",
				ret, payload_len);
		return -1;
	}
#ifdef DEBUG_LOGIN
	hexdump8x32 ("read_server_auth_response, payload", buf, payload_len);
#endif

	return 0;
}
开发者ID:alt-,项目名称:bada-spotify,代码行数:34,代码来源:auth.c

示例3: handle_secret_block

int handle_secret_block (SESSION * session, unsigned char *payload, int len)
{
	unsigned int *t;

	if (len != 336) {
		DSFYDEBUG ("Got cmd=0x02 with len %d, expected 336!\n", len);
		return -1;
	}

	t = (unsigned int *) payload;
	DSFYDEBUG ("Initial time %u (%ld seconds from now)\n",
		 ntohl (*t), time (NULL) - ntohl (*t));
	t++;
	DSFYDEBUG ("Future time %u (%ld seconds in the future)\n",
		 ntohl (*t), ntohl (*t) - time (NULL));

	t++;
	DSFYDEBUG ("Next value is %u\n", ntohl (*t));
	t++;
	DSFYDEBUG ("Next value is %u\n", ntohl (*t));

	assert (memcmp (session->rsa_pub_exp, payload + 16, 128) == 0);

	/* At payload+16+128 is a  144 bytes (1536-bit) RSA signature */

	/*
	 * Actually the cache hash is sent before the server has sent any
	 * packets. It's just put here out of convenience, because this is
	 * one of the first packets ever by the server, and also not
	 * repeated during a session.
	 *
	 */

	return cmd_send_cache_hash (session);
}
开发者ID:FauxFaux,项目名称:despotify,代码行数:35,代码来源:handlers.c

示例4: snd_init

/* Initialize sound session, called once */
bool snd_init(struct despotify_session *ds)
{
	DSFYDEBUG ("Initializing sound FIFO etc (happens once)\n");

	DSFYDEBUG("Setting state to DL_FILLING\n");
	ds->dlstate = DL_FILLING;

	/* This is the fifo that will hold fragments of compressed audio */
        ds->fifo = calloc(1, sizeof(struct ds_snd_fifo));
        if (!ds->fifo)
		return false;
        ds->fifo->maxbytes = 1024 * 1024; /* 1 MB default buffer size */
        ds->fifo->watermark = 200 * 1024; /* 200 KB default watermark */

        if (pthread_mutex_init (&ds->fifo->lock, NULL)) {
            DSFYfree (ds->fifo);
            return NULL;
	}

	if (pthread_cond_init (&ds->fifo->cs, NULL)) {
            DSFYfree (ds->fifo);
		pthread_mutex_destroy (&ds->fifo->lock);
		return NULL;
	}

        return true;
}
开发者ID:xrobau,项目名称:despotify,代码行数:28,代码来源:sndqueue.c

示例5: snd_fill_fifo

static void snd_fill_fifo(struct despotify_session* ds)
{
    if (ds->dlabort) {
        while (ds->dlstate == DL_FILLING_BUSY) {
            DSFYDEBUG("dlstate = %d. waiting...\n", ds->dlstate);
            shortsleep();
        }
        ds->dlstate = DL_DRAINING;
        return;
    }

    switch (ds->dlstate) {
        case DL_DRAINING:
            if (ds->fifo->totbytes < ds->fifo->watermark ) {
                DSFYDEBUG("Low on data (%d / %d), fetching another channel\n",
                          ds->fifo->totbytes, ds->fifo->maxbytes);
                DSFYDEBUG("dlstate = DL_FILLING_BUSY\n");
                ds->dlstate = DL_FILLING_BUSY;
                despotify_snd_read_stream(ds);
            }
            break;

        case DL_FILLING:
            if (ds->fifo->totbytes < (ds->fifo->maxbytes - SUBSTREAM_SIZE)) {
                DSFYDEBUG("dlstate = DL_FILLING_BUSY\n");
                ds->dlstate = DL_FILLING_BUSY;
                despotify_snd_read_stream(ds);
            }
            else {
                DSFYDEBUG("buffer filled. setting dlstate DL_DRAINING\n");
                ds->dlstate = DL_DRAINING;
            }
            break;
    }
}
开发者ID:xrobau,项目名称:despotify,代码行数:35,代码来源:sndqueue.c

示例6: login_release

/* Free a login context */
void login_release(struct login_ctx *l) {

	/* Only close the socket if an error occurred */
	if(l->error != SP_LOGIN_ERROR_OK && l->sock != -1) {
		DSFYDEBUG("Closing open socket %d, login error was %d\n",
			l->sock, l->error);
#ifdef _WIN32
		closesocket(l->sock);
#else
		close(l->sock);
#endif
	}

	if(l->service_records)
		dns_free_list(l->service_records);

	if(l->server_ai != NULL)
		freeaddrinfo(l->server_ai);

	RSA_free(l->rsa);
	DH_free(l->dh);

	if(l->client_parameters)
		buf_free(l->client_parameters);

	if(l->server_parameters)
		buf_free(l->server_parameters);


	free(l);

	DSFYDEBUG("Done free'ing login context\n");
}
开发者ID:Kitof,项目名称:openspotify,代码行数:34,代码来源:login.c

示例7: openspotify_thread

DWORD __stdcall openspotify_thread(LPVOID *arg) {
	MSG msg;
	WNDCLASS wcOpenspotify;
	ATOM wc;


	hwndLibraryParent = (HWND)arg;
	DSFYDEBUG("Ping from thread\n");



	/* Create a window to communicate with the plugin, playlist view and Winamp */
	memset(&wcOpenspotify, 0, sizeof(WNDCLASS));
	wcOpenspotify.lpszClassName = L"ml_openspotify";
	wcOpenspotify.lpfnWndProc = wndproc;
	wc = RegisterClass(&wcOpenspotify);

	m_hWnd = CreateWindow(szAppName, L"ml_openspotify message sink", 0, 0, 0, 0, 0, hwndLibraryParent, NULL, 0, 0);
	DSFYDEBUG("Created window at %p\n", m_hWnd);

	if(openspotify_init() < 0) {
		DSFYDEBUG("Failed to initialize libopenspotify\n");
		PostQuitMessage(0);
	}


	DSFYDEBUG("Openspotify initialized, now dispatching messages\n");
	while(GetMessage(&msg, 0, 0, 0) == TRUE) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return msg.wParam;
}
开发者ID:Kitof,项目名称:openspotify,代码行数:34,代码来源:openspotify.cpp

示例8: event_loop

static void event_loop(sp_session *session) {
	int timeout = -1;
#ifndef _WIN32
	sigset_t sigset;

	sigemptyset(&sigset);
	sigaddset(&sigset, SIGIO);
#endif

	while (g_exit_code < 0) {

#ifndef _WIN32
		pthread_sigmask(SIG_BLOCK, &sigset, NULL);
#endif

		DSFYDEBUG("Calling sp_session_process_events()\n");
		sp_session_process_events(session, &timeout);

		if(test_run() < 0) {
			DSFYDEBUG("Done running test, existing event loop\n");
			break;
		}

#ifdef _WIN32
		WaitForSingleObject(g_notify_event, timeout);
#else
		pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
		usleep(timeout * 1000);
#endif
	}

	DSFYDEBUG("Exiting from loop()\n");
}
开发者ID:Kitof,项目名称:openspotify,代码行数:33,代码来源:session.c

示例9: send_client_auth

int send_client_auth (SESSION * session)
{
	int ret;
	struct buf* buf = buf_new();

	buf_append_data(buf, session->auth_hmac, 20);
	buf_append_u8(buf, 0); /* random data length */
	buf_append_u8(buf, 0); /* unknown */
	buf_append_u16(buf, 8); /* puzzle solution length */
	buf_append_u32(buf, 0);
	/* <-- random data would go here */
	buf_append_data (buf, session->puzzle_solution, 8);

#ifdef DEBUG_LOGIN
	hexdump8x32 ("send_client_auth, second client packet", buf->ptr,
			buf->len);
#endif

	ret = send(session->ap_sock, buf->ptr, buf->len, 0);
	if (ret <= 0) {
		DSFYDEBUG("send_client_auth(): connection lost\n");
		buf_free(buf);
		return -1;
	}
	else if (ret != buf->len) {
		DSFYDEBUG("send_client_auth(): only wrote %d of %d bytes\n",
				ret, buf->len);
		buf_free(buf);
		return -1;
	}

	buf_free(buf);

	return 0;
}
开发者ID:alt-,项目名称:bada-spotify,代码行数:35,代码来源:auth.c

示例10: send_client_initial_packet

int send_client_initial_packet (SESSION * session)
{
	int ret;
	unsigned int len_idx;
	
	struct buf* b = buf_new();

	buf_append_u16 (b, 3); /* protocol version */

	len_idx = b->len;
	buf_append_u16(b, 0); /* packet length - updated later */
	buf_append_u32(b, 0x00000300); /* unknown */
	buf_append_u32(b, 0x00030c00); /* unknown */
	buf_append_u32(b, session->client_revision);
	buf_append_u32(b, 0); /* unknown */
	buf_append_u32(b, 0x01000000); /* unknown */
	buf_append_data(b, session->client_id, 4);
	buf_append_u32(b, 0); /* unknown */
	buf_append_data (b, session->client_random_16, 16);
	buf_append_data (b, session->my_pub_key, 96);

	BN_bn2bin (session->rsa->n, session->rsa_pub_exp);
	buf_append_data (b, session->rsa_pub_exp, sizeof(session->rsa_pub_exp));

	buf_append_u8 (b, 0); /* length of random data */
	buf_append_u8 (b, session->username_len);
	buf_append_u16(b, 0x0100); /* unknown */
        /* <-- random data would go here */
	buf_append_data (b, (unsigned char *) session->username,
			   session->username_len);
	buf_append_u8 (b, 0x40); /* unknown */

	/*
	 * Update length bytes
	 *
	 */
	b->ptr[len_idx] = (b->len >> 8) & 0xff;
	b->ptr[len_idx+1] = b->len & 0xff;

#ifdef DEBUG_LOGIN
	hexdump8x32 ("initial client packet", b->ptr, b->len);
#endif
        ret = send (session->ap_sock, b->ptr, b->len, 0);
	if (ret <= 0) {
		DSFYDEBUG("connection lost\n");
		buf_free(b);
		return -1;
	}
	else if (ret != b->len) {
                DSFYDEBUG("only wrote %d of %d bytes\n", ret, b->len);
		buf_free(b);
		return -1;
	}

        /* save initial server packet for auth hmac generation */
        session->init_client_packet = b;
	
	return 0;
}
开发者ID:8W9aG,项目名称:spooftify,代码行数:59,代码来源:keyexchange.c

示例11: osfy_artistbrowse_browse_callback

static int osfy_artistbrowse_browse_callback(struct browse_callback_ctx *brctx) {
	sp_artistbrowse *arb;
	int i;
	struct buf *xml;
	ezxml_t root;

	for(i = 0; i < brctx->num_in_request; i++) {
		arb = brctx->data.artistbrowses[brctx->num_browsed + i];

		/* Set defaults */
		arb->is_loaded = 0;
		arb->error = SP_ERROR_OTHER_TRANSIENT;
	}

	/* Might happen because of a channel error */
	if(brctx->buf == NULL)
		return 0;

	xml = despotify_inflate(brctx->buf->ptr, brctx->buf->len);
#ifdef DEBUG
	{
		FILE *fd;
		DSFYDEBUG("Decompresed %d bytes data, xml=%p\n",
			  brctx->buf->len, xml);
		fd = fopen("browse-artistbrowse.xml", "w");
		if(fd) {
			fwrite(xml->ptr, xml->len, 1, fd);
			fclose(fd);
		}
	}
#endif

	root = ezxml_parse_str((char *) xml->ptr, xml->len);
	if(root == NULL) {
		DSFYDEBUG("Failed to parse XML\n");
		buf_free(xml);
		return -1;
	}

	for(i = 0; i < brctx->num_in_request; i++) {
		arb = brctx->data.artistbrowses[brctx->num_browsed + i];
		osfy_artistbrowse_load_from_xml(brctx->session, arb, root);
		arb->is_loaded = 1;
		arb->error = SP_ERROR_OK;
	}


	ezxml_free(root);
	buf_free(xml);


	/* Release references made in sp_artistbrowse_create() */
	for(i = 0; i < brctx->num_in_request; i++)
		sp_artistbrowse_release(brctx->data.artistbrowses[brctx->num_browsed + i]);


	return 0;
}
开发者ID:Kitof,项目名称:openspotify,代码行数:58,代码来源:sp_artistbrowse.c

示例12: packet_read

int packet_read (SESSION * session, PHEADER * h, unsigned char **payload)
{
	int ret;
	int packet_len;
	unsigned char nonce[4];
	unsigned char *ptr;

	packet_len = 0;
	if ((ret = block_read (session->ap_sock, h, 3)) != 3) {
		DSFYDEBUG
			("packet_read(): read short count %d, expected 3 (header)\n",
			 ret);
		return -1;
	}

	*(unsigned int *) nonce = htonl (session->key_recv_IV);
	shn_nonce (&session->shn_recv, nonce, 4);

	shn_decrypt (&session->shn_recv, (unsigned char *) h, 3);

#ifdef DEBUG_PACKETS
	DSFYDEBUG ("packet_read(): cmd=%d [0x%02x], len=%d [0x%04x]\n",
		   h->cmd, h->cmd, ntohs (h->len), ntohs (h->len));
	logdata ("recv-hdr", session->key_recv_IV, (unsigned char *) h, 3);
#endif

	/* Length of payload */
	h->len = ntohs (h->len);
	packet_len = h->len;

	/* Account for MAC */
	packet_len += 4;

	ptr = (unsigned char *) malloc (packet_len);
	if ((*payload = ptr) == NULL)
		return -1;

	if ((ret =
	     block_read (session->ap_sock, ptr, packet_len)) != packet_len) {
		DSFYDEBUG
			("packet_read(cmd=0x%02x): read short count %d, expected %d\n",
			 h->cmd, ret, packet_len);
		return -1;
	}

	shn_decrypt (&session->shn_recv, *payload, packet_len);

#ifdef DEBUG_PACKETS
	logdata ("recv-dec", session->key_recv_IV, *payload, h->len);
#endif

	/* Increment IV */
	session->key_recv_IV++;

	return 0;
}
开发者ID:estock,项目名称:spot,代码行数:56,代码来源:packet.c

示例13: session_connect

int session_connect (SESSION * session)
{
	struct sockaddr_in sin;
	char host[1025 + 1], *service_list, *service;
	int port;

	/* Lookup service hosts in DNS */
        service_list = dns_srv_list ("_spotify-client._tcp.spotify.com");
	if (!service_list) {
            DSFYDEBUG("service lookup failed. falling back to ap.spotify.com\n");
            service_list = malloc(200);
            strcpy(service_list, "ap.spotify.com:4070\n");
        }

	for (service = service_list; *service;) {
		if (sscanf (service, "%[^:]:%d\n", host, &port) != 2)
			return -1;

		service += strlen (host) + 7;
		DSFYDEBUG ("session_connect(): Connecting to %s:%d\n", host,
			   port);

		memset (&sin, 0, sizeof (sin));
		sin.sin_family = PF_INET;
		sin.sin_port = htons (port);
		sin.sin_addr.s_addr = dns_resolve_name (host);
		if (sin.sin_addr.s_addr == INADDR_NONE)
			continue;

		session->ap_sock = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
		if (connect (session->ap_sock, (struct sockaddr *) &sin,
			     sizeof (sin)) != -1)
			break;

		sock_close (session->ap_sock);
		session->ap_sock = -1;
	}

	free (service_list);
	if (sin.sin_addr.s_addr == INADDR_NONE)
		return -1;

	/*
	 * Save for later use in ConnectionInfo message
	 * (too lazy to do getpeername() later ;)
	 */
	DSFYstrncpy (session->server_host, host, sizeof session->server_host);
	session->server_port = port;

	DSFYstrncpy (session->user_info.server_host, host,
		     sizeof session->user_info.server_host);
	session->user_info.server_port = port;

	return 0;
}
开发者ID:estock,项目名称:spot,代码行数:55,代码来源:session.c

示例14: packet_write

int packet_write (SESSION * session, unsigned char cmd,
		  unsigned char *payload, unsigned short len)
{
	unsigned char nonce[4];
	unsigned char *buf, *ptr;
	PHEADER *h;
	int ret;

	*(unsigned int *) nonce = htonl (session->key_send_IV);
	shn_nonce (&session->shn_send, nonce, 4);

	buf = (unsigned char *) malloc (3 + len + 4);

	h = (PHEADER *) buf;
	h->cmd = cmd;
	h->len = htons (len);

	ptr = buf + 3;
	if (payload != NULL)
	{
 		memcpy (ptr, payload, len);
	}
	
#ifdef DEBUG_PACKETS
	DSFYDEBUG
		("packet_write(): Sending packet with command 0x%02x, length %d\n",
		 h->cmd, ntohs (h->len));
	logdata ("send-hdr", session->key_send_IV, (unsigned char *) h, 3);
	if (payload != NULL) logdata ("send-payload", session->key_send_IV, payload, len);
#endif

	shn_encrypt (&session->shn_send, buf, 3 + len);
	ptr += len;

	shn_finish (&session->shn_send, ptr, 4);

	ret = block_write (session->ap_sock, buf, 3 + len + 4);

	free(buf);

	session->key_send_IV++;


	if(ret != 3 + len + 4) {
#ifdef DEBUG_PACKETS
		DSFYDEBUG ("packet_write(): only wrote %d of %d bytes\n", ret,
			   3 + len + 4);
#endif
		return -1;
	}

	return 0;
}
开发者ID:estock,项目名称:spot,代码行数:53,代码来源:packet.c

示例15: logged_in

static void  SP_CALLCONV logged_in(sp_session *session, sp_error error) {
	DSFYDEBUG("SESSION CALLBACK\n");
	if (SP_ERROR_OK != error) {
		fprintf(stderr, "failed to log in to Spotify: %s\n",
		                sp_error_message(error));
		g_exit_code = 4;
		return;
	}

	DSFYDEBUG("Running session_ready()\n");
	session_ready(session);
}
开发者ID:Kitof,项目名称:openspotify,代码行数:12,代码来源:session.c


注:本文中的DSFYDEBUG函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。