/* run_pipe_real() starts all the jobs, but doesn't wait for anything * to finish. See checkjobs(). * * return code is normally -1, when the caller has to wait for children * to finish to determine the exit status of the pipe. If the pipe * is a simple builtin command, however, the action is done by the * time run_pipe_real returns, and the exit code is provided as the * return value. * * The input of the pipe is always stdin, the output is always * stdout. The outpipe[] mechanism in BusyBox-0.48 lash is bogus, * because it tries to avoid running the command substitution in * subshell, when that is in fact necessary. The subshell process * now has its stdout directed to the input of the appropriate pipe, * so this routine is noticeably simpler. */ static int run_pipe_real(struct pipe *pi) { int i; int nextin; int flag = do_repeat ? CMD_FLAG_REPEAT : 0; struct child_prog *child; cmd_tbl_t *cmdtp; char *p; # if __GNUC__ /* Avoid longjmp clobbering */ (void) &i; (void) &nextin; (void) &child; # endif nextin = 0; /* Check if this is a simple builtin (not part of a pipe). * Builtins within pipes have to fork anyway, and are handled in * pseudo_exec. "echo foo | read bar" doesn't work on bash, either. */ if (pi->num_progs == 1) child = &(pi->progs[0]); if (pi->num_progs == 1 && child->group) { int rcode; debug_printf("non-subshell grouping\n"); rcode = run_list_real(child->group); return rcode; } else if (pi->num_progs == 1 && pi->progs[0].argv != NULL) { for (i = 0; is_assignment(child->argv[i]); i++) { /* nothing */ } if (i != 0 && child->argv[i] == NULL) { /* assignments, but no command: set the local environment */ for (i = 0; child->argv[i] != NULL; i++) { /* Ok, this case is tricky. We have to decide if this is a * local variable, or an already exported variable. If it is * already exported, we have to export the new value. If it is * not exported, we need only set this as a local variable. * This junk is all to decide whether or not to export this * variable. */ int export_me = 0; char *name, *value; name = xstrdup(child->argv[i]); debug_printf("Local environment set: %s\n", name); value = strchr(name, '='); if (value) *value = 0; free(name); p = insert_var_value(child->argv[i]); set_local_var(p, export_me); if (p != child->argv[i]) free(p); } return EXIT_SUCCESS; /* don't worry about errors in set_local_var() yet */ } for (i = 0; is_assignment(child->argv[i]); i++) { p = insert_var_value(child->argv[i]); set_local_var(p, 0); if (p != child->argv[i]) { child->sp--; free(p); } } if (child->sp) { char * str = NULL; str = make_string((child->argv + i)); parse_string_outer(str, FLAG_EXIT_FROM_LOOP | FLAG_REPARSING); free(str); return last_return_code; } /* check ";", because ,example , argv consist from * "help;flinfo" must not execute */ if (strchr(child->argv[i], ';')) { printf("## Error: unknown command '%s' - try 'help' or use 'run' command\n", child->argv[i]); return -1; } /* Look up command in command table */ if ((cmdtp = find_cmd(child->argv[i])) == NULL) { printf("## Error: unknown command '%s' - try 'help'\n", child->argv[i]); return -1; /* give up after bad command */ } else { int rcode; #if defined(CONFIG_CMD_BOOTD) extern int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); /* avoid "bootd" recursion */ if (cmdtp->cmd == do_bootd) { if (flag & CMD_FLAG_BOOTD) { printf ("## Error: 'bootd' recursion detected!\n"); return -1; } else { flag |= CMD_FLAG_BOOTD; } } #endif /* CONFIG_CMD_BOOTD */ /* found - check max args */ if ((child->argc - i) > cmdtp->maxargs) { print_cmd_help(cmdtp); return -1; } child->argv += i; /* XXX horrible hack */ /* OK - call function to do the command */ rcode = (cmdtp->cmd)(cmdtp, flag, child->argc - i, &child->argv[i]); if (!cmdtp->repeatable) flag_repeat = 0; child->argv -= i; /* XXX restore hack so free() can work right */ return rcode; } } return -1; }
int main () { struct ss ss; struct ss ssa[2]; struct arraystruct arraystruct; string x = make_string ("this is x"); zzz_type c = make_container ("container"); zzz_type c2 = make_container ("container2"); const struct string_repr cstring = { { "const string" } }; /* Clearing by being `static' could invoke an other GDB C++ bug. */ struct nullstr nullstr; nostring_type nstype, nstype2; struct memory_error me; struct ns ns, ns2; struct lazystring estring, estring2; struct hint_error hint_error; struct children_as_list children_as_list; nstype.elements = narray; nstype.len = 0; me.s = "blah"; init_ss(&ss, 1, 2); init_ss(ssa+0, 3, 4); init_ss(ssa+1, 5, 6); memset (&nullstr, 0, sizeof nullstr); arraystruct.y = 7; init_s (&arraystruct.x[0], 23); init_s (&arraystruct.x[1], 24); ns.null_str = "embedded\0null\0string"; ns.length = 20; /* Make a "corrupted" string. */ ns2.null_str = NULL; ns2.length = 20; estring.lazy_str = "embedded x\201\202\203\204" ; /* Incomplete UTF-8, but ok Latin-1. */ estring2.lazy_str = "embedded x\302"; #ifdef __cplusplus S cps; cps.zs = 7; init_s(&cps, 8); SS cpss; cpss.zss = 9; init_s(&cpss.s, 10); SS cpssa[2]; cpssa[0].zss = 11; init_s(&cpssa[0].s, 12); cpssa[1].zss = 13; init_s(&cpssa[1].s, 14); SSS sss(15, cps); SSS& ref (sss); Derived derived; Fake fake (42); #endif add_item (&c, 23); /* MI breakpoint here */ add_item (&c, 72); #ifdef MI add_item (&c, 1011); c.elements[0] = 1023; c.elements[0] = 2323; add_item (&c2, 2222); add_item (&c2, 3333); substruct_test (); do_nothing (); #endif nstype.elements[0] = 7; nstype.elements[1] = 42; nstype.len = 2; nstype2 = nstype; eval_sub (); bug_14741(); /* break to inspect struct and union */ return 0; }
static Lisp_Object xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size) { FcResult result; Display *display = FRAME_X_DISPLAY (f); Lisp_Object val, filename, idx, font_object; FcPattern *pat = NULL, *match; struct xftfont_info *xftfont_info = NULL; struct font *font; double size = 0; XftFont *xftfont = NULL; int spacing; char name[256]; int len, i; XGlyphInfo extents; FT_Face ft_face; FcMatrix *matrix; val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX)); if (! CONSP (val)) return Qnil; val = XCDR (val); filename = XCAR (val); idx = XCDR (val); size = XINT (AREF (entity, FONT_SIZE_INDEX)); if (size == 0) size = pixel_size; pat = FcPatternCreate (); FcPatternAddInteger (pat, FC_WEIGHT, FONT_WEIGHT_NUMERIC (entity)); i = FONT_SLANT_NUMERIC (entity) - 100; if (i < 0) i = 0; FcPatternAddInteger (pat, FC_SLANT, i); FcPatternAddInteger (pat, FC_WIDTH, FONT_WIDTH_NUMERIC (entity)); FcPatternAddDouble (pat, FC_PIXEL_SIZE, pixel_size); val = AREF (entity, FONT_FAMILY_INDEX); if (! NILP (val)) FcPatternAddString (pat, FC_FAMILY, (FcChar8 *) SDATA (SYMBOL_NAME (val))); val = AREF (entity, FONT_FOUNDRY_INDEX); if (! NILP (val)) FcPatternAddString (pat, FC_FOUNDRY, (FcChar8 *) SDATA (SYMBOL_NAME (val))); val = AREF (entity, FONT_SPACING_INDEX); if (! NILP (val)) FcPatternAddInteger (pat, FC_SPACING, XINT (val)); val = AREF (entity, FONT_DPI_INDEX); if (! NILP (val)) { double dbl = XINT (val); FcPatternAddDouble (pat, FC_DPI, dbl); } val = AREF (entity, FONT_AVGWIDTH_INDEX); if (INTEGERP (val) && XINT (val) == 0) FcPatternAddBool (pat, FC_SCALABLE, FcTrue); /* This is necessary to identify the exact font (e.g. 10x20.pcf.gz over 10x20-ISO8859-1.pcf.gz). */ FcPatternAddCharSet (pat, FC_CHARSET, ftfont_get_fc_charset (entity)); xftfont_add_rendering_parameters (pat, entity); FcPatternAddString (pat, FC_FILE, (FcChar8 *) SDATA (filename)); FcPatternAddInteger (pat, FC_INDEX, XINT (idx)); block_input (); /* Make sure that the Xrender extension is added before the Xft one. Otherwise, the close-display hook set by Xft is called after the one for Xrender, and the former tries to re-add the latter. This results in inconsistency of internal states and leads to X protocol error when one reconnects to the same X server. (Bug#1696) */ { int event_base, error_base; XRenderQueryExtension (display, &event_base, &error_base); } /* Substitute in values from X resources and XftDefaultSet. */ XftDefaultSubstitute (display, FRAME_X_SCREEN_NUMBER (f), pat); match = XftFontMatch (display, FRAME_X_SCREEN_NUMBER (f), pat, &result); xftfont_fix_match (pat, match); FcPatternDestroy (pat); xftfont = XftFontOpenPattern (display, match); if (!xftfont) { unblock_input (); XftPatternDestroy (match); return Qnil; } ft_face = XftLockFace (xftfont); unblock_input (); /* We should not destroy PAT here because it is kept in XFTFONT and destroyed automatically when XFTFONT is closed. */ font_object = font_make_object (VECSIZE (struct xftfont_info), entity, size); ASET (font_object, FONT_TYPE_INDEX, Qxft); len = font_unparse_xlfd (entity, size, name, 256); if (len > 0) ASET (font_object, FONT_NAME_INDEX, make_string (name, len)); len = font_unparse_fcname (entity, size, name, 256); if (len > 0) ASET (font_object, FONT_FULLNAME_INDEX, make_string (name, len)); else ASET (font_object, FONT_FULLNAME_INDEX, AREF (font_object, FONT_NAME_INDEX)); ASET (font_object, FONT_FILE_INDEX, filename); ASET (font_object, FONT_FORMAT_INDEX, ftfont_font_format (xftfont->pattern, filename)); font = XFONT_OBJECT (font_object); font->pixel_size = size; font->driver = &xftfont_driver; font->encoding_charset = font->repertory_charset = -1; xftfont_info = (struct xftfont_info *) font; xftfont_info->display = display; xftfont_info->xftfont = xftfont; /* This means that there's no need of transformation. */ xftfont_info->matrix.xx = 0; if (FcPatternGetMatrix (xftfont->pattern, FC_MATRIX, 0, &matrix) == FcResultMatch) { xftfont_info->matrix.xx = 0x10000L * matrix->xx; xftfont_info->matrix.yy = 0x10000L * matrix->yy; xftfont_info->matrix.xy = 0x10000L * matrix->xy; xftfont_info->matrix.yx = 0x10000L * matrix->yx; } if (INTEGERP (AREF (entity, FONT_SPACING_INDEX))) spacing = XINT (AREF (entity, FONT_SPACING_INDEX)); else spacing = FC_PROPORTIONAL; if (! ascii_printable[0]) { int ch; for (ch = 0; ch < 95; ch++) ascii_printable[ch] = ' ' + ch; } block_input (); /* Unfortunately Xft doesn't provide a way to get minimum char width. So, we set min_width to space_width. */ if (spacing != FC_PROPORTIONAL #ifdef FC_DUAL && spacing != FC_DUAL #endif /* FC_DUAL */ ) { font->min_width = font->max_width = font->average_width = font->space_width = xftfont->max_advance_width; XftTextExtents8 (display, xftfont, ascii_printable + 1, 94, &extents); } else { XftTextExtents8 (display, xftfont, ascii_printable, 1, &extents); font->min_width = font->max_width = font->space_width = extents.xOff; if (font->space_width <= 0) /* dirty workaround */ font->space_width = pixel_size; XftTextExtents8 (display, xftfont, ascii_printable + 1, 94, &extents); font->average_width = (font->space_width + extents.xOff) / 95; } unblock_input (); font->ascent = xftfont->ascent; font->descent = xftfont->descent; if (pixel_size >= 5) { /* The above condition is a dirty workaround because XftTextExtents8 behaves strangely for some fonts (e.g. "Dejavu Sans Mono") when pixel_size is less than 5. */ if (font->ascent < extents.y) font->ascent = extents.y; if (font->descent < extents.height - extents.y) font->descent = extents.height - extents.y; } font->height = font->ascent + font->descent; if (XINT (AREF (entity, FONT_SIZE_INDEX)) == 0) { int upEM = ft_face->units_per_EM; font->underline_position = -ft_face->underline_position * size / upEM; font->underline_thickness = ft_face->underline_thickness * size / upEM; if (font->underline_thickness > 2) font->underline_position -= font->underline_thickness / 2; } else { font->underline_position = -1; font->underline_thickness = 0; } #ifdef HAVE_LIBOTF xftfont_info->maybe_otf = (ft_face->face_flags & FT_FACE_FLAG_SFNT) != 0; xftfont_info->otf = NULL; #endif /* HAVE_LIBOTF */ xftfont_info->ft_size = ft_face->size; font->baseline_offset = 0; font->relative_compose = 0; font->default_ascent = 0; font->vertical_centering = 0; #ifdef FT_BDF_H if (! (ft_face->face_flags & FT_FACE_FLAG_SFNT)) { BDF_PropertyRec rec; if (FT_Get_BDF_Property (ft_face, "_MULE_BASELINE_OFFSET", &rec) == 0 && rec.type == BDF_PROPERTY_TYPE_INTEGER) font->baseline_offset = rec.u.integer; if (FT_Get_BDF_Property (ft_face, "_MULE_RELATIVE_COMPOSE", &rec) == 0 && rec.type == BDF_PROPERTY_TYPE_INTEGER) font->relative_compose = rec.u.integer; if (FT_Get_BDF_Property (ft_face, "_MULE_DEFAULT_ASCENT", &rec) == 0 && rec.type == BDF_PROPERTY_TYPE_INTEGER) font->default_ascent = rec.u.integer; } #endif return font_object; }
void CSE_ALifeInventoryItem::UPDATE_Read (NET_Packet &tNetPacket) { tNetPacket.r_u8 (m_u8NumItems); if (!m_u8NumItems) { //Msg("* Object [%d] has no sync items", this->cast_abstract()->ID); return; } mask_num_items num_items; num_items.common = m_u8NumItems; m_u8NumItems = num_items.num_items; R_ASSERT2 ( m_u8NumItems < (u8(1) << 5), make_string("%d",m_u8NumItems) ); /*if (check(num_items.mask,animated)) { tNetPacket.r_float(m_blend_timeCurrent); anim_use=true; } else { anim_use=false; }*/ { tNetPacket.r_vec3 (State.force); tNetPacket.r_vec3 (State.torque); tNetPacket.r_vec3 (State.position); base()->o_Position.set (State.position); //this is very important because many functions use this o_Position.. tNetPacket.r_float (State.quaternion.x); tNetPacket.r_float (State.quaternion.y); tNetPacket.r_float (State.quaternion.z); tNetPacket.r_float (State.quaternion.w); State.enabled = check(num_items.mask,inventory_item_state_enabled); if (!check(num_items.mask,inventory_item_angular_null)) { tNetPacket.r_float (State.angular_vel.x); tNetPacket.r_float (State.angular_vel.y); tNetPacket.r_float (State.angular_vel.z); } else State.angular_vel.set (0.f,0.f,0.f); if (!check(num_items.mask,inventory_item_linear_null)) { tNetPacket.r_float (State.linear_vel.x); tNetPacket.r_float (State.linear_vel.y); tNetPacket.r_float (State.linear_vel.z); } else State.linear_vel.set (0.f,0.f,0.f); /*if (check(num_items.mask,animated)) { anim_use=true; }*/ } prev_freezed = freezed; if (tNetPacket.r_eof()) // in case spawn + update { freezed = false; return; } if (tNetPacket.r_u8()) { freezed = false; } else { if (!freezed) #ifdef XRGAME_EXPORTS m_freeze_time = Device.dwTimeGlobal; #else m_freeze_time = 0; #endif freezed = true; } };
void imotion_position::state_start( ) { VERIFY( shell ); inherited::state_start( ); IKinematics *K = shell->PKinematics(); saved_visual_callback = K->GetUpdateCallback(); K->SetUpdateCallback( 0 ); IKinematicsAnimated *KA = smart_cast<IKinematicsAnimated*>( shell->PKinematics() ); VERIFY( KA ); KA->SetUpdateTracksCalback( &update_callback ); update_callback.motion = this; struct get_controled_blend: public IterateBlendsCallback, private boost::noncopyable { CBlend *blend; const PlayCallback cb; get_controled_blend(const PlayCallback _cb):blend( 0 ),cb(_cb){} virtual void operator () ( CBlend &B ) { if( cb == B.Callback && B.bone_or_part == 0 ) blend = &B; } } get_blend(anim_callback); KA->LL_IterateBlends( get_blend ); #ifdef DEBUG if(!get_blend.blend) { Msg( "bad animation params : %p", anim_callback ); KA->LL_DumpBlends_dbg(); NODEFAULT; } #endif VERIFY( get_blend.blend ); const CBlend &B = *get_blend.blend; blend = get_blend.blend; VERIFY2( B.stop_at_end, make_string( "can not use cyclic anim in death animth motion: %s", KA->LL_MotionDefName_dbg( B.motionID ).first ) ); time_to_end = B.timeTotal - (SAMPLE_SPF+EPS) - B.timeCurrent; time_to_end/=B.speed; shell->add_ObjectContactCallback( get_depth ); /* collide(); if( flags.test( fl_switch_dm_toragdoll ) ) { flags.assign( 0 ); shell->remove_ObjectContactCallback( get_depth ); return; } */ if( !is_enabled( ) ) return; CPhysicsShellHolder *obj= static_cast<CPhysicsShellHolder*>( shell->get_ElementByStoreOrder( 0 )->PhysicsRefObject() ); VERIFY( obj ); obj->processing_activate(); shell->Disable( ); //K->LL_SetBoneRoot( 0 ); shell->EnabledCallbacks( FALSE ); init_bones(); shell->mXFORM.set( obj->XFORM() ); disable_update( true ); disable_bone_calculation( *K, true ); //K->CalculateBones_Invalidate(); collide_not_move( *KA ); if(flags.test(fl_switch_dm_toragdoll)) { interactive_motion_diagnostic("stoped immediately"); switch_to_free ( ); flags.set(fl_not_played,TRUE); return; } move( float( Device.dwTimeDelta )/1000, *KA ); if(flags.test(fl_switch_dm_toragdoll)) switch_to_free ( ); //K->CalculateBones_Invalidate(); }
void CPhysicObject::RunStartupAnim(CSE_Abstract *D) { if(Visual()&&smart_cast<IKinematics*>(Visual())) { // CSE_PHSkeleton *po = smart_cast<CSE_PHSkeleton*>(D); IKinematicsAnimated* PKinematicsAnimated=NULL; R_ASSERT (Visual()&&smart_cast<IKinematics*>(Visual())); PKinematicsAnimated =smart_cast<IKinematicsAnimated*>(Visual()); if(PKinematicsAnimated) { CSE_Visual *visual = smart_cast<CSE_Visual*>(D); R_ASSERT (visual); R_ASSERT2 (*visual->startup_animation,"no startup animation"); VERIFY2( (!!PKinematicsAnimated->LL_MotionID( visual->startup_animation.c_str() ) .valid() ) , ( make_string(" animation %s not faund ",visual->startup_animation.c_str() ) + dbg_object_base_dump_string( this )).c_str() ); m_anim_blend = m_anim_script_callback.play_cycle( PKinematicsAnimated, visual->startup_animation ); } smart_cast<IKinematics*>(Visual())->CalculateBones_Invalidate(); smart_cast<IKinematics*>(Visual())->CalculateBones (TRUE); } }
stringOop stringTable::basic_add(const char *name, int32 len, int32 hashValue, bool mustAllocate) { stringOop str= make_string(name, len, mustAllocate); if (oop(str) != failedAllocationOop) basic_add(str, hashValue); return str; }
object *number_to_string_proc(object *arguments) { char buffer[100]; sprintf(buffer, "%ld", (car(arguments))->data.fixnum.value); return make_string(buffer); }
object *symbol_to_string_proc(object *arguments) { return make_string((car(arguments))->data.symbol.value); }
static void on_netlink_read(struct io *io, void *fsv) { struct dfs *fs = (struct dfs *)fsv; char *b = io->buffer, *fragment_header = b, *is = b, *ms = b, *i = b, *max = (b + io->length), frag_boundary = 0; sexpr attributes = sx_end_of_list; while (i < max) { frag_boundary = 0; switch (*i) { case 0: if (i == (max - 1)) /* definitely a fragment end */ { frag_boundary = 1; } if (is == ms) /* fragment header */ { if (is != b) /* first fragment header: nothing to examine */ { attributes = cons(make_symbol (fragment_header), attributes); dev9_rules_apply (attributes, fs); } fragment_header = is; attributes = sx_end_of_list; } else /* key/value pair */ { *ms = 0; attributes = cons (cons(make_symbol(is), make_string(ms+1)), attributes); *ms = '='; } i++; is = ms = i; break; case '=': if (ms == is) ms = i; } i++; } if (frag_boundary) { attributes = cons(make_symbol (fragment_header), attributes); dev9_rules_apply (attributes, fs); io->position += io->length; } else { io->position += (int_pointer)(max - fragment_header); } optimise_static_memory_pools(); io_flush (io); }
/* * Do the actual output. Take a va_list so that we can be called from * multiple different places, even functions that took "..." as input * arguments. */ static int output(int output_id, const char *format, va_list arglist) { int rc = PMIX_SUCCESS; char *str, *out = NULL; output_desc_t *ldi; /* Setup */ if (!initialized) { pmix_output_init(); } /* If it's valid, used, and enabled, output */ if (output_id >= 0 && output_id < PMIX_OUTPUT_MAX_STREAMS && info[output_id].ldi_used && info[output_id].ldi_enabled) { ldi = &info[output_id]; /* Make the strings */ if (PMIX_SUCCESS != (rc = make_string(&str, ldi, format, arglist))) { return rc; } /* Syslog output -- does not use the newline-appended string */ #if defined(HAVE_SYSLOG) if (ldi->ldi_syslog) { syslog(ldi->ldi_syslog_priority, "%s", str); } #endif /* All others (stdout, stderr, file) use temp_str, potentially with a newline appended */ out = temp_str; /* stdout output */ if (ldi->ldi_stdout) { write(fileno(stdout), out, (int)strlen(out)); fflush(stdout); } /* stderr output */ if (ldi->ldi_stderr) { write((-1 == default_stderr_fd) ? fileno(stderr) : default_stderr_fd, out, (int)strlen(out)); fflush(stderr); } /* File output -- first check to see if the file opening was * delayed. If so, try to open it. If we failed to open it, * then just discard (there are big warnings in the * pmix_output.h docs about this!). */ if (ldi->ldi_file) { if (ldi->ldi_fd == -1) { if (PMIX_SUCCESS != open_file(output_id)) { ++ldi->ldi_file_num_lines_lost; } else if (ldi->ldi_file_num_lines_lost > 0 && 0 <= ldi->ldi_fd) { char buffer[BUFSIZ]; char *out = buffer; memset(buffer, 0, BUFSIZ); snprintf(buffer, BUFSIZ - 1, "[WARNING: %d lines lost because the PMIx process session directory did\n not exist when pmix_output() was invoked]\n", ldi->ldi_file_num_lines_lost); write(ldi->ldi_fd, buffer, (int)strlen(buffer)); ldi->ldi_file_num_lines_lost = 0; if (out != buffer) { free(out); } } } if (ldi->ldi_fd != -1) { write(ldi->ldi_fd, out, (int)strlen(out)); } } free(str); } return rc; }
obj os_errormsg( int err_code ) { return make_string( strerror(err_code) ); }
void x_session_initialize (struct x_display_info *dpyinfo) { #define SM_ERRORSTRING_LEN 512 char errorstring[SM_ERRORSTRING_LEN]; char* previous_id = NULL; SmcCallbacks callbacks; int name_len = 0; ice_fd = -1; doing_interact = False; /* Check if we where started by the session manager. If so, we will have a previous id. */ if (! EQ (Vx_session_previous_id, Qnil) && STRINGP (Vx_session_previous_id)) previous_id = SSDATA (Vx_session_previous_id); /* Construct the path to the Emacs program. */ if (! EQ (Vinvocation_directory, Qnil)) name_len += strlen (SSDATA (Vinvocation_directory)); name_len += strlen (SSDATA (Vinvocation_name)); /* This malloc will not be freed, but it is only done once, and hopefully not very large */ emacs_program = xmalloc (name_len + 1); emacs_program[0] = '\0'; if (! EQ (Vinvocation_directory, Qnil)) strcpy (emacs_program, SSDATA (Vinvocation_directory)); strcat (emacs_program, SSDATA (Vinvocation_name)); /* The SM protocol says all callbacks are mandatory, so set up all here and in the mask passed to SmcOpenConnection. */ callbacks.save_yourself.callback = smc_save_yourself_CB; callbacks.save_yourself.client_data = 0; callbacks.die.callback = smc_die_CB; callbacks.die.client_data = 0; callbacks.save_complete.callback = smc_save_complete_CB; callbacks.save_complete.client_data = 0; callbacks.shutdown_cancelled.callback = smc_shutdown_cancelled_CB; callbacks.shutdown_cancelled.client_data = 0; /* Set error handlers. */ SmcSetErrorHandler (smc_error_handler); IceSetErrorHandler (ice_error_handler); IceSetIOErrorHandler (ice_io_error_handler); /* Install callback for when connection status changes. */ IceAddConnectionWatch (ice_conn_watch_CB, 0); /* Open the connection to the session manager. A failure is not critical, it usually means that no session manager is running. The errorstring is here for debugging. */ smc_conn = SmcOpenConnection (NULL, NULL, 1, 0, (SmcSaveYourselfProcMask| SmcDieProcMask| SmcSaveCompleteProcMask| SmcShutdownCancelledProcMask), &callbacks, previous_id, &client_id, SM_ERRORSTRING_LEN, errorstring); if (smc_conn != 0) { Vx_session_id = make_string (client_id, strlen (client_id)); #ifdef USE_GTK /* GTK creats a leader window by itself, but we need to tell it about our client_id. */ gdk_set_sm_client_id (client_id); #else create_client_leader_window (dpyinfo, client_id); #endif } }
sooty::lexing::lexeme_t::lexeme_t( id_t id, const input_iterator& begin, const input_iterator& end, const position_t& position ) : id_(id), begin_(begin), end_(end), position_(position) { text_ = make_string(begin_, end_); }
str->value = MALLOC_TN(char, str->length); if (str->value != NULL) { memcpy(str->value, ptr, realsize); strcat(str->value, "\0"); fprintf(stderr, "RECIEVED: %ld bytes\n", realsize); fprintf(stderr, "[USER STREAM] received -> %s\n", str->value); } return realsize; } int main() { T4C t4c = { .consumerKey = make_string("Your Consumer Key"), .consumerSecret = make_string("Your Consumer Secret"), .accessToken = make_string("Your AccessToken"), .accessTokenSecret = make_string("Your AccessTokenSecret") }; // POST REQUEST Parameters* params = new_parameters(); add_parameter(params, make_string("status"), make_string("Hello World!")); string result = request(&t4c, POST, make_string("/statuses/update.json"), params); printf("RESULT for Tweet: %s\n", string_get_value(result)); free_parameters(params);
static void dequeue_is_empty( char *op ) { scheme_error( "~a: <dequeue> is empty", 1, make_string(op) ); }
void init_editfns () { char *user_name; register unsigned char *p, *q; struct passwd *pw; /* password entry for the current user */ Lisp_Object tem; extern char *index (); /* Turn off polling so the SIGALRM won't bother getpwuid. */ stop_polling (); /* Set up system_name even when dumping. */ Vsystem_name = build_string (get_system_name ()); p = XSTRING (Vsystem_name)->data; while (*p) { if (*p == ' ' || *p == '\t') *p = '-'; p++; } #ifndef CANNOT_DUMP /* Don't bother with this on initial start when just dumping out */ if (!initialized) return; #endif /* not CANNOT_DUMP */ pw = (struct passwd *) getpwuid (getuid ()); #ifndef OS2 Vuser_real_name = build_string (pw ? pw->pw_name : "unknown"); #endif /* Get the effective user name, by consulting environment variables, or the effective uid if those are unset. */ user_name = (char *) getenv ("USER"); if (!user_name) user_name = (char *) getenv ("LOGNAME"); /* USG equivalent */ if (!user_name) { pw = (struct passwd *) getpwuid (geteuid ()); user_name = pw ? pw->pw_name : "unknown"; } Vuser_name = build_string (user_name); #ifdef OS2 Vuser_real_name = build_string (user_name); #endif /* If the user name claimed in the environment vars differs from the real uid, use the claimed name to find the full name. */ tem = Fstring_equal (Vuser_name, Vuser_real_name); if (NULL (tem)) pw = (struct passwd *) getpwnam (XSTRING (Vuser_name)->data); p = (unsigned char *) getenv("USERFULLNAME"); if (p==0) p = (unsigned char *) (pw ? USER_FULL_NAME : "unknown"); q = (unsigned char *) index (p, ','); Vuser_full_name = make_string (p, q ? q - p : strlen (p)); #ifdef AMPERSAND_FULL_NAME p = XSTRING (Vuser_full_name)->data; q = (unsigned char *) index (p, '&'); /* Substitute the login name for the &, upcasing the first character. */ if (q) { char *r = (char *) alloca (strlen (p) + XSTRING (Vuser_name)->size + 1); bcopy (p, r, q - p); r[q - p] = 0; strcat (r, XSTRING (Vuser_real_name)->data); r[q - p] = UPCASE (r[q - p]); strcat (r, q + 1); Vuser_full_name = build_string (r); } #endif /* AMPERSAND_FULL_NAME */ start_polling (); }
void CInifile::Load(IReader* F, LPCSTR path) { R_ASSERT(F); Sect *Current = 0; string4096 str; string4096 str2; BOOL bInsideSTR = FALSE; while (!F->eof()) { F->r_string (str,sizeof(str)); _Trim (str); LPSTR comm = strchr(str,';'); LPSTR comm_1 = strchr(str,'/'); if(comm_1 && (*(comm_1+1)=='/') && ((!comm) || (comm && (comm_1<comm) )) ) { comm = comm_1; } #ifdef DEBUG LPSTR comment = 0; #endif if (comm) { //."bla-bla-bla;nah-nah-nah" char quot = '"'; bool in_quot = false; LPCSTR q1 = strchr(str,quot); if(q1 && q1<comm) { LPCSTR q2 = strchr(++q1,quot); if(q2 && q2>comm) in_quot = true; } if(!in_quot) { *comm = 0; #ifdef DEBUG comment = comm+1; #endif } } if (str[0] && (str[0]=='#') && strstr(str,"#include")) //handle includes { string_path inc_name; R_ASSERT (path&&path[0]); if (_GetItem (str,1,inc_name,'"')) { string_path fn,inc_path,folder; strconcat (sizeof(fn),fn,path,inc_name); _splitpath (fn,inc_path,folder, 0, 0 ); strcat (inc_path,folder); IReader* I = FS.r_open(fn); R_ASSERT3(I,"Can't find include file:", inc_name); Load (I,inc_path); FS.r_close (I); } } else if (str[0] && (str[0]=='[')) //new section ? { // insert previous filled section if (Current) { //store previous section RootIt I = std::lower_bound(DATA.begin(),DATA.end(),*Current->Name,sect_pred); if ((I!=DATA.end())&&((*I)->Name==Current->Name)) xrDebug::Fatal(DEBUG_INFO, "Duplicate section '%s' found.", *Current->Name); DATA.insert (I,Current); } Current = new Sect(); Current->Name = 0; // start new section R_ASSERT3(strchr(str,']'),"Bad ini section found: ",str); LPCSTR inherited_names = strstr(str,"]:"); if (0!=inherited_names) { VERIFY2 (m_flags.test(eReadOnly),"Allow for readonly mode only."); inherited_names += 2; int cnt = _GetItemCount(inherited_names); for (int k=0; k<cnt; ++k) { xr_string tmp; _GetItem (inherited_names,k,tmp); Sect& inherited_section = r_section(tmp.c_str()); for (SectIt_ it =inherited_section.Data.begin(); it!=inherited_section.Data.end(); it++) insert_item (Current,*it); } } *strchr(str,']') = 0; Current->Name = strlwr(str+1); } else // name = value { if (Current) { string4096 value_raw; char* name = str; char* t = strchr(name,'='); if (t) { *t = 0; _Trim (name); ++t; strcpy_s (value_raw, sizeof(value_raw), t); bInsideSTR = _parse(str2, value_raw); if(bInsideSTR)//multiline str value { while(bInsideSTR) { strcat_s (value_raw, sizeof(value_raw),"\r\n"); string4096 str_add_raw; F->r_string (str_add_raw, sizeof(str_add_raw)); R_ASSERT2 ( xr_strlen(value_raw) + xr_strlen(str_add_raw) < sizeof(value_raw), make_string( "Incorrect inifile format: section[%s], variable[%s]. Odd number of quotes (\") found, but should be even.", Current->Name.c_str(), name ) ); strcat_s (value_raw, sizeof(value_raw),str_add_raw); bInsideSTR = _parse(str2, value_raw); if(bInsideSTR) { if( is_empty_line_now(F) ) strcat_s (value_raw, sizeof(value_raw),"\r\n"); } } } } else { _Trim (name); str2[0] = 0; } Item I; I.first = (name[0]?name:NULL); I.second = (str2[0]?str2:NULL); #ifdef DEBUG I.comment = m_flags.test(eReadOnly)?0:comment; #endif if (m_flags.test(eReadOnly)) { if (*I.first) insert_item (Current,I); } else { if ( *I.first || *I.second #ifdef DEBUG || *I.comment #endif ) insert_item (Current,I); } } } } if (Current) { RootIt I = std::lower_bound(DATA.begin(),DATA.end(),*Current->Name,sect_pred); if ((I!=DATA.end())&&((*I)->Name==Current->Name)) xrDebug::Fatal(DEBUG_INFO, "Duplicate section '%s' found.", *Current->Name); DATA.insert (I,Current); } }
int expandargv (arg_parser const& ap, int *argcp, char ***argvp) { /* The argument we are currently processing. */ int i = 0; /* Non-zero if ***argvp has been dynamically allocated. */ int argv_dynamic = 0; /* Limit the number of response files that we parse in order to prevent infinite recursion. */ unsigned int iteration_limit = 2000; /* Loop over the arguments, handling response files. We always skip ARGVP[0], as that is the name of the program being run. */ while (++i < *argcp) { /* The name of the response file. */ const char *filename; /* The response file. */ FILE *f; /* An upper bound on the number of characters in the response file. */ long pos; /* The number of characters in the response file, when actually read. */ size_t len; /* A dynamically allocated buffer used to hold options read from a response file. */ char *buffer; /* Dynamically allocated storage for the options read from the response file. */ char **file_argv; /* The number of options read from the response file, if any. */ size_t file_argc; /* We are only interested in options of the form "@file". */ filename = (*argvp)[i]; if (filename[0] != '@') continue; /* If we have iterated too many times then stop. */ if (-- iteration_limit == 0) { ap.error( make_string() << "Too many @-files encountered: " "possible infinite recursion in " << (*argvp)[0] ); exit (1); } /* Read the contents of the file. */ f = fopen (++filename, "r"); if (!f) { ap.error( make_string() << "Unable to open @file " << filename ); exit (1); } if (fseek (f, 0L, SEEK_END) == -1) goto error; pos = ftell (f); if (pos == -1) goto error; if (fseek (f, 0L, SEEK_SET) == -1) goto error; buffer = (char *) malloc (pos * sizeof (char) + 1); if (!buffer) throw std::bad_alloc(); len = fread (buffer, sizeof (char), pos, f); if (len != (size_t) pos /* On Windows, fread may return a value smaller than POS, due to CR/LF->CR translation when reading text files. That does not in-and-of itself indicate failure. */ && ferror (f)) goto error; /* Add a NUL terminator. */ buffer[len] = '\0'; /* If the file is empty or contains only whitespace, buildargv would return a single empty argument. In this context we want no arguments, instead. */ if (only_whitespace (buffer)) { file_argv = (char **) malloc (sizeof (char *)); if (!file_argv) throw std::bad_alloc(); file_argv[0] = NULL; } else /* Parse the string. */ file_argv = buildargv (ap, buffer); /* If *ARGVP is not already dynamically allocated, copy it. */ if (!argv_dynamic) { *argvp = dupargv (ap, *argvp); if (!*argvp) throw std::bad_alloc(); } ++argv_dynamic; /* Count the number of arguments. */ file_argc = 0; while (file_argv[file_argc]) ++file_argc; /* Now, insert FILE_ARGV into ARGV. The "+1" below handles the NULL terminator at the end of ARGV. */ *argvp = ((char **) realloc (*argvp, (*argcp + file_argc + 1) * sizeof (char *))); memmove (*argvp + i + file_argc, *argvp + i + 1, (*argcp - i) * sizeof (char *)); memcpy (*argvp + i, file_argv, file_argc * sizeof (char *)); /* The original option has been replaced by all the new options. */ *argcp += file_argc - 1; /* Free up memory allocated to process the response file. We do not use freeargv because the individual options in FILE_ARGV are now in the main ARGV. */ free (file_argv); free (buffer); /* Rescan all of the arguments just read to support response files that include other response files. */ --i; error: /* We're all done with the file now. */ fclose (f); } return argv_dynamic; }
std::string get_string(const Fbox &box) { return make_string( "[ min: %s - max: %s ]", get_string( box.min ).c_str(), get_string( box.max ).c_str() ); }
static Statement *ParseFunctionBody(SYM *sp) { std::string lbl; char *p; Statement *stmt; Statement *plg; Statement *eplg; dfs.printf("<Parse function body>:%s|\n", (char *)sp->name->c_str()); lbl[0] = 0; needpunc(begin,47); tmpReset(); //ParseAutoDeclarations(); cseg(); if (sp->storage_class == sc_static) { //strcpy(lbl,GetNamespace()); //strcat(lbl,"_"); // strcpy(lbl,sp->name); lbl = *sp->mangledName; //gen_strlab(lbl); } // put_label((unsigned int) sp->value.i); else { if (sp->storage_class == sc_global) lbl = "public code "; // strcat(lbl,sp->name); lbl += *sp->mangledName; //gen_strlab(lbl); } dfs.printf("B"); p = my_strdup((char *)lbl.c_str()); dfs.printf("b"); GenerateMonadic(op_fnname,0,make_string(p)); currentFn = sp; currentFn->IsLeaf = TRUE; currentFn->DoesThrow = FALSE; currentFn->UsesPredicate = FALSE; regmask = 0; bregmask = 0; currentStmt = (Statement *)NULL; dfs.printf("C"); stmt = ParseCompoundStatement(); dfs.printf("D"); // stmt->stype = st_funcbody; if (isThor) GenerateFunction(sp, stmt); else if (isTable888) GenerateTable888Function(sp, stmt); else if (isRaptor64) GenerateRaptor64Function(sp, stmt); else if (is816) Generate816Function(sp, stmt); else if (isFISA64) GenerateFISA64Function(sp, stmt); dfs.putch('E'); flush_peep(); if (sp->storage_class == sc_global) { ofs.printf("endpublic\r\n\r\n"); } ofs.printf("%sSTKSIZE_ EQU %d\r\n", (char *)sp->mangledName->c_str(), tmpVarSpace() + lc_auto); isFuncBody = false; dfs.printf("</ParseFunctionBody>\n"); return stmt; }
std::string get_string( const Fvector& v ) { return make_string ("( %f, %f, %f )", v.x, v.y, v.z ); }
/* * Parse a "value" from the remainder of the expression in infoPtr. * * Results: * Normally TCL_OK is returned. The value of the expression is * returned in *valuePtr. If an error occurred, then interp->result * contains an error message and TCL_ERROR is returned. * InfoPtr->token will be left pointing to the token AFTER the * expression, and infoPtr->expr will point to the character just * after the terminating token. * * Side effects: * None. */ static unsigned char get_value (Tcl_Interp *interp, /* Interpreter to use for error reporting. */ Expr_info_t *infoPtr, /* Describes the state of the parse just * before the value (i.e. get_lex will be * called to get first token of value). */ int prec, /* Treat any un-parenthesized operator * with precedence <= this as the end * of the expression. */ Value_t *valuePtr) /* Where to store the value of the * expression. Caller must have * initialized pv field. */ { Interp *iPtr = (Interp *) interp; Value_t value2; /* Second operand for current * operator. */ int operator; /* Current operator (either unary * or binary). */ int badType; /* Type of offending argument; used * for error messages. */ int gotOp; /* Non-zero means already lexed the * operator (while picking up value * for unary operator). Don't lex * again. */ unsigned char result; /* * There are two phases to this procedure. First, pick off an initial * value. Then, parse (binary operator, value) pairs until done. */ gotOp = 0; value2.pv.buffer = value2.pv.next = value2.static_space; value2.pv.end = value2.pv.buffer + STATIC_STRING_SPACE - 1; value2.pv.expandProc = TclExpandParseValue; value2.pv.clientData = (void*) 0; result = get_lex(interp, infoPtr, valuePtr); if (result != TCL_OK) { goto done; } if (infoPtr->token == OPEN_PAREN) { /* * Parenthesized sub-expression. */ result = get_value(interp, infoPtr, -1, valuePtr); if (result != TCL_OK) { goto done; } if (infoPtr->token != CLOSE_PAREN) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "unmatched parentheses in expression \"", infoPtr->original_expr, "\"", 0); result = TCL_ERROR; goto done; } } else { if (infoPtr->token == MINUS) { infoPtr->token = UNARY_MINUS; } if (infoPtr->token >= UNARY_MINUS) { /* * Process unary operators. */ operator = infoPtr->token; result = get_value(interp, infoPtr, prec_table[infoPtr->token], valuePtr); if (result != TCL_OK) { goto done; } switch (operator) { case UNARY_MINUS: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = -valuePtr->int_value; } else { badType = valuePtr->type; goto illegalType; } break; case NOT: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = !valuePtr->int_value; } else { badType = valuePtr->type; goto illegalType; } break; case BIT_NOT: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = ~valuePtr->int_value; } else { badType = valuePtr->type; goto illegalType; } break; } gotOp = 1; } else if (infoPtr->token != VALUE) { goto syntaxError; } } /* * Got the first operand. Now fetch (operator, operand) pairs. */ if (!gotOp) { result = get_lex(interp, infoPtr, &value2); if (result != TCL_OK) { goto done; } } while (1) { operator = infoPtr->token; value2.pv.next = value2.pv.buffer; if ((operator < MULT) || (operator >= UNARY_MINUS)) { if ((operator == END) || (operator == CLOSE_PAREN)) { result = TCL_OK; goto done; } else { goto syntaxError; } } if (prec_table[operator] <= prec) { result = TCL_OK; goto done; } /* * If we're doing an AND or OR and the first operand already * determines the result, don't execute anything in the * second operand: just parse. Same style for ?: pairs. */ if ((operator == AND) || (operator == OR) || (operator == QUESTY)) { if (valuePtr->type == TYPE_STRING) { badType = TYPE_STRING; goto illegalType; } if (((operator == AND) && !valuePtr->int_value) || ((operator == OR) && valuePtr->int_value)) { iPtr->noEval++; result = get_value(interp, infoPtr, prec_table[operator], &value2); iPtr->noEval--; } else if (operator == QUESTY) { if (valuePtr->int_value != 0) { valuePtr->pv.next = valuePtr->pv.buffer; result = get_value(interp, infoPtr, prec_table[operator], valuePtr); if (result != TCL_OK) { goto done; } if (infoPtr->token != COLON) { goto syntaxError; } value2.pv.next = value2.pv.buffer; iPtr->noEval++; result = get_value(interp, infoPtr, prec_table[operator], &value2); iPtr->noEval--; } else { iPtr->noEval++; result = get_value(interp, infoPtr, prec_table[operator], &value2); iPtr->noEval--; if (result != TCL_OK) { goto done; } if (infoPtr->token != COLON) { goto syntaxError; } valuePtr->pv.next = valuePtr->pv.buffer; result = get_value(interp, infoPtr, prec_table[operator], valuePtr); } } else { result = get_value(interp, infoPtr, prec_table[operator], &value2); } } else { result = get_value(interp, infoPtr, prec_table[operator], &value2); } if (result != TCL_OK) { goto done; } if ((infoPtr->token < MULT) && (infoPtr->token != VALUE) && (infoPtr->token != END) && (infoPtr->token != CLOSE_PAREN)) { goto syntaxError; } /* * At this point we've got two values and an operator. Check * to make sure that the particular data types are appropriate * for the particular operator, and perform type conversion * if necessary. */ switch (operator) { /* * For the operators below, no strings are allowed and * ints get converted to floats if necessary. */ case MULT: case DIVIDE: case PLUS: case MINUS: if ((valuePtr->type == TYPE_STRING) || (value2.type == TYPE_STRING)) { badType = TYPE_STRING; goto illegalType; } break; /* * For the operators below, only integers are allowed. */ case MOD: case LEFT_SHIFT: case RIGHT_SHIFT: case BIT_AND: case BIT_XOR: case BIT_OR: if (valuePtr->type != TYPE_INT) { badType = valuePtr->type; goto illegalType; } else if (value2.type != TYPE_INT) { badType = value2.type; goto illegalType; } break; /* * For the operators below, any type is allowed but the * two operands must have the same type. Convert integers * to floats and either to strings, if necessary. */ case LESS: case GREATER: case LEQ: case GEQ: case EQUAL: case NEQ: if (valuePtr->type == TYPE_STRING) { if (value2.type != TYPE_STRING) { make_string (interp->pool, &value2); } } else if (value2.type == TYPE_STRING) { if (valuePtr->type != TYPE_STRING) { make_string (interp->pool, valuePtr); } } break; /* * For the operators below, no strings are allowed. */ case AND: case OR: if (valuePtr->type == TYPE_STRING) { badType = valuePtr->type; goto illegalType; } if (value2.type == TYPE_STRING) { badType = value2.type; goto illegalType; } break; /* * For the operators below, type and conversions are * irrelevant: they're handled elsewhere. */ case QUESTY: case COLON: break; /* * Any other operator is an error. */ default: interp->result = (unsigned char*) "unknown operator in expression"; result = TCL_ERROR; goto done; } /* * If necessary, convert one of the operands to the type * of the other. If the operands are incompatible with * the operator (e.g. "+" on strings) then return an * error. */ switch (operator) { case MULT: if (valuePtr->type == TYPE_INT) { valuePtr->int_value *= value2.int_value; } break; case DIVIDE: if (valuePtr->type == TYPE_INT) { if (value2.int_value == 0) { divideByZero: interp->result = (unsigned char*) "divide by zero"; result = TCL_ERROR; goto done; } valuePtr->int_value /= value2.int_value; } break; case MOD: if (value2.int_value == 0) { goto divideByZero; } valuePtr->int_value %= value2.int_value; break; case PLUS: if (valuePtr->type == TYPE_INT) { valuePtr->int_value += value2.int_value; } break; case MINUS: if (valuePtr->type == TYPE_INT) { valuePtr->int_value -= value2.int_value; } break; case LEFT_SHIFT: valuePtr->int_value <<= value2.int_value; break; case RIGHT_SHIFT: /* * The following code is a bit tricky: it ensures that * right shifts propagate the sign bit even on machines * where ">>" won't do it by default. */ if (valuePtr->int_value < 0) { valuePtr->int_value = ~((~valuePtr->int_value) >> value2.int_value); } else { valuePtr->int_value >>= value2.int_value; } break; case LESS: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = valuePtr->int_value < value2.int_value; } else { valuePtr->int_value = strcmp(valuePtr->pv.buffer, value2.pv.buffer) < 0; } valuePtr->type = TYPE_INT; break; case GREATER: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = valuePtr->int_value > value2.int_value; } else { valuePtr->int_value = strcmp(valuePtr->pv.buffer, value2.pv.buffer) > 0; } valuePtr->type = TYPE_INT; break; case LEQ: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = valuePtr->int_value <= value2.int_value; } else { valuePtr->int_value = strcmp(valuePtr->pv.buffer, value2.pv.buffer) <= 0; } valuePtr->type = TYPE_INT; break; case GEQ: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = valuePtr->int_value >= value2.int_value; } else { valuePtr->int_value = strcmp(valuePtr->pv.buffer, value2.pv.buffer) >= 0; } valuePtr->type = TYPE_INT; break; case EQUAL: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = valuePtr->int_value == value2.int_value; } else { valuePtr->int_value = strcmp(valuePtr->pv.buffer, value2.pv.buffer) == 0; } valuePtr->type = TYPE_INT; break; case NEQ: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = valuePtr->int_value != value2.int_value; } else { valuePtr->int_value = strcmp(valuePtr->pv.buffer, value2.pv.buffer) != 0; } valuePtr->type = TYPE_INT; break; case BIT_AND: valuePtr->int_value &= value2.int_value; break; case BIT_XOR: valuePtr->int_value ^= value2.int_value; break; case BIT_OR: valuePtr->int_value |= value2.int_value; break; case AND: valuePtr->int_value = valuePtr->int_value && value2.int_value; break; case OR: valuePtr->int_value = valuePtr->int_value || value2.int_value; break; case COLON: interp->result = (unsigned char*) "can't have : operator without ? first"; result = TCL_ERROR; goto done; }
std::string dump_string( LPCSTR name, const Fvector &v ) { return make_string( "%s : (%f,%f,%f) ", name, v.x, v.y, v.z ); }
float imotion_position::motion_collide( float dt, IKinematicsAnimated& KA ) { VERIFY( shell ); float advance_time = collide_animation( dt, KA ); if( time_to_end < ( max_collide_timedelta + end_delta ) ) { interactive_motion_diagnostic( make_string( "motion_collide 0: stoped: time out, time delta %f", dt ).c_str() ); flags.set( fl_switch_dm_toragdoll, TRUE ); return advance_time; } if( depth > depth_resolve ) { #ifdef DEBUG if( dbg_imotion_collide_debug ) { //interactive_motion_diagnostic( make_string( " motion_collide collided0: deppth= %f", depth ).c_str() ); interactive_motion_diagnostic( make_string( "motion_collide 1: stoped: colide: %s, depth %f", collide_diag().c_str(), depth ).c_str() ); DBG_OpenCashedDraw(); shell->dbg_draw_geometry( 0.02, D3DCOLOR_ARGB( 255, 0, 255, 0 ) ); DBG_ClosedCashedDraw( 50000 ); } #endif u32 sv_blends_num = blends_num( KA ); buffer_vector<sblend_save> saved_blends( _alloca( sv_blends_num*sizeof( sblend_save ) ), sv_blends_num ); save_blends( saved_blends, KA ); // sv1 float depth0 = depth; advance_time += collide_animation( collide_adwance_delta, KA ); #ifdef DEBUG if( dbg_imotion_collide_debug ) { interactive_motion_diagnostic( make_string( " motion_collide collided1: deppth= %f", depth ).c_str() ); DBG_OpenCashedDraw(); shell->dbg_draw_geometry( 0.02, D3DCOLOR_ARGB( 255, 0, 255, 255 ) ); DBG_ClosedCashedDraw( 50000 ); } #endif if( depth > depth0 ) { interactive_motion_diagnostic( make_string( "motion_collide 1: stoped: colide: %s, depth %f", collide_diag().c_str(), depth ).c_str() ); flags.set( fl_switch_dm_toragdoll, TRUE ); } else { depth0= depth; advance_time += collide_animation( collide_adwance_delta, KA ); #ifdef DEBUG if( dbg_imotion_collide_debug ) { interactive_motion_diagnostic( make_string( " motion_collide collided2: deppth= %f", depth ).c_str() ); DBG_OpenCashedDraw(); shell->dbg_draw_geometry( 0.02, D3DCOLOR_ARGB( 255, 0, 255, 0 ) ); DBG_ClosedCashedDraw( 50000 ); } #endif if( depth > depth_resolve ) { interactive_motion_diagnostic( make_string( "motion_collide 2: stoped: colide: %s, depth %f", collide_diag().c_str(), depth ).c_str() ); flags.set( fl_switch_dm_toragdoll, TRUE ); } } restore_blends( saved_blends );// rs1 //advance_time += advance_animation( dt-advance_time, KA ); time_to_end += (dt-advance_time); advance_time += (dt-advance_time); force_calculate_bones( KA ); shell->ToAnimBonesPositions( shell_motion_has_history ? mh_clear : mh_unspecified ); #ifdef DEBUG if( dbg_imotion_collide_debug ) { depth = 0; shell->CollideAll(); interactive_motion_diagnostic( make_string( " motion_collide restore: %f ", depth ).c_str() ); DBG_OpenCashedDraw(); shell->dbg_draw_geometry( 0.02, D3DCOLOR_ARGB( 255, 255, 0, 0 ) ); DBG_ClosedCashedDraw( 50000 ); } #endif } return advance_time; }
void image_dump_to_fits(image_str *image, char *filename) { fitsfile *fits; int status; long naxis = 2; long naxes[2] = {image->width, image->height}; char *filename_exclam = make_string("!%s", filename); if(!filename) return; cfitsio_lock(); status = 0; fits_create_file(&fits, filename_exclam, &status); free(filename_exclam); /* Creating 3-dimensional FITS file of necessary type. */ if(image->type == IMAGE_DOUBLE){ fits_create_img(fits, DOUBLE_IMG, naxis, naxes, &status); fits_write_2d_dbl(fits, 0, image->width, image->width, image->height, image->double_data, &status); } else { fits_create_img(fits, USHORT_IMG, naxis, naxes, &status); fits_write_2d_usht(fits, 0, image->width, image->width, image->height, image->data, &status); } if(!coords_is_empty(&image->coords)) image_keyword_add_coords(image, image->coords); /* Write keywords */ image_keywords_to_fits(image, fits); /* Write header */ { double ra = image->coords.ra0; double dec = image->coords.dec0; char *ra_string = NULL; char *dec_string = NULL; char *time_string = time_str_get_date_time(image->time); char *date_obs_string = make_string("%04d-%02d-%02d", image->time.year, image->time.month, image->time.day); char *time_obs_string = make_string("%02d:%02d:%04.2lf", image->time.hour, image->time.minute, image->time.second + 1e-6*image->time.microsecond); double jd = time_str_get_JD(image->time); if(!coords_is_empty(&image->coords)) coords_get_ra_dec(&image->coords, 0.5*image->width, 0.5*image->height, &ra, &dec); ra_string = make_ra_string(ra); dec_string = make_dec_string(dec); fits_update_key(fits, TSTRING, "RA", ra_string, "Rough center coordinates", &status); fits_update_key(fits, TSTRING, "DEC", dec_string, "Rough center coordinates", &status); fits_update_key(fits, TSTRING, "TIME", time_string, "Date and time", &status); fits_update_key(fits, TSTRING, "DATE-OBS", date_obs_string, NULL, &status); fits_update_key(fits, TSTRING, "TIME-OBS", time_obs_string, NULL, &status); fits_update_key(fits, TDOUBLE, "JD", &jd, "Julianic date, millisecond precision", &status); free(ra_string); free(dec_string); free(time_string); free(date_obs_string); free(time_obs_string); } fits_close_file(fits, &status); /* Print out error messages if any */ fits_report_error(stderr, status); cfitsio_unlock(); }
// printf("parse_ok %d\n", parse_ok); if(!parse_ok) { fprintf(stderr, "NGS: Failed to parse at position %d (%s), rule %s. Exiting.\n", yyctx.fail_pos, sprintf_position(&yyctx, yyctx.fail_pos), yyctx.fail_rule); exit(2); } tree = yyctx.__; IF_DEBUG(COMPILER, print_ast(tree, 0);) yyrelease(&yyctx); // TODO: use native_... methods to load and run the code bytecode = compile(tree, source_file_name, &len); // BROKEN SINCE BYTECODE FORMAT CHANGE // IF_DEBUG(COMPILER, decompile(bytecode, 0, len);) vm_init(&vm, argc, argv); set_global(&vm, "BOOTSTRAP_FILE", make_string(bootstrap_file_name)); ctx_init(&ctx); ip = vm_load_bytecode(&vm, bytecode); closure = make_closure_obj(ip, 0, 0, 0, 0, 0, NULL); mr = vm_call(&vm, &ctx, &result, closure, 0, NULL); if(mr == METHOD_OK) { return 0; } if(mr == METHOD_EXCEPTION) { if(obj_is_of_type(result, vm.Exception)) { printf("========= Uncaught exception of type '%s' =========\n", obj_to_cstring(NGS_TYPE_NAME(NORMAL_TYPE_INSTANCE_TYPE(result)))); print_exception(&vm, result); } else { dump_titled("Uncaught exception", result); } return 1;
/* * mangled ieee80211_status() */ int get_nwinfo(char *ifname, char *str, int str_len, int type) { char tmp[128]; int ifs, len, i, nwkey_verbose; ifs = socket(AF_INET, SOCK_DGRAM, 0); if (ifs < 0) { printf("%% get_nwinfo: socket: %s\n", strerror(errno)); return(NULL); } memset(str, 0, str_len); switch(type) { case NWID: { struct ieee80211_nwid nwid; struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); ifr.ifr_data = (caddr_t)&nwid; (void) strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(ifs, SIOCG80211NWID, (caddr_t) & ifr) == 0) { /* nwid.i_nwid is not NUL terminated. */ len = nwid.i_len; if (len > IEEE80211_NWID_LEN) len = IEEE80211_NWID_LEN; make_string(str, str_len, nwid.i_nwid, len); } } break; case TXPOWER: { struct ieee80211_txpower txpower; memset(&txpower, 0, sizeof(txpower)); (void) strlcpy(txpower.i_name, ifname, sizeof(txpower.i_name)); if (ioctl(ifs, SIOCG80211TXPOWER, (caddr_t) &txpower) == 0) { /* XXX FIXED is always set? For now, check for == 100, txpower is totally broken in the kernel anyways */ if (txpower.i_mode == IEEE80211_TXPOWER_MODE_FIXED && txpower.i_val != 100) snprintf(str, str_len, "%d", txpower.i_val); } else { if (errno != EINVAL) { printf("%% get_nwinfo: SIOCG80211TXPOWER: %s\n", strerror(errno)); } } } break; case POWERSAVE: { struct ieee80211_power power; memset(&power, 0, sizeof(power)); strlcpy(power.i_name, ifname, sizeof(power.i_name)); if (ioctl(ifs, SIOCG80211POWER, &power) == 0) { if (power.i_enabled && power.i_maxsleep != DEFAULT_POWERSAVE) snprintf(str, str_len, "%d", power.i_maxsleep); else if (power.i_enabled) memset(&str, '\0', str_len); /* "powersave " */ } else { printf("%% get_nwinfo: SIOCG80211POWER: %s\n", strerror(errno)); } } break; case BSSID: { struct ieee80211_bssid bssid; struct ether_addr ea; u_int8_t zero_bssid[IEEE80211_ADDR_LEN]; memset(&zero_bssid, 0, sizeof(zero_bssid)); strlcpy(bssid.i_name, ifname, sizeof(bssid.i_name)); if (ioctl(ifs, SIOCG80211BSSID, &bssid) == 0) { if (memcmp(bssid.i_bssid, zero_bssid, IEEE80211_ADDR_LEN) != 0) { memcpy(&ea.ether_addr_octet, bssid.i_bssid, sizeof(ea.ether_addr_octet)); snprintf(str, str_len, "%s", ether_ntoa(&ea)); } } else { printf("%% get_nwinfo: SIOCG80211BSSID: %s\n", strerror(errno)); } } break; case NWKEY: { struct ieee80211_nwkey nwkey; u_int8_t keybuf[IEEE80211_WEP_NKID][16]; memset(&nwkey, 0, sizeof(nwkey)); (void) strlcpy(nwkey.i_name, ifname, sizeof(nwkey.i_name)); if (ioctl(ifs, SIOCG80211NWKEY, (caddr_t) & nwkey) == 0 && nwkey.i_wepon > 0) { /* try to retrieve WEP keys */ for (i = 0; i < IEEE80211_WEP_NKID; i++) { nwkey.i_key[i].i_keydat = keybuf[i]; nwkey.i_key[i].i_keylen = sizeof(keybuf[i]); } if (ioctl(ifs, SIOCG80211NWKEY, (caddr_t) & nwkey) == -1) { strlcat(str, "*****", str_len); } else { nwkey_verbose = 0; /* * check to see non default key or multiple keys * defined */ if (nwkey.i_defkid != 1) { nwkey_verbose = 1; } else { for (i = 1; i < IEEE80211_WEP_NKID; i++) { if (nwkey.i_key[i].i_keylen != 0) { nwkey_verbose = 1; break; } } } /* check extra ambiguity with keywords */ if (!nwkey_verbose) { if (nwkey.i_key[0].i_keylen >= 2 && isdigit(nwkey.i_key[0].i_keydat[0]) && nwkey.i_key[0].i_keydat[1] == ':') nwkey_verbose = 1; else if (nwkey.i_key[0].i_keylen >= 7 && MIN_ARG( nwkey.i_key[0].i_keydat, "persist")) nwkey_verbose = 1; } if (nwkey_verbose) { snprintf(tmp, sizeof(tmp), "%d:", nwkey.i_defkid); strlcat(str, tmp, str_len); } for (i = 0; i < IEEE80211_WEP_NKID; i++) { if (i > 0) strlcat(str, ",", str_len); if (nwkey.i_key[i].i_keylen < 0) { strlcat(str, "persist", str_len); } else { /* * XXX - sanity check * nwkey.i_key[i].i_keylen */ make_string(str, str_len, nwkey.i_key[i].i_keydat, nwkey.i_key[i].i_keylen); } if (!nwkey_verbose) break; } } } } break; } /* switch {} */ close(ifs); return(strlen(str)); }
int main() { auto x = make_string(concat("Hello "_s, "World!"_s)); std::cout << x << std::endl; }
// Generate a function body. // void GenerateFunction(SYM *sym, Statement *stmt) { char buf[20]; char *bl; int cnt, nn; AMODE *ap; ENODE *ep; throwlab = retlab = contlab = breaklab = -1; lastsph = 0; memset(semaphores,0,sizeof(semaphores)); throwlab = nextlabel++; while( lc_auto & 7 ) /* round frame size to word */ ++lc_auto; if (sym->IsInterrupt) { //GenerateTriadic(op_subui,0,makereg(30),makereg(30),make_immed(30*8)); //GenerateDiadic(op_sm,0,make_indirect(30), make_mask(0x9FFFFFFE)); } if (!sym->IsNocall) { GenerateTriadic(op_subui,0,makereg(SP),makereg(SP),make_immed(32)); if (lc_auto || sym->NumParms > 0) GenerateDiadic(op_sw,0,makereg(BP),make_indirect(SP)); // if (sym->UsesPredicate) GenerateDiadic(op_sws, 0, make_string("pregs"), make_indexed(24,SP)); // For a leaf routine don't bother to store the link register or exception link register. if (!sym->IsLeaf) { if (exceptions) GenerateDiadic(op_sws, 0, makebreg(XLR), make_indexed(8,SP)); GenerateDiadic(op_sws, 0, makebreg(LR), make_indexed(16,SP)); if (exceptions) { ep = xalloc(sizeof(struct enode)); ep->nodetype = en_clabcon; ep->i = throwlab; ap = allocAmode(); ap->mode = am_immed; ap->offset = ep; GenerateDiadic(op_ldis,0, makebreg(XLR), ap); } } if (lc_auto || sym->NumParms > 0) { GenerateDiadic(op_mov,0,makereg(BP),makereg(SP)); if (lc_auto) GenerateTriadic(op_subui,0,makereg(SP),makereg(SP),make_immed(lc_auto)); } // Save registers used as register variables. // **** Done in Analyze.c **** //if( save_mask != 0 ) { // GenerateTriadic(op_subui,0,makereg(SP),makereg(SP),make_immed(popcnt(save_mask)*8)); // cnt = (bitsset(save_mask)-1)*8; // for (nn = 31; nn >=1 ; nn--) { // if (save_mask & (1 << nn)) { // GenerateTriadic(op_sw,0,makereg(nn),make_indexed(cnt,SP),NULL); // cnt -= 8; // } // } //} } if (optimize) sym->NumRegisterVars = opt1(stmt); GenerateStatement(stmt); GenerateReturn(sym,0); // Generate code for the hidden default catch if (exceptions) { if (sym->IsLeaf){ if (sym->DoesThrow) { GenerateLabel(throwlab); ap = GetTempRegister(); GenerateDiadic(op_mfspr,0,ap,makebreg(XLR)); GenerateDiadic(op_mtspr,0,makebreg(LR),ap); ReleaseTempRegister(ap); GenerateDiadic(op_bra,0,make_clabel(retlab),NULL); // goto regular return cleanup code } } else { GenerateLabel(throwlab); GenerateDiadic(op_lws,0,makebreg(LR),make_indexed(8,BP)); // load throw return address from stack into LR GenerateDiadic(op_sws,0,makebreg(LR),make_indexed(16,BP)); // and store it back (so it can be loaded with the lm) GenerateDiadic(op_bra,0,make_clabel(retlab),NULL); // goto regular return cleanup code } } }