void RTMFPServer::start(RTMFPServerParams& params) { if(running()) { ERROR("RTMFPServer server is yet running, call stop method before"); return; } _port = params.port; if(_port==0) { ERROR("RTMFPServer port must have a positive value"); return; } if(params.pCirrus) { _pCirrus = new Target(*params.pCirrus); NOTE("RTMFPServer started in man-in-the-middle mode with server %s (unstable debug mode)",_pCirrus->address.toString().c_str()); } _middle = params.middle; if(_middle) NOTE("RTMFPServer started in man-in-the-middle mode between peers (unstable debug mode)"); _pSocket = new DatagramSocket(); (UInt32&)udpBufferSize = params.udpBufferSize==0 ? _pSocket->getReceiveBufferSize() : params.udpBufferSize; _pSocket->setReceiveBufferSize(udpBufferSize); _pSocket->setSendBufferSize(udpBufferSize); DEBUG("Socket buffer receving/sending size = %u/%u",udpBufferSize,udpBufferSize); (UInt32&)keepAliveServer = params.keepAliveServer<5 ? 5000 : params.keepAliveServer*1000; (UInt32&)keepAlivePeer = params.keepAlivePeer<5 ? 5000 : params.keepAlivePeer*1000; Startable::start(); setPriority(params.threadPriority); }
/**@internal * @brief Handles SIGCHLD signals to avoid zombie processes * * When a child process exits, it causes a SIGCHLD to be sent to the * parent process. This handler catches it and reaps the child process so it * can exit. Otherwise we'd get zombie processes. */ void sigchld_handler(int s) { int status; pid_t rc; //NOTE("SIGCHLD handler: Trying to reap a child"); rc = waitpid(-1, &status, WNOHANG | WUNTRACED); if(rc == -1) { if(errno == ECHILD) { NOTE("SIGCHLD handler: waitpid(): No child exists now."); } else { ERROR("SIGCHLD handler: Error reaping child (waitpid() returned -1): %s", strerror(errno)); } return; } if(WIFEXITED(status)) { //DEBUG("SIGCHLD handler: Process PID %d exited normally, status %d", (int)rc, WEXITSTATUS(status)); return; } if(WIFSIGNALED(status)) { NOTE("SIGCHLD handler: Process PID %d exited due to signal %d", (int)rc, WTERMSIG(status)); return; } NOTE("SIGCHLD handler: Process PID %d changed state, status %d not exited, ignoring", (int)rc, status); return; }
void Daemon::processDisconnected( Channel dead ) { switch ( _state ) { case State::Leaving: break; case State::Supervising: NOTE(); if ( _rope == dead ) Logger::log( "working child died" ); else Logger::log( "internal error happened - other connection than rope to the child has died" ); setDefault(); break; case State::Free: case State::Enslaved: case State::FormingGroup: NOTE(); Logger::log( "closed connection to " + info( dead ) + " which is weird" ); setDefault(); break; case State::Running: case State::Grouped: NOTE(); Logger::log( "closed connection to " + info( dead ) ); ::exit( 0 ); } }
static void dump_src_AttrType(FILE *output, const char *name, AttrList data, const char **from) { int n; fprintf(output, "static const attr %s_attr_list[] = {\n", name); if (data != 0) { for (n = 0; data[n].name != 0; ++n) { dump_AttrItem(output, data + n); } } fprintf(output, "\t{ 0 T(N) } /* Terminate list */\n"); fprintf(output, "};\n"); NOTE(""); fprintf(output, "static const AttrType %s_attr_type[] = {\n", name); if (from != 0) { while (*from != 0) { fprintf(output, "\t{ ATTR_TYPE(%s) },\n", *from); ++from; } } else { fprintf(output, "\t{ ATTR_TYPE(%s) },\n", name); } fprintf(output, "\t{ 0, 0 },\n"); fprintf(output, "};\n"); NOTE(""); }
static void dnssd_client_cb(AvahiClient *c, /* I - Client */ AvahiClientState state, /* I - Current state */ void *userdata) /* I - User data (unused) */ { (void)userdata; int error; /* Error code, if any */ if (!c) return; switch (state) { default : NOTE("Ignore Avahi state %d.", state); break; case AVAHI_CLIENT_CONNECTING: NOTE("Waiting for Avahi server."); break; case AVAHI_CLIENT_S_RUNNING: NOTE("Avahi server connection got available, registering printer."); dnssd_register(c); break; case AVAHI_CLIENT_S_REGISTERING: case AVAHI_CLIENT_S_COLLISION: NOTE("Dropping printer registration because of possible host name change."); if (g_options.dnssd_data->ipp_ref) avahi_entry_group_reset(g_options.dnssd_data->ipp_ref); break; case AVAHI_CLIENT_FAILURE: if (avahi_client_errno(c) == AVAHI_ERR_DISCONNECTED) { NOTE("Avahi server disappeared, unregistering printer"); dnssd_unregister(); /* Renewing client */ if (g_options.dnssd_data->DNSSDClient) avahi_client_free(g_options.dnssd_data->DNSSDClient); if ((g_options.dnssd_data->DNSSDClient = avahi_client_new(avahi_threaded_poll_get (g_options.dnssd_data->DNSSDMaster), AVAHI_CLIENT_NO_FAIL, dnssd_client_cb, NULL, &error)) == NULL) { ERR("Error: Unable to initialize DNS-SD client."); g_options.terminate = 1; } } else { ERR("Avahi server connection failure: %s", avahi_strerror(avahi_client_errno(c))); g_options.terminate = 1; } break; } }
HRESULT CLoadDirectDraw::IsDirectDrawLoaded() { NOTE("Entering IsDirectDrawLoaded"); if (m_pDirectDraw == NULL) { NOTE("DirectDraw not loaded"); return S_FALSE; } return NOERROR; }
// advance one cycle void proc_t::advance_one_cycle() { int data; int A = 100 % test_args.addr_range; int B = 200 % test_args.addr_range; switch (args.test) { case 0: // first Command // store at cycle 1 if(!command1[0]){ addr = random() % 32 + 16 * proc; NOTE("proc store A"); response = cache->store(addr, 0, 50, false); if(response.retry_p == false){ command1[0] = true; NOTE("proc first store finish"); } } // second Command // load to same address // should hit else if(command1[0] && !command1[1]){ NOTE("proc load A"); response = cache->load(addr, 0, &data, false); if(response.retry_p == false){ command1[1] = true; NOTE("proc load finish"); if(data != 50){ ERROR("fail this case"); }else{ NOTE_ARGS(("%d: get correct value", proc)); NOTE("pass this case"); } } } break; default: ERROR("don't know this test case"); } }
int main(int argc, const char **argv) { utils::log::setfile("tests.log"); NOTE("RUNNING TESTS..."); #include "test_str.h" #include "test_Variant.h" NOTE("All tests passed!"); return 0; }
void actionBookmarkAdd(void *data) { DVDBookmark_t *bm; unsigned char id[16]; char *state = NULL; char volid[33]; int volid_type; char *disccomment = NULL; if(DVDGetDiscID(nav, id) != DVD_E_Ok) { NOTE("%s", "GetDiscID failed\n"); return; } if(DVDGetVolumeIdentifiers(nav, 0, &volid_type, volid, NULL) != DVD_E_Ok) { DNOTE("%s", "GetVolumeIdentifiers failed\n"); volid_type = 0; } if(DVDGetState(nav, &state) == DVD_E_Ok) { if((bm = DVDBookmarkOpen(id, NULL, 1)) == NULL) { if(errno != ENOENT) { NOTE("%s", "BookmarkOpen failed: "); perror(""); } free(state); return; } if(DVDBookmarkAdd(bm, state, NULL, NULL, NULL) == -1) { DNOTE("%s", "BookmarkAdd failed\n"); DVDBookmarkClose(bm); free(state); return; } free(state); if(volid_type != 0) { if(DVDBookmarkGetDiscComment(bm, &disccomment) != -1) { if((disccomment == NULL) || (disccomment[0] == '\0')) { if(DVDBookmarkSetDiscComment(bm, volid) == -1) { DNOTE("%s", "SetDiscComment failed\n"); } } if(disccomment) { free(disccomment); } } } if(DVDBookmarkSave(bm, 0) == -1) { NOTE("%s", "BookmarkSave failed\n"); } DVDBookmarkClose(bm); } }
void autoload_bookmark(void) { DVDBookmark_t *bm; unsigned char id[16]; char *state = NULL; int n; if(!nav) { return; } if(!bookmarks_autoload) { return; } if(DVDGetDiscID(nav, id) != DVD_E_Ok) { NOTE("%s", "GetDiscID failed\n"); return; } if((bm = DVDBookmarkOpen(id, NULL, 0)) == NULL) { if(errno != ENOENT) { NOTE("%s", "BookmarkOpen failed: "); perror(""); } return; } n = DVDBookmarkGetNr(bm); if(n == -1) { NOTE("%s", "DVDBookmarkGetNr failed\n"); } else if(n > 0) { char *appinfo; if(DVDBookmarkGet(bm, n-1, &state, NULL, "common", &appinfo) != -1) { if(state) { if(appinfo && !strcmp(appinfo, "autobookmark")) { if(DVDSetState(nav, state) != DVD_E_Ok) { NOTE("%s", "DVDSetState failed\n"); } } free(state); } if(appinfo) { free(appinfo); } } else { NOTE("%s", "BookmarkGet failed\n"); } } DVDBookmarkClose(bm); }
LPDIRECTDRAW CLoadDirectDraw::GetDirectDraw() { NOTE("Entering GetDirectDraw"); if (m_pDirectDraw == NULL) { NOTE("No DirectDraw"); return NULL; } NOTE("Returning DirectDraw"); m_pDirectDraw->AddRef(); return m_pDirectDraw; }
void CLoadDirectDraw::ReleaseDirectDraw() { NOTE("Releasing DirectDraw driver"); // Release any DirectDraw provider interface if (m_pDirectDraw) { NOTE("Releasing instance"); m_pDirectDraw->Release(); m_pDirectDraw = NULL; } }
void* handle_gps(int *arg) { char one_line[512] = {0}; // int ret = 0; // unsigned int count = 0; char *p = one_line; char ch = 0; int valid_flag = 0; NOTE("GPS Thread start...\n"); int fd = open_gps_com("/dev/ttyS0"); while(!exit_flag) { ch = get_char(fd); if(ch <=0) goto RECONN; if(ch == '$') { memset(one_line,0,512); p = one_line; *p = ch; valid_flag = 1; } else if(ch == '\r' || ch == '\n') { if(valid_flag) { //valid data is between '$' to '\r' or '\n' //tail add ',' *p = ','; p++; *p = '\0'; // DEBUG("[%d][%s]\n",++count,one_line); parse_var(one_line,"/tmp/gps_info"); //the all gps info,can not sleep here } valid_flag = 0; } if(valid_flag) { *p = ch; p++; } continue; RECONN: ERROR("Read GPS Com Error!%d:%s\n",errno,strerror(errno)); if(fd >= 0) port_close(fd); sleep_seconds_intr(10); fd = open_gps_com("/dev/ttyS0"); } NOTE("GPS Thread exit!\n"); if(fd >= 0) port_close(fd); system("/bin/echo GPS_thread_EXIT > /tmp/gps_status"); return NULL; }
void RTMFPServer::run() { try { _pSocket->bind(SocketAddress("0.0.0.0",_port)); _mainSockets.add(*_pSocket,*this); NOTE("RTMFP server starts on %u port",_port); onStart(); RTMFPManager manager(*this); bool terminate=false; while(!terminate) handle(terminate); } catch(Exception& ex) { FATAL("RTMFPServer, %s",ex.displayText().c_str()); } catch (exception& ex) { FATAL("RTMFPServer, %s",ex.what()); } catch (...) { FATAL("RTMFPServer, unknown error"); } _mainSockets.remove(*_pSocket); // terminate handle terminate(); // clean sessions, and send died message if need _handshake.clear(); _sessions.clear(); // stop receiving and sending engine (it waits the end of sending last session messages) poolThreads.clear(); // close UDP socket delete _pSocket; sockets.clear(); _mainSockets.clear(); _port=0; onStop(); if(_pCirrus) { delete _pCirrus; _pCirrus = NULL; } NOTE("RTMFP server stops"); }
/** @internal * Registers all the signal handlers */ static void init_signals(void) { struct sigaction sa; NOTE("Setting SIGCHLD handler to sigchld_handler()"); sa.sa_handler = sigchld_handler; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_RESTART; if (sigaction(SIGCHLD, &sa, NULL) == -1) { ERROR("sigaction(): %s", strerror(errno)); exit(1); } /* Trap SIGPIPE */ /* This is done so that when libhttpd does a socket operation on * a disconnected socket (i.e.: Broken Pipes) we catch the signal * and do nothing. The alternative is to exit. SIGPIPE are harmless * if not desirable. */ NOTE("Setting SIGPIPE handler to SIG_IGN\n"); sa.sa_handler = SIG_IGN; if (sigaction(SIGPIPE, &sa, NULL) == -1) { ERROR("sigaction(): %s\n", strerror(errno)); exit(1); } NOTE("Setting SIGTERM,SIGQUIT,SIGINT handlers to termination_handler()\n"); sa.sa_handler = termination_handler; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_RESTART; /* Trap SIGTERM */ if (sigaction(SIGTERM, &sa, NULL) == -1) { ERROR("sigaction(): %s\n", strerror(errno)); exit(1); } /* Trap SIGQUIT */ if (sigaction(SIGQUIT, &sa, NULL) == -1) { ERROR("sigaction(): %s\n", strerror(errno)); exit(1); } /* Trap SIGINT */ if (sigaction(SIGINT, &sa, NULL) == -1) { ERROR("sigaction(): %s\n", strerror(errno)); exit(1); } }
STDMETHODIMP CDVSBasePPage::GetPageInfo(LPPROPPAGEINFO pPageInfo) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CString str; if(!str.LoadString(m_TitleId)) return E_FAIL; WCHAR wszTitle[STR_MAX_LENGTH]; #ifdef UNICODE wcscpy(wszTitle, str); #else mbstowcs(wszTitle, str, str.GetLength()+1); #endif CheckPointer(pPageInfo, E_POINTER); // Allocate dynamic memory for the property page title LPOLESTR pszTitle; HRESULT hr = AMGetWideString(wszTitle, &pszTitle); if(FAILED(hr)) {NOTE("No caption memory"); return hr;} pPageInfo->cb = sizeof(PROPPAGEINFO); pPageInfo->pszTitle = pszTitle; pPageInfo->pszDocString = NULL; pPageInfo->pszHelpFile = NULL; pPageInfo->dwHelpContext = 0; // Set defaults in case GetDialogSize fails pPageInfo->size.cx = 340; pPageInfo->size.cy = 150; MyGetDialogSize(m_DialogId, DialogProc, 0L, &pPageInfo->size); return NOERROR; }
/** Perform op->name on each node of op->k_closest or carry out op->service(). */ void KDA_Map(KDA_Operation* op) { NOTE_F; if (op->name) { printf("map: %s \n", op->name); for (struct ilist_item* item = op->k_closest->head; item; item = item->next) { KDA_Neighbor* n = (KDA_Neighbor*) item->data; if (n->id == id) continue; MPIRPC_Call(n->node, op->name, op->args, op, op->proceed); } } else if (op->query) { NOTE("op->query"); op->query->service(op); } else assert(false); op->returned = list_create(); }
/** Return the KDA_Neighbor for this MPIRPC_Node. Could fail if other_id is not in local neighbor table. */ KDA_Neighbor* KDA_Neighbor_node(MPIRPC_Node node) { int i; struct list_item* item; NOTE_F; for (i = 0; i < KDA_SPACE_SIZE; i++) { for (item = k_bucket[i]->head; item; item = item->next) { KDA_Neighbor* n = (KDA_Neighbor*) item->data; if (node.comm == n->node.comm) return n; } } for (item = clients->head; item; item = item->next) { KDA_Neighbor* n = (KDA_Neighbor*) item->data; if (node.comm == n->node.comm) return n; } NOTE("KDA_Neighbor_node: NULL!"); return NULL; }
void usb_register_callback(struct usb_sock_t *usb) { IGNORE(usb); int status = libusb_hotplug_register_callback( NULL, LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT, // Note: libusb's enum has no default value // a bug has been filled with libusb. // Please switch the below line to 0 // once the issue has been fixed in // deployed versions of libusb // https://github.com/libusb/libusb/issues/35 // 0, LIBUSB_HOTPLUG_ENUMERATE, g_options.vendor_id, g_options.product_id, LIBUSB_HOTPLUG_MATCH_ANY, &usb_exit_on_unplug, NULL, NULL); if (status == LIBUSB_SUCCESS) { pthread_t thread_handle; pthread_create(&thread_handle, NULL, &usb_pump_events, NULL); NOTE("Registered unplug callback"); } else ERR("Failed to register unplug callback"); }
void Daemon::grouped( Channel channel ) { NOTE(); OutputMessage response( MessageType::Control ); if ( _state != State::FormingGroup ) { response.tag( Code::Refuse ); channel->send( response ); return; } Channel top, bottom; std::tie( top, bottom ) = Communicator::socketPair(); response.tag( Code::OK ); channel->send( response ); int pid = ::fork(); if ( pid == -1 ) throw brick::net::SystemException( "fork" ); if ( pid == 0 ) becomeChild( std::move( bottom ) ); else { _childPid = pid; becomeParent( std::move( top ) ); } }
Session& RTMFPServer::createSession(const Peer& peer,Cookie& cookie) { Target* pTarget=_pCirrus; if(_middle) { if(!cookie.pTarget) { cookie.pTarget = new Target(peer.address,&cookie); memcpy((UInt8*)cookie.pTarget->peerId,peer.id,ID_SIZE); memcpy((UInt8*)peer.id,cookie.pTarget->id,ID_SIZE); NOTE("Mode 'man in the middle' : to connect to peer '%s' use the id :\n%s",Util::FormatHex(cookie.pTarget->peerId,ID_SIZE).c_str(),Util::FormatHex(cookie.pTarget->id,ID_SIZE).c_str()); } else pTarget = cookie.pTarget; } ServerSession* pSession; if(pTarget) { pSession = new Middle(_sessions.nextId(),cookie.farId,peer,cookie.decryptKey(),cookie.encryptKey(),*this,_sessions,*pTarget); if(_pCirrus==pTarget) pSession->pTarget = cookie.pTarget; DEBUG("Wait cirrus handshaking"); pSession->manage(); // to wait the cirrus handshake } else { pSession = new ServerSession(_sessions.nextId(),cookie.farId,peer,cookie.decryptKey(),cookie.encryptKey(),*this); pSession->pTarget = cookie.pTarget; } _sessions.add(pSession); return *pSession; }
/** Blocking call. */ CMPI_RETURN //cmpi_put(char* key, char* value, int length) cmpi_put(char* key, void* value, int length) { struct inlist_item* item; MPIRPC_Node node; SHOW_FS(key); int i = inlist_random(contacts); MPIRPC_Node_make(MPI_COMM_WORLD, i, &node); MPIRPC* lookup = DENSE_Lookup_k(node, key); MPIRPC_Wait(lookup); struct inlist* ranks = inlist_parse(lookup->result); free(lookup->result); MPIRPC_Free(lookup); NOTE("got ranks: "); DEBUG(inlist_printf(ranks)); for (item = ranks->head; item; item = item->next) { SHOW_I(item->data); MPIRPC_Node_make(MPI_COMM_WORLD, item->data, &node); MPIRPC* rpc = DENSE_Store(node, key, value, length); MPIRPC_Wait(rpc); MPIRPC_Free(rpc); } inlist_free(ranks); DONE; return CMPI_SUCCESS; }
/** Form client->node connections */ void KDA_Attach(struct list* contacts) { NOTE_F; MPIRPC_Comm_add(MPI_COMM_WORLD); for (int i = 0; i < 3; i++) { int other_rank = rand_lt(mpi_size/2); MPIRPC_Node node; MPIRPC_Node_make(MPI_COMM_WORLD, other_rank, &node); char* result = MPIRPC_Block(node, "get_id", NULL); NOTE("got id"); KDA_ID other_id; sscanf(result, "%X", &other_id); free(result); KDA_Neighbor* neighbor = KDA_Neighbor_create_id(other_id, node); if (KDA_Attach_to(neighbor, contacts)) { NOTE_XI("added neighbor: ", other_id, neighbor->node.comm); assert(neighbor->node.comm != MPI_COMM_NULL); } else free(neighbor); } }
// // GetStaticImage // // Return a copy of the current image in the video renderer // HRESULT CVideoText::GetStaticImage(long *pBufferSize,long *pDIBImage) { NOTE("Entering GetStaticImage"); IMediaSample *pMediaSample; pMediaSample = m_pRenderer->GetCurrentSample(); RECT SourceRect; // Is there an image available if (pMediaSample == NULL) return E_UNEXPECTED; // Find a scaled source rectangle for the current bitmap m_pRenderer->m_DrawImage.GetSourceRect(&SourceRect); SourceRect = m_pRenderer->m_DrawImage.ScaleSourceRect(&SourceRect); VIDEOINFOHEADER *pVideoInfo = (VIDEOINFOHEADER *) m_pRenderer->m_mtIn.Format(); // Call the base class helper method to do the work HRESULT hr = CopyImage(pMediaSample, // Buffer containing image pVideoInfo, // Type representing bitmap pBufferSize, // Size of buffer for DIB (BYTE*) pDIBImage, // Data buffer for output &SourceRect); // Current source position pMediaSample->Release(); return hr; } // GetStaticImage
static void dnssd_callback(AvahiEntryGroup *g, /* I - Service */ AvahiEntryGroupState state, /* I - Registration state */ void *context) /* I - Printer */ { (void)context; if (g == NULL || (g_options.dnssd_data->ipp_ref != NULL && g_options.dnssd_data->ipp_ref != g)) return; switch (state) { case AVAHI_ENTRY_GROUP_ESTABLISHED : /* The entry group has been established successfully */ NOTE("Service entry for the printer successfully established."); break; case AVAHI_ENTRY_GROUP_COLLISION : ERR("DNS-SD service name for this printer already exists"); case AVAHI_ENTRY_GROUP_FAILURE : ERR("Entry group failure: %s\n", avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(g)))); g_options.terminate = 1; break; case AVAHI_ENTRY_GROUP_UNCOMMITED: case AVAHI_ENTRY_GROUP_REGISTERING: default: break; } }
void Daemon::run( InputMessage &message, Channel channel ) { NOTE(); { OutputMessage response( MessageType::Control ); if ( _state != State::Grouped ) { Logger::log( "command Run came at bad moment" ); response.tag( Code::Refuse ); channel->send( response ); return; } response.tag( Code::OK ); channel->send( response ); channel->receive( message, [&,this] ( size_t length ) { char *arg = new char[ length + 1 ](); _arguments.emplace_back( arg ); return arg; } ); message.clear(); channel->receiveHeader( message ); if ( message.tag< Code >() != Code::Start ) { throw ResponseException( { Code::Start }, message.tag< Code >() ); } } _runMain = true; }
STDMETHODIMP CBasePropertyPage::GetPageInfo(__out LPPROPPAGEINFO pPageInfo) { CheckPointer(pPageInfo,E_POINTER); WCHAR wszTitle[STR_MAX_LENGTH]; WideStringFromResource(wszTitle,m_TitleId); // Allocate dynamic memory for the property page title LPOLESTR pszTitle; HRESULT hr = AMGetWideString(wszTitle, &pszTitle); if (FAILED(hr)) { NOTE("No caption memory"); return hr; } pPageInfo->cb = sizeof(PROPPAGEINFO); pPageInfo->pszTitle = pszTitle; pPageInfo->pszDocString = NULL; pPageInfo->pszHelpFile = NULL; pPageInfo->dwHelpContext = 0; // Set defaults in case GetDialogSize fails pPageInfo->size.cx = 340; pPageInfo->size.cy = 150; GetDialogSize(m_DialogId, DialogProc,0L,&pPageInfo->size); return NOERROR; }
/* - skip - skip white space and comments in expanded form ^ static VOID skip(struct vars *); */ static void skip( struct vars *v) { const chr *start = v->now; assert(v->cflags®_EXPANDED); for (;;) { while (!ATEOS() && iscspace(*v->now)) { v->now++; } if (ATEOS() || *v->now != CHR('#')) { break; /* NOTE BREAK OUT */ } assert(NEXT1('#')); while (!ATEOS() && *v->now != CHR('\n')) { v->now++; } /* * Leave the newline to be picked up by the iscspace loop. */ } if (v->now != start) { NOTE(REG_UNONPOSIX); } }
/* * element - map collating-element name to celt */ static celt element(struct vars * v, /* context */ const chr *startp, /* points to start of name */ const chr *endp) /* points just past end of name */ { const struct cname *cn; size_t len; /* generic: one-chr names stand for themselves */ assert(startp < endp); len = endp - startp; if (len == 1) return *startp; NOTE(REG_ULOCALE); /* search table */ for (cn = cnames; cn->name != NULL; cn++) { if (strlen(cn->name) == len && pg_char_and_wchar_strncmp(cn->name, startp, len) == 0) { break; /* NOTE BREAK OUT */ } } if (cn->name != NULL) return CHR(cn->code); /* couldn't find it */ ERR(REG_ECOLLATE); return 0; }
bool xplayerNPObject::Invoke (NPIdentifier aName, const NPVariant *argv, uint32_t argc, NPVariant *_result) { if (!IsValid ()) return false; NOTE (g_print ("xplayerNPObject::Invoke [%p] %s\n", (void*) this, NPN_UTF8FromIdentifier (aName))); int methodIndex = GetClass()->GetMethodIndex (aName); if (methodIndex >= 0) return InvokeByIndex (methodIndex, argv, argc, _result); if (aName == NPN_GetStringIdentifier ("__noSuchMethod__")) { /* http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object:_noSuchMethod */ if (!CheckArgv (argv, argc, 2, NPVariantType_String, NPVariantType_Object)) return false; const char *id = NPVARIANT_TO_STRING (argv[0]).UTF8Characters; g_message ("NOTE: site calls unknown function \"%s\" on xplayerNPObject %p\n", id ? id : "(null)", (void*) this); /* Silently ignore the invocation */ VOID_TO_NPVARIANT (*_result); return true; } return Throw ("No method with this name exists."); }