static void place_line_x(int x, int y) { int dx, dy; canvas_leftbut_proc = null_proc; canvas_middlebut_proc = null_proc; canvas_rightbut_proc = null_proc; canvas_locmove_proc = null_proc; canvas_ref_proc = null_proc; adjust_pos(x, y, fix_x, fix_y, &x, &y); dx = x - fix_x; dy = y - fix_y; translate_line(new_l, dx, dy); clean_up(); set_latestline(new_l); if (return_proc == copy_selected) { add_line(new_l); adjust_links(cur_linkmode, cur_links, dx, dy, 0, 0, 1.0, 1.0, True); free_linkinfo(&cur_links); } else { list_add_line(&objects.lines, new_l); adjust_links(cur_linkmode, cur_links, dx, dy, 0, 0, 1.0, 1.0, False); set_lastposition(fix_x, fix_y); set_newposition(x, y); set_lastlinkinfo(cur_linkmode, cur_links); cur_links = NULL; set_action_object(F_MOVE, O_POLYLINE); } set_modifiedflag(); redisplay_line(new_l); /* turn back on all relevant markers */ update_markers(new_objmask); (*return_proc) (); draw_mousefun_canvas(); }
void undo_move(void) { int dx, dy; int xmin1, ymin1, xmax1, ymax1; int xmin2, ymin2, xmax2, ymax2; int dum; dx = last_position.x - new_position.x; dy = last_position.y - new_position.y; switch (last_object) { case O_POLYLINE: line_bound(saved_objects.lines, &xmin1, &ymin1, &xmax1, &ymax1); translate_line(saved_objects.lines, dx, dy); line_bound(saved_objects.lines, &xmin2, &ymin2, &xmax2, &ymax2); adjust_links(last_linkmode, last_links, dx, dy, 0, 0, 1.0, 1.0, False); redisplay_regions(xmin1, ymin1, xmax1, ymax1, xmin2, ymin2, xmax2, ymax2); break; case O_ELLIPSE: ellipse_bound(saved_objects.ellipses, &xmin1, &ymin1, &xmax1, &ymax1); translate_ellipse(saved_objects.ellipses, dx, dy); ellipse_bound(saved_objects.ellipses, &xmin2, &ymin2, &xmax2, &ymax2); redisplay_regions(xmin1, ymin1, xmax1, ymax1, xmin2, ymin2, xmax2, ymax2); break; case O_TXT: text_bound(saved_objects.texts, &xmin1, &ymin1, &xmax1, &ymax1, &dum,&dum,&dum,&dum,&dum,&dum,&dum,&dum); translate_text(saved_objects.texts, dx, dy); text_bound(saved_objects.texts, &xmin2, &ymin2, &xmax2, &ymax2, &dum,&dum,&dum,&dum,&dum,&dum,&dum,&dum); redisplay_regions(xmin1, ymin1, xmax1, ymax1, xmin2, ymin2, xmax2, ymax2); break; case O_SPLINE: spline_bound(saved_objects.splines, &xmin1, &ymin1, &xmax1, &ymax1); translate_spline(saved_objects.splines, dx, dy); spline_bound(saved_objects.splines, &xmin2, &ymin2, &xmax2, &ymax2); redisplay_regions(xmin1, ymin1, xmax1, ymax1, xmin2, ymin2, xmax2, ymax2); break; case O_ARC: arc_bound(saved_objects.arcs, &xmin1, &ymin1, &xmax1, &ymax1); translate_arc(saved_objects.arcs, dx, dy); arc_bound(saved_objects.arcs, &xmin2, &ymin2, &xmax2, &ymax2); redisplay_regions(xmin1, ymin1, xmax1, ymax1, xmin2, ymin2, xmax2, ymax2); break; case O_COMPOUND: compound_bound(saved_objects.compounds, &xmin1, &ymin1, &xmax1, &ymax1); translate_compound(saved_objects.compounds, dx, dy); compound_bound(saved_objects.compounds, &xmin2, &ymin2, &xmax2, &ymax2); adjust_links(last_linkmode, last_links, dx, dy, 0, 0, 1.0, 1.0, False); redisplay_regions(xmin1, ymin1, xmax1, ymax1, xmin2, ymin2, xmax2, ymax2); break; } swap_newp_lastp(); }
static void align_line(void) { F_line *l; for (l = cur_c->lines; l != NULL; l = l->next) { if (!active_layer(l->depth)) continue; line_bound(l, &llx, &lly, &urx, &ury); get_dx_dy(); translate_line(l, dx, dy); } }
static void adjust_object_pos (F_line *obj_ptr, int obj_type, int delta_x, int delta_y) { F_ellipse *e; F_arc *a; F_line *l; F_spline *s; F_compound *c; F_text *t; switch (obj_type) { case O_ELLIPSE: e = (F_ellipse *) obj_ptr; translate_ellipse(e, delta_x, delta_y); e->distrib = 1; break; case O_POLYLINE: l = (F_line *) obj_ptr; translate_line(l, delta_x, delta_y); l->distrib = 1; break; case O_SPLINE: s = (F_spline *) obj_ptr; translate_spline(s, delta_x, delta_y); s->distrib = 1; break; case O_TEXT: t = (F_text *) obj_ptr; translate_text(t, delta_x, delta_y); t->distrib = 1; break; case O_ARC: a = (F_arc *) obj_ptr; translate_arc(a, delta_x, delta_y); a->distrib = 1; break; case O_COMPOUND: c = (F_compound *) obj_ptr; translate_compound(c, delta_x, delta_y); c->distrib = 1; break; default: break; } } /* adjust_object_pos */
static int translate_files(FILE *inFile, FILE *outFile) { char *Line = malloc(LINESIZE + 1); char *path = malloc(LINESIZE + 1); char *LineOut = malloc(LINESIZE + 1); int c; unsigned char ch; int i = 0; const char *pc = kdbg_cont; const char *p = kdbg_prompt; const char *p_eos = p + sizeof(KDBG_PROMPT) - 1; //end of string pos if (Line && path && LineOut) { memset(Line, '\0', LINESIZE + 1); if (opt_console) { while ((c = fgetc(inFile)) != EOF) { if (opt_quit)break; ch = (unsigned char)c; if (!opt_raw) { switch (ch) { case '\n': if ( strncmp(Line, KDBG_DISCARD, sizeof(KDBG_DISCARD)-1) == 0 ) { memset(Line, '\0', LINESIZE); // flushed } else { Line[1] = handle_escape_cmd(outFile, Line, path, LineOut); if (Line[1] != KDBG_ESC_CHAR) { if (p == p_eos) { // kdbg prompt, so already echoed char by char memset(Line, '\0', LINESIZE); translate_char(c, outFile); } else { if (match_line(outFile, Line)) { translate_line(outFile, Line, path, LineOut); translate_char(c, outFile); report(outFile); } } } } i = 0; p = kdbg_prompt; pc = kdbg_cont; break; case '<': i = 0; Line[i++] = ch; break; case '>': if (ch == *p) { p = p_eos; translate_line(outFile, Line, path, LineOut); } if (p != p_eos) { if (i < LINESIZE) { Line[i++] = ch; translate_line(outFile, Line, path, LineOut); } else { translate_line(outFile, Line, path, LineOut); translate_char(c, outFile); } } else translate_char(c, outFile); i = 0; break; default: if (ch == *p)p++; if (ch == *pc)pc++; if (i < LINESIZE) { Line[i++] = ch; if (p == p_eos) { translate_char(c, outFile); } else if (!*pc) { translate_line(outFile, Line, path, LineOut); i = 0; } } else { translate_line(outFile, Line, path, LineOut); translate_char(c, outFile); i = 0; } } } else translate_char(c, outFile); } } else { // Line by line, slightly faster but less interactive while (fgets(Line, LINESIZE, inFile) != NULL) { if (opt_quit)break; if (!opt_raw) { translate_line(outFile, Line, path, LineOut); report(outFile); } else log(outFile, "%s", Line); } } } if (opt_Revision && (strstr(opt_Revision, "regscan") == opt_Revision)) { char *s = strchr(opt_Revision, ','); if (s) { *s++ = '\0'; revinfo.range = atoi(s); } regscan(outFile); } if (opt_stats) { stat_print(outFile, &summ); if (logFile) stat_print(logFile, &summ); } free(LineOut); free(Line); free(path); return 0; }
int #ifdef _METAPACK webifpage_main #else main #endif (int argc, char **argv) { FILE *f; int i, done; char line[LINE_BUF], *tmp, *arg; char szLangBuffer[LANG_TYPE_MAX]; char *lang = NULL; char *proc = "/usr/bin/haserl"; const char *langfmt = "/usr/lib/webif/lang/%s/%s.txt"; memset(ltable, 0, HASH_MAX * sizeof(lstr *)); if ((f = fopen("/etc/config/webif", "r")) != NULL) { while (!feof(f) && (lang == NULL)) { fgets(line, LINE_BUF - 1, f); lang=extract_lang(line, szLangBuffer, LANG_TYPE_MAX); } fclose(f); if (lang != NULL) { sprintf(buf, langfmt, lang, "common"); load_lang(buf); } } /* * command line options for this parser are stored in argv[1] only. * filename to be processed is in argv[2] */ done = 0; i = 1; while (!done) { if (argv[1] == NULL) { done = 1; } else if (strncmp(argv[1], "-e", 2) == 0) { argv[1] = strchr(argv[1], ' '); argv[1]++; if (argv[1] != NULL) { arg = argv[1]; if ((tmp = strchr(argv[1], ' ')) != NULL) { *tmp = 0; argv[1] = &tmp[1]; } else { argv[1] = NULL; i++; } system(arg); } } else if (strncmp(argv[1], "-p", 2) == 0) { argv[1] = strchr(argv[1], ' '); argv[1]++; if (argv[1] != NULL) { arg = argv[1]; if ((tmp = strchr(argv[1], ' ')) != NULL) { *tmp = 0; argv[1] = &tmp[1]; } else { argv[1] = NULL; i++; } proc = strdup(arg); } } else { done = 1; } } strcpy(line, proc); while (argv[i]) { sprintf(line + strlen(line), " %s", argv[i++]); } /* * Load standalone translation file */ if (lang != NULL) { if ((arg = strdup(line)) != NULL) { if ((tmp = strrchr(arg, '.')) != NULL) *tmp = 0; if ((tmp = strrchr(arg, '/')) != NULL) tmp++; else { if ((tmp = strrchr(arg, ' ')) != NULL) tmp++; else tmp = arg; } sprintf(buf2, langfmt, lang, tmp); load_lang(buf2); free(arg); } } f = popen(line, "r"); while (!feof(f) && (fgets(buf, LINE_BUF - 1, f)) != NULL) { fprintf(stdout, "%s", translate_line(buf)); fflush(stdout); } return 0; }