JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_Secmod_nssLoadLibrary (JNIEnv *env, jclass thisClass, jstring jName) { HINSTANCE hModule; LPVOID lpMsgBuf; const char *libName = (*env)->GetStringUTFChars(env, jName, NULL); dprintf1("-lib %s\n", libName); hModule = LoadLibrary(libName); (*env)->ReleaseStringUTFChars(env, jName, libName); if (hModule == NULL) { FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0, /* Default language */ (LPTSTR) &lpMsgBuf, 0, NULL ); dprintf1("-error: %s\n", lpMsgBuf); JNU_ThrowIOException(env, (char*)lpMsgBuf); LocalFree(lpMsgBuf); return 0; } dprintf2("-handle: %d (0X%X)\n", hModule, hModule); return (jlong)hModule; }
static int test7(gs_state * pgs, gs_memory_t * mem) { /* Define a non-monotonic 4 x 4 halftone with 4 gray levels. */ static const byte masks[1 * 4 * 4] = { /* 0% */ 0x00, 0x00, 0x00, 0x00, /* 25% */ 0x80, 0x40, 0x20, 0x10, /* 50% */ 0xa0, 0xa0, 0x50, 0x50, /* 75% */ 0xd0, 0xe0, 0x70, 0xb0 }; gs_ht *pht; int code; int i; /* Fabricate a Type 5 halftone. */ code = gs_ht_build(&pht, 1, mem); dprintf1("ht build code = %d\n", code); code = gs_ht_set_mask_comp(pht, 0, 4, 4, 4, masks, NULL, NULL); dprintf1("set mask code = %d\n", code); code = gs_sethalftone(pgs, pht); dprintf1("sethalftone code = %d\n", code); for (i = 0; i <= 4; ++i) { gs_setgray(pgs, i / 4.0); fill_rect1(pgs, 100 + i * 100, 100, 50, 50); } return 0; }
JNIEXPORT jobjectArray JNICALL Java_sun_security_smartcardio_PCSC_SCardListReaders (JNIEnv *env, jclass thisClass, jlong jContext) { SCARDCONTEXT context = (SCARDCONTEXT)jContext; LONG rv; LPTSTR mszReaders = NULL; DWORD size = 0; jobjectArray result; dprintf1("-context: %x\n", context); rv = CALL_SCardListReaders(context, NULL, NULL, &size); if (handleRV(env, rv)) { return NULL; } dprintf1("-size: %d\n", size); if (size) { mszReaders = malloc(size); if (mszReaders == NULL) { throwOutOfMemoryError(env, NULL); return NULL; } rv = CALL_SCardListReaders(context, NULL, mszReaders, &size); if (handleRV(env, rv)) { free(mszReaders); return NULL; } dprintf1("-String: %s\n", mszReaders); } result = pcsc_multi2jstring(env, mszReaders); free(mszReaders); return result; }
static void trace_drawing_color(const char *prefix, const gx_drawing_color *pdcolor) { dprintf1("%scolor=", prefix); if (pdcolor->type == gx_dc_type_none) dputs("none"); else if (pdcolor->type == gx_dc_type_null) dputs("null"); else if (pdcolor->type == gx_dc_type_pure) dprintf1("0x%lx", (ulong)pdcolor->colors.pure); else if (pdcolor->type == gx_dc_type_ht_binary) { int ci = pdcolor->colors.binary.b_index; dprintf5("binary(0x%lx, 0x%lx, %d/%d, index=%d)", (ulong)pdcolor->colors.binary.color[0], (ulong)pdcolor->colors.binary.color[1], pdcolor->colors.binary.b_level, (ci < 0 ? pdcolor->colors.binary.b_ht->order.num_bits : pdcolor->colors.binary.b_ht->components[ci].corder.num_bits), ci); } else if (pdcolor->type == gx_dc_type_ht_colored) { ulong plane_mask = pdcolor->colors.colored.plane_mask; int ci; dprintf1("colored(mask=%lu", plane_mask); for (ci = 0; plane_mask != 0; ++ci, plane_mask >>= 1) if (plane_mask & 1) { dprintf2(", (base=%u, level=%u)", pdcolor->colors.colored.c_base[ci], pdcolor->colors.colored.c_level[ci]); } else dputs(", -"); } else {
/* ---------------------------------------------------------------------------- ** Check for the result of the connect syscall ** - UNIX: called when select() indicates writability ** - Win32: called when select() indicates writablility (successful connected) ** or an exception (connect failed) */ vbi_bool vbi_proxy_msg_finish_connect( int sock_fd, char ** ppErrorText ) { vbi_bool result = FALSE; int sockerr; socklen_t sockerrlen; sockerrlen = sizeof(sockerr); if (getsockopt(sock_fd, SOL_SOCKET, SO_ERROR, (void *)&sockerr, &sockerrlen) == 0) { if (sockerr == 0) { /* success -> send the first message of the startup protocol to the server */ dprintf2("finish_connect: socket connect succeeded\n"); result = TRUE; } else { /* failed to establish a connection to the server */ dprintf1("finish_connect: socket connect failed: %s\n", strerror(sockerr)); asprintf(ppErrorText, _("Cannot connect to server: %s."), strerror(sockerr)); } } else { dprintf1("finish_connect: getsockopt: %s\n", strerror(errno)); asprintf(ppErrorText, _("Socket I/O error: %s."), strerror(errno)); } return result; }
void gslt_alloc_print_leaks(void) { dprintf1("number of allocs: %d\n", num_alloc_called); dprintf1("number of frees: %d\n", num_free_called); dprintf1("number of resizes: %d\n", num_resize_called); dprintf1("number of leaked chunks: %d\n", num_alloc_called - num_free_called); }
/* Dump a region of memory */ void debug_dump_bytes(const byte *from, const byte *to, const char *msg) { const byte *p = from; if ( from < to && msg ) dprintf1("%s:\n", msg); while ( p != to ) { const byte *q = min(p + 16, to); dprintf1("%lx:", (ulong)p); while ( p != q ) dprintf1(" %02x", *p++); dputc('\n'); } }
NTSTATUS SynthPortValid( IN OUT PGLOBAL_SYNTH_INFO pGDI, IN ULONG Port, IN volatile BOOLEAN * Fired ) { NTSTATUS Status; // // Check we're going to be allowed to use this port or whether // some other device thinks it owns this hardware // Status = SoundReportResourceUsage( pGDI->DeviceObject, pGDI->BusType, pGDI->BusNumber, NULL, 0, FALSE, NULL, &Port, NUMBER_OF_SYNTH_PORTS); if (!NT_SUCCESS(Status)) { return Status; } // // Find where our device is mapped // pGDI->Hw.SynthBase = SoundMapPortAddress( pGDI->BusType, pGDI->BusNumber, Port, NUMBER_OF_SYNTH_PORTS, &pGDI->MemType); { PUCHAR base; base = pGDI->Hw.SynthBase; if (!SynthPresent(base, base, Fired)) { dprintf1(("No synthesizer present")); // // Unmap the memory // SynthCleanup(pGDI); return STATUS_DEVICE_CONFIGURATION_ERROR; } } return STATUS_SUCCESS; }
void debug_print_packed_ref(const ref_packed *pref) { ushort elt = *pref; ref nref; switch ( elt >> packed_type_shift ) { case pt_executable_operator: dprintf("<op_name>"); elt &= packed_int_mask; op_index_ref(elt, &nref); debug_print_ref(&nref); break; case pt_integer: dprintf1("<int> %d", (int)(elt & packed_int_mask) + packed_min_intval); break; case pt_literal_name: case pt_literal_name+1: dprintf("<lit_name>"); elt &= packed_max_name_index; goto ptn; case pt_executable_name: case pt_executable_name+1: dprintf("<exec_name>"); elt &= packed_max_name_index; ptn: name_index_ref(elt, &nref); dprintf2("(0x%lx#%x)", (ulong)nref.value.pname, elt); debug_print_name(&nref); break; } }
/***************************************************************************** NOT USED ANYMORE Routine Description : Sets a version DWORD into the registry as a pseudo return code to sndblst.drv As a side effect the key to the registry entry is closed. Arguments : pGlobalInfo - Our driver global info DSPVersion - the version number we want to set Return Value : None *****************************************************************************/ VOID SoundSetVersion( IN PGLOBAL_DEVICE_INFO pGlobalInfo, IN ULONG DSPVersion ) { /***** Local Variables *****/ UNICODE_STRING VersionString; /***** Start *****/ RtlInitUnicodeString(&VersionString, L"DSP Version"); if ( pGlobalInfo->RegistryPathName ) { NTSTATUS SetStatus; SetStatus = SoundWriteRegistryDWORD( pGlobalInfo->RegistryPathName, L"DSP Version", DSPVersion ); if (!NT_SUCCESS(SetStatus)) { dprintf1(("ERROR: SoundSetVersion(): Failed to write version - status %XH", SetStatus)); } } // End IF (pGlobalInfo->RegistryPathName) }
/***************************************************************************** SoundInitInterrupt() *****************************************************************************/ NTSTATUS SoundInitInterrupt( IN OUT PGLOBAL_DEVICE_INFO pGDI, IN OUT PULONG Interrupt ) { /***** Local Variables *****/ NTSTATUS Status; /***** Start *****/ dprintf4(("SoundInitInterrupt(): Start")); // // See if we can get this interrupt // Status = SoundConnectInterrupt(*Interrupt, pGDI->BusType, pGDI->BusNumber, SoundISR, (PVOID)pGDI, INTERRUPT_MODE, IRQ_SHARABLE, &pGDI->WaveInfo.Interrupt ); if (!NT_SUCCESS(Status)) { dprintf1(("ERROR: SoundInitInterrupt(): SoundConnectInterrupt() Failed with Status = %XH", Status)); return Status; } // End IF (!NT_SUCCESS(Status)) return STATUS_SUCCESS; } // End SoundInitInterrupt()
void GenerateInterrupt(void) { /* * Generate 1 interrupt on the master controller * (how do devices normally 'detect' the hardware? and * how can this VDD find a spare interrupt to 'install' * the device?). */ if (/*InterruptAcknowleged*/TRUE) { /* * Set to FALSE FIRST to avoid race conditions */ InterruptAcknowleged = FALSE; dprintf2(("Generating interrupt")); VDDSimulateInterrupt(ICA_MASTER, SB_INTERRUPT, 1); } else { dprintf1(("Missed interrupt !")); } /* * Set the status to see if more apps will work */ WriteStatus = 0xFF; }
int journalResetore(u32 device) { // copys apa headers from apal to apa system int i; u32 sector; apa_cache *clink; dprintf1("ps2hdd: checking log...\n"); if(atadDmaTransfer(device, &journalBuf, APA_SECTOR_APAL, sizeof(apa_journal_t)/512, ATAD_MODE_READ)){ journalReset(device); return -EIO; } if(journalBuf.magic==APAL_MAGIC) { if(journalBuf.num==0) return 0; clink=cacheGetFree(); for(i=0, sector=APA_SECTOR_APAL_HEADERS;i<journalBuf.num;i++, sector+=2) { if(atadDmaTransfer(device, clink->header, sector, 2, ATAD_MODE_READ)) break; if(atadDmaTransfer(device, clink->header, journalBuf.sectors[i], 2, ATAD_MODE_WRITE)) break; } cacheAdd(clink); return journalReset(device);// only do if journal.. } memset(&journalBuf, 0, sizeof(apa_journal_t));// safe e journalBuf.magic=APAL_MAGIC; return 0;//-EINVAL; }
/* UNC handling * * client can pass us a SSREQ_UNC: this contains both a password and a server * name (in the form \\server\share). We make a connection to it here and * remember the connection so that we can remove it (in ss_cleanconnections) * when the client session terminates. * * We are passed the head of a FNAMELIST in which we should store the connect * name for later cleanup. We return the new head of this list. * * the client will send this request if a unc-style named scan fails * with the SSRESP_BADPASS error. */ PFNAMELIST ss_handleUNC( HANDLE hpipe, long lVersion , LPSTR password, LPSTR server, PFNAMELIST connects) { NETRESOURCE resource; int errorcode; resource.lpRemoteName = server; resource.lpLocalName = NULL; resource.dwType = RESOURCETYPE_DISK; resource.lpProvider = NULL; errorcode = (int)WNetAddConnection2(&resource, password, NULL, 0); if (errorcode == NO_ERROR) { /* remember the connection name */ connects = ss_addtolist(connects, server); /* report success */ ss_sendnewresp( hpipe, lVersion, SSRESP_END , 0, 0, 0, 0, NULL); } else { Log_Write(hlogErrors, "Connect error %d for server %s", GetLastError(), server); dprintf1(("connect error %d for server %s\n", GetLastError(), server)); /* report error */ ss_sendnewresp( hpipe, lVersion, SSRESP_ERROR , 0, 0, 0, 0, NULL); } return(connects); } /* ss_handleUNC */
/* Attempt to Queue.Put Path onto Queue as a FILEDETAILS with default values for all other fields. Return TRUE or FALSE according as it succeeded. */ STATIC BOOL EnqueueName(QUEUE Queue, LPSTR Path, UINT BuffLen) { FILEDETAILS fd; /* unpack Path and LocalName from "superstring" */ strcpy(fd.Path, Path); BuffLen -= (strlen(Path)+1); if (BuffLen<0) return FALSE; // Uh oh! strlen just looked at garbage. Path += strlen(Path)+1; BuffLen -= (strlen(Path)+1); if (BuffLen<0) return FALSE; // Uh oh! strlen just looked at garbage. strcpy(fd.LocalName, Path); /* set defaults for every field */ fd.ErrorCode = 0; fd.ft_lastwrite.dwLowDateTime = 0; fd.ft_lastwrite.dwHighDateTime = 0; fd.ft_create.dwLowDateTime = 0; fd.ft_create.dwHighDateTime = 0; fd.ft_lastaccess.dwLowDateTime = 0; fd.ft_lastaccess.dwHighDateTime = 0; fd.fileattribs = 0; fd.SizeHi = 0; fd.SizeLo = 0; fd.Checksum = 0; fd.TempName[0] = '\0'; if(!Queue_Put(Queue, (LPBYTE)&fd, sizeof(fd))){ dprintf1(("Put to pack queue failed\n")); return FALSE; } return TRUE; } /* EnqueueName */
int pid_load_vaddrs(int pid) { int ret; dprintf2("%s(%d)\n", __func__, pid); if (!ranges) { nr_ranges_allocated = 4; ranges = malloc(nr_ranges_allocated * sizeof(ranges[0])); dprintf2("%s(%d) allocated %d ranges @ %p\n", __func__, pid, nr_ranges_allocated, ranges); assert(ranges != NULL); } do { ret = __pid_load_vaddrs(pid); if (!ret) break; if (ret == -E2BIG) { dprintf2("%s(%d) need to realloc\n", __func__, pid); nr_ranges_allocated *= 2; ranges = realloc(ranges, nr_ranges_allocated * sizeof(ranges[0])); dprintf2("%s(%d) allocated %d ranges @ %p\n", __func__, pid, nr_ranges_allocated, ranges); assert(ranges != NULL); dprintf1("reallocating to hold %d ranges\n", nr_ranges_allocated); } } while (1); dprintf2("%s(%d) done\n", __func__, pid); return ret; }
static void pragma_fini dtrace_dof_fini(void) { int fd; if ((fd = open64(devname, O_RDWR)) < 0) { dprintf1(1, "failed to open helper device %s", devname); return; } if ((gen = ioctl(fd, DTRACEHIOC_REMOVE, gen)) == -1) dprintf1(1, "DTrace ioctl failed to remove DOF (%d)\n", gen); else dprintf1(1, "DTrace ioctl removed DOF (%d)\n", gen); (void) close(fd); }
// This way of handling positivity violations is // not continuous in time. One would have to // transition gradually from one level to another. // stringencyLevel should be changed to double // (integer values could serve as points where // complete transition is made). // void PositivityState::increaseStringency() { if(stringencyLevel==AVERAGE) { dprintf("increasing stringency level to POSITIVITY_POINTS"); stringencyLevel = POSITIVITY_POINTS; repeatStageFlag = true; } //else if(stringencyLevel==POSITIVITY_POINTS) //{ // dprintf("increasing stringency level to IMPLICIT_SOURCE"); // stringencyLevel = IMPLICIT_SOURCE; // repeatStepFlag = true; //} //else if(stringencyLevel==IMPLICIT_SOURCE) else if(stringencyLevel==POSITIVITY_POINTS) { // make this number configurable? // could rescale based on comparison // of minval with minval computed with // larger time step. // // want to modify dt by a factor that will // cause minval to be zero. // // time step must be repeated if step length is changed. repeatStepFlag = true; #if 0 if(suggested_dt_changeFactor < .8) dt_changeFactor = .8; else if(suggested_dt_changeFactor > .95) dt_changeFactor = .95; else dt_changeFactor = suggested_dt_changeFactor; #endif //double dt_changeFactor = .95; //cflFactor *= dt_changeFactor; cflFactor -= .0625; //dt *= dt_changeFactor; //dprint(dt); dprintf1("decreased cflFactor to %f",cflFactor); // if cflFactor gets too small something must have gone wrong. // There should exist a positivity-guaranteeing CFL number // that is independent of the solution (assuming that there // is a positivity-guaranteeing CFL number that is independent // of the solution for the HLLE method, which maybe isn't quite // true because we don't have a perfect way to obtain an upper // bound on physical wave speeds for the Riemann problem between // two cell states (Einfeldt's prescription is a not a guarantee // for all strictly hyperbolic systems). //assert_gt(cflFactor, .08); assert_gt(cflFactor, 0.); } else { invalid_value_error(stringencyLevel); } }
BOOLEAN mpuWrite( PSOUND_HARDWARE pHw, UCHAR value ) /*++ Routine Description: Write a command or data to the MPU Arguments: pHw - Pointer to the device extension data value - the value to be written Return Value: TRUE if written correctly , FALSE otherwise --*/ { ULONG uCount; ASSERT(pHw->Key == HARDWARE_KEY); uCount = 100; while (uCount--) { int InnerCount; HwEnter(pHw); // // Inner count loop protects against dynamic deadlock with // midi. // for (InnerCount = 0; InnerCount < 10; InnerCount++) { if (!(INPORT(pHw, MPU_STATUS_PORT) & 0x40)) { // is it ok to send data (bit 6 clear)? - drude OUTPORT(pHw, MPU_DATA_PORT, value); break; } KeStallExecutionProcessor(1); // 1 us } HwLeave(pHw); if (InnerCount < 10) { return TRUE; } } dprintf1(("mpuWrite:Failed to write %x to mpu", (ULONG)value)); return FALSE; }
/***************************************************************************** SoundInitIoPort() *****************************************************************************/ NTSTATUS SoundInitIoPort( IN OUT PGLOBAL_DEVICE_INFO pGDI, IN OUT PPAS_CONFIG_DATA ConfigData ) { /***** Local Variables *****/ // NTSTATUS Status; NTSTATUS PasStatus; /***** Start *****/ // // Find where our device is mapped // dprintf4(("SoundInitIoPort(): Start")); #if 0 // Do this in FindPasHardware instead!! pGDI->Hw.PortBase = SoundMapPortAddress( pGDI->BusType, pGDI->BusNumber, ConfigData->Port, NUMBER_OF_PAS_PORTS, &pGDI->MemType); #else pGDI->Hw.PortBase = (PUCHAR) &pGDI->PASInfo.ProPort; #endif // 0 // // Try to Locate any ProAudio Spectrums // PasStatus = FindPasHardware( pGDI, ConfigData ); if ( !NT_SUCCESS(PasStatus) ) { dprintf1(("ERROR: SoundInitIoPort(): FindPasHardware() Failed with Status = %XH", PasStatus)); return STATUS_DEVICE_CONFIGURATION_ERROR; } // End IF (!NT_SUCCESS(PasStatus)) pGDI->ProAudioSpectrum = TRUE; pGDI->Hw.ThunderBoard = FALSE; InitPasAndMixer( pGDI, &pGDI->PASInfo, ConfigData ); // // Setup Min & Max values // pGDI->MinHz = MIN_SAMPLE_RATE; pGDI->MaxInHz = MAX_SAMPLE_RATE; pGDI->MaxOutHz = MAX_SAMPLE_RATE; return STATUS_SUCCESS; } // End SoundInitIoPort()
int gs_setblendmode(gs_state *pgs, gs_blend_mode_t mode) { #ifdef DEBUG if (gs_debug_c('v')) { static const char *const bm_names[] = { GS_BLEND_MODE_NAMES }; dlprintf1("[v](0x%lx)blend_mode = ", (ulong)pgs); if (mode >= 0 && mode < countof(bm_names)) dprintf1("%s\n", bm_names[mode]); else dprintf1("%d??\n", (int)mode); } #endif if (mode < 0 || mode > MAX_BLEND_MODE) return_error(gs_error_rangecheck); pgs->blend_mode = mode; return 0; }
/* Page management */ static int svg_beginpage(gx_device_vector *vdev) { gx_device_svg *svg = (gx_device_svg *)vdev; svg_write_header(svg); dprintf1("svg_beginpage (page count %d)\n", svg->page_count); return 0; }
int fioPartitionSizeLookUp(char *str) { int i; for(i=0;i<APA_NUMBER_OF_SIZES;i++){ if(strcmp(str, sizeList[i])==0) return (256*1024) << i; } dprintf1("ps2hdd: Error: Invalid partition size, %s.\n", str); return -EINVAL; }
JNIEXPORT void JNICALL Java_sun_security_smartcardio_PCSC_SCardEndTransaction (JNIEnv *env, jclass thisClass, jlong jCard, jint jDisposition) { SCARDHANDLE card = (SCARDHANDLE)jCard; LONG rv; rv = CALL_SCardEndTransaction(card, jDisposition); dprintf1("-endTransaction: 0x%X\n", rv); handleRV(env, rv); return; }
/* Imager state */ static int svg_setlinewidth(gx_device_vector *vdev, floatp width) { gx_device_svg *svg = (gx_device_svg *)vdev; dprintf1("svg_setlinewidth(%lf)\n", width); svg->linewidth = width; svg->dirty++; return 0; }
/* modules were compiled with DEBUG set. */ #undef gs_log_error /* in case DEBUG isn't set */ int gs_log_error(int err, const char *file, int line) { if (gs_log_errors) { if (file == NULL) dprintf1("Returning error %d.\n", err); else dprintf3("%s(%d): Returning error %d.\n", (const char *)file, line, err); } return err; }
static void dprintf_font_scoring(const char *type, const pl_font_t *pfont, pl_symbol_map_t *pmap, match_score_t score) { int i; dprintf1("%s: ", type); dprint_font_t(pfont); dprint_font_map(pmap); dputs(" score:"); for ( i = 0; i < score_limit; ++i ) dprintf2(" %s: %d", score_name[i], score[i]); dputs("\n"); }
/* * compress a file. original is the pathname of the original file, * compressed is the pathname of the output compressed file. * * spawns a copy of compress.exe to compress the file, and waits for * it to complete successfully. */ BOOL ss_compress(PSTR original, PSTR compressed) { char szCmdLine[MAX_PATH * 2]; STARTUPINFO si; PROCESS_INFORMATION pi; DWORD exitcode; si.cb = sizeof(STARTUPINFO); si.lpDesktop = NULL; si.lpReserved = NULL; si.lpReserved2 = NULL; si.cbReserved2 = 0; si.lpTitle = "Sumserve Compression"; si.dwFlags = STARTF_FORCEOFFFEEDBACK; sprintf(szCmdLine, "compress %s %s", original, compressed); if (!CreateProcess(NULL, szCmdLine, NULL, NULL, FALSE, DETACHED_PROCESS | NORMAL_PRIORITY_CLASS, //??? Can't we silence the console? NULL, NULL, &si, &pi)) { return(FALSE); } /* wait for completion. */ WaitForSingleObject(pi.hProcess, INFINITE); if (!GetExitCodeProcess(pi.hProcess, &exitcode)) { return(FALSE); } /* close process and thread handles */ CloseHandle(pi.hProcess); CloseHandle(pi.hThread); if (exitcode != 0) { dprintf1(("compress exit code %ld\n", exitcode)); return(FALSE); } else { return(TRUE); } } /* ss_compress */
static int svg_print_path_type(gx_device_svg *svg, gx_path_type_t type) { const char *path_type_names[] = {"winding number", "fill", "stroke", "fill and stroke", "clip" }; if (type <= 4) dprintf2("type %d (%s)", type, path_type_names[type]); else dprintf1("type %d", type); return 0; }
JNIEXPORT jbyteArray JNICALL Java_sun_security_smartcardio_PCSC_SCardStatus (JNIEnv *env, jclass thisClass, jlong jCard, jbyteArray jStatus) { SCARDHANDLE card = (SCARDHANDLE)jCard; LONG rv; char readerName[READERNAME_BUFFER_SIZE]; DWORD readerLen = READERNAME_BUFFER_SIZE; unsigned char atr[ATR_BUFFER_SIZE]; DWORD atrLen = ATR_BUFFER_SIZE; DWORD state = 0; DWORD protocol = 0; jbyteArray jArray; jbyte status[2]; rv = CALL_SCardStatus(card, readerName, &readerLen, &state, &protocol, atr, &atrLen); if (handleRV(env, rv)) { return NULL; } dprintf1("-reader: %s\n", readerName); dprintf1("-status: %d\n", state); dprintf1("-protocol: %d\n", protocol); jArray = (*env)->NewByteArray(env, atrLen); if (jArray == NULL) { return NULL; } (*env)->SetByteArrayRegion(env, jArray, 0, atrLen, (jbyte *)atr); if ((*env)->ExceptionCheck(env)) { return NULL; } status[0] = (jbyte) state; status[1] = (jbyte) protocol; (*env)->SetByteArrayRegion(env, jStatus, 0, 2, status); if ((*env)->ExceptionCheck(env)) { return NULL; } return jArray; }