int bson_encoder_append_int(bson_encoder_t encoder, const char *name, int64_t value) { bool result; CODER_CHECK(encoder); /* use the smallest encoding that will hold the value */ if (value == (int32_t)value) { debug("encoding %lld as int32", value); result = write_int8(encoder, BSON_INT32) || write_name(encoder, name) || write_int32(encoder, value); } else { debug("encoding %lld as int64", value); result = write_int8(encoder, BSON_INT64) || write_name(encoder, name) || write_int64(encoder, value); } if (result) { CODER_KILL(encoder, "write error on BSON_INT"); } return 0; }
void Read_sw(void) { u8 READsw ; TSW_u8ReadState(0,&READsw); if(READsw==1) { if(f==0) { f=1 ; flag1=1 ; old_ADC=0; if(ADCREAD<10) old_ADC=20; write_name(); } ADC_conv(); } else { if(f==1) { flag1=0 ; f=0 ; } ADC_conv(); } }
int bson_encoder_append_bool(bson_encoder_t encoder, const char *name, bool value) { CODER_CHECK(encoder); if (write_int8(encoder, BSON_BOOL) || write_name(encoder, name) || write_int8(encoder, value ? 1 : 0)) { CODER_KILL(encoder, "write error on BSON_BOOL"); } return 0; }
static void show_dir_entry(const char *tag, struct dir_entry *ent) { int len = max_prefix_len; if (len >= ent->len) die("git ls-files: internal error - directory entry not superset of prefix"); if (!match_pathspec(pathspec, ent->name, ent->len, len, ps_matched)) return; fputs(tag, stdout); write_name(ent->name, ent->len); }
int bson_encoder_append_double(bson_encoder_t encoder, const char *name, double value) { CODER_CHECK(encoder); if (write_int8(encoder, BSON_DOUBLE) || write_name(encoder, name) || write_double(encoder, value)) { CODER_KILL(encoder, "write error on BSON_DOUBLE"); } return 0; }
int bson_encoder_append_binary(bson_encoder_t encoder, const char *name, bson_binary_subtype_t subtype, size_t size, const void *data) { CODER_CHECK(encoder); if (write_int8(encoder, BSON_BINDATA) || write_name(encoder, name) || write_int32(encoder, size) || write_int8(encoder, subtype) || write_x(encoder, data, size)) { CODER_KILL(encoder, "write error on BSON_BINDATA"); } return 0; }
int bson_encoder_append_string(bson_encoder_t encoder, const char *name, const char *string) { size_t len; CODER_CHECK(encoder); len = strlen(string) + 1; /* include trailing nul */ if (write_int8(encoder, BSON_STRING) || write_name(encoder, name) || write_int32(encoder, len) || write_x(encoder, string, len)) { CODER_KILL(encoder, "write error on BSON_STRING"); } return 0; }
static void write_single_file(FILE *out, const char *path) { static const char c1[] = "const char *gl_"; static const char c2[] = " = \""; static const char c3[] = "\";\n"; const char *name; char *content; size_t len; name = get_basename(path); content = read_file(path, &len); fwrite(c1, sizeof(c1) - 1, 1, out); write_name(out, name); fwrite(c2, sizeof(c2) - 1, 1, out); write_seq(out, content, len); fwrite(c3, sizeof(c3) - 1, 1, out); free(content); }
static int show_one_ru(struct string_list_item *item, void *cbdata) { const char *path = item->string; struct resolve_undo_info *ui = item->util; int i, len; len = strlen(path); if (len < max_prefix_len) return 0; /* outside of the prefix */ if (!match_pathspec(pathspec, path, len, max_prefix_len, ps_matched)) return 0; /* uninterested */ for (i = 0; i < 3; i++) { if (!ui->mode[i]) continue; printf("%s%06o %s %d\t", tag_resolve_undo, ui->mode[i], find_unique_abbrev(ui->sha1[i], abbrev), i + 1); write_name(path, len); } return 0; }
static void show_ce_entry(const char *tag, struct cache_entry *ce) { int len = max_prefix_len; if (len >= ce_namelen(ce)) die("git ls-files: internal error - cache entry not superset of prefix"); if (!match_pathspec(pathspec, ce->name, ce_namelen(ce), len, ps_matched)) return; if (tag && *tag && show_valid_bit && (ce->ce_flags & CE_VALID)) { static char alttag[4]; memcpy(alttag, tag, 3); if (isalpha(tag[0])) alttag[0] = tolower(tag[0]); else if (tag[0] == '?') alttag[0] = '!'; else { alttag[0] = 'v'; alttag[1] = tag[0]; alttag[2] = ' '; alttag[3] = 0; } tag = alttag; } if (!show_stage) { fputs(tag, stdout); } else { printf("%s%06o %s %d\t", tag, ce->ce_mode, find_unique_abbrev(ce->sha1,abbrev), ce_stage(ce)); } write_name(ce->name, ce_namelen(ce)); }
static void write_function_stubs(type_t *iface, unsigned int *proc_offset) { const func_t *func; const var_t *var; const var_t* explicit_handle_var; if (!iface->funcs) return; LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry ) { const var_t *def = func->def; int has_full_pointer = is_full_pointer_function(func); /* check for a defined binding handle */ explicit_handle_var = get_explicit_handle_var(func); fprintf(server, "void __RPC_STUB\n"); fprintf(server, "%s_", iface->name); write_name(server, def); fprintf(server, "(\n"); indent++; print_server("PRPC_MESSAGE _pRpcMessage)\n"); indent--; /* write the functions body */ fprintf(server, "{\n"); indent++; /* Declare arguments */ declare_stub_args(server, indent, func); print_server("MIDL_STUB_MESSAGE _StubMsg;\n"); print_server("RPC_STATUS _Status;\n"); fprintf(server, "\n"); print_server("((void)(_Status));\n"); print_server("NdrServerInitializeNew(\n"); indent++; print_server("_pRpcMessage,\n"); print_server("&_StubMsg,\n"); print_server("&%s_StubDesc);\n", iface->name); indent--; fprintf(server, "\n"); write_parameters_init(server, indent, func); if (explicit_handle_var) { print_server("%s = _pRpcMessage->Handle;\n", explicit_handle_var->name); fprintf(server, "\n"); } print_server("RpcTryFinally\n"); print_server("{\n"); indent++; print_server("RpcTryExcept\n"); print_server("{\n"); indent++; if (has_full_pointer) write_full_pointer_init(server, indent, func, TRUE); if (func->args) { print_server("if ((_pRpcMessage->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n"); indent++; print_server("NdrConvert(\n"); indent++; print_server("(PMIDL_STUB_MESSAGE)&_StubMsg,\n"); print_server("(PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n", *proc_offset); indent -= 2; fprintf(server, "\n"); /* unmarshall arguments */ write_remoting_arguments(server, indent, func, PASS_IN, PHASE_UNMARSHAL); } print_server("if (_StubMsg.Buffer > _StubMsg.BufferEnd)\n"); print_server("{\n"); indent++; print_server("RpcRaiseException(RPC_X_BAD_STUB_DATA);\n"); indent--; print_server("}\n"); indent--; print_server("}\n"); print_server("RpcExcept(RPC_BAD_STUB_DATA_EXCEPTION_FILTER)\n"); print_server("{\n"); indent++; print_server("RpcRaiseException(RPC_X_BAD_STUB_DATA);\n"); indent--; print_server("}\n"); print_server("RpcEndExcept\n"); fprintf(server, "\n"); /* Assign 'out' arguments */ assign_stub_out_args(server, indent, func); /* Call the real server function */ if (!is_void(get_func_return_type(func))) print_server("_RetVal = "); else print_server(""); write_prefix_name(server, prefix_server, def); if (func->args) { int first_arg = 1; fprintf(server, "(\n"); indent++; LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) { if (first_arg) first_arg = 0; else fprintf(server, ",\n"); if (is_context_handle(var->type)) { /* if the context_handle attribute appears in the chain of types * without pointers being followed, then the context handle must * be direct, otherwise it is a pointer */ int is_ch_ptr = is_aliaschain_attr(var->type, ATTR_CONTEXTHANDLE) ? FALSE : TRUE; print_server("("); write_type_decl_left(server, var->type); fprintf(server, ")%sNDRSContextValue(%s)", is_ch_ptr ? "" : "*", var->name); } else { print_server(""); if (var->type->declarray) fprintf(server, "*"); write_name(server, var); } } fprintf(server, ");\n"); indent--; } else {
pdf_obj * CMap_create_stream (CMap *cmap) { pdf_obj *stream; pdf_obj *stream_dict; CIDSysInfo *csi; struct sbuf wbuf; struct rangeDef *ranges; unsigned char *codestr; int i, j, count = 0; if (!cmap || !CMap_is_valid(cmap)) { WARN("Invalid CMap"); return NULL; } if (cmap->type == CMAP_TYPE_IDENTITY) return NULL; stream = pdf_new_stream(STREAM_COMPRESS); stream_dict = pdf_stream_dict(stream); csi = CMap_get_CIDSysInfo(cmap); if (!csi) { csi = (cmap->type != CMAP_TYPE_TO_UNICODE) ? &CSI_IDENTITY : &CSI_UNICODE; } if (cmap->type != CMAP_TYPE_TO_UNICODE) { pdf_obj *csi_dict; csi_dict = pdf_new_dict(); pdf_add_dict(csi_dict, pdf_new_name("Registry"), pdf_new_string(csi->registry, strlen(csi->registry))); pdf_add_dict(csi_dict, pdf_new_name("Ordering"), pdf_new_string(csi->ordering, strlen(csi->ordering))); pdf_add_dict(csi_dict, pdf_new_name("Supplement"), pdf_new_number(csi->supplement)); pdf_add_dict(stream_dict, pdf_new_name("Type"), pdf_new_name("CMap")); pdf_add_dict(stream_dict, pdf_new_name("CMapName"), pdf_new_name(cmap->name)); pdf_add_dict(stream_dict, pdf_new_name("CIDSystemInfo"), csi_dict); if (cmap->wmode != 0) pdf_add_dict(stream_dict, pdf_new_name("WMode"), pdf_new_number(cmap->wmode)); } /* TODO: * Predefined CMaps need not to be embedded. */ if (cmap->useCMap) { ERROR("UseCMap found (not supported yet)..."); if (CMap_is_Identity(cmap->useCMap)) { /* not sure */ if (CMap_get_wmode(cmap) == 1) { pdf_add_dict(stream_dict, pdf_new_name("UseCMap"), pdf_new_name("Identity-V")); } else { pdf_add_dict(stream_dict, pdf_new_name("UseCMap"), pdf_new_name("Identity-H")); } } else { int res_id; pdf_obj *ucmap_ref; res_id = pdf_findresource("CMap", CMap_get_name(cmap->useCMap)); if (res_id >= 0) { ucmap_ref = pdf_get_resource_reference(res_id); } else { pdf_obj *ucmap_obj; ucmap_obj = CMap_create_stream(cmap->useCMap); if (!ucmap_obj) { ERROR("Uh ah. I cannot continue..."); } res_id = pdf_defineresource("CMap", CMap_get_name(cmap->useCMap), ucmap_obj, PDF_RES_FLUSH_IMMEDIATE); ucmap_ref = pdf_get_resource_reference(res_id); } pdf_add_dict(stream_dict, pdf_new_name("UseCMap"), ucmap_ref); } } #define WBUF_SIZE 40960 wbuf.buf = NEW(WBUF_SIZE, char); codestr = NEW(cmap->profile.maxBytesIn, unsigned char); memset(codestr, 0, cmap->profile.maxBytesIn); wbuf.curptr = wbuf.buf; wbuf.limptr = wbuf.buf + WBUF_SIZE - 2 * (cmap->profile.maxBytesIn + cmap->profile.maxBytesOut) + 16; /* Start CMap */ pdf_add_stream(stream, (const void *) CMAP_BEGIN, strlen(CMAP_BEGIN)); wbuf.curptr += sprintf(wbuf.curptr, "/CMapName "); write_name(&wbuf.curptr, wbuf.limptr, cmap->name); wbuf.curptr += sprintf(wbuf.curptr, " def\n"); wbuf.curptr += sprintf(wbuf.curptr, "/CMapType %d def\n" , cmap->type); if (cmap->wmode != 0 && cmap->type != CMAP_TYPE_TO_UNICODE) wbuf.curptr += sprintf(wbuf.curptr, "/WMode %d def\n", cmap->wmode); #define CMAP_CSI_FMT "/CIDSystemInfo <<\n\ /Registry (%s)\n\ /Ordering (%s)\n\ /Supplement %d\n\ >> def\n" wbuf.curptr += sprintf(wbuf.curptr, "/CIDSystemInfo <<\n"); wbuf.curptr += sprintf(wbuf.curptr, " /Registry "); write_string(&wbuf.curptr, wbuf.limptr, csi->registry); wbuf.curptr += sprintf(wbuf.curptr, "\n"); wbuf.curptr += sprintf(wbuf.curptr, " /Ordering "); write_string(&wbuf.curptr, wbuf.limptr, csi->ordering); wbuf.curptr += sprintf(wbuf.curptr, "\n"); wbuf.curptr += sprintf(wbuf.curptr, " /Supplement %d\n>> def\n", csi->supplement); pdf_add_stream(stream, wbuf.buf, (int)(wbuf.curptr - wbuf.buf)); wbuf.curptr = wbuf.buf; /* codespacerange */ ranges = cmap->codespace.ranges; wbuf.curptr += sprintf(wbuf.curptr, "%d begincodespacerange\n", cmap->codespace.num); for (i = 0; i < cmap->codespace.num; i++) { *(wbuf.curptr)++ = '<'; for (j = 0; j < ranges[i].dim; j++) { sputx(ranges[i].codeLo[j], &(wbuf.curptr), wbuf.limptr); } *(wbuf.curptr)++ = '>'; *(wbuf.curptr)++ = ' '; *(wbuf.curptr)++ = '<'; for (j = 0; j < ranges[i].dim; j++) { sputx(ranges[i].codeHi[j], &(wbuf.curptr), wbuf.limptr); } *(wbuf.curptr)++ = '>'; *(wbuf.curptr)++ = '\n'; } pdf_add_stream(stream, wbuf.buf, (int)(wbuf.curptr - wbuf.buf)); wbuf.curptr = wbuf.buf; pdf_add_stream(stream, "endcodespacerange\n", strlen("endcodespacerange\n")); /* CMap body */ if (cmap->mapTbl) { count = write_map(cmap->mapTbl, 0, codestr, 0, &wbuf, stream); /* Top node */ if (count > 0) { /* Flush */ char fmt_buf[32]; if (count > 100) ERROR("Unexpected error....: %d", count); sprintf(fmt_buf, "%d beginbfchar\n", count); pdf_add_stream(stream, fmt_buf, strlen(fmt_buf)); pdf_add_stream(stream, wbuf.buf, (int) (wbuf.curptr - wbuf.buf)); pdf_add_stream(stream, "endbfchar\n", strlen("endbfchar\n")); count = 0; wbuf.curptr = wbuf.buf; } } /* End CMap */ pdf_add_stream(stream, CMAP_END, strlen(CMAP_END)); RELEASE(codestr); RELEASE(wbuf.buf); return stream; }
bool PointDLists::write(const yarp::os::idl::WireWriter& writer) const { if (!write_name(writer)) return false; if (!write_firstList(writer)) return false; if (!write_secondList(writer)) return false; return !writer.isError(); }