这篇教程C++ xzalloc函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中xzalloc函数的典型用法代码示例。如果您正苦于以下问题:C++ xzalloc函数的具体用法?C++ xzalloc怎么用?C++ xzalloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了xzalloc函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: parse_subst_cmd/* * Process the commands arguments */static const char *parse_cmd_args(sed_cmd_t *sed_cmd, const char *cmdstr){ /* handle (s)ubstitution command */ if (sed_cmd->cmd == 's') cmdstr += parse_subst_cmd(sed_cmd, cmdstr); /* handle edit cmds: (a)ppend, (i)nsert, and (c)hange */ else if (strchr("aic", sed_cmd->cmd)) { if ((sed_cmd->end_line || sed_cmd->end_match) && sed_cmd->cmd != 'c') bb_error_msg_and_die ("only a beginning address can be specified for edit commands"); for (;;) { if (*cmdstr == '/n' || *cmdstr == '//') { cmdstr++; break; } else if (isspace(*cmdstr)) cmdstr++; else break; } sed_cmd->string = xstrdup(cmdstr); /* "/anychar" -> "anychar" */ parse_escapes(sed_cmd->string, sed_cmd->string, strlen(cmdstr), '/0', '/0'); cmdstr += strlen(cmdstr); /* handle file cmds: (r)ead */ } else if (strchr("rw", sed_cmd->cmd)) { if (sed_cmd->end_line || sed_cmd->end_match) bb_error_msg_and_die("command only uses one address"); cmdstr += parse_file_cmd(sed_cmd, cmdstr, &sed_cmd->string); if (sed_cmd->cmd == 'w') { sed_cmd->sw_file = xfopen(sed_cmd->string, "w"); sed_cmd->sw_last_char = '/n'; } /* handle branch commands */ } else if (strchr(":btT", sed_cmd->cmd)) { int length; cmdstr = skip_whitespace(cmdstr); length = strcspn(cmdstr, semicolon_whitespace); if (length) { sed_cmd->string = xstrndup(cmdstr, length); cmdstr += length; } } /* translation command */ else if (sed_cmd->cmd == 'y') { char *match, *replace; int i = cmdstr[0]; cmdstr += parse_regex_delim(cmdstr, &match, &replace)+1; /* /n already parsed, but /delimiter needs unescaping. */ parse_escapes(match, match, strlen(match), i, i); parse_escapes(replace, replace, strlen(replace), i, i); sed_cmd->string = xzalloc((strlen(match) + 1) * 2); for (i = 0; match[i] && replace[i]; i++) { sed_cmd->string[i*2] = match[i]; sed_cmd->string[i*2+1] = replace[i]; } free(match); free(replace); } /* if it wasnt a single-letter command that takes no arguments * then it must be an invalid command. */ else if (strchr("dDgGhHlnNpPqx={}", sed_cmd->cmd) == 0) { bb_error_msg_and_die("unsupported command %c", sed_cmd->cmd); } /* give back whatever's left over */ return cmdstr;}
开发者ID:benjaminlevine,项目名称:Huawei-HG633-Open-Source-Software-Package,代码行数:74,
示例2: man_mainint man_main(int argc UNUSED_PARAM, char **argv){ parser_t *parser; const char *pager; char **man_path_list; char *sec_list; char *cur_path, *cur_sect; int count_mp, cur_mp; int opt, not_found; char *token[2]; opt_complementary = "-1"; /* at least one argument */ opt = getopt32(argv, "+aw"); argv += optind; sec_list = xstrdup("1:2:3:4:5:6:7:8:9"); /* Last valid man_path_list[] is [0x10] */ count_mp = 0; man_path_list = xzalloc(0x11 * sizeof(man_path_list[0])); man_path_list[0] = getenv("MANPATH"); if (!man_path_list[0]) /* default, may be overridden by /etc/man.conf */ man_path_list[0] = (char*)"/usr/man"; else count_mp++; pager = getenv("MANPAGER"); if (!pager) { pager = getenv("PAGER"); if (!pager) pager = "more"; } /* Parse man.conf[ig] or man_db.conf */ /* man version 1.6f uses man.config */ /* man-db implementation of man uses man_db.conf */ parser = config_open2("/etc/man.config", fopen_for_read); if (!parser) parser = config_open2("/etc/man.conf", fopen_for_read); if (!parser) parser = config_open2("/etc/man_db.conf", fopen_for_read); while (config_read(parser, token, 2, 0, "# /t", PARSE_NORMAL)) { if (!token[1]) continue; if (strcmp("MANDATORY_MANPATH"+10, token[0]) == 0 /* "MANPATH"? */ || strcmp("MANDATORY_MANPATH", token[0]) == 0 ) { char *path = token[1]; while (*path) { char *next_path; char **path_element; next_path = strchr(path, ':'); if (next_path) { *next_path = '/0'; if (next_path++ == path) /* "::"? */ goto next; } /* Do we already have path? */ path_element = man_path_list; while (*path_element) { if (strcmp(*path_element, path) == 0) goto skip; path_element++; } man_path_list = xrealloc_vector(man_path_list, 4, count_mp); man_path_list[count_mp] = xstrdup(path); count_mp++; /* man_path_list is NULL terminated */ /*man_path_list[count_mp] = NULL; - xrealloc_vector did it */ skip: if (!next_path) break; next: path = next_path; } } if (strcmp("MANSECT", token[0]) == 0) { free(sec_list); sec_list = xstrdup(token[1]); } } config_close(parser); not_found = 0; do { /* for each argv[] */ int found = 0; cur_mp = 0; if (strchr(*argv, '/')) { found = show_manpage(pager, *argv, /*man:*/ 1, 0); goto check_found; } while ((cur_path = man_path_list[cur_mp++]) != NULL) { /* for each MANPATH */ cur_sect = sec_list; do { /* for each section */ char *next_sect = strchrnul(cur_sect, ':'); int sect_len = next_sect - cur_sect; char *man_filename; int cat0man1 = 0;//.........这里部分代码省略.........
开发者ID:Aircell,项目名称:asp-busybox,代码行数:101,
示例3: cut_filestatic void cut_file(FILE *file, char delim, const struct cut_list *cut_lists, unsigned nlists){ char *line; unsigned linenum = 0; /* keep these zero-based to be consistent */ /* go through every line in the file */ while ((line = xmalloc_fgetline(file)) != NULL) { /* set up a list so we can keep track of what's been printed */ int linelen = strlen(line); char *printed = xzalloc(linelen + 1); char *orig_line = line; unsigned cl_pos = 0; int spos; /* cut based on chars/bytes XXX: only works when sizeof(char) == byte */ if (option_mask32 & (CUT_OPT_CHAR_FLGS | CUT_OPT_BYTE_FLGS)) { /* print the chars specified in each cut list */ for (; cl_pos < nlists; cl_pos++) { spos = cut_lists[cl_pos].startpos; while (spos < linelen) { if (!printed[spos]) { printed[spos] = 'X'; putchar(line[spos]); } spos++; if (spos > cut_lists[cl_pos].endpos /* NON_RANGE is -1, so if below is true, * the above was true too (spos is >= 0) */ /* || cut_lists[cl_pos].endpos == NON_RANGE */ ) { break; } } } } else if (delim == '/n') { /* cut by lines */ spos = cut_lists[cl_pos].startpos; /* get out if we have no more lists to process or if the lines * are lower than what we're interested in */ if (((int)linenum < spos) || (cl_pos >= nlists)) goto next_line; /* if the line we're looking for is lower than the one we were * passed, it means we displayed it already, so move on */ while (spos < (int)linenum) { spos++; /* go to the next list if we're at the end of this one */ if (spos > cut_lists[cl_pos].endpos || cut_lists[cl_pos].endpos == NON_RANGE ) { cl_pos++; /* get out if there's no more lists to process */ if (cl_pos >= nlists) goto next_line; spos = cut_lists[cl_pos].startpos; /* get out if the current line is lower than the one * we just became interested in */ if ((int)linenum < spos) goto next_line; } } /* If we made it here, it means we've found the line we're * looking for, so print it */ puts(line); goto next_line; } else { /* cut by fields */ int ndelim = -1; /* zero-based / one-based problem */ int nfields_printed = 0; char *field = NULL; char delimiter[2]; delimiter[0] = delim; delimiter[1] = 0; /* does this line contain any delimiters? */ if (strchr(line, delim) == NULL) { if (!(option_mask32 & CUT_OPT_SUPPRESS_FLGS)) puts(line); goto next_line; } /* process each list on this line, for as long as we've got * a line to process */ for (; cl_pos < nlists && line; cl_pos++) { spos = cut_lists[cl_pos].startpos; do { /* find the field we're looking for */ while (line && ndelim < spos) { field = strsep(&line, delimiter); ndelim++; } /* we found it, and it hasn't been printed yet */ if (field && ndelim == spos && !printed[ndelim]) { /* if this isn't our first time through, we need to * print the delimiter after the last field that was * printed */ if (nfields_printed > 0)//.........这里部分代码省略.........
开发者ID:593141477,项目名称:Learning-Linux,代码行数:101,
示例4: huft_build//.........这里部分代码省略......... do { j = *p++; if (j != 0) { v[x[j]++] = i; } } while (++i < n); /* Generate the Huffman codes and for each, make the table entries */ x[0] = i = 0; /* first Huffman code is zero */ p = v; /* grab values in bit order */ htl = -1; /* no tables yet--level -1 */ w = ws[0] = 0; /* bits decoded */ u[0] = NULL; /* just to keep compilers happy */ q = NULL; /* ditto */ z = 0; /* ditto */ /* go through the bit lengths (k already is bits in shortest code) */ for (; k <= g; k++) { a = c[k]; while (a--) { /* here i is the Huffman code of length k bits for value *p */ /* make tables up to required level */ while (k > ws[htl + 1]) { w = ws[++htl]; /* compute minimum size table less than or equal to *m bits */ z = g - w; z = z > *m ? *m : z; /* upper limit on table size */ j = k - w; f = 1 << j; if (f > a + 1) { /* try a k-w bit table */ /* too few codes for k-w bit table */ f -= a + 1; /* deduct codes from patterns left */ xp = c + k; while (++j < z) { /* try smaller tables up to z bits */ f <<= 1; if (f <= *++xp) { break; /* enough codes to use up j bits */ } f -= *xp; /* else deduct codes from patterns */ } } j = (w + j > eob_len && w < eob_len) ? eob_len - w : j; /* make EOB code end at table */ z = 1 << j; /* table entries for j-bit table */ ws[htl+1] = w + j; /* set bits decoded in stack */ /* allocate and link in new table */ q = xzalloc((z + 1) * sizeof(huft_t)); *t = q + 1; /* link to list for huft_free() */ t = &(q->v.t); u[htl] = ++q; /* table starts after link */ /* connect to last table, if there is one */ if (htl) { x[htl] = i; /* save pattern for backing up */ r.b = (unsigned char) (w - ws[htl - 1]); /* bits to dump before this table */ r.e = (unsigned char) (16 + j); /* bits in this table */ r.v.t = q; /* pointer to this table */ j = (i & ((1 << w) - 1)) >> ws[htl - 1]; u[htl - 1][j] = r; /* connect to last table */ } } /* set up table entry in r */ r.b = (unsigned char) (k - w); if (p >= v + n) { r.e = 99; /* out of values--invalid code */ } else if (*p < s) { r.e = (unsigned char) (*p < 256 ? 16 : 15); /* 256 is EOB code */ r.v.n = (unsigned short) (*p++); /* simple code is just the value */ } else { r.e = (unsigned char) e[*p - s]; /* non-simple--look up in lists */ r.v.n = d[*p++ - s]; } /* fill code-like entries with r */ f = 1 << (k - w); for (j = i >> w; j < z; j += f) { q[j] = r; } /* backwards increment the k-bit code i */ for (j = 1 << (k - 1); i & j; j >>= 1) { i ^= j; } i ^= j; /* backup over finished tables */ while ((i & ((1 << w) - 1)) != x[htl]) { w = ws[--htl]; } } } /* return actual size of base table */ *m = ws[1]; /* Return true (1) if we were given an incomplete table */ return y != 0 && g != 1;}
开发者ID:fullstory-morgue,项目名称:busybox-sidux,代码行数:101,
示例5: hosts_info_get_by_name/* hosts_info_get_by_name parses a UNIX like hosts file in * the following format: * IP_address canonical_hostname [aliases...] * * see RFC 592 and the manual pages for hosts(5), hostname(1), * resolver(3), resolver(5), hostname(7) */int hosts_info_get_by_name(const char *filename, const char *hostname, size_t hostname_len, struct hosts_info **res){ FILE *file; int i; char line_buf[MAX_LINE_SIZE + 1], white_spaces[] = " /t/n"; char fileentry[MAX_LINE_SIZE]; char *buf, *cp; char *alias_array[MAX_ALIASES]; int alias_index; char *domain_name, *addr_name; struct hosts_info *hi, *hi_prev; hi = hi_prev = *res = NULL; if (filename == NULL || hostname == NULL || hostname_len <= 0) return -ERROR_CODE_ARGUMENT; file = fopen(filename, "r"); if (!file) return -ERROR_CODE_FILE; while (fgets(line_buf, MAX_LINE_SIZE, file) != NULL) { buf = cp = NULL; /* skip comments */ if (line_buf[0] == '#') continue; cp = strtok_r(line_buf, "#", &buf); if (!cp) continue; memset(fileentry, 0, MAX_LINE_SIZE); strncpy(fileentry, cp, MAX_LINE_SIZE); /* IPv{4,6} address */ cp = strtok_r(fileentry, white_spaces, &buf); if (!cp) continue; addr_name = cp; /* full domain name */ cp = strtok_r(NULL, white_spaces, &buf); if (!cp) continue; domain_name = cp; if (!strcasecmp(domain_name, hostname)) { struct addrinfo hosthints, *hostres; hi = xzalloc(sizeof(*hi)); hi->name = xstrdup(domain_name); hi->type = HOST_INFO_TYPE_DOMAIN; hi->addr_str = xstrdup(addr_name); /* validate address and convert into sockaddr_storage */ memset(&hosthints, 0, sizeof(hosthints)); hosthints.ai_family = AF_UNSPEC; hosthints.ai_flags = AI_NUMERICHOST; xgetaddrinfo(addr_name, NULL, &hosthints, &hostres); if (hostres != NULL) { memcpy(&hi->addr, &hostres->ai_addr, hostres->ai_addrlen); hi->addr_len = hostres->ai_addrlen; hi->family = hostres->ai_family; } hi->next = NULL; freeaddrinfo(hostres); hi_prev = *res = hi; } /* iterate over all aliases */ alias_index = 0; while (((cp = strtok_r(NULL, white_spaces, &buf)) != NULL) && alias_index < MAX_ALIASES) { if (!strcasecmp(cp, hostname)) alias_array[alias_index++] = cp; } for (i = 0; i < alias_index; i++) { struct addrinfo hosthints, *hostres;//.........这里部分代码省略.........
开发者ID:hgn,项目名称:ldnsd,代码行数:101,
示例6: p2m_mem_access_checkbool_t p2m_mem_access_check(paddr_t gpa, vaddr_t gla, const struct npfec npfec){ int rc; bool_t violation; xenmem_access_t xma; vm_event_request_t *req; struct vcpu *v = current; struct p2m_domain *p2m = p2m_get_hostp2m(v->domain); /* Mem_access is not in use. */ if ( !p2m->mem_access_enabled ) return true; rc = p2m_get_mem_access(v->domain, _gfn(paddr_to_pfn(gpa)), &xma); if ( rc ) return true; /* Now check for mem_access violation. */ switch ( xma ) { case XENMEM_access_rwx: violation = false; break; case XENMEM_access_rw: violation = npfec.insn_fetch; break; case XENMEM_access_wx: violation = npfec.read_access; break; case XENMEM_access_rx: case XENMEM_access_rx2rw: violation = npfec.write_access; break; case XENMEM_access_x: violation = npfec.read_access || npfec.write_access; break; case XENMEM_access_w: violation = npfec.read_access || npfec.insn_fetch; break; case XENMEM_access_r: violation = npfec.write_access || npfec.insn_fetch; break; default: case XENMEM_access_n: case XENMEM_access_n2rwx: violation = true; break; } if ( !violation ) return true; /* First, handle rx2rw and n2rwx conversion automatically. */ if ( npfec.write_access && xma == XENMEM_access_rx2rw ) { rc = p2m_set_mem_access(v->domain, _gfn(paddr_to_pfn(gpa)), 1, 0, ~0, XENMEM_access_rw, 0); return false; } else if ( xma == XENMEM_access_n2rwx ) { rc = p2m_set_mem_access(v->domain, _gfn(paddr_to_pfn(gpa)), 1, 0, ~0, XENMEM_access_rwx, 0); } /* Otherwise, check if there is a vm_event monitor subscriber */ if ( !vm_event_check_ring(&v->domain->vm_event->monitor) ) { /* No listener */ if ( p2m->access_required ) { gdprintk(XENLOG_INFO, "Memory access permissions failure, " "no vm_event listener VCPU %d, dom %d/n", v->vcpu_id, v->domain->domain_id); domain_crash(v->domain); } else { /* n2rwx was already handled */ if ( xma != XENMEM_access_n2rwx ) { /* A listener is not required, so clear the access * restrictions. */ rc = p2m_set_mem_access(v->domain, _gfn(paddr_to_pfn(gpa)), 1, 0, ~0, XENMEM_access_rwx, 0); } } /* No need to reinject */ return false; } req = xzalloc(vm_event_request_t); if ( req ) { req->reason = VM_EVENT_REASON_MEM_ACCESS; /* Send request to mem access subscriber */ req->u.mem_access.gfn = gpa >> PAGE_SHIFT; req->u.mem_access.offset = gpa & ((1 << PAGE_SHIFT) - 1);//.........这里部分代码省略.........
开发者ID:mirage,项目名称:xen,代码行数:101,
示例7: key_newrdpKey* key_new(const char* keyfile){ rdpKey* key; RSA *rsa; FILE *fp; key = (rdpKey*) xzalloc(sizeof(rdpKey)); if (key == NULL) return NULL; fp = fopen(keyfile, "r"); if (fp == NULL) { printf("unable to load RSA key from %s: %s.", keyfile, strerror(errno)); xfree(key) ; return NULL; } rsa = PEM_read_RSAPrivateKey(fp, NULL, NULL, NULL); if (rsa == NULL) { ERR_print_errors_fp(stdout); fclose(fp); xfree(key) ; return NULL; } fclose(fp); switch (RSA_check_key(rsa)) { case 0: RSA_free(rsa); printf("invalid RSA key in %s", keyfile); xfree(key) ; return NULL; case 1: /* Valid key. */ break; default: ERR_print_errors_fp(stdout); RSA_free(rsa); xfree(key) ; return NULL; } if (BN_num_bytes(rsa->e) > 4) { RSA_free(rsa); printf("RSA public exponent too large in %s", keyfile); xfree(key) ; return NULL; } freerdp_blob_alloc(&key->modulus, BN_num_bytes(rsa->n)); BN_bn2bin(rsa->n, key->modulus.data); crypto_reverse(key->modulus.data, key->modulus.length); freerdp_blob_alloc(&key->private_exponent, BN_num_bytes(rsa->d)); BN_bn2bin(rsa->d, key->private_exponent.data); crypto_reverse(key->private_exponent.data, key->private_exponent.length); memset(key->exponent, 0, sizeof(key->exponent)); BN_bn2bin(rsa->e, key->exponent + sizeof(key->exponent) - BN_num_bytes(rsa->e)); crypto_reverse(key->exponent, sizeof(key->exponent)); RSA_free(rsa); return key;}
开发者ID:felfert,项目名称:FreeRDP,代码行数:73,
示例8: seize_wait_task/* * This routine seizes task putting it into a special * state where we can manipulate the task via ptrace * interface, and finally we can detach ptrace out of * of it so the task would not know if it was saddled * up with someone else. */int seize_wait_task(pid_t pid, pid_t ppid, struct proc_status_creds **creds){ siginfo_t si; int status, nr_sigstop; int ret = 0, ret2, wait_errno = 0; struct proc_status_creds cr; /* * For the comparison below, let's zero out any padding. */ memzero(&cr, sizeof(struct proc_status_creds)); /* * It's ugly, but the ptrace API doesn't allow to distinguish * attaching to zombie from other errors. Thus we have to parse * the target's /proc/pid/stat. Sad, but parse whatever else * we might need at that early point. */ processes_to_wait--;try_again: ret = wait4(pid, &status, __WALL, NULL); if (ret < 0) { /* * wait4() can expectedly fail only in a first time * if a task is zombie. If we are here from try_again, * this means that we are tracing this task. * * processes_to_wait should be descrimented only once in this * function if a first wait was success. */ processes_to_wait++; wait_errno = errno; } ret2 = parse_pid_status(pid, &cr); if (ret2) goto err; if (ret < 0 || WIFEXITED(status) || WIFSIGNALED(status)) { if (cr.state != 'Z') { if (pid == getpid()) pr_err("The criu itself is within dumped tree./n"); else pr_err("Unseizable non-zombie %d found, state %c, err %d/%d/n", pid, cr.state, ret, wait_errno); return -1; } return TASK_DEAD; } if ((ppid != -1) && (cr.ppid != ppid)) { pr_err("Task pid reused while suspending (%d: %d -> %d)/n", pid, ppid, cr.ppid); goto err; } if (!WIFSTOPPED(status)) { pr_err("SEIZE %d: task not stopped after seize/n", pid); goto err; } ret = ptrace(PTRACE_GETSIGINFO, pid, NULL, &si); if (ret < 0) { pr_perror("SEIZE %d: can't read signfo", pid); goto err; } if (SI_EVENT(si.si_code) != PTRACE_EVENT_STOP) { /* * Kernel notifies us about the task being seized received some * event other than the STOP, i.e. -- a signal. Let the task * handle one and repeat. */ if (ptrace(PTRACE_CONT, pid, NULL, (void *)(unsigned long)si.si_signo)) { pr_perror("Can't continue signal handling, aborting"); goto err; } ret = 0; goto try_again; } if (*creds == NULL) { *creds = xzalloc(sizeof(struct proc_status_creds)); if (!*creds) goto err; **creds = cr;//.........这里部分代码省略.........
开发者ID:Open-Party,项目名称:criu,代码行数:101,
示例9: rail_unicode_string_allocvoid rail_unicode_string_alloc(UNICODE_STRING* unicode_string, uint16 cbString){ unicode_string->length = cbString; unicode_string->string = xzalloc(cbString);}
开发者ID:BillTheBest,项目名称:FreeRDP,代码行数:5,
示例10: credssp_server_authenticate//.........这里部分代码省略......... credssp->negoToken.cbBuffer = p_buffer->cbBuffer; if ((status == SEC_I_COMPLETE_AND_CONTINUE) || (status == SEC_I_COMPLETE_NEEDED)) { if (credssp->table->CompleteAuthToken != NULL) credssp->table->CompleteAuthToken(&credssp->context, &output_buffer_desc); have_pub_key_auth = true; sspi_SecBufferFree(&credssp->negoToken); credssp->negoToken.pvBuffer = NULL; credssp->negoToken.cbBuffer = 0; if (credssp->table->QueryContextAttributes(&credssp->context, SECPKG_ATTR_SIZES, &credssp->ContextSizes) != SEC_E_OK) { printf("QueryContextAttributes SECPKG_ATTR_SIZES failure/n"); return 0; } if (have_pub_key_auth) { uint8* p; SecBuffer Buffers[2]; SecBufferDesc Message; Buffers[0].BufferType = SECBUFFER_DATA; /* TLS Public Key */ Buffers[1].BufferType = SECBUFFER_TOKEN; /* Signature */ Buffers[0].cbBuffer = credssp->PublicKey.cbBuffer; Buffers[0].pvBuffer = xmalloc(Buffers[0].cbBuffer); memcpy(Buffers[0].pvBuffer, credssp->PublicKey.pvBuffer, Buffers[0].cbBuffer); Buffers[1].cbBuffer = credssp->ContextSizes.cbMaxSignature; Buffers[1].pvBuffer = xzalloc(Buffers[1].cbBuffer); Message.cBuffers = 2; Message.ulVersion = SECBUFFER_VERSION; Message.pBuffers = (PSecBuffer) &Buffers; p = (uint8*) Buffers[0].pvBuffer; p[0]++; /* Public Key +1 */ sspi_SecBufferAlloc(&credssp->pubKeyAuth, Buffers[0].cbBuffer + Buffers[1].cbBuffer); credssp->table->EncryptMessage(&credssp->context, 0, &Message, 0); p = (uint8*) credssp->pubKeyAuth.pvBuffer; memcpy(p, Buffers[1].pvBuffer, Buffers[1].cbBuffer); /* Message Signature */ memcpy(&p[Buffers[1].cbBuffer], Buffers[0].pvBuffer, Buffers[0].cbBuffer); /* Encrypted Public Key */ } if (status == SEC_I_COMPLETE_NEEDED) status = SEC_E_OK; else if (status == SEC_I_COMPLETE_AND_CONTINUE) status = SEC_I_CONTINUE_NEEDED; } /* send authentication token */#ifdef WITH_DEBUG_CREDSSP printf("Sending Authentication Token/n"); credssp_buffer_print(credssp);#endif credssp_send(credssp); credssp_buffer_free(credssp);
开发者ID:ArvidNorr,项目名称:FreeRDP,代码行数:67,
示例11: new_excludestruct exclude *new_exclude (void){ return xzalloc (sizeof *new_exclude ());}
开发者ID:ajnelson,项目名称:gnulib,代码行数:5,
示例12: man_mainint man_main(int argc UNUSED_PARAM, char **argv){ parser_t *parser; const char *pager = ENABLE_LESS ? "less" : "more"; char *sec_list; char *cur_path, *cur_sect; char **man_path_list; int count_mp; int cur_mp; int opt, not_found; char *token[2]; opt_complementary = "-1"; /* at least one argument */ opt = getopt32(argv, "+aw"); argv += optind; sec_list = xstrdup("0p:1:1p:2:3:3p:4:5:6:7:8:9"); count_mp = 0; man_path_list = add_MANPATH(NULL, &count_mp, getenv("MANDATORY_MANPATH"+10) /* "MANPATH" */ ); if (!man_path_list) { /* default, may be overridden by /etc/man.conf */ man_path_list = xzalloc(2 * sizeof(man_path_list[0])); man_path_list[0] = (char*)"/usr/man"; /* count_mp stays 0. * Thus, man.conf will overwrite man_path_list[0] * if a path is defined there. */ } /* Parse man.conf[ig] or man_db.conf */ /* man version 1.6f uses man.config */ /* man-db implementation of man uses man_db.conf */ parser = config_open2("/etc/man.config", fopen_for_read); if (!parser) parser = config_open2("/etc/man.conf", fopen_for_read); if (!parser) parser = config_open2("/etc/man_db.conf", fopen_for_read); while (config_read(parser, token, 2, 0, "# /t", PARSE_NORMAL)) { if (!token[1]) continue; if (strcmp("DEFINE", token[0]) == 0) { if (is_prefixed_with("pager", token[1])) { pager = xstrdup(skip_whitespace(token[1]) + 5); } } else if (strcmp("MANDATORY_MANPATH"+10, token[0]) == 0 /* "MANPATH"? */ || strcmp("MANDATORY_MANPATH", token[0]) == 0 ) { man_path_list = add_MANPATH(man_path_list, &count_mp, token[1]); } if (strcmp("MANSECT", token[0]) == 0) { free(sec_list); sec_list = xstrdup(token[1]); } } config_close(parser); { /* environment overrides setting from man.config */ char *env_pager = getenv("MANPAGER"); if (!env_pager) env_pager = getenv("PAGER"); if (env_pager) pager = env_pager; } not_found = 0; do { /* for each argv[] */ int found = 0; cur_mp = 0; if (strchr(*argv, '/')) { found = show_manpage(pager, *argv, /*man:*/ 1, 0); goto check_found; } while ((cur_path = man_path_list[cur_mp++]) != NULL) { /* for each MANPATH */ cur_sect = sec_list; do { /* for each section */ char *next_sect = strchrnul(cur_sect, ':'); int sect_len = next_sect - cur_sect; char *man_filename; int cat0man1 = 0; /* Search for cat, then man page */ while (cat0man1 < 2) { int found_here; man_filename = xasprintf("%s/%s%.*s/%s.%.*s", cur_path, "cat/0man" + (cat0man1 * 4), sect_len, cur_sect, *argv, sect_len, cur_sect); found_here = show_manpage(pager, man_filename, cat0man1, 0); found |= found_here; cat0man1 += found_here + 1;//.........这里部分代码省略.........
开发者ID:bra1nb3am3r,项目名称:busybox-1,代码行数:101,
示例13: process_files//.........这里部分代码省略......... case 'T': if (substituted) break; /* Fall through */ /* Branch to label */ case 'b': if (!sed_cmd->string) goto discard_commands; else sed_cmd = branch_to(sed_cmd->string); break; /* Transliterate characters */ case 'y': { int i, j; for (i = 0; pattern_space[i]; i++) { for (j = 0; sed_cmd->string[j]; j += 2) { if (pattern_space[i] == sed_cmd->string[j]) { pattern_space[i] = sed_cmd->string[j + 1]; break; } } } break; } case 'g': /* Replace pattern space with hold space */ free(pattern_space); pattern_space = xstrdup(G.hold_space ? G.hold_space : ""); break; case 'G': /* Append newline and hold space to pattern space */ { int pattern_space_size = 2; int hold_space_size = 0; if (pattern_space) pattern_space_size += strlen(pattern_space); if (G.hold_space) hold_space_size = strlen(G.hold_space); pattern_space = xrealloc(pattern_space, pattern_space_size + hold_space_size); if (pattern_space_size == 2) pattern_space[0] = 0; strcat(pattern_space, "/n"); if (G.hold_space) strcat(pattern_space, G.hold_space); last_gets_char = '/n'; break; } case 'h': /* Replace hold space with pattern space */ free(G.hold_space); G.hold_space = xstrdup(pattern_space); break; case 'H': /* Append newline and pattern space to hold space */ { int hold_space_size = 2; int pattern_space_size = 0; if (G.hold_space) hold_space_size += strlen(G.hold_space); if (pattern_space) pattern_space_size = strlen(pattern_space); G.hold_space = xrealloc(G.hold_space, hold_space_size + pattern_space_size); if (hold_space_size == 2) *G.hold_space = 0; strcat(G.hold_space, "/n"); if (pattern_space) strcat(G.hold_space, pattern_space); break; } case 'x': /* Exchange hold and pattern space */ { char *tmp = pattern_space; pattern_space = G.hold_space ? : xzalloc(1); last_gets_char = '/n'; G.hold_space = tmp; break; } } } } /* * exit point from sedding... */ discard_commands: /* we will print the line unless we were told to be quiet ('-n') or if the line was suppressed (ala 'd'elete) */ if (!G.be_quiet) sed_puts(pattern_space, last_gets_char); /* Delete and such jump here. */ discard_line: flush_append(); free(pattern_space); goto again;}
开发者ID:benjaminlevine,项目名称:Huawei-HG633-Open-Source-Software-Package,代码行数:101,
示例14: add_cmdstatic void add_cmd(const char *cmdstr){ sed_cmd_t *sed_cmd; int temp; /* Append this line to any unfinished line from last time. */ if (G.add_cmd_line) { char *tp = xasprintf("%s/n%s", G.add_cmd_line, cmdstr); free(G.add_cmd_line); cmdstr = G.add_cmd_line = tp; } /* If this line ends with backslash, request next line. */ temp = strlen(cmdstr); if (temp && cmdstr[--temp] == '//') { if (!G.add_cmd_line) G.add_cmd_line = xstrdup(cmdstr); G.add_cmd_line[temp] = '/0'; return; } /* Loop parsing all commands in this line. */ while (*cmdstr) { /* Skip leading whitespace and semicolons */ cmdstr += strspn(cmdstr, semicolon_whitespace); /* If no more commands, exit. */ if (!*cmdstr) break; /* if this is a comment, jump past it and keep going */ if (*cmdstr == '#') { /* "#n" is the same as using -n on the command line */ if (cmdstr[1] == 'n') G.be_quiet++; cmdstr = strpbrk(cmdstr, "/n/r"); if (!cmdstr) break; continue; } /* parse the command * format is: [addr][,addr][!]cmd * |----||-----||-| * part1 part2 part3 */ sed_cmd = xzalloc(sizeof(sed_cmd_t)); /* first part (if present) is an address: either a '$', a number or a /regex/ */ cmdstr += get_address(cmdstr, &sed_cmd->beg_line, &sed_cmd->beg_match); /* second part (if present) will begin with a comma */ if (*cmdstr == ',') { int idx; cmdstr++; idx = get_address(cmdstr, &sed_cmd->end_line, &sed_cmd->end_match); if (!idx) bb_error_msg_and_die("no address after comma"); cmdstr += idx; } /* skip whitespace before the command */ cmdstr = skip_whitespace(cmdstr); /* Check for inversion flag */ if (*cmdstr == '!') { sed_cmd->invert = 1; cmdstr++; /* skip whitespace before the command */ cmdstr = skip_whitespace(cmdstr); } /* last part (mandatory) will be a command */ if (!*cmdstr) bb_error_msg_and_die("missing command"); sed_cmd->cmd = *(cmdstr++); cmdstr = parse_cmd_args(sed_cmd, cmdstr); /* Add the command to the command array */ G.sed_cmd_tail->next = sed_cmd; G.sed_cmd_tail = G.sed_cmd_tail->next; } /* If we glued multiple lines together, free the memory. */ free(G.add_cmd_line); G.add_cmd_line = NULL;}
开发者ID:benjaminlevine,项目名称:Huawei-HG633-Open-Source-Software-Package,代码行数:88,
示例15: wf_pre_connectboolean wf_pre_connect(freerdp* instance){ int i1; wfInfo* wfi; wfContext* context; rdpSettings* settings; wfi = (wfInfo*) xzalloc(sizeof(wfInfo)); context = (wfContext*) instance->context; wfi->instance = instance; context->wfi = wfi; settings = instance->settings; settings->os_major_type = OSMAJORTYPE_WINDOWS; settings->os_minor_type = OSMINORTYPE_WINDOWS_NT; settings->order_support[NEG_DSTBLT_INDEX] = true; settings->order_support[NEG_PATBLT_INDEX] = true; settings->order_support[NEG_SCRBLT_INDEX] = true; settings->order_support[NEG_OPAQUE_RECT_INDEX] = true; settings->order_support[NEG_DRAWNINEGRID_INDEX] = false; settings->order_support[NEG_MULTIDSTBLT_INDEX] = false; settings->order_support[NEG_MULTIPATBLT_INDEX] = false; settings->order_support[NEG_MULTISCRBLT_INDEX] = false; settings->order_support[NEG_MULTIOPAQUERECT_INDEX] = true; settings->order_support[NEG_MULTI_DRAWNINEGRID_INDEX] = false; settings->order_support[NEG_LINETO_INDEX] = true; settings->order_support[NEG_POLYLINE_INDEX] = true; settings->order_support[NEG_MEMBLT_INDEX] = true; settings->order_support[NEG_MEM3BLT_INDEX] = false; settings->order_support[NEG_SAVEBITMAP_INDEX] = false; settings->order_support[NEG_GLYPH_INDEX_INDEX] = false; settings->order_support[NEG_FAST_INDEX_INDEX] = false; settings->order_support[NEG_FAST_GLYPH_INDEX] = false; settings->order_support[NEG_POLYGON_SC_INDEX] = false; settings->order_support[NEG_POLYGON_CB_INDEX] = false; settings->order_support[NEG_ELLIPSE_SC_INDEX] = false; settings->order_support[NEG_ELLIPSE_CB_INDEX] = false; settings->glyph_cache = false; wfi->cursor = g_default_cursor; wfi->fullscreen = settings->fullscreen; wfi->fs_toggle = wfi->fullscreen; wfi->sw_gdi = settings->sw_gdi; wfi->clrconv = (HCLRCONV) xzalloc(sizeof(CLRCONV)); wfi->clrconv->palette = NULL; wfi->clrconv->alpha = 0; instance->context->cache = cache_new(settings); if (wfi->percentscreen > 0) { i1 = (GetSystemMetrics(SM_CXSCREEN) * wfi->percentscreen) / 100; settings->width = i1; i1 = (GetSystemMetrics(SM_CYSCREEN) * wfi->percentscreen) / 100; settings->height = i1; } if (wfi->fs_toggle) { settings->width = GetSystemMetrics(SM_CXSCREEN); settings->height = GetSystemMetrics(SM_CYSCREEN); } i1 = settings->width; i1 = (i1 + 3) & (~3); settings->width = i1; if ((settings->width < 64) || (settings->height < 64) || (settings->width > 4096) || (settings->height > 4096)) { printf("wf_pre_connect: invalid dimensions %d %d/n", settings->width, settings->height); return 1; } settings->kbd_layout = (int) GetKeyboardLayout(0) & 0x0000FFFF; freerdp_channels_pre_connect(instance->context->channels, instance); return true;}
开发者ID:adambprotiviti,项目名称:FreeRDP,代码行数:84,
示例16: imx_ocotp_probestatic int imx_ocotp_probe(struct device_d *dev){ struct resource *iores; struct ocotp_priv *priv; int ret = 0; const struct imx_ocotp_data *data; struct nvmem_device *nvmem; ret = dev_get_drvdata(dev, (const void **)&data); if (ret) return ret; iores = dev_request_mem_resource(dev, 0); if (IS_ERR(iores)) return PTR_ERR(iores); priv = xzalloc(sizeof(*priv)); priv->data = data; priv->base = IOMEM(iores->start); priv->clk = clk_get(dev, NULL); if (IS_ERR(priv->clk)) return PTR_ERR(priv->clk); strcpy(priv->dev.name, "ocotp"); priv->dev.parent = dev; register_device(&priv->dev); priv->map_config.reg_bits = 32; priv->map_config.val_bits = 32; priv->map_config.reg_stride = 4; priv->map_config.max_register = data->num_regs - 1; priv->map = regmap_init(dev, &imx_ocotp_regmap_bus, priv, &priv->map_config); if (IS_ERR(priv->map)) return PTR_ERR(priv->map); priv->config.name = "imx-ocotp"; priv->config.dev = dev; priv->config.stride = 4; priv->config.word_size = 4; priv->config.size = data->num_regs; priv->config.bus = &imx_ocotp_nvmem_bus; dev->priv = priv; nvmem = nvmem_register(&priv->config); if (IS_ERR(nvmem)) return PTR_ERR(nvmem); imx_ocotp = priv; if (IS_ENABLED(CONFIG_IMX_OCOTP_WRITE)) { dev_add_param_bool(&(priv->dev), "permanent_write_enable", NULL, NULL, &priv->permanent_write_enable, NULL); } if (IS_ENABLED(CONFIG_NET)) { int i; struct ocotp_priv_ethaddr *ethaddr; for (i = 0; i < priv->data->mac_offsets_num; i++) { ethaddr = &priv->ethaddr[i]; ethaddr->map = priv->map; ethaddr->offset = priv->data->mac_offsets[i]; ethaddr->data = data; dev_add_param_mac(&priv->dev, xasprintf("mac_addr%d", i), imx_ocotp_set_mac, imx_ocotp_get_mac, ethaddr->value, ethaddr); } /* * Alias to mac_addr0 for backwards compatibility */ ethaddr = &priv->ethaddr[0]; dev_add_param_mac(&priv->dev, "mac_addr", imx_ocotp_set_mac, imx_ocotp_get_mac, ethaddr->value, ethaddr); } imx_ocotp_init_dt(priv); dev_add_param_bool(&(priv->dev), "sense_enable", NULL, NULL, &priv->sense_enable, priv); return 0;}
开发者ID:MinimumLaw,项目名称:ravion-barebox,代码行数:86,
示例17: WinMainINT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ freerdp* instance; thread_data* data; WSADATA wsa_data; WNDCLASSEX wnd_cls; if (NULL == getenv("HOME")) { char home[MAX_PATH * 2] = "HOME="; strcat(home, getenv("HOMEDRIVE")); strcat(home, getenv("HOMEPATH")); _putenv(home); } if (WSAStartup(0x101, &wsa_data) != 0) return 1; g_done_event = CreateEvent(0, 1, 0, 0);#if defined(WITH_DEBUG) || defined(_DEBUG) wf_create_console();#endif g_default_cursor = LoadCursor(NULL, IDC_ARROW); wnd_cls.cbSize = sizeof(WNDCLASSEX); wnd_cls.style = CS_HREDRAW | CS_VREDRAW; wnd_cls.lpfnWndProc = wf_event_proc; wnd_cls.cbClsExtra = 0; wnd_cls.cbWndExtra = 0; wnd_cls.hIcon = LoadIcon(NULL, IDI_APPLICATION); wnd_cls.hCursor = g_default_cursor; wnd_cls.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wnd_cls.lpszMenuName = NULL; wnd_cls.lpszClassName = g_wnd_class_name; wnd_cls.hInstance = hInstance; wnd_cls.hIconSm = LoadIcon(NULL, IDI_APPLICATION); RegisterClassEx(&wnd_cls); g_hInstance = hInstance; freerdp_channels_global_init(); instance = freerdp_new(); instance->PreConnect = wf_pre_connect; instance->PostConnect = wf_post_connect; instance->VerifyCertificate = wf_verify_certificate; instance->ReceiveChannelData = wf_receive_channel_data; instance->context_size = sizeof(wfContext); instance->ContextNew = wf_context_new; instance->ContextFree = wf_context_free; freerdp_context_new(instance); instance->context->argc = __argc; instance->context->argv = __argv; if (!CreateThread(NULL, 0, kbd_thread_func, NULL, 0, NULL)) printf("error creating keyboard handler thread"); //while (1) { data = (thread_data*) xzalloc(sizeof(thread_data)); data->instance = instance; freerdp_parse_args(instance->settings, __argc, __argv, wf_process_plugin_args, instance->context->channels, wf_process_client_args, NULL); if (CreateThread(NULL, 0, thread_func, data, 0, NULL) != 0) g_thread_count++; } if (g_thread_count > 0) WaitForSingleObject(g_done_event, INFINITE); else MessageBox(GetConsoleWindow(), L"Failed to start wfreerdp./n/nPlease check the debug output.", L"FreeRDP Error", MB_ICONSTOP); WSACleanup();#ifdef _DEBUG system("pause");#endif return 0;}
开发者ID:adambprotiviti,项目名称:FreeRDP,代码行数:87,
示例18: volume_id_probe_msdos_part_tableint FAST_FUNC volume_id_probe_msdos_part_table(struct volume_id *id, uint64_t off){ const uint8_t *buf; int i; uint64_t poff; uint64_t plen; uint64_t extended = 0; uint64_t current; uint64_t next; int limit; int empty = 1; struct msdos_partition_entry *part; struct volume_id_partition *p; dbg("probing at offset 0x%llx", (unsigned long long) off); buf = volume_id_get_buffer(id, off, 0x200); if (buf == NULL) return -1; if (buf[MSDOS_SIG_OFF] != 0x55 || buf[MSDOS_SIG_OFF + 1] != 0xaa) return -1; /* check flags on all entries for a valid partition table */ part = (struct msdos_partition_entry*) &buf[MSDOS_PARTTABLE_OFFSET]; for (i = 0; i < 4; i++) { if (part[i].boot_ind != 0 && part[i].boot_ind != 0x80 ) { return -1; } if (part[i].nr_sects != 0) empty = 0; } if (empty == 1) return -1; if (id->partitions != NULL) free(id->partitions); id->partitions = xzalloc(VOLUME_ID_PARTITIONS_MAX * sizeof(struct volume_id_partition)); for (i = 0; i < 4; i++) { poff = (uint64_t) le32_to_cpu(part[i].start_sect) * BSIZE; plen = (uint64_t) le32_to_cpu(part[i].nr_sects) * BSIZE; if (plen == 0) continue; p = &id->partitions[i];// p->pt_type_raw = part[i].sys_ind; if (is_extended(part[i].sys_ind)) { dbg("found extended partition at 0x%llx", (unsigned long long) poff);// volume_id_set_usage_part(p, VOLUME_ID_PARTITIONTABLE);// p->type = "msdos_extended_partition"; if (extended == 0) extended = off + poff; } else { dbg("found 0x%x data partition at 0x%llx, len 0x%llx", part[i].sys_ind, (unsigned long long) poff, (unsigned long long) plen);// if (is_raid(part[i].sys_ind))// volume_id_set_usage_part(p, VOLUME_ID_RAID);// else// volume_id_set_usage_part(p, VOLUME_ID_UNPROBED); }// p->pt_off = off + poff;// p->pt_len = plen; id->partition_count = i+1; } next = extended; current = extended; limit = 50; /* follow extended partition chain and add data partitions */ while (next != 0) { if (limit-- == 0) { dbg("extended chain limit reached"); break; } buf = volume_id_get_buffer(id, current, 0x200); if (buf == NULL) break; part = (struct msdos_partition_entry*) &buf[MSDOS_PARTTABLE_OFFSET]; if (buf[MSDOS_SIG_OFF] != 0x55 || buf[MSDOS_SIG_OFF + 1] != 0xaa) break; next = 0; for (i = 0; i < 4; i++) { poff = (uint64_t) le32_to_cpu(part[i].start_sect) * BSIZE; plen = (uint64_t) le32_to_cpu(part[i].nr_sects) * BSIZE;//.........这里部分代码省略.........
开发者ID:b08060514,项目名称:busybox,代码行数:101,
示例19: split_mainint split_main(int argc UNUSED_PARAM, char **argv){ unsigned suffix_len = 2; char *pfx; char *count_p; const char *sfx; off_t cnt = 1000; off_t remaining = 0; unsigned opt; ssize_t bytes_read, to_write; char *src; opt_complementary = "?2:a+"; /* max 2 args; -a N */ opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &suffix_len); if (opt & SPLIT_OPT_l) cnt = XATOOFF(count_p); if (opt & SPLIT_OPT_b) // FIXME: also needs XATOOFF cnt = xatoull_sfx(count_p, split_suffices); sfx = "x"; argv += optind; if (argv[0]) { int fd; if (argv[1]) sfx = argv[1]; fd = open_or_warn_stdin(argv[0]); if (fd == -1) return EXIT_FAILURE; xmove_fd(fd, STDIN_FILENO); } else { argv[0] = (char *) bb_msg_standard_input; } if (NAME_MAX < strlen(sfx) + suffix_len) bb_error_msg_and_die("suffix too long"); { char *char_p = xzalloc(suffix_len + 1); memset(char_p, 'a', suffix_len); pfx = xasprintf("%s%s", sfx, char_p); if (ENABLE_FEATURE_CLEAN_UP) free(char_p); } while (1) { bytes_read = safe_read(STDIN_FILENO, read_buffer, READ_BUFFER_SIZE); if (!bytes_read) break; if (bytes_read < 0) bb_simple_perror_msg_and_die(argv[0]); src = read_buffer; do { if (!remaining) { if (!pfx) bb_error_msg_and_die("suffixes exhausted"); xmove_fd(xopen(pfx, O_WRONLY | O_CREAT | O_TRUNC), 1); pfx = next_file(pfx, suffix_len); remaining = cnt; } if (opt & SPLIT_OPT_b) { /* split by bytes */ to_write = (bytes_read < remaining) ? bytes_read : remaining; remaining -= to_write; } else { /* split by lines */ /* can be sped up by using _memrchr_ * and writing many lines at once... */ char *end = memchr(src, '/n', bytes_read); if (end) { --remaining; to_write = end - src + 1; } else { to_write = bytes_read; } } xwrite(STDOUT_FILENO, src, to_write); bytes_read -= to_write; src += to_write; } while (bytes_read); } return EXIT_SUCCESS;}
开发者ID:0xD34D,项目名称:android_external_busybox,代码行数:85,
示例20: update_read_window_icon_ordervoid update_read_window_icon_order(STREAM* s, WINDOW_ORDER_INFO* orderInfo, WINDOW_ICON_ORDER* window_icon){ window_icon->iconInfo = (ICON_INFO*) xzalloc(sizeof(ICON_INFO)); update_read_icon_info(s, window_icon->iconInfo); /* iconInfo (ICON_INFO) */}
开发者ID:ArvidNorr,项目名称:FreeRDP,代码行数:5,
示例21: alloc_statestatic state_t* alloc_state(void){ state_t* state = xzalloc(sizeof(*state)); INIT_STATE; return state;}
开发者ID:fullstory-morgue,项目名称:busybox-sidux,代码行数:6,
示例22: tsmf_ffmpeg_init_streamstatic tbool tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYPE* media_type){ TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder; uint32 size; const uint8* s; uint8* p; mdecoder->codec = avcodec_find_decoder(mdecoder->codec_id); if (!mdecoder->codec) { DEBUG_WARN("avcodec_find_decoder failed."); return false; } mdecoder->codec_context->codec_id = mdecoder->codec_id; mdecoder->codec_context->codec_type = mdecoder->media_type; if (mdecoder->media_type == AVMEDIA_TYPE_VIDEO) { if (!tsmf_ffmpeg_init_video_stream(decoder, media_type)) return false; } else if (mdecoder->media_type == AVMEDIA_TYPE_AUDIO) { if (!tsmf_ffmpeg_init_audio_stream(decoder, media_type)) return false; } if (media_type->ExtraData) { if (media_type->SubType == TSMF_SUB_TYPE_AVC1 && media_type->FormatType == TSMF_FORMAT_TYPE_MPEG2VIDEOINFO) { /* The extradata format that FFmpeg uses is following CodecPrivate in Matroska. See http://haali.su/mkv/codecs.pdf */ mdecoder->codec_context->extradata_size = media_type->ExtraDataSize + 8; mdecoder->codec_context->extradata = xzalloc(mdecoder->codec_context->extradata_size); p = mdecoder->codec_context->extradata; *p++ = 1; /* Reserved? */ *p++ = media_type->ExtraData[8]; /* Profile */ *p++ = 0; /* Profile */ *p++ = media_type->ExtraData[12]; /* Level */ *p++ = 0xff; /* Flag? */ *p++ = 0xe0 | 0x01; /* Reserved | #sps */ s = media_type->ExtraData + 20; size = ((uint32)(*s)) * 256 + ((uint32)(*(s + 1))); memcpy(p, s, size + 2); s += size + 2; p += size + 2; *p++ = 1; /* #pps */ size = ((uint32)(*s)) * 256 + ((uint32)(*(s + 1))); memcpy(p, s, size + 2); } else { /* Add a padding to avoid invalid memory read in some codec */ mdecoder->codec_context->extradata_size = media_type->ExtraDataSize + 8; mdecoder->codec_context->extradata = xzalloc(mdecoder->codec_context->extradata_size); memcpy(mdecoder->codec_context->extradata, media_type->ExtraData, media_type->ExtraDataSize); memset(mdecoder->codec_context->extradata + media_type->ExtraDataSize, 0, 8); } } if (mdecoder->codec->capabilities & CODEC_CAP_TRUNCATED) mdecoder->codec_context->flags |= CODEC_FLAG_TRUNCATED; return true;}
开发者ID:authentic8,项目名称:NeutrinoRDP,代码行数:68,
示例23: ipsvd_perhost_initvoid ipsvd_perhost_init(unsigned c){// free(cc); cc = xzalloc(c * sizeof(*cc)); cclen = c;}
开发者ID:915546302,项目名称:busybox-osx,代码行数:6,
示例24: tsmf_ffmpeg_decode_videostatic tbool tsmf_ffmpeg_decode_video(ITSMFDecoder* decoder, const uint8* data, uint32 data_size, uint32 extensions){ TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder; int decoded; int len; AVFrame* frame; tbool ret = true;#if LIBAVCODEC_VERSION_MAJOR < 52 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR <= 20) len = avcodec_decode_video(mdecoder->codec_context, mdecoder->frame, &decoded, data, data_size);#else { AVPacket pkt; av_init_packet(&pkt); pkt.data = (uint8*) data; pkt.size = data_size; if (extensions & TSMM_SAMPLE_EXT_CLEANPOINT) pkt.flags |= AV_PKT_FLAG_KEY; len = avcodec_decode_video2(mdecoder->codec_context, mdecoder->frame, &decoded, &pkt); }#endif if (len < 0) { DEBUG_WARN("data_size %d, avcodec_decode_video failed (%d)", data_size, len); ret = false; } else if (!decoded) { DEBUG_WARN("data_size %d, no frame is decoded.", data_size); ret = false; } else { DEBUG_DVC("linesize[0] %d linesize[1] %d linesize[2] %d linesize[3] %d " "pix_fmt %d width %d height %d", mdecoder->frame->linesize[0], mdecoder->frame->linesize[1], mdecoder->frame->linesize[2], mdecoder->frame->linesize[3], mdecoder->codec_context->pix_fmt, mdecoder->codec_context->width, mdecoder->codec_context->height); mdecoder->decoded_size = avpicture_get_size(mdecoder->codec_context->pix_fmt, mdecoder->codec_context->width, mdecoder->codec_context->height); mdecoder->decoded_data = xzalloc(mdecoder->decoded_size); frame = avcodec_alloc_frame(); avpicture_fill((AVPicture *) frame, mdecoder->decoded_data, mdecoder->codec_context->pix_fmt, mdecoder->codec_context->width, mdecoder->codec_context->height); av_picture_copy((AVPicture *) frame, (AVPicture *) mdecoder->frame, mdecoder->codec_context->pix_fmt, mdecoder->codec_context->width, mdecoder->codec_context->height); av_free(frame); }#if SAVE_VIDEO n_save_data(data, data_size, mdecoder->codec_context->width, mdecoder->codec_context->height);#endif return ret;}
开发者ID:authentic8,项目名称:NeutrinoRDP,代码行数:62,
示例25: parse_optsunsigned parse_opts(int argc, char **argv, const struct options *opt, const char *usage){ int help = 0; int size = parse_opt_size(opt); const int LONGOPT_OFFSET = 256; struct strbuf *shortopts = strbuf_new(); struct option *longopts = xzalloc(sizeof(longopts[0]) * (size+2)); struct option *curopt = longopts; int ii; for (ii = 0; ii < size; ++ii) { curopt->name = opt[ii].long_name; /*curopt->flag = 0; - xzalloc did it */ if (opt[ii].short_name) curopt->val = opt[ii].short_name; else curopt->val = LONGOPT_OFFSET + ii; switch (opt[ii].type) { case OPTION_BOOL: curopt->has_arg = no_argument; if (opt[ii].short_name) strbuf_append_char(shortopts, opt[ii].short_name); break; case OPTION_INTEGER: case OPTION_STRING: case OPTION_LIST: curopt->has_arg = required_argument; if (opt[ii].short_name) strbuf_append_strf(shortopts, "%c:", opt[ii].short_name); break; case OPTION_OPTSTRING: curopt->has_arg = optional_argument; if (opt[ii].short_name) strbuf_append_strf(shortopts, "%c::", opt[ii].short_name); break; case OPTION_GROUP: case OPTION_END: break; } //log("curopt[%d].name:'%s' .has_arg:%d .flag:%p .val:%d", (int)(curopt-longopts), // curopt->name, curopt->has_arg, curopt->flag, curopt->val); /* * getopt_long() thinks that NULL name marks the end of longopts. * Example: * [0] name:'verbose' val:'v' * [1] name:NULL val:'c' * [2] name:'force' val:'f' * ... ... ... * In this case, --force won't be accepted! * Therefore we can only advance if name is not NULL. */ if (curopt->name) curopt++; } curopt->name = "help"; curopt->has_arg = no_argument; curopt->flag = &help; curopt->val = 1; /* xzalloc did it already: curopt++; curopt->name = NULL; curopt->has_arg = 0; curopt->flag = NULL; curopt->val = 0; */ unsigned retval = 0; while (1) { int c = getopt_long(argc, argv, shortopts->buf, longopts, NULL); if (c == -1) break; if (c == '?' || help) { free(longopts); strbuf_free(shortopts); xfunc_error_retval = 0; /* this isn't error, exit code = 0 */ show_usage_and_die(usage, opt); } for (ii = 0; ii < size; ++ii) { if (opt[ii].short_name == c || LONGOPT_OFFSET + ii == c) { if (ii < sizeof(retval)*8) retval |= (1 << ii); if (opt[ii].value != NULL) switch (opt[ii].type) { case OPTION_BOOL: *(int*)(opt[ii].value) += 1; break; case OPTION_INTEGER://.........这里部分代码省略.........
开发者ID:credmon,项目名称:libreport,代码行数:101,
示例26: tsmf_ffmpeg_decode_audiostatic tbool tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const uint8* data, uint32 data_size, uint32 extensions){ TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder; int len; int frame_size; uint32 src_size; const uint8* src; uint8* dst; int dst_offset;#if 0 LLOGLN(0, ("tsmf_ffmpeg_decode_audio: data_size %d", data_size)); int i; for (i = 0; i < data_size; i++) { LLOG(0, ("%02X ", data[i])); if (i % 16 == 15) LLOG(0, ("/n")); } LLOG(0, ("/n"));#endif if (mdecoder->decoded_size_max == 0) mdecoder->decoded_size_max = AVCODEC_MAX_AUDIO_FRAME_SIZE + 16; mdecoder->decoded_data = xzalloc(mdecoder->decoded_size_max); /* align the memory for SSE2 needs */ dst = (uint8*) (((uintptr_t)mdecoder->decoded_data + 15) & ~ 0x0F); dst_offset = dst - mdecoder->decoded_data; src = data; src_size = data_size; while (src_size > 0) { /* Ensure enough space for decoding */ if (mdecoder->decoded_size_max - mdecoder->decoded_size < AVCODEC_MAX_AUDIO_FRAME_SIZE) { mdecoder->decoded_size_max = mdecoder->decoded_size_max * 2 + 16; mdecoder->decoded_data = xrealloc(mdecoder->decoded_data, mdecoder->decoded_size_max); dst = (uint8*) (((uintptr_t)mdecoder->decoded_data + 15) & ~ 0x0F); if (dst - mdecoder->decoded_data != dst_offset) { /* re-align the memory if the alignment has changed after realloc */ memmove(dst, mdecoder->decoded_data + dst_offset, mdecoder->decoded_size); dst_offset = dst - mdecoder->decoded_data; } dst += mdecoder->decoded_size; } frame_size = mdecoder->decoded_size_max - mdecoder->decoded_size;#if LIBAVCODEC_VERSION_MAJOR < 52 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR <= 20) len = avcodec_decode_audio2(mdecoder->codec_context, (int16_t*) dst, &frame_size, src, src_size);#else { AVPacket pkt; av_init_packet(&pkt); pkt.data = (uint8*) src; pkt.size = src_size; len = avcodec_decode_audio3(mdecoder->codec_context, (int16_t*) dst, &frame_size, &pkt); }#endif if (len <= 0 || frame_size <= 0) { DEBUG_WARN("error decoding"); break; } src += len; src_size -= len; mdecoder->decoded_size += frame_size; dst += frame_size; } if (mdecoder->decoded_size == 0) { xfree(mdecoder->decoded_data); mdecoder->decoded_data = NULL; } else if (dst_offset) { /* move the aligned decoded data to original place */ memmove(mdecoder->decoded_data, mdecoder->decoded_data + dst_offset, mdecoder->decoded_size); } DEBUG_DVC("data_size %d decoded_size %d", data_size, mdecoder->decoded_size); return true;}
开发者ID:authentic8,项目名称:NeutrinoRDP,代码行数:89,
示例27: date_main//.........这里部分代码省略......... } } else { int nr; char *cp; nr = sscanf(date_str, "%2d%2d%2d%2d%d", &tm_time.tm_mon, &tm_time.tm_mday, &tm_time.tm_hour, &tm_time.tm_min, &tm_time.tm_year); if (nr < 4 || nr > 5) { bb_error_msg_and_die(bb_msg_invalid_date, date_str); } cp = strchr(date_str, '.'); if (cp) { nr = sscanf(cp + 1, "%2d", &tm_time.tm_sec); if (nr != 1) { bb_error_msg_and_die(bb_msg_invalid_date, date_str); } } /* correct for century - minor Y2K problem here? */ if (tm_time.tm_year >= 1900) { tm_time.tm_year -= 1900; } /* adjust date */ tm_time.tm_mon -= 1; } /* Correct any day of week and day of year etc. fields */ tm_time.tm_isdst = -1; /* Be sure to recheck dst. */ tm = mktime(&tm_time); if (tm < 0) { bb_error_msg_and_die(bb_msg_invalid_date, date_str); } maybe_set_utc(opt); /* if setting time, set it */ if ((opt & DATE_OPT_SET) && stime(&tm) < 0) { bb_perror_msg("cannot set date"); } } /* Display output */ /* Deal with format string */ if (date_fmt == NULL) { int i; date_fmt = xzalloc(32); if (ENABLE_FEATURE_DATE_ISOFMT && ifmt >= 0) { strcpy(date_fmt, "%Y-%m-%d"); if (ifmt > 0) { i = 8; date_fmt[i++] = 'T'; date_fmt[i++] = '%'; date_fmt[i++] = 'H'; if (ifmt > 1) { date_fmt[i++] = ':'; date_fmt[i++] = '%'; date_fmt[i++] = 'M'; } if (ifmt > 2) { date_fmt[i++] = ':'; date_fmt[i++] = '%'; date_fmt[i++] = 'S'; } format_utc: date_fmt[i++] = '%'; date_fmt[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z'; } } else if (opt & DATE_OPT_RFC2822) { /* Undo busybox.c for date -R */ if (ENABLE_LOCALE_SUPPORT) setlocale(LC_TIME, "C"); strcpy(date_fmt, "%a, %d %b %Y %H:%M:%S "); i = 22; goto format_utc; } else /* default case */ date_fmt = (char*)"%a %b %e %H:%M:%S %Z %Y"; }#define date_buf bb_common_bufsiz1 if (*date_fmt == '/0') { /* With no format string, just print a blank line */ date_buf[0] = '/0'; } else { /* Handle special conversions */ if (strncmp(date_fmt, "%f", 2) == 0) { date_fmt = (char*)"%Y.%m.%d-%H:%M:%S"; } /* Generate output string */ strftime(date_buf, sizeof(date_buf), date_fmt, &tm_time); } puts(date_buf); return EXIT_SUCCESS;}
开发者ID:Predator-SD,项目名称:Tarixy,代码行数:101,
示例28: parse_aufs_branches/* * Kernel stores patchnames to AUFS branches in the br<n> files in * the /sys/fs/aufs/si_<sbinfo> directory where <n> denotes a branch * number and <sbinfo> is a hexadecimal number in %lx format. For * example: * * $ cat /sys/fs/aufs/si_f598876b087ed883/br0 * /path/to/branch0/directory=rw * * This function sets up an array of pointers to branch pathnames. */int parse_aufs_branches(struct mount_info *mi){ char path[AUFSBR_PATH_LEN]; char *cp; int n; int ret; unsigned int br_num; unsigned int br_max; DIR *dp; FILE *fp; struct dirent *de; pr_info("Collecting AUFS branch pathnames .../n"); if (mi->nsid == 0) { pr_err("No nsid to parse its aufs branches/n"); return -1; } if (mi->nsid == aufs_nsid) { pr_debug("Using cached aufs branch paths for nsid %p/n", aufs_nsid); return 0; } if (aufs_nsid) free_aufs_branches(); strcpy(path, SYSFS_AUFS); /* /sys/fs/aufs/ */ if (parse_aufs_sbinfo(mi, &path[sizeof SYSFS_AUFS - 1], SBINFO_LEN) < 0) return -1; if ((dp = opendir(path)) == NULL) { pr_perror("Cannot opendir %s", path); return -1; } /* * Find out how many branches we have. */ br_max = 0; ret = 0; while (1) { errno = 0; if ((de = readdir(dp)) == NULL) { if (errno) { pr_perror("Cannot readdir %s", path); ret = -1; } break; } ret = sscanf(de->d_name, "br%d", &br_num); if (ret == 1 && br_num > br_max) br_max = br_num; } closedir(dp); if (ret == -1) return -1; /* * Default AUFS maximum is 127, so 1000 should be plenty. * If you increase the maximum to more than 3 digits, * make sure to change AUFSBR_PATH_LEN accordingly. */ if (br_max > 999) { pr_err("Too many branches %d/n", br_max); return -1; } /* * Allocate an array of pointers to branch pathnames to be read. * Branches are indexed from 0 and we need a NULL pointer at the end. */ aufs_branches = xzalloc((br_max + 2) * sizeof (char *)); if (!aufs_branches) return -1; /* * Now read branch pathnames from the branch files. */ n = strlen(path); fp = NULL; for (br_num = 0; br_num <= br_max; br_num++) { ret = snprintf(&path[n], sizeof path - n, "/br%d", br_num); if (ret >= sizeof path - n) { pr_err("Buffer overrun creating path for branch %d/n", br_num); goto err; } if ((fp = fopen(path, "r")) == NULL) {//.........这里部分代码省略.........
开发者ID:kawamuray,项目名称:criu,代码行数:101,
示例29: parse_optionsstatic void parse_options(struct videohub_data *data, int argc, char **argv) { int j, err = 0; // Check environment data->dev_host = getenv("VIDEOHUB_HOST"); data->dev_port = getenv("VIDEOHUB_PORT"); // Set defaults if (!data->dev_port) data->dev_port = "9990"; while ((j = getopt_long(argc, argv, short_options, long_options, NULL)) != -1) { if (j == '?') // Invalid parameter exit(EXIT_FAILURE); switch (j) { case 'h': // --host data->dev_host = optarg; break; case 'p': // --port data->dev_port = optarg; break; case 'T': { // --test-input struct stat st; FILE *f; if (stat(optarg, &st) != 0) die("Can't stat %s: %s", optarg, strerror(errno)); f = fopen(optarg, "r"); if (!f) die("Can't open %s: %s", optarg, strerror(errno)); test_data = xzalloc(st.st_size + 1); if (fread(test_data, st.st_size, 1, f) < 1) die("Can't read from %s: %s", optarg, strerror(errno)); fclose(f); data->dev_host = "sdi-matrix"; break; } case 'd': // --debug debug++; if (debug) quiet = 0; // Disable quiet break; case 'q': // --quiet quiet = !quiet; break; case 'i': // --info show_info = 1; break; case 'm': // --monitor show_monitor = 1; break; case 'b': // --backup show_backup = 1; break; case 901: show_list |= action_list_device; break; // --list-device case 902: show_list |= action_list_vinputs; break; // --list-vinputs case 903: show_list |= action_list_voutputs; break; // --list-voutputs case 904: show_list |= action_list_moutputs; break; // --list-moutputs case 905: show_list |= action_list_serial; break; // --list-serial case 906: show_list |= action_list_proc_units; break; // --list-proc-units case 907: show_list |= action_list_frames; break; // --list-frames case 950: set_device_option("Friendly name", optarg); break; // --set-name case 1001: parse_cmd2(argc, argv, CMD_INPUT_LABELS); break; // --in-name case 1002: parse_cmd2(argc, argv, CMD_VIDEO_OUTPUT_ROUTING); switch_cmd_args(); break; // --in-output case 1003: parse_cmd2(argc, argv, CMD_MONITORING_OUTPUT_ROUTING); switch_cmd_args(); break; // --in-monitor case 2001: parse_cmd2(argc, argv, CMD_OUTPUT_LABELS); break; // --out-name case 2002: parse_cmd2(argc, argv, CMD_VIDEO_OUTPUT_ROUTING); break; // --out-input case 2003: parse_cmd1(argc, argv, CMD_VIDEO_OUTPUT_LOCKS, true); break; // --out-lock case 2004: parse_cmd1(argc, argv, CMD_VIDEO_OUTPUT_LOCKS, false); break; // --out-unlock case 3001: parse_cmd2(argc, argv, CMD_MONITORING_OUTPUT_LABELS); break; // --mon-name case 3002: parse_cmd2(argc, argv, CMD_MONITORING_OUTPUT_ROUTING); break; // --mon-input case 3003: parse_cmd1(argc, argv, CMD_MONITORING_OUTPUT_LOCKS, true); break; // --mon-lock case 3004: parse_cmd1(argc, argv, CMD_MONITORING_OUTPUT_LOCKS, false); break; // --mon-unlock case 4001: parse_cmd2(argc, argv, CMD_SERIAL_PORT_LABELS); break; // --ser-name case 4002: parse_cmd2(argc, argv, CMD_SERIAL_PORT_ROUTING); break; // --ser-input case 4003: parse_cmd1(argc, argv, CMD_SERIAL_PORT_LOCKS, true); break; // --ser-lock case 4004: parse_cmd1(argc, argv, CMD_SERIAL_PORT_LOCKS, false); break; // --ser-unlock case 4005: parse_cmd2(argc, argv, CMD_SERIAL_PORT_DIRECTIONS); break; // --ser-dir case 4006: parse_cmd2s(argc, argv, CMD_SERIAL_PORT_ROUTING); break; // --ser-clear case 5001: parse_cmd2(argc, argv, CMD_PROCESSING_UNIT_ROUTING); break; // --pu-input case 5002: parse_cmd1(argc, argv, CMD_PROCESSING_UNIT_LOCKS, true); break; // --pu-lock case 5003: parse_cmd1(argc, argv, CMD_PROCESSING_UNIT_LOCKS, false); break; // --pu-unlock case 5004: parse_cmd2s(argc, argv, CMD_PROCESSING_UNIT_ROUTING); break; // --pu-clear case 6001: parse_cmd2(argc, argv, CMD_FRAME_LABELS); break; // --fr-name case 6002: parse_cmd2(argc, argv, CMD_FRAME_BUFFER_ROUTING); break; // --fr-input case 6003: parse_cmd1(argc, argv, CMD_FRAME_BUFFER_LOCKS, true); break; // --fr-lock case 6004: parse_cmd1(argc, argv, CMD_FRAME_BUFFER_LOCKS, false); break; // --fr-unlock case 6005: parse_cmd2s(argc, argv, CMD_FRAME_BUFFER_ROUTING); break; // --fr-clear case 'H': // --help show_help(data); exit(EXIT_SUCCESS); case 'V': // --version printf("%s/n", program_id); exit(EXIT_SUCCESS); } } if (!data->dev_host || !strtoul(data->dev_port, NULL, 10)) err = 1; if (err) { show_help(data); if (!data->dev_host) fprintf(stderr, "ERROR: host is not set. Use --host option./n");//.........这里部分代码省略.........
开发者ID:gfto,项目名称:videohubctrl,代码行数:101,
示例30: rewritestatic NOINLINE void rewrite(priv_dumper_t *dumper, FS *fs){ enum { NOTOKAY, USEBCNT, USEPREC } sokay; PR *pr, **nextpr = NULL; FU *fu; char *p1, *p2, *p3; char savech, *fmtp; const char *byte_count_str; int nconv, prec = 0; for (fu = fs->nextfu; fu; fu = fu->nextfu) { /* * break each format unit into print units; each * conversion character gets its own. */ for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) { /* NOSTRICT */ /* DBU:[[email C++ y函数代码示例 C++ xy函数代码示例
|