//virtual ~EditableForm(); void AddMenuProgram () { assert (!_menuProgramInBar ); _menuProgramInBar=&_menuBar.push_back(STR("&Programm")); InitMenu (*_menuProgramInBar); }
const std::set<unsigned int>& memory::get_proxied_internal_variables(unsigned int funID_scope) const { THROW_ASSERT(has_proxied_internal_variables(funID_scope), "No proxy variables for " + STR(funID_scope)); return internal_variable_proxy.find(funID_scope)->second; }
int mime_state_update(MIME_STATE *state, int rec_type, const char *text, int len) { int input_is_text = (rec_type == REC_TYPE_NORM || rec_type == REC_TYPE_CONT); MIME_STACK *sp; HEADER_OPTS *header_info; const unsigned char *cp; #define SAVE_PREV_REC_TYPE_AND_RETURN_ERR_FLAGS(state, rec_type) do { \ state->prev_rec_type = rec_type; \ return (state->err_flags); \ } while (0) /* * Be sure to flush any partial output line that might still be buffered * up before taking any other "end of input" actions. */ if (!input_is_text && state->prev_rec_type == REC_TYPE_CONT) mime_state_update(state, REC_TYPE_NORM, "", 0); /* * This message state machine is kept simple for the sake of robustness. * Standards evolve over time, and we want to be able to correctly * process messages that are not yet defined. This state machine knows * about headers and bodies, understands that multipart/whatever has * multiple body parts with a header and body, and that message/whatever * has message headers at the start of a body part. */ switch (state->curr_state) { /* * First, deal with header information that we have accumulated from * previous input records. Discard text that does not fit in a header * buffer. Our limit is quite generous; Sendmail will refuse mail * with only 32kbyte in all the message headers combined. */ case MIME_STATE_PRIMARY: case MIME_STATE_MULTIPART: case MIME_STATE_NESTED: if (LEN(state->output_buffer) > 0) { if (input_is_text) { if (state->prev_rec_type == REC_TYPE_CONT) { if (LEN(state->output_buffer) < var_header_limit) { vstring_strcat(state->output_buffer, text); } else { if (state->static_flags & MIME_OPT_REPORT_TRUNC_HEADER) REPORT_ERROR(state, MIME_ERR_TRUNC_HEADER, STR(state->output_buffer)); } SAVE_PREV_REC_TYPE_AND_RETURN_ERR_FLAGS(state, rec_type); } if (IS_SPACE_TAB(*text)) { if (LEN(state->output_buffer) < var_header_limit) { vstring_strcat(state->output_buffer, "\n"); vstring_strcat(state->output_buffer, text); } else { if (state->static_flags & MIME_OPT_REPORT_TRUNC_HEADER) REPORT_ERROR(state, MIME_ERR_TRUNC_HEADER, STR(state->output_buffer)); } SAVE_PREV_REC_TYPE_AND_RETURN_ERR_FLAGS(state, rec_type); } } /* * The input is (the beginning of) another message header, or is * not a message header, or is not even a text record. With no * more input to append to this saved header, do output * processing and reset the saved header buffer. Hold on to the * content transfer encoding header if we have to do a 8->7 * transformation, because the proper information depends on the * content type header: message and multipart require a domain, * leaf entities have either a transformation or a domain. */ if (LEN(state->output_buffer) > 0) { header_info = header_opts_find(STR(state->output_buffer)); if (!(state->static_flags & MIME_OPT_DISABLE_MIME) && header_info != 0) { if (header_info->type == HDR_CONTENT_TYPE) mime_state_content_type(state, header_info); if (header_info->type == HDR_CONTENT_TRANSFER_ENCODING) mime_state_content_encoding(state, header_info); } if ((state->static_flags & MIME_OPT_REPORT_8BIT_IN_HEADER) != 0 && (state->err_flags & MIME_ERR_8BIT_IN_HEADER) == 0) { for (cp = CU_CHAR_PTR(STR(state->output_buffer)); cp < CU_CHAR_PTR(END(state->output_buffer)); cp++) if (*cp & 0200) { REPORT_ERROR(state, MIME_ERR_8BIT_IN_HEADER, STR(state->output_buffer)); break; } } /* Output routine is explicitly allowed to change the data. */ if (header_info == 0 || header_info->type != HDR_CONTENT_TRANSFER_ENCODING || (state->static_flags & MIME_OPT_DOWNGRADE) == 0 || state->curr_domain == MIME_ENC_7BIT) HEAD_OUT(state, header_info, len); state->prev_rec_type = 0; VSTRING_RESET(state->output_buffer); } } /* * With past header information moved out of the way, proceed with a * clean slate. */ if (input_is_text) { int header_len; /* * See if this input is (the beginning of) a message header. * Normalize obsolete "name space colon" syntax to "name colon". * Things would be too confusing otherwise. */ if ((header_len = is_header(text)) > 0) { vstring_strncpy(state->output_buffer, text, header_len); for (text += header_len; IS_SPACE_TAB(*text); text++) /* void */ ; vstring_strcat(state->output_buffer, text); SAVE_PREV_REC_TYPE_AND_RETURN_ERR_FLAGS(state, rec_type); } } /* * This input terminates a block of message headers. When converting * 8-bit to 7-bit mail, this is the right place to emit the correct * content-transfer-encoding header. With message or multipart we * specify 7bit, with leaf entities we specify quoted-printable. * * We're not going to convert non-text data into base 64. If they send * arbitrary binary data as 8-bit text, then the data is already * broken beyond recovery, because the Postfix SMTP server sanitizes * record boundaries, treating broken record boundaries as CRLF. * * Clear the output buffer, we will need it for storage of the * conversion result. */ if ((state->static_flags & MIME_OPT_DOWNGRADE) && state->curr_domain != MIME_ENC_7BIT) { if (state->curr_ctype == MIME_CTYPE_MESSAGE || state->curr_ctype == MIME_CTYPE_MULTIPART) cp = CU_CHAR_PTR("7bit"); else cp = CU_CHAR_PTR("quoted-printable"); vstring_sprintf(state->output_buffer, "Content-Transfer-Encoding: %s", cp); HEAD_OUT(state, (HEADER_OPTS *) 0, len); VSTRING_RESET(state->output_buffer); } /* * This input terminates a block of message headers. Call the * optional header end routine at the end of the first header block. */ if (state->curr_state == MIME_STATE_PRIMARY && state->head_end) state->head_end(state->app_context); /* * This is the right place to check if the sender specified an * appropriate identity encoding (7bit, 8bit, binary) for multipart * and for message. */ if (state->static_flags & MIME_OPT_REPORT_ENCODING_DOMAIN) { if (state->curr_ctype == MIME_CTYPE_MESSAGE) { if (state->curr_stype == MIME_STYPE_PARTIAL || state->curr_stype == MIME_STYPE_EXTERN_BODY) { if (state->curr_domain != MIME_ENC_7BIT) REPORT_ERROR(state, MIME_ERR_ENCODING_DOMAIN, mime_state_enc_name(state->curr_encoding)); } else { if (state->curr_encoding != state->curr_domain) REPORT_ERROR(state, MIME_ERR_ENCODING_DOMAIN, mime_state_enc_name(state->curr_encoding)); } } else if (state->curr_ctype == MIME_CTYPE_MULTIPART) { if (state->curr_encoding != state->curr_domain) REPORT_ERROR(state, MIME_ERR_ENCODING_DOMAIN, mime_state_enc_name(state->curr_encoding)); } } /* * Find out if the next body starts with its own message headers. In * agressive mode, examine headers of partial and external-body * messages. Otherwise, treat such headers as part of the "body". Set * the proper encoding information for the multipart prolog. * * XXX This changes state to MIME_STATE_NESTED and then outputs a body * line, so that the body offset is not properly reset. */ if (input_is_text) { if (*text == 0) { state->body_offset = 0; /* XXX */ if (state->curr_ctype == MIME_CTYPE_MESSAGE) { if (state->curr_stype == MIME_STYPE_RFC822 || (state->static_flags & MIME_OPT_RECURSE_ALL_MESSAGE)) SET_MIME_STATE(state, MIME_STATE_NESTED, MIME_CTYPE_TEXT, MIME_STYPE_PLAIN, MIME_ENC_7BIT, MIME_ENC_7BIT); else SET_CURR_STATE(state, MIME_STATE_BODY); } else if (state->curr_ctype == MIME_CTYPE_MULTIPART) { SET_MIME_STATE(state, MIME_STATE_BODY, MIME_CTYPE_OTHER, MIME_STYPE_OTHER, MIME_ENC_7BIT, MIME_ENC_7BIT); } else { SET_CURR_STATE(state, MIME_STATE_BODY); } } /* * Invalid input. Force output of one blank line and jump to the * body state, leaving all other state alone. */ else { SET_CURR_STATE(state, MIME_STATE_BODY); BODY_OUT(state, REC_TYPE_NORM, "", 0); } } /* * This input is not text. Go to body state, unconditionally. */ else { SET_CURR_STATE(state, MIME_STATE_BODY); } /* FALLTHROUGH */ /* * Body text. Look for message boundaries, and recover from missing * boundary strings. Missing boundaries can happen in agressive mode * with text/rfc822-headers or with message/partial. Ignore non-space * cruft after --boundary or --boundary--, because some MUAs do, and * because only perverse software would take advantage of this to * escape detection. We have to ignore trailing cruft anyway, because * our saved copy of the boundary string may have been truncated for * safety reasons. * * Optionally look for 8-bit data in content that was announced as, or * that defaults to, 7-bit. Unfortunately, we cannot turn this on by * default. Majordomo sends requests for approval that do not * propagate the MIME information from the enclosed message to the * message headers of the approval request. * * Set the proper state information after processing a message boundary * string. * * Don't look for boundary strings at the start of a continued record. */ case MIME_STATE_BODY: if (input_is_text) { if ((state->static_flags & MIME_OPT_REPORT_8BIT_IN_7BIT_BODY) != 0 && state->curr_encoding == MIME_ENC_7BIT && (state->err_flags & MIME_ERR_8BIT_IN_7BIT_BODY) == 0) { for (cp = CU_CHAR_PTR(text); cp < CU_CHAR_PTR(text + len); cp++) if (*cp & 0200) { REPORT_ERROR(state, MIME_ERR_8BIT_IN_7BIT_BODY, text); break; } } if (state->stack && state->prev_rec_type != REC_TYPE_CONT && text[0] == '-' && text[1] == '-') { for (sp = state->stack; sp != 0; sp = sp->next) { if (strncmp(text + 2, sp->boundary, sp->bound_len) == 0) { while (sp != state->stack) mime_state_pop(state); if (strncmp(text + 2 + sp->bound_len, "--", 2) == 0) { mime_state_pop(state); SET_MIME_STATE(state, MIME_STATE_BODY, MIME_CTYPE_OTHER, MIME_STYPE_OTHER, MIME_ENC_7BIT, MIME_ENC_7BIT); } else { SET_MIME_STATE(state, MIME_STATE_MULTIPART, sp->def_ctype, sp->def_stype, MIME_ENC_7BIT, MIME_ENC_7BIT); } break; } } } /* Put last for consistency with header output routine. */ if ((state->static_flags & MIME_OPT_DOWNGRADE) && state->curr_domain != MIME_ENC_7BIT) mime_state_downgrade(state, rec_type, text, len); else BODY_OUT(state, rec_type, text, len); } /* * The input is not a text record. Inform the application that this * is the last opportunity to send any pending output. */ else { if (state->body_end) state->body_end(state->app_context); } SAVE_PREV_REC_TYPE_AND_RETURN_ERR_FLAGS(state, rec_type); /* * Oops. This can't happen. */ default: msg_panic("mime_state_update: unknown state: %d", state->curr_state); } }
void ReCollocate( std::string Layout) { _myLayout.swap(Layout); try { ReCollocate( ); } catch(std::exception& e) { (nana::msgbox(*_EdWd_owner, STR("std::exception during EditableWidget ReCollocation: ")) .icon(nana::msgbox::icon_error) <<STR("\n in widget: ") << nana::API::window_caption( _thisEdWd) <<STR("\n Title: " ) << _Titel <<STR("\n owned by: " ) << nana::API::window_caption(*_EdWd_owner) <<STR("\n trying to layout: \n " ) << _myLayout <<STR("\n ocurred exception: ") << e.what() ).show(); } catch(...) { (nana::msgbox(*_EdWd_owner, STR("An uncaptured exception during EditableWidget ReCollocation: ")) .icon(nana::msgbox::icon_error) <<STR("\n in widget: ") << nana::API::window_caption( _thisEdWd) <<STR("\n Title: " ) << _Titel <<STR("\n owned by: " ) << nana::API::window_caption(*_EdWd_owner) <<STR("\n trying to layout: \n " ) << _myLayout ).show(); } _myLayout.swap(Layout); /// call ReCollocate again??? }
static unsigned int call_syscall(struct syscall_desc *scall, char *argv[]) { struct stat64 sb; long long flags; unsigned int i; char *endp; int name, rval; union { char *str; long long num; } args[MAX_ARGS]; #ifdef HAS_FREEBSD_ACL int entry_id = ACL_FIRST_ENTRY; acl_t acl, newacl; acl_entry_t entry, newentry; #endif /* * Verify correctness of the arguments. */ for (i = 0; i < sizeof(args)/sizeof(args[0]); i++) { if (scall->sd_args[i] == TYPE_NONE) { if (argv[i] == NULL || strcmp(argv[i], ":") == 0) break; fprintf(stderr, "too many arguments [%s]\n", argv[i]); exit(1); } else { if (argv[i] == NULL || strcmp(argv[i], ":") == 0) { if (scall->sd_args[i] & TYPE_OPTIONAL) break; fprintf(stderr, "too few arguments\n"); exit(1); } if ((scall->sd_args[i] & TYPE_MASK) == TYPE_STRING) { if (strcmp(argv[i], "NULL") == 0) args[i].str = NULL; else if (strcmp(argv[i], "DEADCODE") == 0) args[i].str = (void *)0xdeadc0de; else args[i].str = argv[i]; } else if ((scall->sd_args[i] & TYPE_MASK) == TYPE_NUMBER) { args[i].num = strtoll(argv[i], &endp, 0); if (*endp != '\0' && !isspace((unsigned char)*endp)) { fprintf(stderr, "invalid argument %u, number expected [%s]\n", i, endp); exit(1); } } else if ((scall->sd_args[i] & TYPE_MASK) == TYPE_DESCRIPTOR) { if (strcmp(argv[i], "AT_FDCWD") == 0) { args[i].num = AT_FDCWD; } else if (strcmp(argv[i], "BADFD") == 0) { /* In case AT_FDCWD is -1 on some systems... */ if (AT_FDCWD == -1) args[i].num = -2; else args[i].num = -1; } else { int pos; pos = strtoll(argv[i], &endp, 0); if (*endp != '\0' && !isspace((unsigned char)*endp)) { fprintf(stderr, "invalid argument %u, number expected [%s]\n", i, endp); exit(1); } args[i].num = descriptor_get(pos); } } } } /* * Call the given syscall. */ #define NUM(n) (args[(n)].num) #define STR(n) (args[(n)].str) switch (scall->sd_action) { case ACTION_OPEN: flags = str2flags(open_flags, STR(1)); if (flags & O_CREAT) { if (i == 2) { fprintf(stderr, "too few arguments\n"); exit(1); } rval = open(STR(0), (int)flags, (mode_t)NUM(2)); } else { if (i == 3) { fprintf(stderr, "too many arguments\n"); exit(1); } rval = open(STR(0), (int)flags); } if (rval >= 0) descriptor_add(rval); break; case ACTION_OPENAT: flags = str2flags(open_flags, STR(2)); if (flags & O_CREAT) { if (i == 3) { fprintf(stderr, "too few arguments\n"); exit(1); } rval = openat(NUM(0), STR(1), (int)flags, (mode_t)NUM(3)); } else { if (i == 4) { fprintf(stderr, "too many arguments\n"); exit(1); } rval = openat(NUM(0), STR(1), (int)flags); } if (rval >= 0) descriptor_add(rval); break; case ACTION_CREATE: rval = open(STR(0), O_CREAT | O_EXCL, (mode_t)NUM(1)); if (rval >= 0) close(rval); break; case ACTION_UNLINK: rval = unlink(STR(0)); break; case ACTION_UNLINKAT: rval = unlinkat(NUM(0), STR(1), (int)str2flags(unlinkat_flags, STR(2))); break; case ACTION_MKDIR: rval = mkdir(STR(0), (mode_t)NUM(1)); break; case ACTION_MKDIRAT: rval = mkdirat(NUM(0), STR(1), (mode_t)NUM(2)); break; case ACTION_RMDIR: rval = rmdir(STR(0)); break; case ACTION_LINK: rval = link(STR(0), STR(1)); break; case ACTION_LINKAT: rval = linkat(NUM(0), STR(1), NUM(2), STR(3), (int)str2flags(linkat_flags, STR(4))); break; case ACTION_SYMLINK: rval = symlink(STR(0), STR(1)); break; case ACTION_SYMLINKAT: rval = symlinkat(STR(0), NUM(1), STR(2)); break; case ACTION_RENAME: rval = rename(STR(0), STR(1)); break; case ACTION_RENAMEAT: rval = renameat(NUM(0), STR(1), NUM(2), STR(3)); break; case ACTION_MKFIFO: rval = mkfifo(STR(0), (mode_t)NUM(1)); break; case ACTION_MKFIFOAT: rval = mkfifoat(NUM(0), STR(1), (mode_t)NUM(2)); break; case ACTION_MKNOD: case ACTION_MKNODAT: { mode_t ntype; dev_t dev; int fa; switch (scall->sd_action) { case ACTION_MKNOD: fa = 0; break; case ACTION_MKNODAT: fa = 1; break; default: abort(); } dev = makedev(NUM(fa + 3), NUM(fa + 4)); if (strcmp(STR(fa + 1), "c") == 0) /* character device */ ntype = S_IFCHR; else if (strcmp(STR(fa + 1), "b") == 0) /* block device */ ntype = S_IFBLK; else if (strcmp(STR(fa + 1), "f") == 0) /* fifo special */ ntype = S_IFIFO; else if (strcmp(STR(fa + 1), "d") == 0) /* directory */ ntype = S_IFDIR; else if (strcmp(STR(fa + 1), "o") == 0) /* regular file */ ntype = S_IFREG; else { fprintf(stderr, "wrong argument 1\n"); exit(1); } switch (scall->sd_action) { case ACTION_MKNOD: rval = mknod(STR(0), ntype | NUM(2), dev); break; case ACTION_MKNODAT: rval = mknodat(NUM(0), STR(1), ntype | NUM(3), dev); break; default: abort(); } break; } case ACTION_BIND: { struct sockaddr_un sunx; sunx.sun_family = AF_UNIX; strncpy(sunx.sun_path, STR(0), sizeof(sunx.sun_path) - 1); sunx.sun_path[sizeof(sunx.sun_path) - 1] = '\0'; rval = socket(AF_UNIX, SOCK_STREAM, 0); if (rval < 0) break; rval = bind(rval, (struct sockaddr *)&sunx, sizeof(sunx)); break; } #ifdef HAS_BINDAT case ACTION_BINDAT: { struct sockaddr_un sunx; sunx.sun_family = AF_UNIX; strncpy(sunx.sun_path, STR(1), sizeof(sunx.sun_path) - 1); sunx.sun_path[sizeof(sunx.sun_path) - 1] = '\0'; rval = socket(AF_UNIX, SOCK_STREAM, 0); if (rval < 0) break; rval = bindat(NUM(0), rval, (struct sockaddr *)&sunx, sizeof(sunx)); break; } #endif case ACTION_CONNECT: { struct sockaddr_un sunx; sunx.sun_family = AF_UNIX; strncpy(sunx.sun_path, STR(0), sizeof(sunx.sun_path) - 1); sunx.sun_path[sizeof(sunx.sun_path) - 1] = '\0'; rval = socket(AF_UNIX, SOCK_STREAM, 0); if (rval < 0) break; rval = connect(rval, (struct sockaddr *)&sunx, sizeof(sunx)); break; } #ifdef HAS_CONNECTAT case ACTION_CONNECTAT: { struct sockaddr_un sunx; sunx.sun_family = AF_UNIX; strncpy(sunx.sun_path, STR(1), sizeof(sunx.sun_path) - 1); sunx.sun_path[sizeof(sunx.sun_path) - 1] = '\0'; rval = socket(AF_UNIX, SOCK_STREAM, 0); if (rval < 0) break; rval = connectat(NUM(0), rval, (struct sockaddr *)&sunx, sizeof(sunx)); break; } #endif case ACTION_CHMOD: rval = chmod(STR(0), (mode_t)NUM(1)); break; case ACTION_FCHMOD: rval = fchmod(NUM(0), (mode_t)NUM(1)); break; #ifdef HAS_LCHMOD case ACTION_LCHMOD: rval = lchmod(STR(0), (mode_t)NUM(1)); break; #endif case ACTION_FCHMODAT: rval = fchmodat(NUM(0), STR(1), (mode_t)NUM(2), str2flags(fchmodat_flags, STR(3))); break; case ACTION_CHOWN: rval = chown(STR(0), (uid_t)NUM(1), (gid_t)NUM(2)); break; case ACTION_FCHOWN: rval = fchown(NUM(0), (uid_t)NUM(1), (gid_t)NUM(2)); break; case ACTION_LCHOWN: rval = lchown(STR(0), (uid_t)NUM(1), (gid_t)NUM(2)); break; case ACTION_FCHOWNAT: rval = fchownat(NUM(0), STR(1), (uid_t)NUM(2), (gid_t)NUM(3), (int)str2flags(fchownat_flags, STR(4))); break; #ifdef HAS_CHFLAGS case ACTION_CHFLAGS: rval = chflags(STR(0), (unsigned long)str2flags(chflags_flags, STR(1))); break; #endif #ifdef HAS_FCHFLAGS case ACTION_FCHFLAGS: rval = fchflags(NUM(0), (unsigned long)str2flags(chflags_flags, STR(1))); break; #endif #ifdef HAS_CHFLAGSAT case ACTION_CHFLAGSAT: rval = chflagsat(NUM(0), STR(1), (unsigned long)str2flags(chflags_flags, STR(2)), (int)str2flags(chflagsat_flags, STR(3))); break; #endif #ifdef HAS_LCHFLAGS case ACTION_LCHFLAGS: rval = lchflags(STR(0), (unsigned long)str2flags(chflags_flags, STR(1))); break; #endif case ACTION_TRUNCATE: rval = truncate64(STR(0), NUM(1)); break; case ACTION_FTRUNCATE: rval = ftruncate64(NUM(0), NUM(1)); break; case ACTION_STAT: rval = stat64(STR(0), &sb); if (rval == 0) { show_stats(&sb, STR(1)); return (i); } break; case ACTION_FSTAT: rval = fstat64(NUM(0), &sb); if (rval == 0) { show_stats(&sb, STR(1)); return (i); } break; case ACTION_LSTAT: rval = lstat64(STR(0), &sb); if (rval == 0) { show_stats(&sb, STR(1)); return (i); } break; case ACTION_FSTATAT: rval = fstatat(NUM(0), STR(1), &sb, (int)str2flags(fstatat_flags, STR(2))); if (rval == 0) { show_stats(&sb, STR(3)); return (i); } break; case ACTION_PATHCONF: case ACTION_FPATHCONF: case ACTION_LPATHCONF: { long lrval; name = str2name(pathconf_names, STR(1)); if (name == -1) { fprintf(stderr, "unknown name %s", STR(1)); exit(1); } errno = 0; switch (scall->sd_action) { case ACTION_PATHCONF: lrval = pathconf(STR(0), name); break; case ACTION_FPATHCONF: lrval = fpathconf(NUM(0), name); break; case ACTION_LPATHCONF: lrval = lpathconf(STR(0), name); break; default: abort(); } if (lrval == -1 && errno == 0) { printf("unlimited\n"); return (i); } else if (lrval >= 0) { printf("%ld\n", lrval); return (i); } rval = -1; break; } #ifdef HAS_FREEBSD_ACL case ACTION_PREPENDACL: rval = -1; acl = acl_get_file(STR(0), ACL_TYPE_NFS4); if (acl == NULL) break; newacl = acl_from_text(STR(1)); if (acl == NULL) break; while (acl_get_entry(newacl, entry_id, &newentry) == 1) { entry_id = ACL_NEXT_ENTRY; if (acl_create_entry_np(&acl, &entry, 0)) break; if (acl_copy_entry(entry, newentry)) break; } rval = acl_set_file(STR(0), ACL_TYPE_NFS4, acl); break; case ACTION_READACL: acl = acl_get_file(STR(0), ACL_TYPE_NFS4); if (acl == NULL) rval = -1; else rval = 0; break; #endif case ACTION_WRITE: rval = write(NUM(0), STR(1), strlen(STR(1))); break; default: fprintf(stderr, "unsupported syscall\n"); exit(1); } #undef STR #undef NUM if (rval < 0) { const char *serrno; serrno = err2str(errno); fprintf(stderr, "%s returned %d\n", scall->sd_name, rval); printf("%s\n", serrno); exit(1); } printf("0\n"); return (i); }
string& string::operator =(const string& s) { MCP(vbf_, STR(s.vbf_), LEN(s.vbf_)); TERM(vbf_); return *this; }
UINTN read_mbr(VOID) { UINTN status; UINTN i; BOOLEAN used; MBR_PARTITION_INFO *table; Print(L"\nCurrent MBR partition table:\n"); // read MBR data status = read_sector(0, sector); if (status != 0) return status; // check for validity if (*((UINT16 *)(sector + 510)) != 0xaa55) { Print(L" No MBR partition table present!\n"); return 1; } table = (MBR_PARTITION_INFO *)(sector + 446); for (i = 0; i < 4; i++) { if (table[i].flags != 0x00 && table[i].flags != 0x80) { Print(L" MBR partition table is invalid!\n"); return 1; } } // check if used used = FALSE; for (i = 0; i < 4; i++) { if (table[i].start_lba > 0 && table[i].size > 0) { used = TRUE; break; } } if (!used) { Print(L" No partitions defined\n"); return 0; } // dump current state & fill internal structures Print(L" # A Start LBA End LBA Type\n"); for (i = 0; i < 4; i++) { if (table[i].start_lba == 0 || table[i].size == 0) continue; mbr_parts[mbr_part_count].index = i; mbr_parts[mbr_part_count].start_lba = (UINT64)table[i].start_lba; mbr_parts[mbr_part_count].end_lba = (UINT64)table[i].start_lba + (UINT64)table[i].size - 1; mbr_parts[mbr_part_count].mbr_type = table[i].type; mbr_parts[mbr_part_count].active = (table[i].flags == 0x80) ? TRUE : FALSE; Print(L" %d %s %12lld %12lld %02x %s\n", mbr_parts[mbr_part_count].index + 1, mbr_parts[mbr_part_count].active ? STR("*") : STR(" "), mbr_parts[mbr_part_count].start_lba, mbr_parts[mbr_part_count].end_lba, mbr_parts[mbr_part_count].mbr_type, mbr_parttype_name(mbr_parts[mbr_part_count].mbr_type)); mbr_part_count++; } return 0; }
void memory::xwrite(xml_element* node) { xml_element* Enode = node->add_child_element("HLS_memory"); unsigned int base_address = off_base_address; WRITE_XVM(base_address, node); if (internal.size() or parameter.size()) { xml_element* IntNode = Enode->add_child_element("internal_memory"); for(std::map<unsigned int, std::map<unsigned int, memory_symbolRef> >::iterator iIt = internal.begin(); iIt != internal.end(); iIt++) { xml_element* ScopeNode = IntNode->add_child_element("scope"); std::string id = "@" + STR(iIt->first); WRITE_XVM(id, ScopeNode); std::string name = tree_helper::name_function(TreeM, iIt->first); WRITE_XVM(name, ScopeNode); for(std::map<unsigned int, memory_symbolRef>::iterator vIt = iIt->second.begin(); vIt != iIt->second.end(); vIt++) { xml_element* VarNode = ScopeNode->add_child_element("variable"); std::string variable = "@" + STR(vIt->second->get_variable()); WRITE_XNVM(id, variable, VarNode); unsigned int address = vIt->second->get_address(); WRITE_XVM(address, VarNode); std::string var_name = vIt->second->get_symbol_name(); WRITE_XNVM(name, var_name, VarNode); } if (parameter.find(iIt->first) != parameter.end()) { for(std::map<unsigned int, memory_symbolRef>::iterator vIt = parameter.find(iIt->first)->second.begin(); vIt != parameter.find(iIt->first)->second.end(); vIt++) { xml_element* VarNode = ScopeNode->add_child_element("parameter"); std::string variable = "@" + STR(vIt->second->get_variable()); WRITE_XNVM(id, variable, VarNode); unsigned int address = vIt->second->get_address(); WRITE_XVM(address, VarNode); std::string var_name = vIt->second->get_symbol_name(); WRITE_XNVM(symbol, var_name, VarNode); } } } if (parameter.size()) { for(std::map<unsigned int, std::map<unsigned int, memory_symbolRef> >::iterator iIt = internal.begin(); iIt != internal.end(); iIt++) { if (internal.find(iIt->first) != internal.end()) continue; xml_element* ScopeNode = IntNode->add_child_element("scope"); std::string id = "@" + STR(iIt->first); WRITE_XVM(id, ScopeNode); std::string name = tree_helper::name_function(TreeM, iIt->first); WRITE_XVM(name, ScopeNode); for(std::map<unsigned int, memory_symbolRef>::iterator vIt = parameter.find(iIt->first)->second.begin(); vIt != parameter.find(iIt->first)->second.end(); vIt++) { xml_element* VarNode = ScopeNode->add_child_element("parameter"); std::string variable = "@" + STR(vIt->second->get_variable()); WRITE_XNVM(id, variable, VarNode); unsigned int address = vIt->second->get_address(); WRITE_XVM(address, VarNode); std::string var_name = vIt->second->get_symbol_name(); WRITE_XNVM(symbol, var_name, VarNode); } } } } if (external.size()) { xml_element* ExtNode = Enode->add_child_element("external_memory"); for(std::map<unsigned int, memory_symbolRef>::iterator eIt = external.begin(); eIt != external.end(); eIt++) { xml_element* VarNode = ExtNode->add_child_element("variable"); std::string variable = "@" + STR(eIt->second->get_variable()); WRITE_XNVM(id, variable, VarNode); unsigned int address = eIt->second->get_address(); WRITE_XVM(address, VarNode); std::string var_name = eIt->second->get_symbol_name(); WRITE_XNVM(symbol, var_name, VarNode); } } }
namespace Movement { double gravity = 19.29110527038574; /// Velocity bounds that makes fall speed limited float terminalVelocity = 60.148003f; float terminalSavefallVelocity = 7.f; const float terminal_length = float(terminalVelocity * terminalVelocity) / (2.f * gravity); const float terminal_savefall_length = (terminalSavefallVelocity * terminalSavefallVelocity) / (2.f * gravity); const float terminalFallTime = float(terminalVelocity/gravity); // the time that needed to reach terminalVelocity float computeFallTime(float path_length, bool isSafeFall) { if (path_length < 0.f) return 0.f; float time; if ( isSafeFall ) { if (path_length >= terminal_savefall_length) time = (path_length - terminal_savefall_length)/terminalSavefallVelocity + terminalSavefallVelocity/gravity; else time = sqrtf(2.f * path_length/gravity); } else { if (path_length >= terminal_length) time = (path_length - terminal_length)/terminalVelocity + terminalFallTime; else time = sqrtf(2.f * path_length/gravity); } return time; } float computeFallElevation(float t_passed, bool isSafeFall, float start_velocity) { float termVel; float result; if ( isSafeFall ) termVel = terminalSavefallVelocity; else termVel = terminalVelocity; if ( start_velocity > termVel ) start_velocity = termVel; float terminal_time = terminalFallTime - start_velocity / gravity; // the time that needed to reach terminalVelocity if ( t_passed > terminal_time ) { result = terminalVelocity*(t_passed - terminal_time) + start_velocity*terminal_time + gravity*terminal_time*terminal_time*0.5f; } else result = t_passed * (start_velocity + t_passed * gravity * 0.5f); return result; } float computeFallElevation(float t_passed) { float result; if (t_passed > terminalFallTime) { //result = terminalVelocity * (t_passed - terminal_time) + gravity*terminal_time*terminal_time*0.5f; // simplified view: result = terminalVelocity * (t_passed - terminalFallTime) + terminal_length; } else result = t_passed * t_passed * gravity * 0.5f; return result; } #define STR(x) #x const char * g_MovementFlag_names[]= { STR(Forward), // 0x00000001, STR(Backward), // 0x00000002, STR(Strafe_Left), // 0x00000004, STR(Strafe_Right), // 0x00000008, STR(Turn_Left), // 0x00000010, STR(Turn_Right), // 0x00000020, STR(Pitch_Up), // 0x00000040, STR(Pitch_Down), // 0x00000080, STR(Walk), // 0x00000100, // Walking STR(Levitation), // 0x00000200, STR(Root), // 0x00000400, STR(Falling), // 0x00000800, STR(Fallingfar), // 0x00001000, STR(Pendingstop), // 0x00002000, STR(PendingSTRafestop), // 0x00004000, STR(Pendingforward), // 0x00008000, STR(Pendingbackward), // 0x00010000, STR(PendingSTRafeleft), // 0x00020000, STR(PendingSTRaferight), // 0x00040000, STR(Pendingroot), // 0x00080000, STR(Swimming), // 0x00100000, // Appears With Fly Flag Also STR(Ascending), // 0x00200000, // Swim Up Also STR(Descending), // 0x00400000, // Swim Down Also STR(Can_Fly), // 0x00800000, // Can Fly In 3.3? STR(Flying), // 0x01000000, // Actual Flying Mode STR(Spline_Elevation), // 0x02000000, // Used For Flight Paths STR(Waterwalking), // 0x04000000, // Prevent Unit From Falling Through Water STR(Safe_Fall), // 0x08000000, // Active Rogue Safe Fall Spell (Passive) STR(Hover), // 0x10000000, STR(Unknown11), // 0x20000000 STR(None31), // 0x40000000 STR(None32), // 0x80000000 STR(NoStrafe), // 0x0001 STR(NoJumping), // 0x0002 STR(Unk3), // 0x0004 STR(Fullspeedturning), // 0x0008 STR(Fullspeedpitching), // 0x0010 STR(Allow_Pitching), // 0x0020 STR(Unk4), // 0x0040 STR(Unk5), // 0x0080 STR(Unk6), // 0x0100 STR(Interp_Move), // 0x0200 STR(Interp_Turning), // 0x0400 STR(Interp_Pitching), // 0x0800 STR(Unk8), // 0x1000 STR(Unk9), // 0x2000 STR(Unk10), // 0x4000 STR(Unk11), // 0x8000 }; const char* g_SplineFlag_names[32] = { STR(AnimBit1), // 0x00000001, STR(AnimBit2), // 0x00000002, STR(AnimBit3), // 0x00000004, STR(Unknown0), // 0x00000008, STR(FallingSlow), // 0x00000010, STR(Done), // 0x00000020, STR(Falling), // 0x00000040, // Not Compartible With Trajectory Movement STR(No_Spline), // 0x00000080, STR(Unknown2), // 0x00000100, STR(Flying), // 0x00000200, // Smooth Movement(Catmullrom Interpolation Mode), Flying Animation STR(Knockback), // 0x00000400, // Model Orientation Fixed STR(Catmullrom), // 0x00000800, // Used Catmullrom Interpolation Mode STR(Cyclic), // 0x00001000, // Movement By Cycled Spline STR(Enter_Cycle), // 0x00002000, // Everytime Appears With Cyclic Flag In Monster Move Packet STR(Frozen), // 0x00004000, STR(TransportEnter),// 0x00008000 STR(TransportExit),// 0x00010000, STR(Unknown3), // 0x00020000, STR(Unknown4), // 0x00040000, STR(OrientationInversed), // 0x00080000, // Appears With Runmode Flag, Nodes ),// 1, Handles Orientation STR(SmoothGroundPath), // 0x00100000 STR(Walkmode), // 0x00200000, STR(UncompressedPath), // 0x00400000 STR(Unknown6), // 0x00800000 STR(Animation), // 0x01000000, // Animationid (0...3), Uint32 Time, Not Compartible With Trajectory And Fall Movement STR(Trajectory), // 0x02000000, // Not Compartible With Fall Movement STR(Final_Point), // 0x04000000, STR(Final_Target), // 0x08000000, STR(Final_Angle), // 0x10000000, STR(Unknown7), // 0x20000000, STR(Unknown8), // 0x40000000, STR(Unknown9), // 0x80000000, }; template<class Flags, int N> void print_flags(Flags t, const char* (&names)[N], std::string& str) { for (int i = 0; i < N; ++i) { if ((t & (Flags)(1 << i)) && names[i] != NULL) str.append(" ").append(names[i]); } } std::string MoveSplineFlag::ToString() const { std::string str; print_flags(raw(),g_SplineFlag_names,str); return str; } }
// variables UINT8 empty_guid[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; PARTITION_INFO mbr_parts[4]; UINTN mbr_part_count = 0; PARTITION_INFO gpt_parts[128]; UINTN gpt_part_count = 0; PARTITION_INFO new_mbr_parts[4]; UINTN new_mbr_part_count = 0; UINT8 sector[512]; MBR_PARTTYPE mbr_types[] = { { 0x01, STR("FAT12 (CHS)") }, { 0x04, STR("FAT16 <32M (CHS)") }, { 0x05, STR("Extended (CHS)") }, { 0x06, STR("FAT16 (CHS)") }, { 0x07, STR("NTFS/HPFS") }, { 0x0b, STR("FAT32 (CHS)") }, { 0x0c, STR("FAT32 (LBA)") }, { 0x0e, STR("FAT16 (LBA)") }, { 0x0f, STR("Extended (LBA)") }, { 0x11, STR("Hidden FAT12 (CHS)") }, { 0x14, STR("Hidden FAT16 <32M (CHS)") }, { 0x16, STR("Hidden FAT16 (CHS)") }, { 0x17, STR("Hidden NTFS/HPFS") }, { 0x1b, STR("Hidden FAT32 (CHS)") }, { 0x1c, STR("Hidden FAT32 (LBA)") }, { 0x1e, STR("Hidden FAT16 (LBA)") },
return false; // Initialize new reader. if (!IReader::set(a_crInstance)) return false; // Initialize constant ASCII string buffer. m_cpBuffer = a_crInstance.m_cpBuffer; m_Size = a_crInstance.m_Size; return true; } /*--------------------------------------------------------------------------*/ Tbool CStreamStringBufferASCIIConst::setPosition(const Tuint a_cPosition) { CALL // Check if the current stream is opened. ASSERT(isOpened(), STR("Cannot set position of the closed constant ASCII string buffer stream.")) { return false; } // Check position value and the buffer bounds. ASSERT(((a_cPosition < m_Size) || (a_cPosition == 0)), STR("Cannot set position with the out of bounds index (index = %u, size = %u).") COMMA a_cPosition COMMA m_Size) { return false; } m_Index = a_cPosition; return true; } /*--------------------------------------------------------------------------*/ Tuint CStreamStringBufferASCIIConst::getPosition() const { CALL
int bounce_warn_service(int unused_flags, char *service, char *queue_name, char *queue_id, char *encoding, char *recipient, char *dsn_envid, int dsn_ret, BOUNCE_TEMPLATES *ts) { BOUNCE_INFO *bounce_info; int bounce_status = 1; int postmaster_status = 1; VSTREAM *bounce; int notify_mask = name_mask(VAR_NOTIFY_CLASSES, mail_error_masks, var_notify_classes); VSTRING *new_id = vstring_alloc(10); char *postmaster; int count; /* * Initialize. Open queue file, bounce log, etc. * * XXX DSN This service produces RFC 3464-style "delayed mail" reports from * information in the defer logfile. That same file is used for three * different types of report: * * a) On-demand reports of all delayed deliveries by the mailq(1) command. * This reports all recipients that have a transient delivery error. * * b) RFC 3464-style "delayed mail" notifications by the defer(8) service. * This reports to the sender all recipients that have no DSN NOTIFY * information (compatibility) and all recipients that have DSN * NOTIFY=DELAY; this reports to postmaster all recipients, subject to * notify_classes restrictions. * * c) RFC 3464-style bounce reports by the bounce(8) service when mail is * too old. This reports to the sender all recipients that have no DSN * NOTIFY information (compatibility) and all recipients that have DSN * NOTIFY=FAILURE; this reports to postmaster all recipients, subject to * notify_classes restrictions. */ bounce_info = bounce_mail_init(service, queue_name, queue_id, encoding, dsn_envid, ts->delay); #define NULL_SENDER MAIL_ADDR_EMPTY /* special address */ #define NULL_TRACE_FLAGS 0 /* * The choice of sender address depends on the recipient address. For a * single bounce (a non-delivery notification to the message originator), * the sender address is the empty string. For a double bounce (typically * a failed single bounce, or a postmaster notification that was produced * by any of the mail processes) the sender address is defined by the * var_double_bounce_sender configuration variable. When a double bounce * cannot be delivered, the queue manager blackholes the resulting triple * bounce message. */ /* * Double bounce failed. Never send a triple bounce. * * However, this does not prevent double bounces from bouncing on other * systems. In order to cope with this, either the queue manager must * recognize the double-bounce recipient address and discard mail, or * every delivery agent must recognize the double-bounce sender address * and substitute something else so mail does not come back at us. */ if (strcasecmp(recipient, mail_addr_double_bounce()) == 0) { msg_warn("%s: undeliverable postmaster notification discarded", queue_id); bounce_status = 0; } /* * Single bounce failed. Optionally send a double bounce to postmaster, * subject to notify_classes restrictions. */ #define ANY_BOUNCE (MAIL_ERROR_2BOUNCE | MAIL_ERROR_BOUNCE) #define SEND_POSTMASTER_DELAY_NOTICE (notify_mask & MAIL_ERROR_DELAY) else if (*recipient == 0) { if (!SEND_POSTMASTER_DELAY_NOTICE) { bounce_status = 0; } else { postmaster = var_delay_rcpt; if ((bounce = post_mail_fopen_nowait(mail_addr_double_bounce(), postmaster, INT_FILT_MASK_BOUNCE, NULL_TRACE_FLAGS, new_id)) != 0) { /* * Double bounce to Postmaster. This is the last opportunity * for this message to be delivered. Send the text with * reason for the bounce, and the headers of the original * message. Don't bother sending the boiler-plate text. */ count = -1; if (!bounce_header(bounce, bounce_info, postmaster, POSTMASTER_COPY) && (count = bounce_diagnostic_log(bounce, bounce_info, DSN_NOTIFY_OVERRIDE)) > 0 && bounce_header_dsn(bounce, bounce_info) == 0 && bounce_diagnostic_dsn(bounce, bounce_info, DSN_NOTIFY_OVERRIDE) > 0) { bounce_original(bounce, bounce_info, DSN_RET_FULL); bounce_status = post_mail_fclose(bounce); if (bounce_status == 0) msg_info("%s: postmaster delay notification: %s", queue_id, STR(new_id)); } else { (void) vstream_fclose(bounce); if (count == 0) bounce_status = 0; } } } } /* * Non-bounce failed. Send a single bounce, subject to DSN NOTIFY * restrictions. */ else { if ((bounce = post_mail_fopen_nowait(NULL_SENDER, recipient, INT_FILT_MASK_BOUNCE, NULL_TRACE_FLAGS, new_id)) != 0) { /* * Send the bounce message header, some boilerplate text that * pretends that we are a polite mail system, the text with * reason for the bounce, and a copy of the original message. */ count = -1; if (bounce_header(bounce, bounce_info, recipient, NO_POSTMASTER_COPY) == 0 && bounce_boilerplate(bounce, bounce_info) == 0 && (count = bounce_diagnostic_log(bounce, bounce_info, DSN_NOTIFY_DELAY)) > 0 && bounce_header_dsn(bounce, bounce_info) == 0 && bounce_diagnostic_dsn(bounce, bounce_info, DSN_NOTIFY_DELAY) > 0) { bounce_original(bounce, bounce_info, DSN_RET_HDRS); bounce_status = post_mail_fclose(bounce); if (bounce_status == 0) msg_info("%s: sender delay notification: %s", queue_id, STR(new_id)); } else { (void) vstream_fclose(bounce); if (count == 0) bounce_status = 0; } } /* * Optionally send a postmaster notice, subject to notify_classes * restrictions. * * This postmaster notice is not critical, so if it fails don't * retransmit the bounce that we just generated, just log a warning. */ if (bounce_status == 0 && SEND_POSTMASTER_DELAY_NOTICE && strcasecmp(recipient, mail_addr_double_bounce()) != 0) { /* * Send the text with reason for the bounce, and the headers of * the original message. Don't bother sending the boiler-plate * text. This postmaster notice is not critical, so if it fails * don't retransmit the bounce that we just generated, just log a * warning. */ postmaster = var_delay_rcpt; if ((bounce = post_mail_fopen_nowait(mail_addr_double_bounce(), postmaster, INT_FILT_MASK_BOUNCE, NULL_TRACE_FLAGS, new_id)) != 0) { count = -1; if (bounce_header(bounce, bounce_info, postmaster, POSTMASTER_COPY) == 0 && (count = bounce_diagnostic_log(bounce, bounce_info, DSN_NOTIFY_OVERRIDE)) > 0 && bounce_header_dsn(bounce, bounce_info) == 0 && bounce_diagnostic_dsn(bounce, bounce_info, DSN_NOTIFY_OVERRIDE) > 0) { bounce_original(bounce, bounce_info, DSN_RET_HDRS); postmaster_status = post_mail_fclose(bounce); if (postmaster_status == 0) msg_info("%s: postmaster delay notification: %s", queue_id, STR(new_id)); } else { (void) vstream_fclose(bounce); if (count == 0) postmaster_status = 0; } } if (postmaster_status) msg_warn("%s: postmaster notice failed while warning %s", queue_id, recipient); } } /* * Cleanup. */ bounce_mail_free(bounce_info); vstring_free(new_id); return (bounce_status); }
string& string::operator +=(const string* s) { MCAT(vbf_, STR(s->vbf_), LEN(s->vbf_)); TERM(vbf_); return *this; }
bool memory::is_sds_var(unsigned int var) const { THROW_ASSERT(has_sds_var(var), "variable not classified" + STR(var)); return same_data_size_accesses.find(var)->second; }
UINTN detect_mbrtype_fs(UINT64 partlba, UINTN *parttype, CHARN **fsname) { UINTN status; UINTN signature, score; UINTN sectsize, clustersize, reserved, fatcount, dirsize, sectcount, fatsize, clustercount; *fsname = STR("Unknown"); *parttype = 0; // READ sector 0 / offset 0K status = read_sector(partlba, sector); if (status != 0) return status; // detect XFS signature = *((UINT32 *)(sector)); if (signature == 0x42534658) { *parttype = 0x83; *fsname = STR("XFS"); return 0; } // detect FAT and NTFS sectsize = *((UINT16 *)(sector + 11)); clustersize = sector[13]; if (sectsize >= 512 && (sectsize & (sectsize - 1)) == 0 && clustersize > 0 && (clustersize & (clustersize - 1)) == 0) { // preconditions for both FAT and NTFS are now met if (CompareMem(sector + 3, "NTFS ", 8) == 0) { *parttype = 0x07; *fsname = STR("NTFS"); return 0; } score = 0; // boot jump if ((sector[0] == 0xEB && sector[2] == 0x90) || sector[0] == 0xE9) score++; // boot signature if (sector[510] == 0x55 && sector[511] == 0xAA) score++; // reserved sectors reserved = *((UINT16 *)(sector + 14)); if (reserved == 1 || reserved == 32) score++; // number of FATs fatcount = sector[16]; if (fatcount == 2) score++; // number of root dir entries dirsize = *((UINT16 *)(sector + 17)); // sector count (16-bit and 32-bit versions) sectcount = *((UINT16 *)(sector + 19)); if (sectcount == 0) sectcount = *((UINT32 *)(sector + 32)); // media byte if (sector[21] == 0xF0 || sector[21] >= 0xF8) score++; // FAT size in sectors fatsize = *((UINT16 *)(sector + 22)); if (fatsize == 0) fatsize = *((UINT32 *)(sector + 36)); // determine FAT type dirsize = ((dirsize * 32) + (sectsize - 1)) / sectsize; clustercount = sectcount - (reserved + (fatcount * fatsize) + dirsize); clustercount /= clustersize; if (score >= 3) { if (clustercount < 4085) { *parttype = 0x01; *fsname = STR("FAT12"); } else if (clustercount < 65525) { *parttype = 0x0e; *fsname = STR("FAT16"); } else { *parttype = 0x0c; *fsname = STR("FAT32"); } // TODO: check if 0e and 0c are okay to use, maybe we should use 06 and 0b instead... return 0; } } // READ sector 2 / offset 1K status = read_sector(partlba + 2, sector); if (status != 0) return status; // detect HFS+ signature = *((UINT16 *)(sector)); if (signature == 0x4442) { *parttype = 0xaf; if (*((UINT16 *)(sector + 0x7c)) == 0x2B48) *fsname = STR("HFS Extended (HFS+)"); else *fsname = STR("HFS Standard"); return 0; } else if (signature == 0x2B48) { *parttype = 0xaf; *fsname = STR("HFS Extended (HFS+)"); return 0; } // detect ext2/ext3/ext4 signature = *((UINT16 *)(sector + 56)); if (signature == 0xEF53) { *parttype = 0x83; if (*((UINT16 *)(sector + 96)) & 0x02C0 || *((UINT16 *)(sector + 100)) & 0x0078) *fsname = STR("ext4"); else if (*((UINT16 *)(sector + 92)) & 0x0004) *fsname = STR("ext3"); else *fsname = STR("ext2"); return 0; } // READ sector 128 / offset 64K status = read_sector(partlba + 128, sector); if (status != 0) return status; // detect btrfs if (CompareMem(sector + 64, "_BHRfS_M", 8) == 0) { *parttype = 0x83; *fsname = STR("btrfs"); return 0; } // detect ReiserFS if (CompareMem(sector + 52, "ReIsErFs", 8) == 0 || CompareMem(sector + 52, "ReIsEr2Fs", 9) == 0 || CompareMem(sector + 52, "ReIsEr3Fs", 9) == 0) { *parttype = 0x83; *fsname = STR("ReiserFS"); return 0; } // detect Reiser4 if (CompareMem(sector, "ReIsEr4", 7) == 0) { *parttype = 0x83; *fsname = STR("Reiser4"); return 0; } // READ sector 64 / offset 32K status = read_sector(partlba + 64, sector); if (status != 0) return status; // detect JFS if (CompareMem(sector, "JFS1", 4) == 0) { *parttype = 0x83; *fsname = STR("JFS"); return 0; } // READ sector 16 / offset 8K status = read_sector(partlba + 16, sector); if (status != 0) return status; // detect ReiserFS if (CompareMem(sector + 52, "ReIsErFs", 8) == 0 || CompareMem(sector + 52, "ReIsEr2Fs", 9) == 0 || CompareMem(sector + 52, "ReIsEr3Fs", 9) == 0) { *parttype = 0x83; *fsname = STR("ReiserFS"); return 0; } return 0; }
unsigned int memory::get_rangesize(unsigned int var) const { THROW_ASSERT(has_base_address(var), "Variable not yet allocated: @" + STR(var)); return rangesize.find(var)->second; }
#include "common.hpp" #include <limits> #include <string> TEST_XML(dom_attr_assign, "<node/>") { xml_node node = doc.child(STR("node")); node.append_attribute(STR("attr1")) = STR("v1"); xml_attribute() = STR("v1"); node.append_attribute(STR("attr2")) = -2147483647; node.append_attribute(STR("attr3")) = -2147483647 - 1; xml_attribute() = -2147483647 - 1; node.append_attribute(STR("attr4")) = 4294967295u; node.append_attribute(STR("attr5")) = 4294967294u; xml_attribute() = 4294967295u; node.append_attribute(STR("attr6")) = 0.5; xml_attribute() = 0.5; node.append_attribute(STR("attr7")) = true; xml_attribute() = true; CHECK_NODE(node, STR("<node attr1=\"v1\" attr2=\"-2147483647\" attr3=\"-2147483648\" attr4=\"4294967295\" attr5=\"4294967294\" attr6=\"0.5\" attr7=\"true\" />")); } TEST_XML(dom_attr_set_name, "<node attr='value' />") {
exit(-1); } } /*--------------------------------------------------------------------------*/ //! Linux system layer dynamic-link library unloading. /*! This function will be automatically called under Linux platform when the current library instance is unloading from the process. Here comes the calling of a system uninstalling method to release all system dependant routines and resourses. */ extern "C" void __attribute__ ((destructor)) JOIN(SHARED_LIBRARY_NAME, _fini)(void) { CALL if (loc_pSharedLibrary == 0) { WARNING(STR("DLL unloading: Cannot unload the current shared library, which was non loaded properly.")); exit(-1); } // Unload shared library. NDepth::NTypes::Tbool result = loc_pSharedLibrary->onUnload(); // Destroy shared library instance. loc_pSharedLibrary->~ISharedLibrary(); free(loc_pSharedLibrary); loc_pSharedLibrary = 0; if (!result) { WARNING(STR("DLL unloading: Cannot unload the current shared library.")); exit(-1);
static void mime_state_content_type(MIME_STATE *state, HEADER_OPTS *header_info) { const char *cp; int tok_count; int def_ctype; int def_stype; #define TOKEN_MATCH(tok, text) \ ((tok).type == HEADER_TOK_TOKEN && strcasecmp((tok).u.value, (text)) == 0) #define RFC2045_TSPECIALS "()<>@,;:\\\"/[]?=" #define PARSE_CONTENT_TYPE_HEADER(state, ptr) \ header_token(state->token, MIME_MAX_TOKEN, \ state->token_buffer, ptr, RFC2045_TSPECIALS, ';') cp = STR(state->output_buffer) + strlen(header_info->name) + 1; if ((tok_count = PARSE_CONTENT_TYPE_HEADER(state, &cp)) > 0) { /* * text/whatever. Right now we don't really care if it is plain or * not, but we may want to recognize subtypes later, and then this * code can serve as an example. */ if (TOKEN_MATCH(state->token[0], "text")) { state->curr_ctype = MIME_CTYPE_TEXT; if (tok_count >= 3 && state->token[1].type == '/' && TOKEN_MATCH(state->token[2], "plain")) state->curr_stype = MIME_STYPE_PLAIN; else state->curr_stype = MIME_STYPE_OTHER; return; } /* * message/whatever body parts start with another block of message * headers that we may want to look at. The partial and external-body * subtypes cannot be subjected to 8-bit -> 7-bit conversion, so we * must properly recognize them. */ if (TOKEN_MATCH(state->token[0], "message")) { state->curr_ctype = MIME_CTYPE_MESSAGE; state->curr_stype = MIME_STYPE_OTHER; if (tok_count >= 3 && state->token[1].type == '/') { if (TOKEN_MATCH(state->token[2], "rfc822")) state->curr_stype = MIME_STYPE_RFC822; else if (TOKEN_MATCH(state->token[2], "partial")) state->curr_stype = MIME_STYPE_PARTIAL; else if (TOKEN_MATCH(state->token[2], "external-body")) state->curr_stype = MIME_STYPE_EXTERN_BODY; } return; } /* * multipart/digest has default content type message/rfc822, * multipart/whatever has default content type text/plain. */ if (TOKEN_MATCH(state->token[0], "multipart")) { state->curr_ctype = MIME_CTYPE_MULTIPART; if (tok_count >= 3 && state->token[1].type == '/' && TOKEN_MATCH(state->token[2], "digest")) { def_ctype = MIME_CTYPE_MESSAGE; def_stype = MIME_STYPE_RFC822; } else { def_ctype = MIME_CTYPE_TEXT; def_stype = MIME_STYPE_PLAIN; } /* * Yes, this is supposed to capture multiple boundary strings, * which are illegal and which could be used to hide content in * an implementation dependent manner. The code below allows us * to find embedded message headers as long as the sender uses * only one of these same-level boundary strings. * * Yes, this is supposed to ignore the boundary value type. */ while ((tok_count = PARSE_CONTENT_TYPE_HEADER(state, &cp)) >= 0) { if (tok_count >= 3 && TOKEN_MATCH(state->token[0], "boundary") && state->token[1].type == '=') { if (state->nesting_level > var_mime_maxdepth) { if (state->static_flags & MIME_OPT_REPORT_NESTING) REPORT_ERROR(state, MIME_ERR_NESTING, STR(state->output_buffer)); } else { mime_state_push(state, def_ctype, def_stype, state->token[2].u.value); } } } } return; } /* * other/whatever. */ else { state->curr_ctype = MIME_CTYPE_OTHER; return; } }
bool OutNetRTMP4TSStream::FeedVideoData(uint8_t *pData, uint32_t dataLength, double absoluteTimestamp) { switch (NALU_TYPE(pData[0])) { case NALU_TYPE_SPS: { //1. Prepare the SPS part from video codec if (dataLength > 128) { FATAL("SPS too big"); return false; } memcpy(_pSPSPPS + 6, pData + 1, 3); //profile,profile compat,level EHTONSP(_pSPSPPS + 11, (uint16_t) dataLength); memcpy(_pSPSPPS + 13, pData, dataLength); _PPSStart = 13 + dataLength; _spsAvailable = true; return true; } case NALU_TYPE_PPS: { //2. Prepare the PPS part from video codec if (dataLength > 128) { FATAL("PPS too big"); return false; } if (!_spsAvailable) { WARN("No SPS available yet"); return true; } _pSPSPPS[_PPSStart] = 1; EHTONSP(_pSPSPPS + _PPSStart + 1, (uint16_t) dataLength); memcpy(_pSPSPPS + _PPSStart + 1 + 2, pData, dataLength); _spsAvailable = false; //3. Send the video codec if (!BaseOutNetRTMPStream::FeedData( _pSPSPPS, //pData _PPSStart + 1 + 2 + dataLength, //dataLength 0, //processedLength _PPSStart + 1 + 2 + dataLength, //totalLength absoluteTimestamp, //absoluteTimestamp false //isAudio )) { FATAL("Unable to send video codec setup"); return false; } _videoCodecSent = true; return true; } case NALU_TYPE_IDR: case NALU_TYPE_SLICE: { //10. Make room for the RTMP header _videoBuffer.ReadFromRepeat(0, 9); //11. Add the raw data _videoBuffer.ReadFromBuffer(pData, dataLength); uint8_t *pBuffer = GETIBPOINTER(_videoBuffer); //12. Setup the RTMP header pBuffer[0] = (NALU_TYPE(pData[0]) == NALU_TYPE_IDR) ? 0x17 : 0x27; pBuffer[1] = 0x01; pBuffer[2] = pBuffer[3] = pBuffer[4] = 0; EHTONLP(pBuffer + 5, dataLength); //----MARKED-LONG--- //13. Send it if (!BaseOutNetRTMPStream::FeedData( pBuffer, //pData dataLength + 9, //dataLength 0, //processedLength dataLength + 9, //totalLength absoluteTimestamp, //absoluteTimestamp false //isAudio )) { FATAL("Unable to send video"); return false; } //14. Cleanup _videoBuffer.IgnoreAll(); return true; } case NALU_TYPE_PD: case NALU_TYPE_SEI: case NALU_TYPE_FILL: { return true; } default: { WARN("Ignoring NAL: %s", STR(NALUToString(pData[0]))); return true; } } }
static int deliver_mailbox_file(LOCAL_STATE state, USER_ATTR usr_attr) { const char *myname = "deliver_mailbox_file"; DSN_BUF *why = state.msg_attr.why; MBOX *mp; int mail_copy_status; int deliver_status; int copy_flags; struct stat st; /* * Make verbose logging easier to understand. */ state.level++; if (msg_verbose) MSG_LOG_STATE(myname, state); /* * Don't deliver trace-only requests. */ if (DEL_REQ_TRACE_ONLY(state.request->flags)) { dsb_simple(why, "2.0.0", "delivers to mailbox"); return (sent(BOUNCE_FLAGS(state.request), SENT_ATTR(state.msg_attr))); } /* * Initialize. Assume the operation will fail. Set the delivered * attribute to reflect the final recipient. */ if (vstream_fseek(state.msg_attr.fp, state.msg_attr.offset, SEEK_SET) < 0) msg_fatal("seek message file %s: %m", VSTREAM_PATH(state.msg_attr.fp)); state.msg_attr.delivered = state.msg_attr.rcpt.address; mail_copy_status = MAIL_COPY_STAT_WRITE; /* * Lock the mailbox and open/create the mailbox file. * * Write the file as the recipient, so that file quota work. */ copy_flags = MAIL_COPY_MBOX; set_eugid(usr_attr.uid, usr_attr.gid); mp = mbox_open(usr_attr.mailbox, O_APPEND | O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR, &st, -1, -1, virtual_mbox_lock_mask, "4.2.0", why); if (mp != 0) { if (S_ISREG(st.st_mode) == 0) { vstream_fclose(mp->fp); msg_warn("recipient %s: destination %s is not a regular file", state.msg_attr.rcpt.address, usr_attr.mailbox); dsb_simple(why, "5.3.5", "mail system configuration error"); } else if (var_strict_mbox_owner && st.st_uid != usr_attr.uid) { vstream_fclose(mp->fp); dsb_simple(why, "4.2.0", "destination %s is not owned by recipient", usr_attr.mailbox); msg_warn("specify \"%s = no\" to ignore mailbox ownership mismatch", VAR_STRICT_MBOX_OWNER); } else { if (vstream_fseek(mp->fp, (off_t) 0, SEEK_END) < 0) msg_fatal("%s: seek queue file %s: %m", myname, VSTREAM_PATH(mp->fp)); mail_copy_status = mail_copy(COPY_ATTR(state.msg_attr), mp->fp, copy_flags, "\n", why); } mbox_release(mp); } set_eugid(var_owner_uid, var_owner_gid); /* * As the mail system, bounce, defer delivery, or report success. */ if (mail_copy_status & MAIL_COPY_STAT_CORRUPT) { deliver_status = DEL_STAT_DEFER; } else if (mail_copy_status != 0) { vstring_sprintf_prepend(why->reason, "delivery failed to mailbox %s: ", usr_attr.mailbox); deliver_status = (STR(why->status)[0] == '4' ? defer_append : bounce_append) (BOUNCE_FLAGS(state.request), BOUNCE_ATTR(state.msg_attr)); } else { dsb_simple(why, "2.0.0", "delivered to mailbox"); deliver_status = sent(BOUNCE_FLAGS(state.request), SENT_ATTR(state.msg_attr)); } return (deliver_status); }