本文整理汇总了C++中read_data函数 的典型用法代码示例。如果您正苦于以下问题:C++ read_data函数的具体用法?C++ read_data怎么用?C++ read_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_data函数 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: dialog_gauge
/*
* Display a gauge, or progress meter. Starts at percent% and reads stdin. If
* stdin is not XXX, then it is interpreted as a percentage, and the display is
* updated accordingly. Otherwise the next line is the percentage, and
* subsequent lines up to another XXX are used for the new prompt. Note that
* the size of the window never changes, so the prompt can not get any larger
* than the height and width specified.
*/
int
dialog_gauge(const char *title,
const char *prompt,
int height,
int width,
int percent)
{
int i, x, y;
char buf[MY_LEN];
char prompt_buf[MY_LEN];
WINDOW *dialog;
auto_size(title, prompt, &height, &width, MIN_HIGH, MIN_WIDE);
print_size(height, width);
ctl_size(height, width);
/* center dialog box on screen */
x = box_x_ordinate(width);
y = box_y_ordinate(height);
dialog = new_window(height, width, y, x);
curs_set(0);
do {
(void) werase(dialog);
draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
draw_title(dialog, title);
wattrset(dialog, dialog_attr);
print_autowrap(dialog, prompt, height, width - (2 * MARGIN));
draw_box(dialog,
height - 4, 2 + MARGIN,
2 + MARGIN, width - 2 * (2 + MARGIN),
dialog_attr,
border_attr);
(void) wmove(dialog, height - 3, 4);
wattrset(dialog, title_attr);
for (i = 0; i < (width - 2 * (3 + MARGIN)); i++)
(void) waddch(dialog, ' ');
wattrset(dialog, title_attr);
(void) wmove(dialog, height - 3, (width / 2) - 2);
(void) wprintw(dialog, "%3d%%", percent);
x = (percent * (width - 2 * (3 + MARGIN))) / 100;
wattrset(dialog, A_REVERSE);
(void) wmove(dialog, height - 3, 4);
for (i = 0; i < x; i++)
(void) waddch(dialog, winch(dialog));
(void) wrefresh(dialog);
if (read_data(buf, pipe_fp) == 0)
break;
if (isMarker(buf)) {
/*
* Historically, next line should be percentage, but one of the
* worse-written clones of 'dialog' assumes the number is missing.
* (Gresham's Law applied to software).
*/
if (read_data(buf, pipe_fp) == 0)
break;
prompt_buf[0] = '\0';
if (decode_percent(buf))
percent = atoi(buf);
else
strcpy(prompt_buf, buf);
/* Rest is message text */
while (read_data(buf, pipe_fp) != 0
&& !isMarker(buf)) {
if (strlen(prompt_buf) + strlen(buf) < sizeof(prompt_buf) - 1) {
strcat(prompt_buf, buf);
}
}
prompt = prompt_buf;
} else if (decode_percent(buf)) {
percent = atoi(buf);
}
} while (1);
curs_set(1);
del_window(dialog);
return (DLG_EXIT_OK);
}
开发者ID:guadalinex-archive, 项目名称:guadalinex-2005, 代码行数:97, 代码来源:guage.c
示例2: read_data
UINT8 wd11c00_17_device::dack_r()
{
return read_data();
}
开发者ID:Ander-son, 项目名称:libretro-mame, 代码行数:4, 代码来源:wd11c00_17.c
示例3: read_nist_nls_data
static int read_nist_nls_data (const char *fname)
{
FILE *fp;
char line[128];
int err = 0;
int got_name = 0;
int got_model = 0;
int got_data = -1;
fp = fopen(fname, "r");
if (fp == NULL) {
fprintf(stderr, "Couldn't open %s\n", fname);
return 1;
}
tester_init();
while (fgets(line, sizeof line, fp) && !err) {
tail_strip(line);
if (strstr(line, "Dataset Name:")) {
err = get_id(line + 13);
if (!err) got_name = 1;
} else if (strstr(line, "Number of Observations:")) {
if (sscanf(line + 24, "%d", &tester.nobs) != 1) {
err = 1;
} else {
if (tester.nobs > 0) {
datainfo = create_new_dataset(&Z, tester.nvars + 1,
tester.nobs, 0);
if (datainfo == NULL) err = 1;
} else {
err = 1;
}
}
} else if (strncmp(line, "Model:", 6) == 0) {
err = read_model_lines(line, fp);
if (!err) got_model = 1;
} else if (strstr(line, "Starting") && strstr(line, "Certified")) {
err = read_params(fp);
} else if (strncmp(line, "Data:", 5) == 0) {
if (got_data < 0) {
got_data = 0;
} else {
err = read_data(fp);
if (!err) got_data = 1;
}
} else if (strstr(line, "Predictor")) {
err = get_nvars(line);
} else if (strstr(line, "evel of Diffic")) {
print_grade(line);
}
}
if (!got_name) {
missing("dataset identifier");
}
if (!got_model) {
missing("model specification");
}
if (tester.nparam == 0) {
missing("parameter values");
}
if (got_data <= 0) {
missing("input data");
} else if (tester.nobs == 0) {
missing("number of observations");
}
fclose(fp);
return err;
}
开发者ID:HelioGuilherme66, 项目名称:gretl, 代码行数:73, 代码来源:nist-nls-test.c
示例4: process_select
static void process_select(fd_set *rfds, fd_set *wfds, fd_set *efds)
{
const struct list_node *node = fg_list_front(&flows);
while (node) {
struct flow *flow = node->data;
node = node->next;
DEBUG_MSG(LOG_DEBUG, "processing pselect() for flow %d",
flow->id);
if (flow->listenfd_data != -1 &&
FD_ISSET(flow->listenfd_data, rfds)) {
DEBUG_MSG(LOG_DEBUG, "ready for accept");
if (flow->state == GRIND_WAIT_ACCEPT) {
if (accept_data(flow) == -1) {
DEBUG_MSG(LOG_ERR, "accept_data() "
"failed");
goto remove;
}
}
}
if (flow->fd != -1) {
if (FD_ISSET(flow->fd, efds)) {
int error_number, rc;
socklen_t error_number_size =
sizeof(error_number);
DEBUG_MSG(LOG_DEBUG, "sock of flow %d in efds",
flow->id);
rc = getsockopt(flow->fd, SOL_SOCKET,
SO_ERROR,
(void *)&error_number,
&error_number_size);
if (rc == -1) {
warn("failed to get errno for"
"non-blocking connect");
goto remove;
}
if (error_number != 0) {
warnc(error_number, "connect");
goto remove;
}
}
if (FD_ISSET(flow->fd, wfds))
if (write_data(flow) == -1) {
DEBUG_MSG(LOG_ERR, "write_data() failed");
goto remove;
}
if (FD_ISSET(flow->fd, rfds))
if (read_data(flow) == -1) {
DEBUG_MSG(LOG_ERR, "read_data() failed");
goto remove;
}
}
continue;
remove:
if (flow->fd != -1) {
flow->statistics[FINAL].has_tcp_info =
get_tcp_info(flow,
&flow->statistics[FINAL].tcp_info)
? 0 : 1;
}
flow->pmtu = get_pmtu(flow->fd);
report_flow(flow, FINAL);
uninit_flow(flow);
DEBUG_MSG(LOG_ERR, "removing flow %d", flow->id);
remove_flow(flow);
}
}
开发者ID:flowgrind, 项目名称:flowgrind, 代码行数:70, 代码来源:daemon.c
示例5: record
//.........这里部分代码省略.........
}
rc = calc_buf_settings( &nmsgs, NULL );
if (0 != rc) break;
if( nmsgs < (ssize_t)1 ) {
(void) tmfprintf( g_flog, "Buffer for inbound data is too small [%ld] bytes; "
"the minimum size is [%ld] bytes\n",
(long)g_recopt.bufsize, (long)ETHERNET_MTU );
rc = ERR_PARAM;
break;
}
TRACE( (void)tmfprintf( g_flog, "Inbound buffer set to "
"[%d] messages\n", nmsgs ) );
rc = init_dstream_ctx( &ds, CMD_UDP, NULL, nmsgs );
if( 0 != rc ) {
free( data );
return -1;
}
(void) set_nice( g_recopt.nice_incr, g_flog );
/* set up alarm to break main loop */
if( 0 != g_recopt.end_time ) {
wtime_sec = (int)difftime( g_recopt.end_time, time(NULL) );
assert( wtime_sec >= 0 );
(void) alarm( wtime_sec );
(void)tmfprintf( g_flog, "Recording will end in [%d] seconds\n",
wtime_sec );
}
} while(0);
/* record loop */
ropt.max_frgs = g_recopt.rbuf_msgs;
ropt.buf_tmout = -1;
for( n_total = 0; (0 == rc) && !(quit = must_quit()); ) {
nrcv = read_data( &ds, rsock, data, g_recopt.bufsize, &ropt );
if( -1 == nrcv ) { rc = ERR_INTERNAL; break; }
if( 0 == n_total ) {
(void) tmfprintf( g_flog, "Recording to file=[%s] started.\n",
g_recopt.dstfile );
}
TRACE( check_fragments( "received new", g_recopt.bufsize,
lrcv, nrcv, t_delta, g_flog ) );
lrcv = nrcv;
if( nrcv > 0 ) {
if( g_recopt.max_fsize &&
((int64_t)(n_total + nrcv) >= g_recopt.max_fsize) ) {
break;
}
nwr = write_data( &ds, data, nrcv, destfd );
if( -1 == nwr ) { rc = ERR_INTERNAL; break; }
n_total += (size_t)nwr;
/*
TRACE( tmfprintf( g_flog, "Wrote [%ld] to file, total=[%ld]\n",
(long)nwr, (long)n_total ) );
*/
TRACE( check_fragments( "wrote to file",
nrcv, lwr, nwr, t_delta, g_flog ) );
lwr = nwr;
}
if( ds.flags & F_SCATTERED ) reset_pkt_registry( &ds );
} /* record loop */
(void) tmfprintf( g_flog, "Recording to file=[%s] stopped at filesize=[%lu] bytes\n",
g_recopt.dstfile, (u_long)n_total );
/* CLEANUP
*/
(void) alarm(0);
TRACE( (void)tmfprintf( g_flog, "Exited record loop: wrote [%lu] bytes to file [%s], "
"rc=[%d], alarm=[%ld], quit=[%ld]\n",
(u_long)n_total, g_recopt.dstfile, rc, g_alarm, (long)quit ) );
free_dstream_ctx( &ds );
free( data );
close_mcast_listener( rsock, &mreq );
if( destfd >= 0 ) (void) close( destfd );
if( quit )
TRACE( (void)tmfprintf( g_flog, "%s process must quit\n",
g_udpxrec_app ) );
return rc;
}
开发者ID:qwerty1023, 项目名称:wive-rtnl-firmware, 代码行数:101, 代码来源:udpxrec.c
示例6: main
int main(){
read_data();
buylow();
output_data();
return 0;
}
开发者ID:littleATM, 项目名称:USACO, 代码行数:6, 代码来源:buylow.cpp
示例7: main
int main(int argc, char **argv)
{
unsigned char buf[BUF_SIZE];
int fd, fd_s;
pid_t extpid;
uint32_t crc;
int pfd[2];
int val;
socklen_t optlen;
if (pipe(pfd)) {
pr_perror("pipe() failed");
return 1;
}
extpid = fork();
if (extpid < 0) {
pr_perror("fork() failed");
return 1;
} else if (extpid == 0) {
test_ext_init(argc, argv);
close(pfd[1]);
if (read(pfd[0], &port, sizeof(port)) != sizeof(port)) {
pr_perror("Can't read port");
return 1;
}
fd = tcp_init_client(ZDTM_FAMILY, "localhost", port);
if (fd < 0)
return 1;
#ifdef STREAM
while (1) {
if (read_data(fd, buf, BUF_SIZE)) {
pr_perror("read less then have to");
return 1;
}
if (datachk(buf, BUF_SIZE, &crc))
return 2;
datagen(buf, BUF_SIZE, &crc);
if (write_data(fd, buf, BUF_SIZE)) {
pr_perror("can't write");
return 1;
}
}
#else
if (read_data(fd, buf, BUF_SIZE)) {
pr_perror("read less then have to");
return 1;
}
if (datachk(buf, BUF_SIZE, &crc))
return 2;
datagen(buf, BUF_SIZE, &crc);
if (write_data(fd, buf, BUF_SIZE)) {
pr_perror("can't write");
return 1;
}
#endif
return 0;
}
test_init(argc, argv);
if ((fd_s = tcp_init_server(ZDTM_FAMILY, &port)) < 0) {
pr_perror("initializing server failed");
return 1;
}
close(pfd[0]);
if (write(pfd[1], &port, sizeof(port)) != sizeof(port)) {
pr_perror("Can't send port");
return 1;
}
close(pfd[1]);
/*
* parent is server of TCP connection
*/
fd = tcp_accept_server(fd_s);
if (fd < 0) {
pr_perror("can't accept client connection %m");
return 1;
}
val = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val))) {
pr_perror("setsockopt");
return 1;
}
test_daemon();
#ifdef STREAM
while (test_go()) {
datagen(buf, BUF_SIZE, &crc);
if (write_data(fd, buf, BUF_SIZE)) {
pr_perror("can't write");
return 1;
//.........这里部分代码省略.........
开发者ID:pombredanne, 项目名称:criu, 代码行数:101, 代码来源:socket-tcp.c
示例8: read_ptable
/*
* Actually read the partition table elements into their
* appropriate structure. byte order conversion handeling included
*/
static int read_ptable(off_t offset, struct ptable_entry *table)
{
int i;
sig_t signature;
u_int8_t *index, *buffer;
fbvar_t *sectsize_var;
unsigned sectsize;
enum { PTABLE_OFFSET = 446,
BOOT_INDICATOR_OFF = 0,
START_HEAD_OFF = 1,
START_SECT_OFF = 2,
START_CYL_OFF = 3,
SYS_INDICATOR_OFF = 4,
END_HEAD_OFF = 5,
END_SECT_OFF = 6,
END_CYL_OFF = 7,
SECTOR_OFFSET_OFF = 8,
TOTAL_SECTORS_OFF = 12,
CYL_MASK = 0xC0,
SECT_MASK = ~CYL_MASK,
PTABLE_SIZE = 16
};
if (!table)
return 0;
/* get the sector size from the fatback global variable table */
sectsize_var = get_fbvar("sectsize");
if (!sectsize_var->val.ival) {
display(NORMAL, "Error: sectsize set to 0!\n");
free(sectsize_var);
return 0;
}
sectsize = sectsize_var->val.ival;
free(sectsize_var);
buffer = emalloc(sectsize);
if (!read_data(buffer, offset, sectsize)) {
return 0;
}
index = buffer + PTABLE_OFFSET;
/* Load partition table elements into their apropriate struct. This may
* seem a little cumbersome, but it is the easiest way to do it PORTABLY
*/
for (i = 0; i < NUM_PTABLE_ENTRIES; i++) {
index += !!i * PTABLE_SIZE;
table[i].boot_indicator = little_endian_8(index +BOOT_INDICATOR_OFF);
table[i].start_head = little_endian_8(index + START_HEAD_OFF);
table[i].start_cyl = little_endian_8(index + START_CYL_OFF);
table[i].start_cyl += (index[START_SECT_OFF] & CYL_MASK) << 2;
table[i].start_sect = index[START_SECT_OFF] & SECT_MASK;
table[i].sys_indicator = little_endian_8(index + SYS_INDICATOR_OFF);
table[i].end_head = little_endian_8(index + END_HEAD_OFF);
table[i].end_cyl = little_endian_8(index + END_CYL_OFF);
table[i].end_cyl += (index[END_SECT_OFF] & CYL_MASK) << 2;
table[i].end_sect = index[END_SECT_OFF] & SECT_MASK;
table[i].offset = little_endian_32(index + SECTOR_OFFSET_OFF);
table[i].sectors = little_endian_32(index + TOTAL_SECTORS_OFF);
}
signature = read_sig(&buffer[sectsize - 2]);
free(buffer);
return scheck_ptable(table, signature);
}
开发者ID:andrewgaul, 项目名称:fatback, 代码行数:69, 代码来源:mbr.c
示例9: LOGERR
std::string MROMInstaller::open(const std::string& file)
{
char* manifest = NULL;
const ZipEntry *script_entry;
ZipArchive zip;
MemMapping map;
if (sysMapFile(file.c_str(), &map) != 0) {
LOGERR("Failed to sysMapFile '%s'\n", file.c_str());
return false;
}
if (mzOpenZipArchive(map.addr, map.length, &zip) != 0)
return "Failed to open installer file!";
script_entry = mzFindZipEntry(&zip, "manifest.txt");
if(!script_entry)
{
mzCloseZipArchive(&zip);
sysReleaseMap(&map);
return "Failed to find manifest.txt";
}
int res = read_data(&zip, script_entry, &manifest, NULL);
mzCloseZipArchive(&zip);
sysReleaseMap(&map);
if(res < 0)
return "Failed to read manifest.txt!";
int line_cnt = 1;
for(char *line = strtok(manifest, "\r\n"); line; line = strtok(NULL, "\r\n"), ++line_cnt)
{
if(line[0] == '#')
continue;
char *val = strchr(line, '=');
if(!val)
continue;
std::string key = std::string(line, val-line);
++val; // skip '=' char
char *start = strchr(val, '"');
char *end = strrchr(val, '"');
if(!start || start == end || start+1 == end)
gui_print("Line %d: failed to parse string\n", line_cnt);
else
{
++start;
m_vals[key] = std::string(start, end-start);
LOGI("MROMInstaller: got tag %s=%s\n", key.c_str(), m_vals[key].c_str());
}
}
free(manifest);
static const char* needed[] = {
"manifest_ver", "devices", "base_folders"
};
for(uint32_t i = 0; i < sizeof(needed)/sizeof(needed[0]); ++i)
{
std::map<std::string, std::string>::const_iterator itr = m_vals.find(needed[i]);
if(itr == m_vals.end())
return std::string("Required key not found in manifest: ") + needed[i];
}
m_file = file;
return std::string();
}
开发者ID:AntaresOne, 项目名称:MultiROM-TWRP, 代码行数:73, 代码来源:mrominstaller.cpp
示例10: get_tonecurve
static int get_tonecurve(struct shinkos1245_ctx *ctx, int type, int table, char *fname)
{
int ret = 0, num, remaining;
uint8_t *data, *ptr;
struct shinkos1245_cmd_tone cmd;
struct shinkos1245_resp_status resp;
INFO("Dump %s Tone Curve to '%s'\n", shinkos1245_tonecurves(type, table), fname);
/* Issue a tone_read_start */
shinkos1245_fill_hdr(&cmd.hdr);
cmd.cmd[0] = 0x0c;
cmd.tone[0] = 0x54;
cmd.tone[1] = 0x4f;
cmd.tone[2] = 0x4e;
cmd.tone[3] = 0x45;
cmd.cmd2[0] = 0x72;
cmd.read_write.tone_table = type;
cmd.read_write.param_table = table;
ret = shinkos1245_do_cmd(ctx, &cmd, sizeof(cmd),
&resp, sizeof(resp), &num);
if (ret < 0) {
ERROR("Failed to execute TONE_READ command\n");
return ret;
}
if (resp.code != CMD_CODE_OK) {
ERROR("Bad return code on TONE_READ (%02x)\n",
resp.code);
return -99;
}
/* Get the data out */
remaining = TONE_CURVE_SIZE;
data = malloc(remaining);
if (!data) {
ERROR("Memory Allocation Failure!\n");
return -11;
}
ptr = data;
while(remaining) {
/* Issue a tone_data message */
cmd.cmd2[0] = 0x20;
ret = shinkos1245_do_cmd(ctx, &cmd, sizeof(cmd),
&resp, sizeof(resp), &num);
if (ret < 0) {
ERROR("Failed to execute TONE_DATA command\n");
goto done;
}
if (resp.code != CMD_CODE_OK) {
ERROR("Bad return code on TONE_DATA (%02x)\n",
resp.code);
ret = -99;
goto done;
}
/* And read back 64-bytes of data */
ret = read_data(ctx->dev, ctx->endp_up,
ptr, TONE_CURVE_DATA_BLOCK_SIZE, &num);
if (num != TONE_CURVE_DATA_BLOCK_SIZE) {
ret = -99;
goto done;
}
if (ret < 0)
goto done;
ptr += num;
}
/* Issue a tone_end */
cmd.cmd2[0] = 0x65;
ret = shinkos1245_do_cmd(ctx, &cmd, sizeof(cmd),
&resp, sizeof(resp), &num);
if (ret < 0) {
ERROR("Failed to execute TONE_END command\n");
goto done;
}
if (resp.code != CMD_CODE_OK) {
ERROR("Bad return code on TONE_END (%02x)\n",
resp.code);
ret = -99;
goto done;
}
/* Open file and write it out */
{
int tc_fd = open(fname, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);
if (tc_fd < 0) {
ret = tc_fd;
goto done;
}
ret = write(tc_fd, data, TONE_CURVE_SIZE);
if (ret < 0)
goto done;
//.........这里部分代码省略.........
开发者ID:echiu64, 项目名称:gutenprint, 代码行数:101, 代码来源:shinko_s1245_print.c
示例11: my_readfile_from_fd
int my_readfile_from_fd(int fd, char **data)
{
if (fd < 0 || fd == 1 || fd == 2)
return (0);
return (read_data(fd, data));
}
开发者ID:catuss-a, 项目名称:42sh, 代码行数:6, 代码来源:my_readfile.c
示例12: receive_smb_raw
BOOL receive_smb_raw(int fd, char *buffer, unsigned int timeout)
{
ssize_t len,ret;
smb_read_error = 0;
len = read_smb_length_return_keepalive(fd,buffer,timeout);
if (len < 0) {
DEBUG(10,("receive_smb_raw: length < 0!\n"));
/*
* Correct fix. smb_read_error may have already been
* set. Only set it here if not already set. Global
* variables still suck :-). JRA.
*/
if (smb_read_error == 0)
smb_read_error = READ_ERROR;
return False;
}
/*
* A WRITEX with CAP_LARGE_WRITEX can be 64k worth of data plus 65 bytes
* of header. Don't print the error if this fits.... JRA.
*/
if (len > (BUFFER_SIZE + LARGE_WRITEX_HDR_SIZE)) {
DEBUG(0,("Invalid packet length! (%lu bytes).\n",(unsigned long)len));
if (len > BUFFER_SIZE + (SAFETY_MARGIN/2)) {
/*
* Correct fix. smb_read_error may have already been
* set. Only set it here if not already set. Global
* variables still suck :-). JRA.
*/
if (smb_read_error == 0)
smb_read_error = READ_ERROR;
return False;
}
}
if(len > 0) {
if (timeout > 0) {
ret = read_socket_with_timeout(fd,buffer+4,len,len,timeout);
} else {
ret = read_data(fd,buffer+4,len);
}
if (ret != len) {
if (smb_read_error == 0) {
smb_read_error = READ_ERROR;
}
return False;
}
/* not all of samba3 properly checks for packet-termination of strings. This
ensures that we don't run off into empty space. */
SSVAL(buffer+4,len, 0);
}
return True;
}
开发者ID:jameshilliard, 项目名称:WECB-BH-GPL, 代码行数:63, 代码来源:util_sock.c
示例13: dct
void dct(dct_data_t input[DW * N], dct_data_t output[DW * N])
{
pthread_t thread_id[D];
Params thread_args[D];
TP0Params tp0_thread_args;
#ifdef FPGA
// int fdr, fdw;
fdr = open("/dev/xillybus_read_32", O_RDONLY);
fdw = open("/dev/xillybus_write_32", O_WRONLY);
if ((fdr < 0) || (fdw < 0)) {
perror("Failed to open Xillybus device file(s)");
exit(1);
}
#endif
// int buf_2d_in[D][DCT_SIZE][DCT_SIZE];
// int buf_2d_out[D][DCT_SIZE][DCT_SIZE];
dct_data_t *buf_2d_in0, *buf_2d_in1;
dct_data_t *buf_2d_out0, *buf_2d_out1;
// dct_data_t row_outbuf[D][DCT_SIZE][DCT_SIZE];
// dct_data_t col_outbuf[D][DCT_SIZE][DCT_SIZE], col_inbuf[D][DCT_SIZE][DCT_SIZE];
dct_data_t *row_outbuf0, *row_outbuf1;
dct_data_t *col_outbuf0, *col_outbuf1;
dct_data_t *col_inbuf0, *col_inbuf1;
buf_2d_in0 = (dct_data_t *)malloc(SFN * DCT_SIZE * DCT_SIZE * sizeof(dct_data_t));
buf_2d_in1 = (dct_data_t *)malloc(SFN * DCT_SIZE * DCT_SIZE * sizeof(dct_data_t));
buf_2d_out0 = (dct_data_t *)malloc(SFN * DCT_SIZE * DCT_SIZE * sizeof(dct_data_t));
buf_2d_out1 = (dct_data_t *)malloc(SFN * DCT_SIZE * DCT_SIZE * sizeof(dct_data_t));
row_outbuf0 = (dct_data_t *)malloc(SFN * DCT_SIZE * DCT_SIZE * sizeof(dct_data_t));
row_outbuf1 = (dct_data_t *)malloc(SFN * DCT_SIZE * DCT_SIZE * sizeof(dct_data_t));
col_outbuf0 = (dct_data_t *)malloc(SFN * DCT_SIZE * DCT_SIZE * sizeof(dct_data_t));
col_outbuf1 = (dct_data_t *)malloc(SFN * DCT_SIZE * DCT_SIZE * sizeof(dct_data_t));
col_inbuf0 = (dct_data_t *)malloc(SFN * DCT_SIZE * DCT_SIZE * sizeof(dct_data_t));
col_inbuf1 = (dct_data_t *)malloc(SFN * DCT_SIZE * DCT_SIZE * sizeof(dct_data_t));
thread_args[1].buf_2d_in = buf_2d_in1;
thread_args[1].row_outbuf = row_outbuf1;
thread_args[1].col_inbuf = col_inbuf1;
thread_args[1].nii_block = col_inbuf0;
tp0_thread_args.col_inbuf = col_inbuf0;
tp0_thread_args.col_outbuf = col_outbuf0;
tp0_thread_args.buf_2d_out = buf_2d_out0;
tp0_thread_args.nii_block = buf_2d_in1;
tp0_thread_args.input = input;
tp0_thread_args.output = output;
// pre operations
read_data(input + 0 * SFN * N, buf_2d_in0);
dct_2d(buf_2d_in0, row_outbuf0);
transpose(row_outbuf0, col_inbuf0);
read_data(input + 1 * SFN * N, buf_2d_in1);
pthread_mutex_init(&thread_counter_mutex, NULL);
pthread_cond_init(&thread_counter_cv, NULL);
thread_counter = 0; // used in sync_threads()
pthread_create(&thread_id[1], NULL, &half_dct_2d_pth_1, &thread_args[1]);
pthread_create(&thread_id[0], NULL, &half_dct_2d_pth_0, &tp0_thread_args);
pthread_join(thread_id[1], NULL);
pthread_join(thread_id[0], NULL);
#ifdef FPGA
close(fdr);
close(fdw);
#endif
//post operations
dct_2d(col_inbuf1, col_outbuf1);
transpose(col_outbuf1, buf_2d_out1);
write_data(buf_2d_out1, output + (DW - 1 * SFN) * N);
free(buf_2d_in0);
free(buf_2d_in1);
free(buf_2d_out0);
free(buf_2d_out1);
free(row_outbuf0);
free(row_outbuf1);
free(col_outbuf0);
free(col_outbuf1);
free(col_inbuf0);
free(col_inbuf1);
}
开发者ID:troore, 项目名称:xillybench, 代码行数:89, 代码来源:dct_pth_host.c
示例14: main
//.........这里部分代码省略.........
}
printf("g_fbuf:capabilities=0x%x,flags=0x%x,width=%d,height=%d\n"
"pixelformat=0x%x,bytesperline=%d,colorspace=%d,base=0x%x\n",
fb.capability,fb.flags,fb.fmt.width,fb.fmt.height
,fb.fmt.pixelformat,fb.fmt.bytesperline,fb.fmt.colorspace
,fb.base);
fb.capability = cap.capabilities; //V4L2设备功能赋值给V4L2的FB功能属性
fb.fmt.width =width; //LCD的FB宽度赋值给V4L2的FB宽度
fb.fmt.height = height; //LCD的FB高度赋值给V4L2的FB高度
fb.fmt.pixelformat = (fb_bpp==32)?V4L2_PIX_FMT_BGR32:V4L2_PIX_FMT_RGB565; //赋值V4L2的FB像素位数
if(ioctl(cam_fp, VIDIOC_S_FBUF, &fb)<0) //设置新的FB属性给摄像头
{
printf(" VIDIOC_S_FBUF failed\n");
goto err;
}
on = 1;
if(ioctl(cam_fp, VIDIOC_OVERLAY, &on)<0)//使能摄像头的overlay
{
printf(" VIDIOC_OVERLAY failed\n");
goto err;
}
vf_buff = (char*)malloc(size);
if(vf_buff==NULL)
{
goto err;
}
if(fb_bpp==16)
{ //16位BMP
*((unsigned int*)(bmp_head_t+18)) = width;
*((unsigned int*)(bmp_head_t+22)) = height;
*((unsigned short*)(bmp_head_t+28)) = 16;
}
else
{
bmp_head[0] = 'B';
bmp_head[1] = 'M';
*((unsigned int*)(bmp_head+2)) = (width*fb_bpp/8)*height+54; //整个位图大小
*((unsigned int*)(bmp_head+10)) = 54; //从54字节开始存图像
*((unsigned int*)(bmp_head+14)) = 40; //图像描述信息块的大小
*((unsigned int*)(bmp_head+18)) = width;
*((unsigned int*)(bmp_head+22)) = height;
*((unsigned short*)(bmp_head+26)) = 1; //图像的plane总数
*((unsigned short*)(bmp_head+28)) = fb_bpp;
*((unsigned short*)(bmp_head+34)) = (width*fb_bpp/8)*height; //图像数据区大小
}
while(1)
{
if (!read_data(cam_fp, vf_buff, width, height, fb_bpp)) //读摄像头数据到vf_buff
{
printf("read error\n");
}
memcpy(fb_addr,vf_buff,width*height*fb_bpp/8); //将读到的图像数据从内存拷贝到帧缓冲地址
fd=0; //键盘句柄
tv1.tv_sec=0;
tv1.tv_usec=0; //无限等待
FD_ZERO(&fds1);
FD_SET(fd,&fds1); //绑定句柄跟监控对象
select(fd+1,&fds1,NULL,NULL,&tv1); //监控键盘输入
if(FD_ISSET(fd,&fds1)) //如果键盘有输入
{
memset(cmd,0,sizeof(cmd));
read(fd,cmd,256); //读取键盘输入的字符
if(strncmp(cmd,"quit",4)==0)
{ //如果键盘输入quit
printf("-->quit\n");
on=0;
if(ioctl(cam_fp, VIDIOC_OVERLAY, &on)<0)//关掉V4L2设备的overlay
{
goto err;
}
close(fb_fp);
close(cam_fp); //释放FB跟摄像头的句柄
return 0;
}
else if(strncmp(cmd,"capt",4)==0)
{ //如果键盘输入capt
printf("-->capture\n");
printf("write to img --> ");
writeImageToFile(size); //把FB数据保存到位图中
printf("OK\n");
}
}
}
err:
if (cam_fp)
close(cam_fp);
if (fb_fp)
close(fb_fp);
return 1;
}
开发者ID:TangoZhu, 项目名称:libhal, 代码行数:101, 代码来源:uvcfb.c
示例15: ptrace
void
tcpobserver::exiting_connect(pid_t pid)
{
int result;
result = ptrace(PTRACE_PEEKUSER, pid, RAX * 8, NULL);
if (result < 0)
return;
if (m_proc[pid].m_addrlen < sizeof(long))
return;
sockaddr_storage saddr;
std::string domain;
double datetime;
uint16_t port;
char addr[64];
read_data(pid, &saddr, m_proc[pid].m_addr, sizeof(long));
switch (saddr.ss_family) {
case AF_INET:
{
sockaddr_in *saddr_in;
if (m_proc[pid].m_addrlen < sizeof(sockaddr_in))
return;
read_data(pid, &saddr, m_proc[pid].m_addr, sizeof(sockaddr_in));
saddr_in = (sockaddr_in*)&saddr;
inet_ntop(AF_INET, &saddr_in->sin_addr, addr, sizeof(addr));
port = ntohs(saddr_in->sin_port);
domain = "IPv4";
break;
}
case AF_INET6:
{
sockaddr_in6 *saddr_in6;
if (m_proc[pid].m_addrlen < sizeof(sockaddr_in6))
return;
read_data(pid, &saddr, m_proc[pid].m_addr, sizeof(sockaddr_in6));
saddr_in6 = (sockaddr_in6*)&saddr;
inet_ntop(AF_INET6, &saddr_in6->sin6_addr, addr, sizeof(addr));
port = ntohs(saddr_in6->sin6_port);
domain = "IPv6";
break;
}
default:
return;
}
datetime = get_datetime();
m_fd_set.insert(result);
std::cerr << std::setprecision(19)
<< "[email protected]" << datetime
<< " [email protected]"
<< " [email protected]" << result
<< " [email protected]" << domain
<< " [email protected]" << addr
<< " [email protected]" << port
<< " [email protected]" << pid
<< std::endl;
}
开发者ID:ytakano, 项目名称:tcpobserver, 代码行数:75, 代码来源:tcpobserver_x86_64.cpp
示例16: assemble_arm
const
size_t assemble_arm(
uint8_t *const bytecode,
const size_t bytecode_sz,
const char *const assembly,
const size_t asm_sz)
{
size_t sz = 0;
char path[PATH_MAX];
snprintf(path, sizeof(path), "/tmp/rappel-output.XXXXXX");
const int t = mkstemp(path);
if (t == -1) {
perror("mkstemp");
exit(EXIT_FAILURE);
}
REQUIRE (unlink(path) == 0);
int fildes[2];
REQUIRE (pipe(fildes) == 0);
const pid_t asm_pid = fork();
if (asm_pid < 0) {
perror("fork");
exit(EXIT_FAILURE);
} else if (asm_pid == 0) {
_child_assemble(fildes, t);
// Not reached
abort();
}
verbose_printf("as is pid %d\n", asm_pid);
REQUIRE (close(fildes[0]) == 0);
write_data(fildes[1], (uint8_t *)assembly, asm_sz);
REQUIRE (close(fildes[1]) == 0);
int asm_status;
REQUIRE (waitpid(asm_pid, &asm_status, 0) != -1);
if (WIFSIGNALED(asm_status)) {
fprintf(stderr, "as exited with signal %d.\n", WTERMSIG(asm_status));
} else if (WIFEXITED(asm_status) && WEXITSTATUS(asm_status)) {
fprintf(stderr, "as exited %d.\n", WEXITSTATUS(asm_status));
goto exit;
}
REQUIRE (lseek(t, SEEK_SET, 0) != -1);
int results[2];
REQUIRE (pipe(results) == 0);
const pid_t objcopy_pid = fork();
if (objcopy_pid < 0) {
perror("fork");
exit(EXIT_FAILURE);
} else if (objcopy_pid == 0) {
_child_objcopy(results, t);
// Not reached
abort();
}
verbose_printf("objcopy is pid %d\n", objcopy_pid);
REQUIRE (close(results[1]) == 0);
mem_assign(bytecode, bytecode_sz, TRAP, TRAP_SZ);
sz = read_data(results[0], bytecode, bytecode_sz);
if (sz >= bytecode_sz) {
fprintf(stderr, "Too much bytecode to handle, exiting...\n");
exit(EXIT_FAILURE);
}
int objcopy_status;
REQUIRE (waitpid(objcopy_pid, &objcopy_status, 0) != -1);
if (WIFEXITED(objcopy_status) && WIFSIGNALED(objcopy_status))
fprintf(stderr, "objcopy exited with signal %d.\n", WTERMSIG(objcopy_status));
else if (WIFEXITED(objcopy_status) && WEXITSTATUS(objcopy_status))
fprintf(stderr, "objcopy exited %d.\n", WEXITSTATUS(objcopy_status));
exit:
REQUIRE (close(t) == 0);
return sz;
}
开发者ID:yewang15215, 项目名称:rappel, 代码行数:95, 代码来源:assemble_arm.c
示例17: test_data
static int test_data(void)
{
hid_t fid;
hsize_t pal_dims[2];
hsize_t width;
hsize_t height;
unsigned char pal[256*3]; /* buffer to hold an HDF5 palette */
rgb_t rgb[256]; /* buffer to hold a .pal file palette */
int i, n;
/* create a file using default properties */
if ((fid=H5Fcreate(FILE2,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0)
goto out;
printf("Testing read ascii image data and generate images\n");
/*-------------------------------------------------------------------------
* read 8bit image data
*-------------------------------------------------------------------------
*/
TESTING2("make indexed image");
/* read first data file */
if (read_data(DATA_FILE1,&width,&height)<0)
goto out;
/* make an image */
if (H5IMmake_image_8bit(fid,IMAGE1_NAME,width,height,image_data)<0)
goto out;
PASSED();
TESTING2("attaching palettes");
/*-------------------------------------------------------------------------
* palette #1. rainbow palette. data is contained in "pal_rgb.h"
*-------------------------------------------------------------------------
*/
/* initialize the palette data */
pal_dims[0] = 256;
pal_dims[1] = 3;
/* make a palette */
if (H5IMmake_palette(fid,PAL1_NAME,pal_dims,pal_rgb)<0)
goto out;
/* attach a palette to the image dataset */
if (H5IMlink_palette(fid,IMAGE1_NAME,PAL1_NAME)<0)
goto out;
/*-------------------------------------------------------------------------
* palette #2. sepia palette.
* read a PAL file and attach the palette to the HDF5 file
*-------------------------------------------------------------------------
*/
/* read a PAL file */
if (read_palette(PAL2_FILE, rgb, sizeof(rgb))<0)
goto out;
/* transfer to the HDF5 buffer */
for ( i=0, n=0; i<256*3; i+=3, n++)
{
pal[i] =rgb[n].r;
pal[i+1]=rgb[n].g;
pal[i+2]=rgb[n].b;
}
/* make a palette */
if (H5IMmake_palette(fid,PAL2_NAME,pal_dims,pal)<0)
goto out;
/* attach the palette to the image dataset */
if (H5IMlink_palette(fid,IMAGE1_NAME,PAL2_NAME)<0)
goto out;
/*-------------------------------------------------------------------------
* palette #3. earth palette.
* read a PAL file and attach the palette to the HDF5 file
*-------------------------------------------------------------------------
*/
/* read a PAL file */
if (read_palette(PAL3_FILE, rgb, sizeof(rgb))<0)
goto out;
/* transfer to the HDF5 buffer */
for ( i=0, n=0; i<256*3; i+=3, n++)
{
pal[i] =rgb[n].r;
pal[i+1]=rgb[n].g;
pal[i+2]=rgb[n].b;
}
/* make a palette */
if (H5IMmake_palette(fid,PAL3_NAME,pal_dims,pal)<0)
goto out;
//.........这里部分代码省略.........
开发者ID:UCSantaCruzComputationalGenomicsLab, 项目名称:hdf5, 代码行数:101, 代码来源:test_image.c
示例18: relay_traffic
//.........这里部分代码省略.........
rc = set_timeouts( ssockfd, dsockfd,
ctx->rcv_tmout, 0,
ctx->snd_tmout, 0 );
if( 0 != rc ) break;
}
if( dsockfd > 0 ) {
rc = sync_dsockbuf_len( ssockfd, dsockfd );
if( 0 != rc ) break;
rc = send_http_response( dsockfd, 200, "OK" );
if( 0 != rc ) break;
/* timeshift: to detect PAUSE make destination
* socket non-blocking, otherwise make it blocking
* (since it might have been set unblocking earlier)
*/
rc = set_nblock( dsockfd, (ALLOW_PAUSES ? 1 : 0) );
if( 0 != rc ) break;
}
data = malloc(data_len);
if( NULL == data ) {
mperror( g_flog, errno, "%s: malloc", __func__ );
break;
}
if( g_uopt.cl_tpstat )
tpstat_init( &tps, SET_PID );
} while(0);
TRACE( (void)tmfprintf( g_flog, "Relaying traffic from socket[%d] "
"to socket[%d], buffer size=[%d], Rmsgs=[%d], pauses=[%d]\n",
ssockfd, dsockfd, data_len, g_uopt.rbuf_msgs, ALLOW_PAUSES) );
/* RELAY LOOP
*/
ropt.max_frgs = g_uopt.rbuf_msgs;
ropt.buf_tmout = g_uopt.dhold_tmout;
pause_time = 0;
while( (0 == rc) && !(quit = must_quit()) ) {
if( g_uopt.mcast_refresh > 0 ) {
check_mcast_refresh( ssockfd, &rfr_tm, mifaddr );
}
nrcv = read_data( &ds, ssockfd, data, data_len, &ropt );
if( -1 == nrcv ) break;
TRACE( check_fragments( "received new", data_len,
lrcv, nrcv, t_delta, g_flog ) );
lrcv = nrcv;
if( dsockfd && (nrcv > 0) ) {
nsent = write_data( &ds, data, nrcv, dsockfd );
if( -1 == nsent ) break;
if ( nsent < 0 ) {
if ( !ALLOW_PAUSES ) break;
if ( 0 != pause_detect( nsent, MAX_PAUSE_MSEC, &pause_time ) )
break;
}
TRACE( check_fragments("sent", nrcv,
lsent, nsent, t_delta, g_flog) );
lsent = nsent;
}
if( (dfilefd > 0) && (nrcv > 0) ) {
nwr = write_data( &ds, data, nrcv, dfilefd );
if( -1 == nwr )
break;
TRACE( check_fragments( "wrote to file",
nrcv, lsent, nwr, t_delta, g_flog ) );
lsent = nwr;
}
if( ds.flags & F_SCATTERED ) reset_pkt_registry( &ds );
if( uf_TRUE == g_uopt.cl_tpstat )
tpstat_update( ctx, &tps, nsent );
} /* end of RELAY LOOP */
/* CLEANUP
*/
TRACE( (void)tmfprintf( g_flog, "Exited relay loop: received=[%ld], "
"sent=[%ld], quit=[%ld]\n", (long)nrcv, (long)nsent, (long)quit ) );
free_dstream_ctx( &ds );
if( NULL != data ) free( data );
if( 0 != (quit = must_quit()) ) {
TRACE( (void)tmfprintf( g_flog, "Child process=[%d] must quit\n",
getpid()) );
}
return rc;
}
开发者ID:AllardJ, 项目名称:Tomato, 代码行数:101, 代码来源:udpxy.c
示例19: readTradeInfo
unsigned char readTradeInfo(void)
{
return read_data((void *)&stTotalTrade,sizeof(stTotalTrade),ADD_USER_DATA);
}
开发者ID:glocklueng, 项目名称:EV_cortex_m3_db_driver, 代码行数:5, 代码来源:logApi.c
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:19188| 2023-10-27
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:9988| 2022-11-06
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8325| 2022-11-06
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8695| 2022-11-06
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8639| 2022-11-06
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9657| 2022-11-06
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8624| 2022-11-06
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:7998| 2022-11-06
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8654| 2022-11-06
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7535| 2022-11-06
请发表评论