/*********************************************************************** * PCM_StreamConvert * */ static LRESULT PCM_StreamConvert(PACMDRVSTREAMINSTANCE adsi, PACMDRVSTREAMHEADER adsh) { AcmPcmData* apd = (AcmPcmData*)adsi->dwDriver; DWORD nsrc = NUM_OF(adsh->cbSrcLength, adsi->pwfxSrc->nBlockAlign); DWORD ndst = NUM_OF(adsh->cbDstLength, adsi->pwfxDst->nBlockAlign); TRACE("(%p, %p)\n", adsi, adsh); TRACE("nsrc=%d,adsh->cbSrcLength=%d\n", nsrc, adsh->cbSrcLength); TRACE("ndst=%d,adsh->cbDstLength=%d\n", ndst, adsh->cbDstLength); TRACE("src [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%u, nAvgBytesPerSec=%u, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n", adsi->pwfxSrc->wFormatTag, adsi->pwfxSrc->nChannels, adsi->pwfxSrc->nSamplesPerSec, adsi->pwfxSrc->nAvgBytesPerSec, adsi->pwfxSrc->nBlockAlign, adsi->pwfxSrc->wBitsPerSample, adsi->pwfxSrc->cbSize); TRACE("dst [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%u, nAvgBytesPerSec=%u, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n", adsi->pwfxDst->wFormatTag, adsi->pwfxDst->nChannels, adsi->pwfxDst->nSamplesPerSec, adsi->pwfxDst->nAvgBytesPerSec, adsi->pwfxDst->nBlockAlign, adsi->pwfxDst->wBitsPerSample, adsi->pwfxDst->cbSize); if (adsh->fdwConvert & ~(ACM_STREAMCONVERTF_BLOCKALIGN| ACM_STREAMCONVERTF_END| ACM_STREAMCONVERTF_START)) { FIXME("Unsupported fdwConvert (%08x), ignoring it\n", adsh->fdwConvert); } /* ACM_STREAMCONVERTF_BLOCKALIGN * currently all conversions are block aligned, so do nothing for this flag * ACM_STREAMCONVERTF_END * no pending data, so do nothing for this flag */ if ((adsh->fdwConvert & ACM_STREAMCONVERTF_START) && (adsi->fdwDriver & PCM_RESAMPLE)) { } /* do the job */ if (adsi->fdwDriver & PCM_RESAMPLE) { DWORD nsrc2 = nsrc; DWORD ndst2 = ndst; apd->cvt.cvtChangeRate(adsi->pwfxSrc->nSamplesPerSec, adsh->pbSrc, &nsrc2, adsi->pwfxDst->nSamplesPerSec, adsh->pbDst, &ndst2); nsrc -= nsrc2; ndst -= ndst2; } else { if (nsrc < ndst) ndst = nsrc; else nsrc = ndst; /* nsrc is now equal to ndst */ apd->cvt.cvtKeepRate(adsh->pbSrc, nsrc, adsh->pbDst); } adsh->cbSrcLengthUsed = nsrc * adsi->pwfxSrc->nBlockAlign; adsh->cbDstLengthUsed = ndst * adsi->pwfxDst->nBlockAlign; return MMSYSERR_NOERROR; }
/* fr_findfirst * * Fill in DTA.filename, DTA.path and DTA.attribute for the first file * matching the wildcard specification in path. Return zero if a file * is found, or non-zero if a file was not found or an error occurred. */ int fr_findfirst(char const *path) // Find 1st file (or subdir) meeting path/filespec { if (s_find_context != INVALID_HANDLE_VALUE) { BOOL result = FindClose(s_find_context); _ASSERTE(result); } SetLastError(0); s_find_context = FindFirstFile(path, &s_find_data); if (INVALID_HANDLE_VALUE == s_find_context) { return GetLastError() || -1; } _ASSERTE(strlen(path) < NUM_OF(s_find_base)); strcpy(s_find_base, path); { char *whack = strrchr(s_find_base, '\\'); if (whack != nullptr) { whack[1] = 0; } } fill_dta(); return 0; }
static void fill_dta() { _snprintf(DTA.path, NUM_OF(DTA.path), "%s%s", s_find_base, s_find_data.cFileName); DTA.attribute = DTA_FLAG(FILE_ATTRIBUTE_DIRECTORY, SUBDIR) | DTA_FLAG(FILE_ATTRIBUTE_SYSTEM, SYSTEM) | DTA_FLAG(FILE_ATTRIBUTE_HIDDEN, HIDDEN); strcpy(DTA.filename, s_find_data.cFileName); }
/* keyboard_event ** ** Map a keypress into an event id. */ static fractint_event keyboard_event(int key) { struct { int key; fractint_event event; } mapping[] = { FIK_CTL_A, FE_ANT_AUTOMATON, FIK_CTL_B, FE_BROWSE_PARAMS, FIK_CTL_E, FE_EVOLVER_PARAMS, FIK_CTL_F, FE_SOUND_PARAMS, FIK_BACKSPACE, FE_REVERSE_HISTORY, FIK_TAB, FE_IMAGE_INFO, FIK_CTL_P, FE_PRINT_IMAGE, FIK_CTL_S, FE_STEREOGRAM, FIK_ESC, FE_QUIT, FIK_SPACE, FE_TOGGLE_JULIA, FIK_INSERT, FE_RESTART, DELETE, FE_SELECT_VIDEO_MODE, '@', FE_EXECUTE_COMMANDS, '#', FE_3D_OVERLAY, '3', FE_3D_TRANSFORM, 'a', FE_MAKE_STARFIELD, 'b', FE_SAVE_CURRENT_PARAMS, 'c', FE_COLOR_CYCLING_MODE, 'd', FE_COMMAND_SHELL, 'e', FE_EDIT_PALETTE, 'g', FE_GIVE_COMMAND_STRING, 'h', FE_PRIOR_IMAGE, 'j', FE_TOGGLE_INVERSE, 'i', FE_3D_PARAMS, 'o', FE_ORBITS_WINDOW, 'p', FE_PASSES_OPTIONS, 'r', FE_LOAD_IMAGE, 's', FE_SAVE_IMAGE, 't', FE_SELECT_FRACTAL_TYPE, 'v', FE_VIEW_WINDOW_OPTIONS, 'x', FE_BASIC_OPTIONS, 'y', FE_EXTENDED_OPTIONS, 'z', FE_TYPE_SPECIFIC_PARAMS, '-', FE_ROTATE_PALETTE_DOWN, '+', FE_ROTATE_PALETTE_UP }; key = tolower(key); for (int i = 0; i < NUM_OF(mapping); i++) { if (mapping[i].key == key) { return mapping[i].event; } } return FE_UNKNOWN; }
//---------Interpreter_Parse------- // Compare user's input with table of // available commands. void Interpreter_Parse(void){ printf("\n\r--Enter Command--> "); UART_InStringNL(cmd, CMD_LEN); int i = NUM_OF(Commands); while(i--){ if(!strcmp(cmd,Commands[i].name)){ // check for valid command Commands[i].func(); return; } } printf("Command not recognized.\n\r"); }
/* * parse_rtattrs */ int parse_rtattrs (netlink_msg_ctx_t *ctx, struct rtattr *rta, size_t len) { const char *err_msg; err_msg = NULL; if (!parse_rtattrs_(rta, len, ctx->rtattrs, NUM_OF(ctx->rtattrs), &err_msg)) { netlink_msg_ctx_set_err(ctx, err_msg); return 0; } return 1; }
/* * netlink_msg_ctx_add_nh */ static int netlink_msg_ctx_add_nh (netlink_msg_ctx_t *ctx, int if_index, struct rtattr *gateway) { netlink_nh_t *nh; if (ctx->num_nhs + 1 >= NUM_OF(ctx->nhs)) { warn("Too many next hops"); return 0; } nh = &ctx->nhs[ctx->num_nhs]; ctx->num_nhs++; nh->gateway = gateway; nh->if_index = if_index; return 1; }
//------------cmdHelp----------------- // Display all the available commands void cmdHelp(void){ printf("Below is a list of availble commands:\n\r"); // output formating and display command name for(int i = 0; i < NUM_OF(Commands); i++){ if(i+1 <10) printf(" "); else if(i+1 < 100) printf(" "); printf("%d",i+1); printf(") "); // display command name printf("%s",(char*)Commands[i].name); // output formating for(int j = strlen(Commands[i].name); j<CMD_LEN ; j++){ printf("-"); } // display command tag printf("%s\n\r",(char*)Commands[i].tag); } }
/* * parse_multipath_attr */ int parse_multipath_attr (netlink_msg_ctx_t *ctx, struct rtattr *mpath_rtattr) { size_t len, attr_len; struct rtnexthop *rtnh; struct rtattr *rtattrs[RTA_MAX + 1]; struct rtattr *rtattr, *gateway; int if_index; const char *err_msg; rtnh = RTA_DATA(mpath_rtattr); len = RTA_PAYLOAD(mpath_rtattr); for (; len > 0; len -= NLMSG_ALIGN(rtnh->rtnh_len), rtnh = RTNH_NEXT(rtnh)) { if (!RTNH_OK(rtnh, len)) { netlink_msg_ctx_set_err(ctx, "Malformed nh"); return 0; } if (rtnh->rtnh_len <= sizeof(*rtnh)) { netlink_msg_ctx_set_err(ctx, "NH len too small"); return 0; } /* * Parse attributes included in the nexthop. */ err_msg = NULL; if (!parse_rtattrs_(RTNH_DATA(rtnh), rtnh->rtnh_len - sizeof(*rtnh), rtattrs, NUM_OF(rtattrs), &err_msg)) { netlink_msg_ctx_set_err(ctx, err_msg); return 0; } gateway = rtattrs[RTA_GATEWAY]; netlink_msg_ctx_add_nh(ctx, rtnh->rtnh_ifindex, gateway); } return 1; }
static void test_module(DWORD pid, const char* expected[], unsigned num_expected) { HANDLE hSnapshot; PROCESSENTRY32 pe; THREADENTRY32 te; MODULEENTRY32 me; unsigned found[32]; unsigned i; int num = 0; ok(NUM_OF(found) >= num_expected, "Internal: bump found[] size\n"); hSnapshot = pCreateToolhelp32Snapshot( TH32CS_SNAPMODULE, pid ); ok(hSnapshot != NULL, "Cannot create snapshot\n"); for (i = 0; i < num_expected; i++) found[i] = 0; me.dwSize = sizeof(me); if (pModule32First( hSnapshot, &me )) { do { trace("PID=%x base=%p size=%x %s %s\n", me.th32ProcessID, me.modBaseAddr, me.modBaseSize, me.szExePath, me.szModule); ok(me.th32ProcessID == pid, "wrong returned process id\n"); for (i = 0; i < num_expected; i++) if (!lstrcmpi(expected[i], me.szModule)) found[i]++; num++; } while (pModule32Next( hSnapshot, &me )); } for (i = 0; i < num_expected; i++) ok(found[i] == 1, "Module %s is %s\n", expected[i], found[i] ? "listed more than once" : "not listed"); /* check that first really resets the enumeration */ for (i = 0; i < num_expected; i++) found[i] = 0; me.dwSize = sizeof(me); if (pModule32First( hSnapshot, &me )) { do { trace("PID=%x base=%p size=%x %s %s\n", me.th32ProcessID, me.modBaseAddr, me.modBaseSize, me.szExePath, me.szModule); for (i = 0; i < num_expected; i++) if (!lstrcmpi(expected[i], me.szModule)) found[i]++; num--; } while (pModule32Next( hSnapshot, &me )); } for (i = 0; i < num_expected; i++) ok(found[i] == 1, "Module %s is %s\n", expected[i], found[i] ? "listed more than once" : "not listed"); ok(!num, "mismatch in counting\n"); pe.dwSize = sizeof(pe); ok(!pProcess32First( hSnapshot, &pe ), "shouldn't return a process\n"); te.dwSize = sizeof(te); ok(!pThread32First( hSnapshot, &te ), "shouldn't return a thread\n"); CloseHandle(hSnapshot); ok(!pModule32First( hSnapshot, &me ), "shouldn't return a module\n"); }