/** * @brief Cleanup the parser we created * * This has to be done after we are all done with the parsers that * were used. */ void Test_Client::parser_cleanup(void) { QMS_Trace("Test_Client::parser_cleanup",__LINE__, __FILE__); DEBUG0(DEBUG_L_ENTER, "DEBUG:Test_Client::parser_cleanup\n"); // Terminate the parser before the end. This belongs in a destructor if(!this->_parser_initialized) { return; } /* end of if(!this->_parser_initialized) */ try { XMLPlatformUtils::Terminate(); this->_parser_initialized = false; } catch(const XMLException& toCatch) { cerr << "Error during Xerces-c termination.\n" << " Exception message:" << toCatch.getMessage() << endl; } catch (...) { cerr << "Error during Xerces-c termination.\n"; } DEBUG0(4, "DEBUG:parser_cleanup done\n"); }
/** * @brief This is where we perform cleanup operations for the sensor * * The actions taken include withdrawing our YP offer, walking through * the list of current probes, and performing a probe cleanup, * cleaning up after the XML parser, and, fianlly, shutting down the ORB */ void Test_Client::cleanup(void) { QMS_Trace("Test_Client::cleanup", __LINE__,__FILE__); DEBUG0(DEBUG_L_ENTER, "DEBUG:Test_Client::cleanup"); string data; cerr << "Sending the STOP Message" << endl; this->create_message( 1, data, "stop"); if(this->check_message(data)) { this->_supplier.send(data); } else { cerr << "Message failed to validate" << data << endl; cerr << "Unable to Send STOP Message" << endl; } this->_consumer.disconnect(); this->_supplier.disconnect(); this->parser_cleanup(); DEBUG0(4, "Client cleaned up"); this->_handles.get_orb_handle()->shutdown (); }
/** @fn void mock_message(void) * @brief Generate a test Remos Query randomly * * Here we generate a mock query statically, incrementing the request * ID every time we are invoked. We instantiate a struct Query_struct, * populate it, and use a QMS_Remos_Msg object to facilitate * conversion to XML */ void mock_message(void) { QMS_Trace ("mock_message", __LINE__, __FILE__); Query_struct query; ACE_Write_Guard<ACE_Thread_Mutex> guard(TD_asset_guard); { query.request_id = count++; } query.request_id = 0; query.repeat_count = 5; query.refresh_rate = 2.45; query.type = Query_struct::link; query.host_names = "skywalker_t.stdc.com,kenobee_t.stdc.com,c3po_t.stdc.com"; DEBUG0 (DEBUG_L_CALL, "DEBUG Created Query\n"); cout << "============================================================" <<endl; print_query(&query); cout << "============================================================" <<endl; QMS_Remos_Msg message; message.insert(query); string data = message.as_string(); qms_api.send(data); DEBUG0 (DEBUG_L_LEAVE, "DEBUG Sending all done\n"); }
void truetalkSend(char *buf, KQMLPerformative *perf) { unsigned long marker; DEBUG1("sending \"%s\"", buf); /* Save this performative for use by callbacks */ currentPerf = perf; /* We haven't said anything yet... */ startedSpeaking = 0; /* Temporary for transcripting (send now so it appears with speech) */ sendSpokenMsg(buf); /* Send the line to TrueTalk (will callback ttCB() with output) */ marker = TT_SendText(myclient, buf, strlen(buf)); if (!marker) { ERROR1("TT_SendText failed: %s\n", TT_DecodeLastError()); } /* Let server finish with this text before sending new stuff */ DEBUG0("waiting for TrueTalk to finish"); if (!TT_Sync(myclient, marker)) { ERROR1("TT_Sync failed: %s\n", TT_DecodeLastError()); } /* Sync with server */ DEBUG0("syncing server"); audioSync(); /* We're done speaking */ sendStoppedSpeakingMsg(); /* Send done reply */ if (perf != NULL) { DEBUG0("replying"); sendDoneReply(perf); } /* Done */ DEBUG0("done"); }
int tts_init(char *voice, char *dictfile) { VoiceSpec vspec; int useDefaultVoice = 1; DEBUG0("creating semaphore"); if ((sem = sem_open("speechout-mac.lock", O_CREAT, 0700, 0)) == (sem_t*)SEM_FAILED) { SYSERR0("sem_open failed"); return -1; } if (voice != NULL) { DEBUG0("getting voice spec"); if (getVoiceSpec(voice, &vspec) != 0) { ERROR1("no voice named \"%s\"", voice); return(-1); } useDefaultVoice = 0; } DEBUG0("creating speech channel"); channel = createNewSpeechChannel(useDefaultVoice ? NULL : &vspec); if (channel == NULL) { return(-1); } if (dictfile) { DEBUG0("installing pronunciation dictionary"); installPronunciationDictionary(channel, dictfile); } DEBUG0("done"); return 0; }
void audioClose_SUN(void) { DEBUG0("closing audio device"); close(audioFd); DEBUG0("done"); }
void truetalkClose(void) { DEBUG0("closing connection to TrueTalk"); TT_Close(myclient, server); DEBUG0("done"); }
static bool maybe_populate_impl( const char* name, const char* description, T& destination, const T& source, const bool verbose, bool (* const default_value)(const T& v)) { if (default_value(destination)) { if (verbose) { // Populating a default isn't interesting, hence DEBUG0 if (description) { DEBUG0("Populating " << name << " (" << description << ") to be " << source); } else { DEBUG0("Populating " << name << " to be " << source); } } destination = source; return true; } if (verbose) { if (description) { // Retaining an existing setting is interesting, hence INFO0 INFO0("Clutching onto " << name << " (" << description << ") of " << destination); } else { INFO0("Clutching onto " << name << " of " << destination); } } return false; }
PRIVATE void free_work ( WorkType *Work ) { DEBUG0 (("work free:\n")) ; if (Work) { /* these 16 objects do exist */ Work->Wx = (Entry *) UMF_free ((void *) Work->Wx) ; Work->Wy = (Entry *) UMF_free ((void *) Work->Wy) ; Work->Frpos = (Int *) UMF_free ((void *) Work->Frpos) ; Work->Fcpos = (Int *) UMF_free ((void *) Work->Fcpos) ; Work->Lpattern = (Int *) UMF_free ((void *) Work->Lpattern) ; Work->Upattern = (Int *) UMF_free ((void *) Work->Upattern) ; Work->Wp = (Int *) UMF_free ((void *) Work->Wp) ; Work->Wrp = (Int *) UMF_free ((void *) Work->Wrp) ; Work->Frows = (Int *) UMF_free ((void *) Work->Frows) ; Work->Fcols = (Int *) UMF_free ((void *) Work->Fcols) ; Work->Wio = (Int *) UMF_free ((void *) Work->Wio) ; Work->Woi = (Int *) UMF_free ((void *) Work->Woi) ; Work->Woo = (Int *) UMF_free ((void *) Work->Woo) ; Work->Wm = (Int *) UMF_free ((void *) Work->Wm) ; Work->E = (Int *) UMF_free ((void *) Work->E) ; Work->Front_new1strow = (Int *) UMF_free ((void *) Work->Front_new1strow) ; /* these objects might not exist */ Work->Diagonal_map = (Int *) UMF_free ((void *) Work->Diagonal_map) ; Work->Diagonal_imap = (Int *) UMF_free ((void *) Work->Diagonal_imap) ; } DEBUG0 (("work free done.\n")) ; }
/* routine for taking the provided page (should be a header page) and * placing it on the collection of header pages */ void format_ogg_attach_header (ogg_codec_t *codec, ogg_page *page) { ogg_state_t *ogg_info = codec->parent; refbuf_t *refbuf; if (codec->filtered) return; refbuf = make_refbuf_with_page (codec, page); if (ogg_page_bos (page)) { DEBUG0 ("attaching BOS page"); if (*ogg_info->bos_end == NULL) ogg_info->header_pages_tail = refbuf; refbuf->associated = *ogg_info->bos_end; *ogg_info->bos_end = refbuf; ogg_info->bos_end = &refbuf->associated; return; } DEBUG0 ("attaching header page"); if (ogg_info->header_pages_tail) ogg_info->header_pages_tail->associated = refbuf; ogg_info->header_pages_tail = refbuf; if (ogg_info->header_pages == NULL) ogg_info->header_pages = refbuf; }
SmpStatusType udpSend (SmpSocketType udp, CBytePtrType bp, CIntfType n) { UdpPtrType tp; int result; if (udp == (SmpSocketType) 0) { return (errBad); } DEBUG0 ("udpSend:\n"); DEBUGBYTES (bp, n); DEBUG0 ("\n"); tp = (UdpPtrType) udp; do { result = sendto (tp->udpSocket, (char *) bp, (int) n, (int) 0, & (tp->udpSockAddr), sizeof (struct sockaddr_in)); n -= result; bp += result; } while ((result > 0) && (n > 0)); if (result < 0) { perror ("udpSend"); return (errBad); } else { return (errOk); } }
void audioSync_SUN(void) { DEBUG0("draining audio device"); ioctl(audioFd, AUDIO_DRAIN); DEBUG0("done"); }
/* update the specified source with details from the config or mount. * mountinfo can be NULL in which case default settings should be taken */ void source_update_settings (ice_config_t *config, source_t *source, mount_proxy *mountinfo) { /* skip if source is a fallback to file */ if (source->running && source->client == NULL) { stats_event_hidden (source->mount, NULL, 1); return; } /* set global settings first */ source->queue_size_limit = config->queue_size_limit; source->timeout = config->source_timeout; source->burst_size = config->burst_size; stats_event_args (source->mount, "listenurl", "http://%s:%d%s", config->hostname, config->port, source->mount); source_apply_mount (source, mountinfo); if (source->fallback_mount) DEBUG1 ("fallback %s", source->fallback_mount); if (mountinfo && mountinfo->intro_filename) DEBUG1 ("intro file is %s", mountinfo->intro_filename); if (source->dumpfilename) DEBUG1 ("Dumping stream to %s", source->dumpfilename); if (mountinfo && mountinfo->on_connect) DEBUG1 ("connect script \"%s\"", mountinfo->on_connect); if (mountinfo && mountinfo->on_disconnect) DEBUG1 ("disconnect script \"%s\"", mountinfo->on_disconnect); if (source->on_demand) { DEBUG0 ("on_demand set"); stats_event (source->mount, "on_demand", "1"); stats_event_args (source->mount, "listeners", "%ld", source->listeners); } else stats_event (source->mount, "on_demand", NULL); if (source->hidden) { stats_event_hidden (source->mount, NULL, 1); DEBUG0 ("hidden from public"); } else stats_event_hidden (source->mount, NULL, 0); if (source->max_listeners == -1) stats_event (source->mount, "max_listeners", "unlimited"); else { char buf [10]; snprintf (buf, sizeof (buf), "%ld", source->max_listeners); stats_event (source->mount, "max_listeners", buf); } DEBUG1 ("public set to %d", source->yp_public); DEBUG1 ("max listeners to %ld", source->max_listeners); DEBUG1 ("queue size to %u", source->queue_size_limit); DEBUG1 ("burst size to %u", source->burst_size); DEBUG1 ("source timeout to %u", source->timeout); DEBUG1 ("fallback_when_full to %u", source->fallback_when_full); }
/* wrapper function for auth thread to authenticate new listener * connection details */ static void auth_new_listener (auth_client *auth_user) { client_t *client = auth_user->client; /* make sure there is still a client at this point, a slow backend request * can be avoided if client has disconnected */ if (allow_auth == 0 || is_listener_connected (client) == 0) { DEBUG0 ("dropping listener connection"); client->respcode = 400; return; } if (auth_user->auth->authenticate) { switch (auth_user->auth->authenticate (auth_user)) { case AUTH_OK: case AUTH_FAILED: break; default: return; } } if (auth_postprocess_listener (auth_user) < 0) DEBUG0 ("listener connection failed"); }
/* * Called by speech channel when all speech has been generated. */ void OurSpeechDoneCallBackProc(SpeechChannel inSpeechChannel, long inRefCon) { DEBUG0("posting semaphore"); if (sem_post(sem) < 0) { SYSERR0("sem_post failed"); } DEBUG0("done"); }
static int command_shoutcast_metadata (client_t *client, source_t *source) { const char *action; const char *value; int same_ip = 1; if (COMMAND_REQUIRE(client, "mode", action) < 0) { thread_mutex_unlock (&source->lock); return client_send_400 (client, "missing arg, mode"); } if ((source->flags & SOURCE_SHOUTCAST_COMPAT) == 0) { thread_mutex_unlock (&source->lock); ERROR0 ("illegal request on non-shoutcast compatible stream"); return client_send_400 (client, "Not a shoutcast compatible stream"); } if (strcmp (action, "updinfo") == 0) { DEBUG0("Got shoutcast metadata update request"); if (COMMAND_REQUIRE (client, "song", value) < 0) { thread_mutex_unlock (&source->lock); return client_send_400 (client, "missing arg, song"); } if (source->client && strcmp (client->connection.ip, source->client->connection.ip) != 0) if (connection_check_admin_pass (client->parser) == 0) same_ip = 0; if (same_ip && source->format && source->format->set_tag) { httpp_set_query_param (client->parser, "mount", client->server_conn->shoutcast_mount); source->format->set_tag (source->format, "title", value, NULL); source->format->set_tag (source->format, NULL, NULL, NULL); DEBUG2("Metadata on mountpoint %s changed to \"%s\"", source->mount, value); thread_mutex_unlock (&source->lock); return html_success(client, "Metadata update successful"); } thread_mutex_unlock (&source->lock); return client_send_400 (client, "mountpoint will not accept URL updates"); } if (strcmp (action, "viewxml") == 0) { xmlDocPtr doc; DEBUG0("Got shoutcast viewxml request"); thread_mutex_unlock (&source->lock); doc = stats_get_xml (STATS_ALL, source->mount); return admin_send_response (doc, client, XSLT, "viewxml.xsl"); } thread_mutex_unlock (&source->lock); return client_send_400 (client, "No such action"); }
/* ARGSUSED3 */ static int pci_open(dev_t *devp, int flags, int otyp, cred_t *credp) { pci_t *pci_p; int rval; uint_t orig_pci_soft_state; /* * Make sure the open is for the right file type. */ if (otyp != OTYP_CHR) return (EINVAL); /* * Get the soft state structure for the device. */ pci_p = DEV_TO_SOFTSTATE(*devp); if (pci_p == NULL) return (ENXIO); /* * Handle the open by tracking the device state. */ DEBUG2(DBG_OPEN, pci_p->pci_dip, "devp=%x: flags=%x\n", devp, flags); mutex_enter(&pci_p->pci_mutex); orig_pci_soft_state = pci_p->pci_soft_state; if (flags & FEXCL) { if (pci_p->pci_soft_state != PCI_SOFT_STATE_CLOSED) { mutex_exit(&pci_p->pci_mutex); DEBUG0(DBG_OPEN, pci_p->pci_dip, "busy\n"); return (EBUSY); } pci_p->pci_soft_state = PCI_SOFT_STATE_OPEN_EXCL; } else { if (pci_p->pci_soft_state == PCI_SOFT_STATE_OPEN_EXCL) { mutex_exit(&pci_p->pci_mutex); DEBUG0(DBG_OPEN, pci_p->pci_dip, "busy\n"); return (EBUSY); } pci_p->pci_soft_state = PCI_SOFT_STATE_OPEN; } if (pci_p->hotplug_capable == B_TRUE) { if (rval = pcihp_ops->cb_open(devp, flags, otyp, credp)) { pci_p->pci_soft_state = orig_pci_soft_state; mutex_exit(&pci_p->pci_mutex); return (rval); } } pci_p->pci_open_count++; mutex_exit(&pci_p->pci_mutex); return (0); }
GLOBAL void *UMF_realloc ( void *p, Int n_objects, size_t size_of_object ) { size_t size ; void *p2 ; #ifdef UMF_TCOV_TEST /* For exhaustive statement coverage testing only! */ /* Pretend to fail, to test out-of-memory conditions. */ umf_realloc_fail-- ; if (umf_realloc_fail <= umf_realloc_hi && umf_realloc_fail >= umf_realloc_lo) { return ((void *) NULL) ; } #endif /* make sure that we allocate something */ n_objects = MAX (1, n_objects) ; size = (size_t) n_objects ; ASSERT (size_of_object > 1) ; if (size > Int_MAX / size_of_object) { /* :: int overflow in umf_realloc :: */ return ((void *) NULL) ; } size *= size_of_object ; DEBUG0 (("UMF_realloc: "ID" n_objects "ID" size_of_object "ID"\n", (Int) p, n_objects, (Int) size_of_object)) ; /* see AMD/Source/amd_global.c for the memory allocator selection */ p2 = amd_realloc (p, size) ; #if defined (UMF_MALLOC_COUNT) || !defined (NDEBUG) /* If p didn't exist on input, and p2 exists, then a new object has been * allocated. */ if (p == (void *) NULL && p2 != (void *) NULL) { UMF_malloc_count++ ; } #endif DEBUG0 (("UMF_realloc: "ID" new malloc count "ID"\n", (Int) p2, UMF_malloc_count)) ; return (p2) ; }
int truetalkInit(char *host) { static unsigned int ports[2] = {0, 0}; int who, where, encoding, rate; int retries; DEBUG0("initializing TrueTalk"); /* Initialize the TrueTalk API */ EinitTtbase(NULL); /* Find and connect to the server */ if ((server = TT_BindServer(host, ports)) == NULL) { ERROR1("couldn't bind to TT server on %s", (host ? host : "<local host>")); return -1; } /* Try repeatedly to connect to TrueTalk server */ retries = 100; while (retries) { /* Try to connect */ if ((myclient = TT_Open(server)) != NULL) { /* Yes! Carry on */ break; } /* Really didn't connect? */ if (--retries <= 0) { ERROR2("couldn't connect to TT server on %s: %s", (host ? host : "<local host>"), TT_DecodeLastError()); return -1; } /* Maybe it's still coming up, let's wait and see */ DEBUG2("couldn't connect to TT server on %s: %s (will retry)", (host ? host : "<local host>"), TT_DecodeLastError()); sleep(1); } /* Tell the server to exit after we're done */ TT_ExitOnClose(myclient); /* Tell TrueTalk we want to handle the output ourselves */ who = OUTPUT_CLIENT; where = OUTPUT_FUNC; encoding = ENCODING_PCM; rate = 8000; DEBUG0("setting TrueTalk output parameters"); if (TT_SetOutput(myclient, who, where, encoding, rate, ttCB) == 0) { ERROR1("couldn't set TT output: %s\n", TT_DecodeLastError()); truetalkClose(); return -1; } /* Done */ DEBUG0("done"); return 0; }
GLOBAL void *UMF_malloc ( Int n_objects, size_t size_of_object ) { size_t size ; void *p ; #ifdef UMF_TCOV_TEST /* For exhaustive statement coverage testing only! */ /* Pretend to fail, to test out-of-memory conditions. */ umf_fail-- ; if (umf_fail <= umf_fail_hi && umf_fail >= umf_fail_lo) { DEBUG0 (("umf_malloc: Pretend to fail %d %d %d\n", umf_fail, umf_fail_hi, umf_fail_lo)) ; return ((void *) NULL) ; } #endif DEBUG0 (("UMF_malloc: ")) ; /* make sure that we allocate something */ n_objects = MAX (1, n_objects) ; size = (size_t) n_objects ; ASSERT (size_of_object > 1) ; if (size > Int_MAX / size_of_object) { /* object is too big for integer pointer arithmetic */ return ((void *) NULL) ; } size *= size_of_object ; /* see AMD/Source/amd_global.c for the memory allocator selection */ p = amd_malloc (size) ; DEBUG0 ((ID"\n", (Int) p)) ; #if defined (UMF_MALLOC_COUNT) || !defined (NDEBUG) if (p) { /* One more object has been malloc'ed. Keep track of the count. */ /* (purely for sanity checks). */ UMF_malloc_count++ ; DEBUG0 ((" successful, new malloc count: "ID"\n", UMF_malloc_count)) ; } #endif return (p) ; }
aes_call(AESPB * apb) #endif { #ifdef AES_STRACE aes_strace_begin(aesdebug[apb->contrl[0]].name, aesdebug[apb->contrl[0]].informat, apb); #endif AES_STRACE DEBUG2("Aes call %d (0x%x) %s apid %d pid %d", apb->contrl[0], apb->contrl[0], aescalls[apb->contrl[0]].name ? aescalls[apb->contrl[0]].name : "##", ((AES_PB *)apb)->global->apid, getpid()); if(aescalls[apb->contrl[0]]) { aescalls[apb->contrl[0]]((AES_PB *)apb); } else { #ifdef AES_STRACE if(aesdebug[apb->contrl[0]].name) { DEBUG0("%s: Line %d:\r\n" "Unimplemented AES call %d %s", __FILE__,__LINE__,apb->contrl[0], aesdebug[apb->contrl[0]].name); } else #endif /* AES_STRACE */ { DEBUG0( "%s: Line %d:\r\n" "Illegal AES call %d", __FILE__,__LINE__,apb->contrl[0]); } } #ifdef AES_STRACE aes_strace_end(aesdebug[apb->contrl[0]].name, aesdebug[apb->contrl[0]].outformat, apb); #endif /* AES_STRACE */ DEBUG2("Returned from aes call %d (0x%x) apid %d pid %d", apb->contrl[0], apb->contrl[0], ((AES_PB *)apb)->global->apid, getpid()); }
bool CDynGameData::TestEnemyLocation( CCoord<int>& aPos, bool aStrictCheck ) { int plyDist = KCharacterSpriteSize; const int KEnemyRad = 9; if ( aStrictCheck ) plyDist = KCharacterSpriteSize*5; if (iRuntimeData->Level().Reachable( aPos.Add(KBlockSpriteSize/2, KBlockSpriteSize/2).Div( KBlockSpriteSize ) ) ) { std::vector< CEnemy >::iterator iter = iRuntimeData->Enemies().begin(); while(iter != iRuntimeData->Enemies().end() ) { if (CMath::GetDist(aPos,iter->Location()) < KEnemyRad*2 ) { DEBUG1("CDynGameData::TestEnemyLocation: other enemy %s too close.\n",iter->Location().String().c_str() ); return false; } ++iter; } for(int b=0; b < iRuntimeData->Level().StartPositions() && !aStrictCheck; b++) { // don't put enemies on start blocks. if (CMath::GetDist( aPos, iRuntimeData->Level().StartPosition( b ).Mul( KBlockSpriteSize )) < KBlockSpriteSize ) { DEBUG0("CDynGameData::TestEnemyLocation: enemy on startblock\n"); return false; } } for(int c=0; c < Players().size(); c++) { if ( CMath::GetDist( aPos, iAnyPlayer[c]->Location() ) < plyDist ) { DEBUG0("CDynGameData::TestEnemyLocation: player too close\n"); return false; } } return true; } else { DEBUG0("CDynGameData::TestEnemyLocation: enemy unreachable\n"); return false; } }
/* Add listener to the pending lists of either the source or fserve thread. * This can be run from the connection or auth thread context */ static int add_authenticated_listener (const char *mount, mount_proxy *mountinfo, client_t *client) { int ret = 0; source_t *source = NULL; client->authenticated = 1; /* Here we are parsing the URI request to see if the extension is .xsl, if * so, then process this request as an XSLT request */ if (util_check_valid_extension (mount) == XSLT_CONTENT) { /* If the file exists, then transform it, otherwise, write a 404 */ DEBUG0("Stats request, sending XSL transformed stats"); stats_transform_xslt (client, mount); return 0; } avl_tree_rlock (global.source_tree); source = source_find_mount (mount); if (source) { if (mountinfo) { if (check_duplicate_logins (source, client, mountinfo->auth) == 0) { avl_tree_unlock (global.source_tree); return -1; } /* set a per-mount disconnect time if auth hasn't set one already */ if (mountinfo->max_listener_duration && client->con->discon_time == 0) client->con->discon_time = time(NULL) + mountinfo->max_listener_duration; } ret = add_listener_to_source (source, client); avl_tree_unlock (global.source_tree); if (ret == 0) DEBUG0 ("client authenticated, passed to source"); } else { avl_tree_unlock (global.source_tree); fserve_client_create (client, mount); } return ret; }
/* helper function for reading data from a client */ int client_read_bytes (client_t *client, void *buf, unsigned len) { int bytes; if (client->refbuf && client->refbuf->len) { /* we have data to read from a refbuf first */ if (client->refbuf->len < len) len = client->refbuf->len; memcpy (buf, client->refbuf->data, len); if (len < client->refbuf->len) { char *ptr = client->refbuf->data; memmove (ptr, ptr+len, client->refbuf->len - len); } client->refbuf->len -= len; return len; } bytes = client->con->read (client->con, buf, len); if (bytes == -1 && client->con->error) DEBUG0 ("reading from connection has failed"); return bytes; }
/* helper function for reading data from a client */ int client_read_bytes (client_t *client, void *buf, unsigned len) { int (*con_read)(struct connection_tag *handle, void *buf, size_t len) = connection_read; int bytes; if (len == 0) return 0; if (client->refbuf && client->pos < client->refbuf->len) { unsigned remaining = client->refbuf->len - client->pos; if (remaining > len) remaining = len; memcpy (buf, client->refbuf->data + client->pos, remaining); client->pos += remaining; if (client->pos >= client->refbuf->len) client_set_queue (client, NULL); return remaining; } #ifdef HAVE_OPENSSL if (client->connection.ssl) con_read = connection_read_ssl; #endif bytes = con_read (&client->connection, buf, len); if (bytes == -1 && client->connection.error) DEBUG0 ("reading from connection has failed"); return bytes; }
ogg_codec_t *initial_opus_page (format_plugin_t *plugin, ogg_page *page) { ogg_state_t *ogg_info = plugin->_state; ogg_codec_t *codec = calloc (1, sizeof (ogg_codec_t)); ogg_packet packet; ogg_stream_init (&codec->os, ogg_page_serialno (page)); ogg_stream_pagein (&codec->os, page); ogg_stream_packetout (&codec->os, &packet); DEBUG0("checking for opus codec"); if (strncmp((char *)packet.packet, "OpusHead", 8) != 0) { ogg_stream_clear (&codec->os); free (codec); return NULL; } INFO0 ("seen initial opus header"); codec->process_page = process_opus_page; codec->codec_free = opus_codec_free; codec->headers = 1; codec->parent = ogg_info; codec->name = "Opus"; format_ogg_attach_header (codec, page); return codec; }
static void command_shoutcast_metadata(client_t *client, source_t *source) { const char *action; const char *value; DEBUG0("Got shoutcast metadata update request"); COMMAND_REQUIRE(client, "mode", action); COMMAND_REQUIRE(client, "song", value); if (strcmp (action, "updinfo") != 0) { client_send_400 (client, "No such action"); return; } if (source->format && source->format->set_tag) { source->format->set_tag (source->format, "title", value, NULL); DEBUG2("Metadata on mountpoint %s changed to \"%s\"", source->mount, value); html_success(client, "Metadata update successful"); } else { client_send_400 (client, "mountpoint will not accept URL updates"); } }
static void command_list_mounts(client_t *client, int response) { DEBUG0("List mounts request"); if (response == PLAINTEXT) { snprintf (client->refbuf->data, PER_CLIENT_REFBUF_SIZE, "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"); client->refbuf->len = strlen (client->refbuf->data); client->respcode = 200; client->refbuf->next = stats_get_streams (); fserve_add_client (client, NULL); } else { xmlDocPtr doc; avl_tree_rlock (global.source_tree); doc = admin_build_sourcelist(NULL); avl_tree_unlock (global.source_tree); admin_send_response(doc, client, response, LISTMOUNTS_TRANSFORMED_REQUEST); xmlFreeDoc(doc); } }
/* wrapper function for auth thread to authenticate new listener * connection details */ static void auth_new_listener (auth_t *auth, auth_client *auth_user) { client_t *client = auth_user->client; /* make sure there is still a client at this point, a slow backend request * can be avoided if client has disconnected */ if (is_listener_connected (client) == 0) { DEBUG0 ("listener is no longer connected"); client->respcode = 400; auth_release (client->auth); client->auth = NULL; return; } if (auth->authenticate) { if (auth->authenticate (auth_user) != AUTH_OK) { auth_release (client->auth); client->auth = NULL; return; } } if (auth_postprocess_listener (auth_user) < 0) { auth_release (client->auth); client->auth = NULL; INFO1 ("client %lu failed", client->con->id); } }
void CGameApp::SelfTest() { DEBUG0("Running Self Tests\n"); // Do basic tests on some classes CRect<int>::SelfTest(); CDrawArea::SelfTest(); }