BC_COREPLATFORMIMP_DLL bool bc_platform_file<core_platform::g_api_win32>::open(const bcECHAR* p_file, bc_file_mode p_mode, bc_file_access p_access, bc_file_sharing p_sharing) noexcept { HANDLE l_file; if (get_status() == bc_file_status::open) close(); if ((l_file = CreateFile ( p_file, bc_platform_cast(p_access), bc_platform_cast(p_sharing), nullptr, bc_platform_cast(p_mode), FILE_ATTRIBUTE_NORMAL, nullptr )) == INVALID_HANDLE_VALUE) { m_pack.m_error_code = GetLastError(); return false; } m_pack.m_file = l_file; if (p_mode == bc_file_mode::create_append) { set_pointer(bc_file_seek::end, 0); } return true; }
static void advance(struct qr_iterator * i) { do { /* This XOR is to account for the vertical strip of * timing bits in column 6 which displaces everything. */ if ((i->column < 6) ^ !(i->column % 2)) { /* Right-hand part or at left edge */ i->column -= 1; } else { /* Left-hand part */ i->column += 1; if (( i->up && i->row == 0) || (!i->up && i->row == i->dim - 1)) { /* Hit the top / bottom */ i->column -= 2; i->up = !i->up; } else { i->row += i->up ? -1 : 1; } } if (i->column < 0) continue; /* don't go off left edge */ /* Check for one-past-end */ if (i->column == 0 && i->row >= i->dim - 8) break; } while (!is_data_bit(i)); set_pointer(i); }
value& value::operator=(const value& aOther) { switch (aOther.mType) { case CHAR_T: set_char(aOther.mChar); break; case BOOL_T: set_bool(aOther.mBool); break; case UNSIGNED_T: set_unsigned(aOther.mUnsigned); break; case SIGNED_T: set_signed(aOther.mSigned); break; case FLOAT_T: set_float(aOther.mFloat); break; case POINTER_T: set_pointer(aOther.mPointer); break; case STRING_T: set_string(*static_cast<const c_string*>(aOther.mPointer)); break; case ARRAY_T: set_array(*static_cast<const container<value>*>(aOther.mPointer)); break; case OBJECT_T: set_object(*static_cast<const std::map<c_string, value>*>(aOther.mPointer)); break; default: break; } return *this; }
int setup_search(void) { int count; /* string occurrence counter */ /* set a pointer to start of search */ set_pointer(dot, &aa); /* ::S is 1,1S */ if (colonflag >= 2) { esp->flag2 = esp->flag1 = esp->val2 = esp->val1 = 1; } /* read search count: default is 1 */ if ((count = get_value(1)) == 0) { ERROR(E_ISA); /* search forward */ } else if (count > 0) { /* if bounded search */ if (esp->flag2) { /* set limit */ if (esp->val2 < 0) { esp->val2 = -(esp->val2); } /* or z, whichever less */ if ((aa.z = dot + esp->val2) > z) { aa.z = z; } } else { aa.z = z; } } else { /* if bounded search */ if (esp->flag2) { /* set limit */ if (esp->val2 < 0) { esp->val2 = -(esp->val2); } /* or 0, whichever greater */ if ((locb = dot - esp->val2) < 0) { locb = 0; } } else { locb = 0; } } return(count); }
// If free==0, no new tables will be constructed. // page_size indicates the size of a page. // For VADDR_LSO 12 and PT_INDEX_WIDTH 9, this means: // page_size=0 --> 4KiB // page_size=1 --> 2MiB // page_size=2 --> 1GiB //MLDTODO Rewrite with section nomenclature int write_entry(pt_t* pt0, uint64_t pts_index, void* dst, unsigned page_size, pt_t** next_table, size_t *free, uint8_t r, uint8_t w, uint8_t x){ pt_t* table = pt0; pte_t* entry; int min = page_size; int max = PTS_INDEX_WIDTH / PT_INDEX_WIDTH; for(int i=max-1; i>=min; i--){ uint64_t pt_index = get_index_section(pts_index, i); entry = &(table->entries[pt_index]); if(i == min){ if(entry->p){ return -32; } table = construct_pt(next_table); *free -= 1; entry->p = 1; entry->t = 0; entry->page_p.r = r; entry->page_p.w = w; entry->page_p.x = x; set_pointer(entry, dst); }else if(entry->p){ table = get_pointer(entry); }else{ if(*free == 0){ return 0; } table = construct_pt(next_table); *free -= 1; entry->p = entry->t = 1; set_pointer(entry, table); } } return 1; }
struct qr_iterator * qr_layout_begin(struct qr_code * code) { struct qr_iterator * i; i = malloc(sizeof(*i)); if (i) { i->dim = qr_code_width(code); i->code = code; i->column = i->dim - 1; i->row = i->dim - 1; i->up = 1; set_pointer(i); } return i; }
static void init_structures(void) { int i = 0, j = 0; DEBUG_MSG("init_structures"); set_pointer((struct conf_entry *)&privs, "ec_uid", &GBL_CONF->ec_uid); set_pointer((struct conf_entry *)&privs, "ec_gid", &GBL_CONF->ec_gid); set_pointer((struct conf_entry *)&mitm, "arp_storm_delay", &GBL_CONF->arp_storm_delay); set_pointer((struct conf_entry *)&mitm, "arp_poison_smart", &GBL_CONF->arp_poison_smart); set_pointer((struct conf_entry *)&mitm, "arp_poison_warm_up", &GBL_CONF->arp_poison_warm_up); set_pointer((struct conf_entry *)&mitm, "arp_poison_delay", &GBL_CONF->arp_poison_delay); set_pointer((struct conf_entry *)&mitm, "arp_poison_icmp", &GBL_CONF->arp_poison_icmp); set_pointer((struct conf_entry *)&mitm, "arp_poison_reply", &GBL_CONF->arp_poison_reply); set_pointer((struct conf_entry *)&mitm, "arp_poison_request", &GBL_CONF->arp_poison_request); set_pointer((struct conf_entry *)&mitm, "arp_poison_equal_mac", &GBL_CONF->arp_poison_equal_mac); set_pointer((struct conf_entry *)&mitm, "dhcp_lease_time", &GBL_CONF->dhcp_lease_time); set_pointer((struct conf_entry *)&mitm, "port_steal_delay", &GBL_CONF->port_steal_delay); set_pointer((struct conf_entry *)&mitm, "port_steal_send_delay", &GBL_CONF->port_steal_send_delay); #ifdef WITH_IPV6 set_pointer((struct conf_entry *)&mitm, "ndp_poison_warm_up", &GBL_CONF->ndp_poison_warm_up); set_pointer((struct conf_entry *)&mitm, "ndp_poison_delay", &GBL_CONF->ndp_poison_delay); set_pointer((struct conf_entry *)&mitm, "ndp_poison_send_delay", &GBL_CONF->ndp_poison_send_delay); set_pointer((struct conf_entry *)&mitm, "ndp_poison_icmp", &GBL_CONF->ndp_poison_icmp); set_pointer((struct conf_entry *)&mitm, "ndp_poison_equal_mac", &GBL_CONF->ndp_poison_equal_mac); set_pointer((struct conf_entry *)&mitm, "icmp6_probe_delay", &GBL_CONF->icmp6_probe_delay); #endif set_pointer((struct conf_entry *)&connections, "connection_timeout", &GBL_CONF->connection_timeout); set_pointer((struct conf_entry *)&connections, "connection_idle", &GBL_CONF->connection_idle); set_pointer((struct conf_entry *)&connections, "connection_buffer", &GBL_CONF->connection_buffer); set_pointer((struct conf_entry *)&connections, "connect_timeout", &GBL_CONF->connect_timeout); set_pointer((struct conf_entry *)&stats, "sampling_rate", &GBL_CONF->sampling_rate); set_pointer((struct conf_entry *)&misc, "close_on_eof", &GBL_CONF->close_on_eof); set_pointer((struct conf_entry *)&misc, "store_profiles", &GBL_CONF->store_profiles); set_pointer((struct conf_entry *)&misc, "aggressive_dissectors", &GBL_CONF->aggressive_dissectors); set_pointer((struct conf_entry *)&misc, "skip_forwarded_pcks", &GBL_CONF->skip_forwarded); set_pointer((struct conf_entry *)&misc, "checksum_warning", &GBL_CONF->checksum_warning); set_pointer((struct conf_entry *)&misc, "checksum_check", &GBL_CONF->checksum_check); set_pointer((struct conf_entry *)&misc, "submit_fingerprint", &GBL_CONF->submit_fingerprint); set_pointer((struct conf_entry *)&misc, "sniffing_at_startup", &GBL_CONF->sniffing_at_startup); set_pointer((struct conf_entry *)&curses, "color_bg", &GBL_CONF->colors.bg); set_pointer((struct conf_entry *)&curses, "color_fg", &GBL_CONF->colors.fg); set_pointer((struct conf_entry *)&curses, "color_join1", &GBL_CONF->colors.join1); set_pointer((struct conf_entry *)&curses, "color_join2", &GBL_CONF->colors.join2); set_pointer((struct conf_entry *)&curses, "color_border", &GBL_CONF->colors.border); set_pointer((struct conf_entry *)&curses, "color_title", &GBL_CONF->colors.title); set_pointer((struct conf_entry *)&curses, "color_focus", &GBL_CONF->colors.focus); set_pointer((struct conf_entry *)&curses, "color_menu_bg", &GBL_CONF->colors.menu_bg); set_pointer((struct conf_entry *)&curses, "color_menu_fg", &GBL_CONF->colors.menu_fg); set_pointer((struct conf_entry *)&curses, "color_window_bg", &GBL_CONF->colors.window_bg); set_pointer((struct conf_entry *)&curses, "color_window_fg", &GBL_CONF->colors.window_fg); set_pointer((struct conf_entry *)&curses, "color_selection_bg", &GBL_CONF->colors.selection_bg); set_pointer((struct conf_entry *)&curses, "color_selection_fg", &GBL_CONF->colors.selection_fg); set_pointer((struct conf_entry *)&curses, "color_error_bg", &GBL_CONF->colors.error_bg); set_pointer((struct conf_entry *)&curses, "color_error_fg", &GBL_CONF->colors.error_fg); set_pointer((struct conf_entry *)&curses, "color_error_border", &GBL_CONF->colors.error_border); /* special case for strings */ set_pointer((struct conf_entry *)&strings, "redir_command_on", &GBL_CONF->redir_command_on); set_pointer((struct conf_entry *)&strings, "redir_command_off", &GBL_CONF->redir_command_off); set_pointer((struct conf_entry *)&strings, "remote_browser", &GBL_CONF->remote_browser); set_pointer((struct conf_entry *)&strings, "utf8_encoding", &GBL_CONF->utf8_encoding); /* sanity check */ do { do { if (sections[i].entries[j].value == NULL) { DEBUG_MSG("INVALID init: %s %s", sections[i].entries[j].name, sections[i].title); BUG("check the debug file..."); } } while (sections[i].entries[++j].name != NULL); j = 0; } while (sections[++i].title != NULL); }
static void set_drive(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { set_pointer(obj, v, opaque, parse_drive, name, errp); }
static void set_netdev(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { set_pointer(obj, v, opaque, parse_netdev, name, errp); }
int _doscan(register FILE *stream, const char *format, va_list ap) { int done = 0; /* number of items done */ int nrchars = 0; /* number of characters read */ int conv = 0; /* # of conversions */ int base; /* conversion base */ unsigned long val; /* an integer value */ register char *str; /* temporary pointer */ char *tmp_string; /* ditto */ unsigned width = 0; /* width of field */ int flags; /* some flags */ int reverse; /* reverse the checking in [...] */ int kind; register int ic = EOF; /* the input character */ #ifndef NOFLOAT long double ld_val; #endif if (!*format) return 0; while (1) { if (isspace(*format)) { while (isspace(*format)) format++; /* skip whitespace */ ic = getc(stream); nrchars++; while (isspace (ic)) { ic = getc(stream); nrchars++; } if (ic != EOF) ungetc(ic,stream); nrchars--; } if (!*format) break; /* end of format */ if (*format != '%') { ic = getc(stream); nrchars++; if (ic != *format++) break; /* error */ continue; } format++; if (*format == '%') { ic = getc(stream); nrchars++; if (ic == '%') { format++; continue; } else break; } flags = 0; if (*format == '*') { format++; flags |= FL_NOASSIGN; } if (isdigit (*format)) { flags |= FL_WIDTHSPEC; for (width = 0; isdigit (*format);) width = width * 10 + *format++ - '0'; } switch (*format) { case 'h': flags |= FL_SHORT; format++; break; case 'l': flags |= FL_LONG; format++; break; case 'L': flags |= FL_LONGDOUBLE; format++; break; } kind = *format; if ((kind != 'c') && (kind != '[') && (kind != 'n')) { do { ic = getc(stream); nrchars++; } while (isspace(ic)); if (ic == EOF) break; /* outer while */ } else if (kind != 'n') { /* %c or %[ */ ic = getc(stream); if (ic == EOF) break; /* outer while */ nrchars++; } switch (kind) { default: /* not recognized, like %q */ return conv || (ic != EOF) ? done : EOF; break; case 'n': if (!(flags & FL_NOASSIGN)) { /* silly, though */ if (flags & FL_SHORT) *va_arg(ap, short *) = (short) nrchars; else if (flags & FL_LONG) *va_arg(ap, long *) = (long) nrchars; else *va_arg(ap, int *) = (int) nrchars; } break; case 'p': /* pointer */ set_pointer(flags); /* fallthrough */ case 'b': /* binary */ case 'd': /* decimal */ case 'i': /* general integer */ case 'o': /* octal */ case 'u': /* unsigned */ case 'x': /* hexadecimal */ case 'X': /* ditto */ if (!(flags & FL_WIDTHSPEC) || width > NUMLEN) width = NUMLEN; if (!width) return done; str = o_collect(ic, stream, kind, width, &base); if (str < inp_buf || (str == inp_buf && (*str == '-' || *str == '+'))) return done; /* * Although the length of the number is str-inp_buf+1 * we don't add the 1 since we counted it already */ nrchars += str - inp_buf; if (!(flags & FL_NOASSIGN)) { if (kind == 'd' || kind == 'i') val = strtol(inp_buf, &tmp_string, base); else val = strtoul(inp_buf, &tmp_string, base); if (flags & FL_LONG) *va_arg(ap, unsigned long *) = (unsigned long) val; else if (flags & FL_SHORT) *va_arg(ap, unsigned short *) = (unsigned short) val; else *va_arg(ap, unsigned *) = (unsigned) val; } break; case 'c': if (!(flags & FL_WIDTHSPEC)) width = 1; if (!(flags & FL_NOASSIGN)) str = va_arg(ap, char *); if (!width) return done; while (width && ic != EOF) { if (!(flags & FL_NOASSIGN)) *str++ = (char) ic; if (--width) { ic = getc(stream); nrchars++; } } if (width) { if (ic != EOF) ungetc(ic,stream); nrchars--; } break; case 's': if (!(flags & FL_WIDTHSPEC)) width = 0xffff; if (!(flags & FL_NOASSIGN)) str = va_arg(ap, char *); if (!width) return done; while (width && ic != EOF && !isspace(ic)) { if (!(flags & FL_NOASSIGN)) *str++ = (char) ic; if (--width) { ic = getc(stream); nrchars++; } } /* terminate the string */ if (!(flags & FL_NOASSIGN)) *str = '\0'; if (width) { if (ic != EOF) ungetc(ic,stream); nrchars--; } break; case '[': if (!(flags & FL_WIDTHSPEC)) width = 0xffff; if (!width) return done; if ( *++format == '^' ) { reverse = 1; format++; } else reverse = 0; for (str = Xtable; str < &Xtable[NR_CHARS] ; str++) *str = 0; if (*format == ']') Xtable[*format++] = 1; while (*format && *format != ']') { Xtable[*format++] = 1; if (*format == '-') { format++; if (*format && *format != ']' && *(format) >= *(format -2)) { int c; for( c = *(format -2) + 1 ; c <= *format ; c++) Xtable[c] = 1; format++; } else Xtable['-'] = 1; } } if (!*format) return done; if (!(Xtable[ic] ^ reverse)) { /* MAT 8/9/96 no match must return character */ ungetc(ic, stream); return done; } if (!(flags & FL_NOASSIGN)) str = va_arg(ap, char *); do { if (!(flags & FL_NOASSIGN)) *str++ = (char) ic; if (--width) { ic = getc(stream); nrchars++; } } while (width && ic != EOF && (Xtable[ic] ^ reverse)); if (width) { if (ic != EOF) ungetc(ic, stream); nrchars--; } if (!(flags & FL_NOASSIGN)) { /* terminate string */ *str = '\0'; } break; #ifndef NOFLOAT case 'e': case 'E': case 'f': case 'g': case 'G': if (!(flags & FL_WIDTHSPEC) || width > NUMLEN) width = NUMLEN; if (!width) return done; str = f_collect(ic, stream, width); if (str < inp_buf || (str == inp_buf && (*str == '-' || *str == '+'))) return done; /* * Although the length of the number is str-inp_buf+1 * we don't add the 1 since we counted it already */ nrchars += str - inp_buf; if (!(flags & FL_NOASSIGN)) { ld_val = strtod(inp_buf, &tmp_string); if (flags & FL_LONGDOUBLE) *va_arg(ap, long double *) = (long double) ld_val; else if (flags & FL_LONG) *va_arg(ap, double *) = (double) ld_val; else *va_arg(ap, float *) = (float) ld_val; } break; #endif } /* end switch */ conv++; if (!(flags & FL_NOASSIGN) && kind != 'n') done++; format++; } return conv || (ic != EOF) ? done : EOF; }
/* * routine to do N, _, E_ searches: search, if search fails, then get * next page and continue * * arg - 'n', '_', or 'e' to define which search */ int do_nsearch(char arg) { int scount; /* search count */ /* read the search string */ build_string(&sbuf); /* count must be >0 */ if ((scount = get_value(1)) <= 0) { ERROR(E_ISA); } /* start search at dot */ set_pointer(dot, &aa); /* make it unbounded */ esp->flag2 = locb = 0; /* search until found */ while (scount > 0) { /* search forwards */ if (!do_search(1)) { /* if search fails... */ /* if no input, quit */ if (infile->eofsw || !infile->fd) { break; } if (arg == 'n') { set_pointer(0, &aa); /* write file if 'n' */ write_file(&aa, z, ctrl_e); /* * Not 'n': if _, and an output file, * and data to lose, error */ } else if ((arg == '_') && (outfile->fd) && (z) && (ed_val & ED_YPROT)) { ERROR(E_YCA); } /* clear buffer */ buff_mod = dot = z = 0; set_pointer(0, &aa); /* read next page */ read_file(&aa, &z, (ed_val & ED_EXPMEM ? -1 : 0) ); /* search next page from beginning */ set_pointer(0, &aa); } else { /* search successful: one fewer to look for */ --scount; } } /* use end_search to clean up */ return( end_search( (scount == 0) ? -1 : 0) ); }
void tv_touch(caValue* value) { ca_assert(is_list(value)); ListData* data = (ListData*) get_pointer(value); set_pointer(value, list_touch(data)); }
void resize(caValue* list, int newSize) { ca_assert(is_list(list)); set_pointer(list, list_resize((ListData*) get_pointer(list), newSize)); }