本文整理汇总了C++中reset_buf函数的典型用法代码示例。如果您正苦于以下问题:C++ reset_buf函数的具体用法?C++ reset_buf怎么用?C++ reset_buf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reset_buf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PT_THREAD
static
PT_THREAD(generate_plugins(struct httpd_state *s))
{
static sixlbr_plugin_info_t const *info;
PSOCK_BEGIN(&s->sout);
add("<h2>Plugins</h2>");
add
("<table>"
"<theader><tr class=\"row_first\"><td>Plugin ID</td><td>Description</td><td>Status</td><td>Version</td><td>Init</td><td>Status</td></tr></theader>"
"<tbody>");
SEND_STRING(&s->sout, buf);
reset_buf();
info = plugins_list_head();
while(info != NULL) {
add("<tr><td>%s</td><td>%s</td>", info->plugin->id, info->plugin->description);
if(info->status == 0) {
add("<td>Loaded</td><td>%s</td><td>%s</td><td>%s</td></tr>",
info->plugin->version ? info->plugin->version() : "Unknown",
info->init_status == 0 ? "Successful" : "Failed",
info->plugin->status ? info->plugin->status() : "Unknown");
} else {
add("<td>Not loaded</td><td></td><td></td><td></td></tr>");
}
info = info->next;
SEND_STRING(&s->sout, buf);
reset_buf();
}
add("</tbody></table><br />");
SEND_STRING(&s->sout, buf);
reset_buf();
PSOCK_END(&s->sout);
}
示例2: set_next_line
static int set_next_line(t_buffer *buf, char *newline, char **line)
{
char *s;
t_list *chunk;
size_t new_size;
if (newline)
{
new_size = buf->CHUNK_SIZE - (newline - (char *)buf->CHUNK) - 1;
if (!(s = ft_strnew(new_size - 1)))
return (reset_buf(buf, NULL));
ft_memcpy(s, newline + 1, new_size);
buf->CHUNK_SIZE -= new_size + 1;
buf->size -= new_size + 1;
}
if (!(*line = ft_strnew(buf->size)))
return (reset_buf(buf, &s));
build_line(buf, *line);
if (newline)
{
if (!(chunk = ft_lstnew(s, new_size)))
return (reset_buf(buf, &s));
ft_lstadd(&buf->chunks, chunk);
buf->size = new_size;
}
return (1);
}
示例3: PT_THREAD
/*---------------------------------------------------------------------------*/
static
PT_THREAD(generate_reboot(struct httpd_state *s))
{
#if BUF_USES_STACK
char buf[BUF_SIZE];
#endif
PSOCK_BEGIN(&s->sout);
SEND_STRING(&s->sout, TOP);
SEND_STRING(&s->sout,
"<meta http-equiv=\"refresh\" content=\"2; url=/config.html\" />");
SEND_STRING(&s->sout, BODY);
reset_buf();
add_div_home("Reboot");
add("<div id=\"left_home\">");
add("Restarting BR...<br />");
add
("<a href=\"/config.html\">Click here if the page is not refreshing</a><br /><br />");
add("</div>");
SEND_STRING(&s->sout, buf);
reset_buf();
SEND_STRING(&s->sout, BOTTOM);
process_post(&cetic_6lbr_process, 0, NULL);
PSOCK_END(&s->sout);
}
示例4: del_buf
void del_buf(size_t i) {
char save[BUFSIZ];
if (buf.i < 1) return;
strncpy(save, buf.s, i);
save[i] = '\0';
reset_buf(save);
}
示例5: xstrdup
/* Turn string in buffer into string object. */
static object_t *parse_str (reader_t * r)
{
size_t size = r->bufp - r->buf;
char *str = xstrdup (r->buf);
reset_buf (r);
return c_str (str, size);
}
示例6: _socket_fd
boss::Socket::Socket()
: _socket_fd(INVALID_SOCKET)
{
_error_text[0] = '\0';
reset_buf();
}
示例7: append_buf
void append_buf(char c) {
if (c == '\n') {
break_at(buf.i);
reset_buf("");
} else {
insert_ch(c);
if (buf.i > WRAP_SIZE) {
char save[BUFSIZ] = "";
if (buf.inword) {
// TODO Handle words too long to wrap
strncpy(save, buf.s + buf.wbeg, buf.i - buf.wbeg);
buf.wc--;
}
break_at(buf.wbreak);
reset_buf(save);
}
}
}
示例8: reset
/* Remove top object from the sexp stack. */
static void reset (reader_t * r)
{
r->done = 1;
while (r->state != r->base)
obj_destroy (pop (r));
reset_buf (r);
r->readbufp = r->readbuf;
r->done = 0;
}
示例9: strtol
/* Turn string in buffer into atom object. */
static object_t *parse_atom (reader_t * r)
{
char *str = r->buf;
char *end;
/* Detect integer */
int i = strtol (str, &end, 10);
(void) i;
if (end != str && *end == '\0')
{
object_t *o = c_ints (str);
reset_buf (r);
return o;
}
/* Detect float */
int d = strtod (str, &end);
(void) d;
if (end != str && *end == '\0')
{
object_t *o = c_floats (str);
reset_buf (r);
return o;
}
/* Might be a symbol then */
char *p = r->buf;
while (p <= r->bufp)
{
if (strchr (atom_chars, *p) == NULL)
{
char *errstr = xstrdup ("invalid symbol character: X");
errstr[strlen (errstr) - 1] = *p;
read_error (r, errstr);
xfree (errstr);
return NIL;
}
p++;
}
object_t *o = c_sym (r->buf);
reset_buf (r);
return o;
}
示例10: read_status
/* reads the status of the device */
static void read_status(struct denali_nand_info *denali)
{
uint32_t cmd = 0x0;
/* initialize the data buffer to store status */
reset_buf(denali);
cmd = ioread32(denali->flash_reg + WRITE_PROTECT);
if (cmd)
write_byte_to_buf(denali, NAND_STATUS_WP);
else
write_byte_to_buf(denali, 0);
}
示例11: get_next_line
int get_next_line(int const fd, char **line)
{
ssize_t r;
char *n;
char *s;
static t_buffer buf;
t_list *chunk;
r = 42;
while (!buf.chunks
|| (!(n = ft_memchr(buf.CHUNK, '\n', buf.CHUNK_SIZE)) && r))
{
if (!(s = ft_strnew(BUF_SIZE - 1))
|| (r = read(fd, s, BUF_SIZE)) < 0
|| !(chunk = ft_lstnew(s, r)))
return (reset_buf(&buf, &s));
ft_lstadd(&buf.chunks, chunk);
buf.size += r;
}
if (buf.size)
return (set_next_line(&buf, n, line));
reset_buf(&buf, NULL);
return (0);
}
示例12: init_pw_area
/*
* NAME: init_pw_area
*
* DESCRIPTION: Initialize pre-write area to all zeros.
*
* PARAMETERS: minor_t mnum - minor number identity of metadevice
* md_dev64_t dev_to_write - index of column to resync
* int column_index - index of column to resync
*
* RETURN: 1 if write error on resync device, otherwise 0
*
* LOCKS: Expects Unit Reader Lock to be held across call.
*/
int
init_pw_area(
mr_unit_t *un,
md_dev64_t dev_to_write,
diskaddr_t pwstart,
uint_t col
)
{
buf_t buf;
caddr_t databuffer;
size_t copysize;
size_t bsize;
int error = 0;
int i;
ASSERT(un != NULL);
ASSERT(un->un_column[col].un_devflags & MD_RAID_DEV_ISOPEN);
bsize = un->un_iosize;
copysize = dbtob(bsize);
databuffer = kmem_zalloc(copysize, KM_SLEEP);
init_buf(&buf, (B_BUSY | B_WRITE), copysize);
for (i = 0; i < un->un_pwcnt; i++) {
/* magic field is 0 for 4.0 compatability */
RAID_FILLIN_RPW(databuffer, un, 0, 0,
0, 0, 0,
0, col, 0);
buf.b_un.b_addr = (caddr_t)databuffer;
buf.b_edev = md_dev64_to_dev(dev_to_write);
buf.b_bcount = dbtob(bsize);
buf.b_lblkno = pwstart + (i * un->un_iosize);
/* write buf */
(void) md_call_strategy(&buf, MD_STR_NOTTOP, NULL);
if (biowait(&buf)) {
error = 1;
break;
}
reset_buf(&buf, (B_BUSY | B_WRITE), copysize);
} /* for */
destroy_buf(&buf);
kmem_free(databuffer, copysize);
return (error);
}
示例13: denali_cmdfunc
static void denali_cmdfunc(struct mtd_info *mtd, unsigned int cmd, int col,
int page)
{
struct denali_nand_info *denali = mtd_to_denali(mtd);
uint32_t addr, id;
int i;
switch (cmd) {
case NAND_CMD_PAGEPROG:
break;
case NAND_CMD_STATUS:
read_status(denali);
break;
case NAND_CMD_READID:
case NAND_CMD_PARAM:
reset_buf(denali);
/*sometimes ManufactureId read from register is not right
* e.g. some of Micron MT29F32G08QAA MLC NAND chips
* So here we send READID cmd to NAND insteand
* */
addr = (uint32_t)MODE_11 | BANK(denali->flash_bank);
index_addr(denali, (uint32_t)addr | 0, 0x90);
index_addr(denali, (uint32_t)addr | 1, 0);
for (i = 0; i < 5; i++) {
index_addr_read_data(denali,
(uint32_t)addr | 2,
&id);
write_byte_to_buf(denali, id);
}
break;
case NAND_CMD_READ0:
case NAND_CMD_SEQIN:
denali->page = page;
break;
case NAND_CMD_RESET:
reset_bank(denali);
break;
case NAND_CMD_READOOB:
/* TODO: Read OOB data */
break;
default:
printk(KERN_ERR ": unsupported command"
" received 0x%x\n", cmd);
break;
}
}
示例14: denali_cmdfunc
static void denali_cmdfunc(struct mtd_info *mtd, unsigned int cmd, int col,
int page)
{
struct denali_nand_info *denali = mtd_to_denali(mtd);
uint32_t addr, id;
int i;
switch (cmd) {
case NAND_CMD_PAGEPROG:
break;
case NAND_CMD_STATUS:
read_status(denali);
break;
case NAND_CMD_READID:
case NAND_CMD_PARAM:
reset_buf(denali);
addr = (uint32_t)MODE_11 | BANK(denali->flash_bank);
index_addr(denali, (uint32_t)addr | 0, 0x90);
index_addr(denali, (uint32_t)addr | 1, 0);
for (i = 0; i < 5; i++) {
index_addr_read_data(denali,
(uint32_t)addr | 2,
&id);
write_byte_to_buf(denali, id);
}
break;
case NAND_CMD_READ0:
case NAND_CMD_SEQIN:
denali->page = page;
break;
case NAND_CMD_RESET:
reset_bank(denali);
break;
case NAND_CMD_READOOB:
break;
default:
printk(KERN_ERR ": unsupported command"
" received 0x%x\n", cmd);
break;
}
}
示例15: enable_rom
void SNES_SPC::reset_time_regs()
{
cpu_error = 0;
echo_accessed = 0;
spc_time = 0;
dsp_time = 0;
for ( int i = 0; i < timer_count; i++ )
{
Timer* t = &timers [i];
t->next_time = 1;
t->divider = 0;
}
enable_rom( REGS [r_control] & 0x80 );
timers_loaded();
extra_clocks = 0;
reset_buf();
}