/* Execute ISM event process. */ int ospf_ism_event (struct thread *thread) { int event; int next_state; struct ospf_interface *oi; oi = THREAD_ARG (thread); event = THREAD_VAL (thread); /* Call function. */ next_state = (*(ISM [oi->status][event].func))(oi); if (! next_state) next_state = ISM [oi->status][event].next_state; if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) zlog (NULL, LOG_INFO, "ISM[%s]: %s (%s)", IF_NAME (oi), LOOKUP (ospf_ism_status_msg, oi->status), ospf_ism_event_str[event]); /* If status is changed. */ if (next_state != oi->status) ism_change_status (oi, next_state); /* Make sure timer is set. */ ism_timer_set (oi); return 0; }
int csAxisDrill( char *operation, char *axis, char *surface ) { static LWCommandCode ccode; ModData *md = getModData(); DynaValue argv[ 3 ]; assert( md->edit == NULL ); argv[ 0 ].type = DY_STRING; argv[ 0 ].str.buf = operation; argv[ 0 ].str.bufLen = 0; argv[ 1 ].type = DY_STRING; argv[ 1 ].str.buf = axis; argv[ 1 ].str.bufLen = 0; if ( surface ) { argv[ 2 ].type = DY_STRING; argv[ 2 ].str.buf = surface; argv[ 2 ].str.bufLen = 0; } else argv[ 2 ].type = DY_NULL; LOOKUP( "AXISDRILL" ); EXECUTE( 3, argv ); return OK; }
static void rip_auth_write_leading_rte ( struct stream *s, struct rip_interface *ri, const u_int8_t key_id, char *auth_str, u_int16_t main_body_len ) { u_int8_t dlen; if (IS_RIP_DEBUG_AUTH) zlog_debug ("writing authentication header for %uB of main body", main_body_len); stream_putw (s, RIP_FAMILY_AUTH); switch (ri->auth_type) { case RIP_AUTH_SIMPLE_PASSWORD: { u_int8_t padded_simple_password[RIP_AUTH_SIMPLE_SIZE] = { 0 }; memcpy (padded_simple_password, auth_str, MIN (RIP_AUTH_SIMPLE_SIZE, strlen (auth_str))); stream_putw (s, RIP_AUTH_SIMPLE_PASSWORD); stream_put (s, padded_simple_password, RIP_AUTH_SIMPLE_SIZE); break; } case RIP_AUTH_HASH: if (IS_RIP_DEBUG_AUTH) zlog_debug ("hash algorithm is '%s'", LOOKUP (hash_algo_str, ri->hash_algo)); stream_putw (s, RIP_AUTH_HASH); stream_putw (s, main_body_len); stream_putc (s, key_id); switch (ri->hash_algo) { case HASH_KEYED_MD5: /* Auth Data Len. Set 16 for MD5 authentication data. Older ripds * however expect RIP_HEADER_SIZE + HASH_SIZE_MD5 so we allow for this * to be configurable. */ dlen = ri->md5_auth_len; break; case HASH_HMAC_SHA1: case HASH_HMAC_SHA256: case HASH_HMAC_SHA384: case HASH_HMAC_SHA512: dlen = hash_digest_length[ri->hash_algo]; break; default: assert (0); } if (IS_RIP_DEBUG_AUTH) zlog_debug ("declared auth data length is %uB", dlen); stream_putc (s, dlen); stream_putl (s, time (NULL)); /* Sequence Number (non-decreasing). */ stream_putl (s, 0); /* reserved, MBZ */ stream_putl (s, 0); /* reserved, MBZ */ break; default: assert (0); } }
/* FSM error, unexpected event. This is error of BGP connection. So cut the peer and change to Idle status. */ static int bgp_fsm_event_error (struct peer *peer) { plog_err (peer->log, "%s [FSM] unexpected packet received in state %s", peer->host, LOOKUP (bgp_status_msg, peer->status)); return bgp_stop_with_notify (peer, BGP_NOTIFY_FSM_ERR, 0); }
static void ism_change_callback (struct in_addr ifaddr, struct in_addr area_id, u_char state) { printf ("ism_change: ifaddr: %s ", inet_ntoa (ifaddr)); printf ("area_id: %s\n", inet_ntoa (area_id)); printf ("state: %d [%s]\n", state, LOOKUP (ospf_ism_state_msg, state)); }
static inline struct objc_slot * real_slot_lookup(struct objc_object ** obj, uint32_t sel, id sender) { id object = *obj; struct objc_slot * ret = NULL; do { if(LOOKUP(object)) { return (*LOOKUP(object))(obj, object, sel, sender); } if(SLOTS(object)) { ret = SparseArrayLookup(SLOTS(object), sel); } object = object->isa; } while(object != NULL && ret == NULL); return ret; }
static void nsm_change_callback (struct in_addr ifaddr, struct in_addr nbraddr, struct in_addr router_id, u_char state) { printf ("nsm_change: ifaddr: %s ", inet_ntoa (ifaddr)); printf ("nbraddr: %s\n", inet_ntoa (nbraddr)); printf ("router_id: %s\n", inet_ntoa (router_id)); printf ("state: %d [%s]\n", state, LOOKUP (ospf_nsm_state_msg, state)); }
/* ============================================================================= * rbtree_get * ============================================================================= */ void* rbtree_get (rbtree_t* r, void* key) { node_t* n = LOOKUP(r, key); if (n != NULL) { void* val = LDF(n, v); return val; } return NULL; }
/* Execute event process. */ int bgp_event (struct thread *thread) { int ret = 0; int event; int next; struct peer *peer; peer = THREAD_ARG (thread); event = THREAD_VAL (thread); /* Logging this event. */ next = FSM [peer->status -1][event - 1].next_state; if (BGP_DEBUG (fsm, FSM) && peer->status != next) plog_debug (peer->log, "%s [FSM] %s (%s->%s)", peer->host, bgp_event_str[event], LOOKUP (bgp_status_msg, peer->status), LOOKUP (bgp_status_msg, next)); /* Call function. */ if (FSM [peer->status -1][event - 1].func) ret = (*(FSM [peer->status - 1][event - 1].func))(peer); /* When function do not want proceed next job return -1. */ if (ret >= 0) { /* If status is changed. */ if (next != peer->status) { /* Transition into Clearing must /always/ clear all routes.. */ if (next == Clearing) bgp_clear_route_all (peer); bgp_fsm_change_status (peer, next); } /* Make sure timer is set. */ bgp_timer_set (peer); } return ret; }
int csSelInvert( void ) { static LWCommandCode ccode; ModData *md = getModData(); assert( md->edit == NULL ); LOOKUP( "SEL_INVERT" ); EXECUTE( 0, NULL ); return OK; }
int csSelUnhide( void ) { static LWCommandCode ccode; ModData *md = getModData(); assert( md->edit == NULL ); LOOKUP( "SEL_UNHIDE" ); EXECUTE( 0, NULL ); return OK; }
int csMakeText( char *text, int index, char *cornertype, double spacing, double scale, char *axis, double *pos ) { static LWCommandCode ccode; ModData *md = getModData(); DynaValue argv[ 7 ]; assert( md->edit == NULL ); argv[ 0 ].type = DY_STRING; argv[ 0 ].str.buf = text; argv[ 0 ].str.bufLen = 0; argv[ 1 ].type = DY_INTEGER; argv[ 1 ].intv.value = index; if ( cornertype ) { argv[ 2 ].type = DY_STRING; argv[ 2 ].str.buf = cornertype; argv[ 2 ].str.bufLen = 0; } else argv[ 2 ].type = DY_NULL; if ( spacing != 0.0 ) { argv[ 3 ].type = DY_FLOAT; argv[ 3 ].flt.value = spacing; } else argv[ 3 ].type = DY_NULL; if ( scale != 0.0 ) { argv[ 4 ].type = DY_FLOAT; argv[ 4 ].flt.value = scale; } else argv[ 4 ].type = DY_NULL; if ( axis ) { argv[ 5 ].type = DY_STRING; argv[ 5 ].str.buf = axis; argv[ 5 ].str.bufLen = 0; } else argv[ 5 ].type = DY_NULL; if ( pos ) { argv[ 6 ].type = DY_VFLOAT; argv[ 6 ].fvec.val[ 0 ] = pos[ 0 ]; argv[ 6 ].fvec.val[ 1 ] = pos[ 1 ]; argv[ 6 ].fvec.val[ 2 ] = pos[ 2 ]; } else argv[ 6 ].type = DY_NULL; LOOKUP( "MAKETEXT" ); EXECUTE( 7, argv ); return OK; }
static MCMsgT * MCGetMsg(MCSetT *set, int msgId) { MCMsgT *msg; int32_t lo, hi, cur, dir; if (set == NULL || set->invalid || msgId <= 0) return (NULL); LOOKUP(set, msg, msgId, ntohl(set->numMsgs), u.msgs); return (msg); }
/***************************************************************************** * mmdevice.c : Windows Multimedia Device API audio output plugin for VLC ***************************************************************************** * Copyright (C) 2012-2014 Rémi Denis-Courmont * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #ifdef HAVE_CONFIG_H # include <config.h> #endif #define INITGUID #define COBJMACROS #define CONST_VTABLE #include <stdlib.h> #include <math.h> #include <assert.h> #include <audiopolicy.h> #include <mmdeviceapi.h> #include <endpointvolume.h> DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14); #include <vlc_common.h> #include <vlc_plugin.h> #include <vlc_aout.h> #include <vlc_charset.h> #include <vlc_modules.h> #include "audio_output/mmdevice.h" #if (_WIN32_WINNT < 0x600) static VOID WINAPI (*InitializeConditionVariable)(PCONDITION_VARIABLE); static BOOL WINAPI (*SleepConditionVariableCS)(PCONDITION_VARIABLE, PCRITICAL_SECTION, DWORD); static VOID WINAPI (*WakeConditionVariable)(PCONDITION_VARIABLE); #define LOOKUP(s) \ if (((s) = (void *)GetProcAddress(h, #s)) == NULL) return FALSE BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID); /* avoid warning */ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, LPVOID reserved) { (void) dll; (void) reserved; switch (reason) { case DLL_PROCESS_ATTACH: { HANDLE h = GetModuleHandle(TEXT("kernel32.dll")); if (unlikely(h == NULL)) return FALSE; LOOKUP(InitializeConditionVariable); LOOKUP(SleepConditionVariableCS); LOOKUP(WakeConditionVariable); break; } } return TRUE; }
int csInvertHide( void ) { static LWCommandCode ccode; ModData *md = getModData(); assert( md->edit == NULL ); LOOKUP( "INVERT_HIDE" ); EXECUTE( 0, NULL ); return OK; }
static int findApiSymbols(void) { HMODULE dll = NULL; #define LOOKUP_NOFALLBACK(x, reallyLook) \ symLookup(dll, (PHYSFS_FARPROC *) &p##x, #x, reallyLook, NULL) #define LOOKUP(x, reallyLook) \ symLookup(dll, (PHYSFS_FARPROC *) &p##x, #x, \ reallyLook, (PHYSFS_FARPROC) fallback##x) /* Apparently Win9x HAS the Unicode entry points, they just don't WORK. */ /* ...so don't look them up unless we're on NT+. (see osHasUnicode.) */ dll = libUserEnv = LoadLibraryA("userenv.dll"); if (dll != NULL) LOOKUP_NOFALLBACK(GetUserProfileDirectoryW, osHasUnicode); /* !!! FIXME: what do they call advapi32.dll on Win64? */ dll = libAdvApi32 = LoadLibraryA("advapi32.dll"); if (dll != NULL) LOOKUP(GetUserNameW, osHasUnicode); /* !!! FIXME: what do they call kernel32.dll on Win64? */ dll = libKernel32 = LoadLibraryA("kernel32.dll"); if (dll != NULL) { LOOKUP_NOFALLBACK(GetFileAttributesExA, 1); LOOKUP_NOFALLBACK(GetFileAttributesExW, osHasUnicode); LOOKUP_NOFALLBACK(FindFirstFileW, osHasUnicode); LOOKUP_NOFALLBACK(FindNextFileW, osHasUnicode); LOOKUP(GetModuleFileNameW, osHasUnicode); LOOKUP(FormatMessageW, osHasUnicode); LOOKUP(GetFileAttributesW, osHasUnicode); LOOKUP(GetCurrentDirectoryW, osHasUnicode); LOOKUP(CreateDirectoryW, osHasUnicode); LOOKUP(RemoveDirectoryW, osHasUnicode); LOOKUP(CreateFileW, osHasUnicode); LOOKUP(DeleteFileW, osHasUnicode); } /* if */ #undef LOOKUP_NOFALLBACK #undef LOOKUP return(1); } /* findApiSymbols */
/* Called after event occured, this function change status and reset read/write and timer thread. */ void bgp_fsm_change_status (struct peer *peer, int status) { bgp_dump_state (peer, peer->status, status); /* Transition into Clearing or Deleted must /always/ clear all routes.. * (and must do so before actually changing into Deleted.. */ if (status >= Clearing) bgp_clear_route_all (peer); /* Preserve old status and change into new status. */ peer->ostatus = peer->status; peer->status = status; if (BGP_DEBUG (normal, NORMAL)) zlog_debug ("%s went from %s to %s", peer->host, LOOKUP (bgp_status_msg, peer->ostatus), LOOKUP (bgp_status_msg, peer->status)); }
/* Execute NSM event process. */ int ospf_nsm_event (struct thread *thread) { int event; int next_state; struct ospf_neighbor *nbr; struct in_addr router_id; int old_state; struct ospf_interface *oi; nbr = THREAD_ARG (thread); event = THREAD_VAL (thread); router_id = nbr->router_id; old_state = nbr->state; oi = nbr->oi ; /* Call function. */ next_state = (*(NSM [nbr->state][event].func))(nbr); /* When event is NSM_KillNbr or InactivityTimer, the neighbor is deleted. */ if (event == NSM_KillNbr || event == NSM_InactivityTimer) { if (IS_DEBUG_OSPF (nsm, NSM_EVENTS)) zlog_debug ("NSM[%s:%s]: neighbor deleted", IF_NAME (oi), inet_ntoa (router_id)); /* Timers are canceled in ospf_nbr_free, moreover we cannot call nsm_timer_set here because nbr is freed already!!!*/ /*nsm_timer_set (nbr);*/ return 0; } if (! next_state) next_state = NSM [nbr->state][event].next_state; if (IS_DEBUG_OSPF (nsm, NSM_EVENTS)) zlog_debug ("NSM[%s:%s]: %s (%s)", IF_NAME (oi), inet_ntoa (nbr->router_id), LOOKUP (ospf_nsm_state_msg, nbr->state), ospf_nsm_event_str [event]); /* If state is changed. */ if (next_state != nbr->state) nsm_change_state (nbr, next_state); /* Make sure timer is set. */ nsm_timer_set (nbr); return 0; }
static MCSetT * MCGetSet(MCCatT *cat, int setId) { MCSetT *set; int32_t lo, hi, cur, dir; if (cat == NULL || setId <= 0) return (NULL); LOOKUP(cat, set, setId, cat->numSets, sets); if (set->invalid && loadSet(cat, set) <= 0) return (NULL); return (set); }
ent* LOOKUP_R(ent* e, const char* fmt, ...) { char buf[128]; va_list va; va_start(va, fmt); vprintf(buf, 128, fmt, va, false); va_end(va); vector* v = ksplit_to_vector(buf, "/"); ent * ret = LOOKUP(e, v, 0); cleanup_vector(v); return ret; }
/* ============================================================================= * rbtree_delete * -- Returns TRUE if key exists * ============================================================================= */ bool_t rbtree_delete (rbtree_t* r, void* key) { node_t* node = NULL; node = LOOKUP(r, key); if (node != NULL) { node = DELETE(r, node); } if (node != NULL) { releaseNode(node); } return ((node != NULL) ? TRUE : FALSE); }
int ompt_initialize(ompt_function_lookup_t lookup, const char *version, int ompt_version) { int state; const char *state_name; int ok; LOOKUP(lookup,ompt_enumerate_state); printf("enumerate ompt states:\n" "----------------------\n"); for (ok = ompt_enumerate_state(ompt_state_first, &state, &state_name); ok; ok = ompt_enumerate_state(state, &state, &state_name)) { printf("state name = %s, id = %x\n", state_name, state); } return 1; }
static int bind_objc_Cocoa_ApplicationServices(void) { static Boolean bound = false; if (bound) return 0; bound = true; void* cf_dylib; cf_dylib = dlopen("/usr/lib/libobjc.dylib", RTLD_LAZY); if (!cf_dylib) return -1; #define LOOKUP(NAME) do { \ py2app_ ## NAME = (__typeof__(py2app_ ## NAME))dlsym( \ cf_dylib, #NAME); \ if (!py2app_ ## NAME) return -1; \ } while (0) LOOKUP(objc_getClass); LOOKUP(sel_getUid); LOOKUP(objc_msgSend); cf_dylib = dlopen( "/System/Library/Frameworks/Cocoa.framework/Cocoa", RTLD_LAZY); if (!cf_dylib) return -1; LOOKUP(NSLog); LOOKUP(NSApplicationLoad); LOOKUP(NSRunAlertPanel); cf_dylib = dlopen( "/System/Library/Frameworks/ApplicationServices.framework/ApplicationServices", RTLD_LAZY); if (!cf_dylib) return -1; LOOKUP(GetCurrentProcess); LOOKUP(SetFrontProcess); LOOKUP(LSOpenFSRef); LOOKUP(LSFindApplicationForInfo); #undef LOOKUP return 0; }
AIOEither Pop( AIOFifoTYPE *fifo ) { TYPE tmp; AIOEither retval = {0}; int tmpval = fifo->Read( (AIOFifo*)fifo, &tmp, sizeof(TYPE) ); if( tmpval <= 0 ) { retval.left = tmpval; } else { AIOEitherSetRight( &retval, LOOKUP( uint32_t ), &tmp ); } return retval; }
void ndnx_lsa_header_dump (struct lsa_header *lsah) { const char *lsah_type = LOOKUP (ospf_lsa_type_msg, lsah->type); writeLogg(ospfn->logFile,__FILE__,__FUNCTION__,__LINE__," LSA Header\n"); writeLogg(ospfn->logFile,__FILE__,__FUNCTION__,__LINE__," LS age %d\n", ntohs (lsah->ls_age)); writeLogg(ospfn->logFile,__FILE__,__FUNCTION__,__LINE__," Options %d (%s)\n", lsah->options, ospf_options_dump (lsah->options)); writeLogg(ospfn->logFile,__FILE__,__FUNCTION__,__LINE__," LS type %d (%s)\n", lsah->type, (lsah->type ? lsah_type : "unknown type")); writeLogg(ospfn->logFile,__FILE__,__FUNCTION__,__LINE__," Link State ID %s\n", inet_ntoa (lsah->id)); if( lsah->type == 9 || lsah->type == 10 || lsah->type ==11) { writeLogg(ospfn->logFile,__FILE__,__FUNCTION__,__LINE__," Opaque Type %d\n" ,ntohl(lsah->id.s_addr)>>24); writeLogg(ospfn->logFile,__FILE__,__FUNCTION__,__LINE__," Opaque Id %d\n" ,ntohl(lsah->id.s_addr)& LSID_OPAQUE_ID_MASK); }
/* Called after event occured, this function change status and reset read/write and timer thread. */ void bgp_fsm_change_status (struct peer *peer, int status) { bgp_dump_state (peer, peer->status, status); /* Transition into Clearing or Deleted must /always/ clear all routes.. * (and must do so before actually changing into Deleted.. */ if (status >= Clearing) { bgp_clear_route_all (peer); /* If no route was queued for the clear-node processing, generate the * completion event here. This is needed because if there are no routes * to trigger the background clear-node thread, the event won't get * generated and the peer would be stuck in Clearing. Note that this * event is for the peer and helps the peer transition out of Clearing * state; it should not be generated per (AFI,SAFI). The event is * directly posted here without calling clear_node_complete() as we * shouldn't do an extra unlock. This event will get processed after * the state change that happens below, so peer will be in Clearing * (or Deleted). */ if (!work_queue_is_scheduled (peer->clear_node_queue)) BGP_EVENT_ADD (peer, Clearing_Completed); } /* Preserve old status and change into new status. */ peer->ostatus = peer->status; peer->status = status; if (BGP_DEBUG (normal, NORMAL)) zlog_debug ("%s went from %s to %s", peer->host, LOOKUP (bgp_status_msg, peer->ostatus), LOOKUP (bgp_status_msg, peer->status)); }
/* Execute event process. */ int bgp_event (struct thread *thread) { int ret; int event; int next; struct peer *peer; peer = THREAD_ARG (thread); event = THREAD_VAL (thread); /* Logging this event. */ next = FSM [peer->status -1][event - 1].next_state; if (BGP_DEBUG (fsm, FSM)) plog_info (peer->log, "%s [FSM] %s (%s->%s)", peer->host, bgp_event_str[event], LOOKUP (bgp_status_msg, peer->status), LOOKUP (bgp_status_msg, next)); /* Call function. */ ret = (*(FSM [peer->status - 1][event - 1].func))(peer); /* When function do not want proceed next job return -1. */ if (ret < 0) return ret; /* If status is changed. */ if (next != peer->status) bgp_fsm_change_status (peer, next); /* Make sure timer is set. */ bgp_timer_set (peer); return 0; }
static void add_count_column_to_bookmarks_table (void) { const gchar count_column_name[] = "count"; count_column = grn_column_create(&context, bookmarks, count_column_name, strlen(count_column_name), NULL, 0, LOOKUP("<int>")); grn_test_assert_context(&context); cut_set_message("%s", cut_take_string(grn_collect_logger_to_string(logger))); cut_assert_not_null(count_column); }
int csSmoothScale( double offset ) { static LWCommandCode ccode; ModData *md = getModData(); DynaValue argv; assert( md->edit == NULL ); argv.type = DY_FLOAT; argv.flt.value = offset; LOOKUP( "SMOOTHSCALE" ); EXECUTE( 1, &argv ); return OK; }
int csSelHide( char *state ) { static LWCommandCode ccode; ModData *md = getModData(); DynaValue argv; assert( md->edit == NULL ); argv.type = DY_STRING; argv.str.buf = state; argv.str.bufLen = 0; LOOKUP( "SEL_HIDE" ); EXECUTE( 1, &argv ); return OK; }