static void ascii(char key) { t_line *l; if (data()->cur == NONE) data()->current = init_line(key); else if (data()->cur == CURRENT) { l = data()->current; if (l == NULL) l = init_line(key); else l->tmp = add_char(key, l->tmp, l->edit); set_edit(l); data()->current = l; } else { l = data()->history; while (l->id != data()->cur) l = l->next; if (l->tmp == NULL && l->edit) l->tmp = dup_str(l->line); l->tmp = add_char(key, l->tmp, l->edit); set_edit(l); } }
bool singleFitness(int individual) { int sOnes, rOnes, sZeroes, rZeroes; int i; init_line(population + individual); line_count(&sOnes, &sZeroes); if (sZeroes > sOnes) { sZeroes = sZeroes + sOnes; sOnes = 0; } else { sOnes = sZeroes + sOnes; sZeroes = 0; } for (i=0; i<STEPS_PER_FITNESS; i++) { if (!line_is_stable()) { line_next(); #ifdef FITNESS_DEBUG line_print(); #endif } else { break; } } line_count(&rOnes, &rZeroes); bool success = sZeroes == rZeroes && sOnes == rOnes; #ifdef FITNESS_DEBUG printf("Success: %s\n\n", success? "true" : "false"); #endif return success; }
fz_device * fz_new_text_device(fz_context *ctx, fz_text_sheet *sheet, fz_text_page *page) { fz_device *dev; fz_text_device *tdev = fz_malloc_struct(ctx, fz_text_device); tdev->sheet = sheet; tdev->page = page; tdev->point.x = -1; tdev->point.y = -1; tdev->lastchar = ' '; init_line(ctx, &tdev->cur_line); init_span(ctx, &tdev->cur_span, NULL); dev = fz_new_device(ctx, tdev); dev->hints = FZ_IGNORE_IMAGE | FZ_IGNORE_SHADE; dev->free_user = fz_text_free_user; dev->fill_text = fz_text_fill_text; dev->stroke_text = fz_text_stroke_text; dev->clip_text = fz_text_clip_text; dev->clip_stroke_text = fz_text_clip_stroke_text; dev->ignore_text = fz_text_ignore_text; return dev; }
void where_is (char * name) { struct line seqname; int vec; int code; struct cmd_func * cmd; if (!find_function (&vec, &cmd, name, strlen(name))) code = cmd - the_funcs[vec]; else if (map_id (name) >= 0) { code = map_id (name); vec = -1; } else io_error_msg ("%s is not a function.", name); /* no return */ code = cmd - the_funcs[vec]; init_line (&seqname); set_line (&seqname, ""); if (!search_map_for_cmd (&seqname, the_cmd_frame->top_keymap, vec, code)) io_info_msg ("%s is not on any keys.", name); else io_info_msg ("%s is bound to %s.", name, seqname.buf); free_line (&seqname); }
int my_option(t_alum *am, t_jcj *jcj) { if ((init_line(am)) < 0) return (-1); if ((start_game(am)) < 0) return (-1); return (0); }
static void fz_flush_text_line(fz_context *ctx, fz_text_device *dev, fz_text_style *style) { append_span(ctx, &dev->cur_line, &dev->cur_span); insert_line(ctx, dev->page, &dev->cur_line); init_span(ctx, &dev->cur_span, style); init_line(ctx, &dev->cur_line); }
int my_option(t_alum *am, t_jcj *jcj) { if ((init_story()) < 0) return (-1); if ((init_line(am)) < 0) return (-1); if ((check_option(am)) < 0 || ((check_option(am) > 0))) return (-1); return (0); }
t_info *init_light(t_info *info, t_spot *spot) { t_info *light; light = (t_info *)j_malloc(sizeof(t_info)); light->r_line = init_line(info->r_pos, spot->coord); light->distance = -1; light->light = 0.0f; light->color = (int *)j_malloc(sizeof(int) * 3); light->obj_type = -1; return (light); }
t_point *i_pos(t_point *a, t_point *b, int j) { t_line *line; if ((line = init_line(a, b)) == NULL) return (NULL); if (!(((a->j >= j && b->j < j)) || ((a->j < j && b->j >= j)))) return (NULL); if ((line->abs_i >= line->abs_j)) i_domin(j, line); else if ((line->abs_j > line->abs_i)) j_domin(j, line); return (conv_line_to_point(line)); }
int main (int argc, char *argv[]) { int left, right, rc; /* Initialize MPI */ MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD,&taskid); MPI_Comm_size(MPI_COMM_WORLD,&numtasks); if (numtasks < 2) { printf("ERROR: Number of MPI tasks set to %d\n",numtasks); printf("Need at least 2 tasks! Quitting...\n"); rc = 999; MPI_Abort(MPI_COMM_WORLD, rc); exit(0); } /* Determine left and right neighbors */ if (taskid == numtasks-1) right = 0; else right = taskid + 1; if (taskid == 0) left = numtasks - 1; else left = taskid - 1; /* Get program parameters and initialize wave values */ if (taskid == MASTER) { printf ("Starting mpi_wave using %d tasks.\n", numtasks); printf ("Using %d points on the vibrating string.\n", TPOINTS); init_master(); } else init_workers(); init_line(); /* Update values along the line for nstep time steps */ update(left, right); /* Master collects results from workers and prints */ if (taskid == MASTER) output_master(); else output_workers(); MPI_Finalize(); return 0; }
int check_option(t_alum *am) { char *s; if (!(s = get_next_line(0))) return (-1); else if ((my_strncmp(s, "PLAY", 4)) == 0 || ((my_strncmp(s, "play", 4)) == 0)) { if ((init_line(am)) < 0) return (-1); if ((start_game(am)) < 0 || ((start_game(am)) == 4)) return (-1); } else if ((my_strncmp(s, "exit", 4)) == 0) return (1); return (0); }
int printRuleTest(int rule, int n) { if (n<0) exit(-1); int i,j; for (i=0; i<n; i++) { init_line(population+rule); for (j=0; j<STEPS_PER_FITNESS; j++) { line_print(); printf("\n"); if (!line_is_stable()) { line_next(); } else { break; } } line_print(); printf("\nSucess: %s\n\n", (singleFitness(rule)? "true" : "false")); } }
int main(void) { int num_rect; scanf("%d", &num_rect); int x1, y1, x2, y2; int i, k; for(i=0;i<num_rect;i++) { for(k=0;k<4;k++) { scanf("%d %d %d %d", &x1, &y1, &x2, &y2); init_line(lines+k, x1, y1, x2, y2); } if(is_valid_rect()) printf("YES"); else printf("NO"); printf("\n"); } return 0; }
t_nb_status nb_get_line(const char *prompt, char **line) { t_nboon l; int ret; if (nb_enable_raw(STDIN_FILENO) == -1) return (NB_ERROR); init_line(&l); l.p_cursor = get_str_display_width(prompt); l.p_len = expand_prompt(prompt, &l.prompt); l.nbr_rows = 0; nb_refresh_size(0); ret = line_edit(&l); nb_disable_raw(l.fd); free(l.prompt); free(l.paste_line); free(l.save_line); write(l.fd, "\n", 1); *line = ((ret != NB_EXIT) ? nb_strdup(l.buf) : NULL); return (ret); }
void Renderer::init() { init_shaders(); ortho = new Matrix4f(); mx_translate = new Matrix4f(); mx_scale = new Matrix4f(); mx_rotate = new Matrix4f(); init_rect(); init_grid(); InitPassGrid(); init_line(); init_tower(); init_circle(); init_ring(); InitTriangle(); InitPolygon(); initHexGrid(); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glCullFace(GL_BACK); }
void expand_help_msg (struct info_buffer * out, struct info_buffer * in) { int x; struct line line; struct line seq_buf; int out_offset; int rel_map = the_cmd_frame->top_keymap; if (the_cmd_frame->cmd && (the_cmd_arg.style == &keyseq_style)) rel_map = the_cmd_arg.val.key.cmd.code; print_info (out, ""); out_offset = out->len; out->len += in->len; out->text = (char **)ck_remalloc (out->text, out->len * sizeof (char *)); init_line (&line); init_line (&seq_buf); for (x = 0; x < in->len; ++x) { char * next_burst = in->text[x]; char * end_burst = index (next_burst, '['); set_line (&line, ""); set_line (&seq_buf, ""); while (end_burst) { char * fn_start = end_burst + 1; char * fn_end = index (fn_start, ']'); int vec; struct cmd_func * cmd; if (fn_end && (*fn_start == '[') && fn_end[1] == ']') { int map = map_idn (fn_start + 1, fn_end - fn_start - 1); if (map < 0) map = map_id ("universal"); rel_map = map; catn_line (&line, next_burst, end_burst - next_burst); next_burst = fn_end + 2; end_burst = index (next_burst, '['); } else if ( fn_end && !find_function (&vec, &cmd, fn_start, fn_end - fn_start)) { catn_line (&line, next_burst, end_burst - next_burst); if (search_map_for_cmd (&seq_buf, rel_map, vec, cmd - the_funcs[vec])) { catn_line (&line, seq_buf.buf, strlen (seq_buf.buf)); set_line (&seq_buf, ""); } else { catn_line (&line, "M-x ", 4); catn_line (&line, fn_start, fn_end - fn_start); } next_burst = fn_end + 1; end_burst = index (next_burst, '['); } else if (fn_end) end_burst = index (fn_end + 1, '['); } catn_line (&line, next_burst, strlen(next_burst)); out->text[x + out_offset] = line.buf; init_line (&line); } free_line (&seq_buf); free_line (&line); }
init() { init_line(); add_action("quit","quit"); call_out("_signal_regained_connection",2); }
void MD5_std_init(void) { int index; MD5_pool *current; #if MD5_std_mt int t, n; if (!MD5_std_all_p) { n = omp_get_max_threads(); if (n < 1) n = 1; if (n > MD5_std_mt_max) n = MD5_std_mt_max; MD5_std_min_kpc = n * MD5_N; { int max = n * MD5_std_cpt; while (max > MD5_std_mt_max) max -= n; n = max; } MD5_std_max_kpc = n * MD5_N; /* * The array of MD5_std_all's is not exactly tiny, but we use mem_alloc_tiny() * for its alignment support and error checking. We do not need to free() this * memory anyway. */ MD5_std_all_p = mem_alloc_tiny(n * MD5_std_all_size, MEM_ALIGN_PAGE); MD5_std_nt = n; } #endif for_each_t(MD5_std_nt) { #if !MD5_IMM MD5_std_all.data = MD5_data_init; #endif current = pool; for (index = 0; index < MD5_N; index++) { #define init_line(line, init_even, init_odd) \ order[line][index].even = init_even; \ order[line][index].odd = init_odd; init_line(0, ¤t->e.p, ¤t->o.psp); init_line(1, ¤t->e.spp, ¤t->o.pp); init_line(2, ¤t->e.spp, ¤t->o.psp); init_line(3, ¤t->e.pp, ¤t->o.ps); init_line(4, ¤t->e.spp, ¤t->o.pp); init_line(5, ¤t->e.spp, ¤t->o.psp); init_line(6, ¤t->e.pp, ¤t->o.psp); init_line(7, ¤t->e.sp, ¤t->o.pp); init_line(8, ¤t->e.spp, ¤t->o.psp); init_line(9, ¤t->e.pp, ¤t->o.psp); init_line(10, ¤t->e.spp, ¤t->o.p); init_line(11, ¤t->e.spp, ¤t->o.psp); init_line(12, ¤t->e.pp, ¤t->o.psp); init_line(13, ¤t->e.spp, ¤t->o.pp); init_line(14, ¤t->e.sp, ¤t->o.psp); init_line(15, ¤t->e.pp, ¤t->o.psp); init_line(16, ¤t->e.spp, ¤t->o.pp); init_line(17, ¤t->e.spp, ¤t->o.ps); init_line(18, ¤t->e.pp, ¤t->o.psp); init_line(19, ¤t->e.spp, ¤t->o.pp); init_line(20, ¤t->e.spp, ¤t->o.psp); #undef init_line current++; } } }