extern void snap(JNIEnv *env, char *text, void* start, int length) { int i, j, k; char worktext[20+1]; char *dump; char line[100]; char newline[100]; char oldline[100]; char work[100]; char txt[100]; char tmp[100]; memset(worktext, 0, sizeof(worktext)); memcpy(worktext, text, 20); dump = (char*) start; memset(oldline, 0, sizeof(oldline)); oldline[0] = 0; for (i = 0; i < length; ) { newline[0] = 0; txt[0] = 0; sprintf(work, "%-16s %08x (+%04x): ", worktext, dump, i); strcat(newline, work); worktext[0] = 0; for (j = 0; j < 4; j++) { for (k = 0; (k < 4) && (i < length); k++, i++, dump++) { sprintf(work, "%02X", (unsigned char) *dump); strcat(newline, work); /* if ( *dump >= 0x21 && *dump <= 0x7a) { sprintf(work, "%c", *dump); strcat(txt, work); } else strcat(txt, "."); */ } sprintf(work, " "); strcat(newline, work); } //if (strcmp(&oldline[36], &newline[36]) != 0) { sprintf(tmp, "%-68s%s ", newline, txt); PTOD(tmp); } strcpy(oldline,newline); } //PTOD(""); }
extern jlong file_read(JNIEnv *env, jlong fhandle, jlong seek, jlong length, jlong buffer) { /* Set fixed values at start and end of buffer: */ prepare_read_buffer(env, buffer, length); int rc = pread64((int) fhandle, (void*) buffer, (size_t) (int) length, (off64_t) seek); if (rc == -1) { if (errno == 0) { PTOD("Errno is zero after a failed read. Setting to 799"); return 799; } return errno; } else if (rc != length) { PTOD1("Invalid byte count. Expecting %lld", length); PTOD1("but read only %d bytes.", rc);; return 798; } /* Make sure read was REALLY OK: */ return check_read_buffer(env, buffer, length); }
/*** hnt_internal_GetAttrType() - return the type of the new value ***/ int hnt_internal_GetAttrType(pObject obj, char* attrname) { pTObjData ptod = PTOD(obj); if (strcmp(attrname,"value")) return -1; return ptod->DataType; }
/*** hnt_internal_GetAttrValue() - return the value ***/ int hnt_internal_GetAttrValue(pObject obj, char* attrname, int type, pObjData pod) { pTObjData ptod = PTOD(obj); if (strcmp(attrname,"value")) return -1; if (type != ptod->DataType) return -1; objCopyData(&(ptod->Data), pod, type); return 0; }
extern jlong file_close(JNIEnv *env, jlong fhandle) { int rc = close((int) fhandle); if (rc == -1) { if (errno == 0) { PTOD("Errno is zero after a failed close. Setting to 799"); return 799; } return errno; } return 0; }
extern jlong file_write(JNIEnv *env, jlong fhandle, jlong seek, jlong length, jlong buffer) { int rc = pwrite64((int) fhandle, (void*) buffer, (size_t) length, (off64_t) seek); if (rc == -1) { if (errno == 0) { PTOD("Errno is zero after a failed read. Setting to 799"); return 799; } return errno; } else if (rc != length) { PTOD1("Invalid byte count. Expecting %lld", length); PTOD1("but wrote only %d bytes.", rc);; return 798; } return 0; }