📄 uuencodefs.fist
字号:
%{#include "fist.h"%}debug off;filter sca;filter data;add_mk uuencodefs.mk;%%%%intuuencodefs_encode_buffers(char *hidden_pages_data, /* A PAGE_SIZE buffer (already allocated) passed to us to fill in */ char *page_data, /* The data we are to encode */ int *need_to_call, /* Call us again? */ unsigned to, /* from + no. bytes to write */ inode_t *inode, /* The inode in question */ vfs_t *vfs, /* vfs_t ??? unused */ void **opaque) /* Opaque data */ /* encodes the data in page_data into hidden_pages_data. Returns -errno for error, and the size of hidden_pages_data for success */{ int in_bytes_left; int out_bytes_left = PAGE_CACHE_SIZE; int startpt; unsigned char A, B, C; int bytes_written = 0; print_entry_location(); startpt = (int)*opaque; in_bytes_left = to - startpt; while ((in_bytes_left > 0) && (out_bytes_left >= 4)) { ASSERT(startpt < PAGE_CACHE_SIZE); A = page_data[startpt]; switch(in_bytes_left) { case 1: B = 0; C = 0; in_bytes_left--; startpt += 1; break; case 2: B = page_data[startpt + 1]; C = 0; startpt += 2; in_bytes_left -= 2; break; default: B = page_data[startpt + 1]; C = page_data[startpt + 2]; startpt += 3; in_bytes_left -= 3; break; } hidden_pages_data[bytes_written] = 0x20 + (( A >> 2 ) & 0x3F); out_bytes_left--; bytes_written++; ASSERT(bytes_written < PAGE_CACHE_SIZE); hidden_pages_data[bytes_written] = 0x20 + ((( A << 4 ) | ((B >> 4) & 0xF)) & 0x3F); out_bytes_left--; bytes_written++; ASSERT(bytes_written < PAGE_CACHE_SIZE); hidden_pages_data[bytes_written] = 0x20 + ((( B << 2 ) | ((C >> 6) & 0x3)) & 0x3F); out_bytes_left--; bytes_written++; ASSERT(bytes_written < PAGE_CACHE_SIZE); hidden_pages_data[bytes_written] = 0x20 + ((C) & 0x3F); out_bytes_left--; bytes_written++; ASSERT(bytes_written <= PAGE_CACHE_SIZE); } if (in_bytes_left > 0) *opaque = (void *)startpt; else *need_to_call = 0; print_exit_status(bytes_written); return bytes_written;}intuuencodefs_decode_buffers(int num_hidden_pages, /* The number of pages in hidden_pages_data */ char **hidden_pages_data, /* An array of pages containing encoded data */ char *page_data, /* A pre-allocated PAGE_SIZE buffer to write the decoded data to */ inode_t *inode, /* The inode of the file in question */ vfs_t *vfs, /* vfs_t, unused */ void *opaque) /* opaque data filled in by wrapfs_Sca_count_pages, containing an int, the starting offset within the first page of hidden_pages_data of the encoded page we want */ /* Returns -errno for error, or the number of bytes decoded on success (Should usually return PAGE_SIZE bytes) */{ int i; int startpt = (int)opaque; int bytes_left = PAGE_CACHE_SIZE; unsigned char *ptr; unsigned char A,B,C,D; int outcnt = 0; print_entry_location(); for (i = 0; i < num_hidden_pages; i++) { /* Step through each page */ ptr = hidden_pages_data[i] + startpt; bytes_left = PAGE_CACHE_SIZE - startpt; while(bytes_left >= 4) { A = ptr[0] - 0x20; B = ptr[1] - 0x20; C = ptr[2] - 0x20; D = ptr[3] - 0x20; switch (PAGE_CACHE_SIZE - outcnt) { case 0: goto out; case 1: page_data[outcnt] = (A<<2) | (B>>4); outcnt += 1; goto out; case 2: page_data[outcnt] = (A<<2) | (B>>4); page_data[outcnt+1] = (B<<4) | (C>>2); outcnt += 2; goto out; default: page_data[outcnt] = (A<<2) | (B>>4); page_data[outcnt+1] = (B<<4) | (C>>2); page_data[outcnt+2] = (C<<6) | D; } ptr+=4; outcnt += 3; bytes_left -= 4; } startpt = 0; } out: print_exit_status(outcnt); return(outcnt);}/* * Local variables: * c-basic-offset: 4 * End: */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -