Merge branch 'master' of https://github.com/rafmag/xschem
This commit is contained in:
commit
898f229c61
|
|
@ -1,5 +1,6 @@
|
|||
put /local/xschem/cflags [@
|
||||
@cc/cflags@
|
||||
@?libs/sul/libjpeg/cflags@
|
||||
@?libs/gui/cairo/cflags@
|
||||
@?libs/gui/xrender/cflags@
|
||||
@?libs/gui/xcb/cflags@
|
||||
|
|
@ -13,6 +14,7 @@ put /local/xschem/cflags [@
|
|||
put /local/xschem/ldflags [@
|
||||
@cc/ldflags@
|
||||
-lm
|
||||
@?libs/sul/libjpeg/ldflags@
|
||||
@?libs/gui/cairo/ldflags@
|
||||
@?libs/gui/xrender/ldflags@
|
||||
@?libs/gui/xcb/ldflags@
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\actions.c" />
|
||||
<ClCompile Include="..\src\cairo_jpg.c" />
|
||||
<ClCompile Include="..\src\callback.c" />
|
||||
<ClCompile Include="..\src\check.c" />
|
||||
<ClCompile Include="..\src\clip.c" />
|
||||
|
|
@ -257,6 +258,7 @@
|
|||
<ClCompile Include="parselabel.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\cairo_jpg.h" />
|
||||
<ClInclude Include="..\src\xschem.h" />
|
||||
<ClInclude Include="config.h" />
|
||||
<ClInclude Include="expandlabel.h" />
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\actions.c" />
|
||||
<ClCompile Include="..\src\cairo_jpg.c" />
|
||||
<ClCompile Include="..\src\callback.c" />
|
||||
<ClCompile Include="..\src\check.c" />
|
||||
<ClCompile Include="..\src\clip.c" />
|
||||
|
|
@ -257,6 +258,7 @@
|
|||
<ClCompile Include="parselabel.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\cairo_jpg.h" />
|
||||
<ClInclude Include="..\src\xschem.h" />
|
||||
<ClInclude Include="config.h" />
|
||||
<ClInclude Include="expandlabel.h" />
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ print [@/*************************************************************/
|
|||
/* Source: config.h.in; to regenerate run ./configure */
|
||||
/*************************************************************/@]
|
||||
|
||||
print {\n\n/* Define this var if libjpeg is available and is to be used */\n}
|
||||
print_ternary ?libs/sul/libjpeg/presents {#define HAS_LIBJPEG 1} {/*#undef HAS_LIBJPEG */}
|
||||
|
||||
print {\n\n/* Define this var if cairo is available and is to be used */\n}
|
||||
print_ternary ?libs/gui/cairo/presents {#define HAS_CAIRO 1} {/*#undef HAS_CAIRO */}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,38 +9,38 @@
|
|||
|
||||
#define version "2.0.1"
|
||||
|
||||
int find_sul_pcre(const char *name, int logdepth, int fatal)
|
||||
int find_sul_libjpeg(const char *name, int logdepth, int fatal)
|
||||
{
|
||||
const char *test_c =
|
||||
NL "#include <stdio.h>"
|
||||
NL "#include <stdlib.h>"
|
||||
NL "#include <pcre.h>"
|
||||
NL "#include <jpeglib.h>"
|
||||
NL ""
|
||||
NL "int main()"
|
||||
NL "{"
|
||||
NL " const char *err;"
|
||||
NL " int erro, ret;"
|
||||
NL " pcre *p = pcre_compile(\"fo+b\", 0, &err, &erro, NULL);"
|
||||
NL " ret = pcre_exec(p, NULL, \"hi foobar\", 9, 0, 0, &erro, 1);"
|
||||
NL " if (ret == 0)"
|
||||
NL " puts(\"OK\");"
|
||||
NL " return 0;"
|
||||
NL " struct jpeg_compress_struct cinfo;"
|
||||
NL " struct jpeg_error_mgr jerr;"
|
||||
NL " jerr.error_exit = NULL;"
|
||||
NL " cinfo.err = jpeg_std_error(&jerr);"
|
||||
NL " jpeg_create_compress(&cinfo);"
|
||||
NL " jpeg_destroy_compress(&cinfo);"
|
||||
NL " if(jerr.error_exit)"
|
||||
NL " puts(\"OK\");"
|
||||
NL " return 0;"
|
||||
NL "}"
|
||||
NL;
|
||||
|
||||
const char *node = "libs/sul/pcre";
|
||||
const char *node = "libs/sul/libjpeg";
|
||||
|
||||
if (require("cc/cc", logdepth, fatal))
|
||||
return 1;
|
||||
|
||||
report("Checking for pcre... ");
|
||||
report("Checking for libjpeg... ");
|
||||
|
||||
if (try_icl_pkg_config(logdepth, "libs/sul/pcre", test_c, NULL, "libpcre", NULL))
|
||||
if (try_icl_pkg_config(logdepth, node, test_c, NULL, "libjpeg", NULL))
|
||||
return 0;
|
||||
|
||||
if (try_icl(logdepth, node, test_c, NULL, "-I/usr/include/pcre", "-lpcre"))
|
||||
return 0;
|
||||
|
||||
if (try_icl(logdepth, node, test_c, NULL, "-I/usr/include/pcre", "-lpcre3"))
|
||||
if (try_icl(logdepth, node, test_c, NULL, NULL, "-ljpeg"))
|
||||
return 0;
|
||||
|
||||
return try_fail(logdepth, node);
|
||||
|
|
@ -123,6 +123,9 @@ int hook_preinit()
|
|||
/* Runs after initialization */
|
||||
int hook_postinit()
|
||||
{
|
||||
/* libjpeg detection */
|
||||
dep_add("libs/sul/libjpeg/*", find_sul_libjpeg);
|
||||
|
||||
db_mkdir("/local");
|
||||
db_mkdir("/local/xschem");
|
||||
|
||||
|
|
@ -289,6 +292,7 @@ int hook_detect_target()
|
|||
require("fstools/awk", 0, 1);
|
||||
require("libs/gui/xpm/*", 0, 1);
|
||||
require("libs/gui/cairo/*", 0, 0);
|
||||
require("libs/sul/libjpeg/*", 0, 0);
|
||||
|
||||
if (require("libs/gui/cairo-xcb/*", 0, 0) != 0) {
|
||||
put("libs/gui/xcb/presents", sfalse);
|
||||
|
|
@ -357,6 +361,7 @@ int hook_generate()
|
|||
printf(" tcl: %s\n", get("/target/libs/script/tcl/ldflags"));
|
||||
printf(" tk: %s\n", get("/target/libs/script/tk/ldflags"));
|
||||
printf(" cairo: %s\n", istrue(get("/target/libs/gui/cairo/presents")) ? "yes" : "no");
|
||||
printf(" libjpeg: %s\n", istrue(get("/target/libs/sul/libjpeg/presents")) ? "yes" : "no");
|
||||
printf(" xcb: %s\n", istrue(get("/target/libs/gui/xcb/presents")) ? "yes" : "no");
|
||||
|
||||
printf("\nConfiguration complete, ready to compile.\n\n");
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ rawtovcd: rawtovcd.o
|
|||
$(CC) -o rawtovcd rawtovcd.o -lm
|
||||
|
||||
xschem: $(OBJ)
|
||||
$(CC) -o xschem $(OBJ) $(LDFLAGS) -ljpeg
|
||||
$(CC) -o xschem $(OBJ) $(LDFLAGS)
|
||||
|
||||
parselabel.c: parselabel.l expandlabel.h
|
||||
flex -l -oparselabel.c parselabel.l
|
||||
|
|
|
|||
|
|
@ -273,16 +273,16 @@ void new_xschem_process(const char *cell, int symbol)
|
|||
fprintf(errfp, "new_xschem_process(): executable not found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fflush(NULL); /* flush all stdio streams before process forking */
|
||||
/* double fork method to avoid zombies 20180925*/
|
||||
if ( (pid1 = fork()) ) {
|
||||
if ( (pid1 = fork()) > 0 ) {
|
||||
/* parent process */
|
||||
waitpid(pid1, &status, 0);
|
||||
} else if (!pid1) {
|
||||
} else if (pid1 == 0) {
|
||||
/* child process */
|
||||
if ( (pid2 = fork()) ) {
|
||||
exit(0); /* --> child of child will be reparented to init */
|
||||
} else if (!pid2) {
|
||||
if ( (pid2 = fork()) > 0 ) {
|
||||
_exit(0); /* --> child of child will be reparented to init */
|
||||
} else if (pid2 == 0) {
|
||||
/* child of child */
|
||||
if(!cell || !cell[0]) {
|
||||
if(!symbol)
|
||||
|
|
@ -303,7 +303,7 @@ void new_xschem_process(const char *cell, int symbol)
|
|||
} else {
|
||||
/* error */
|
||||
fprintf(errfp, "new_xschem_process(): fork error 1\n");
|
||||
tcleval("exit");
|
||||
_exit(1);
|
||||
}
|
||||
} else {
|
||||
/* error */
|
||||
|
|
|
|||
1263
src/cairo_jpg.c
1263
src/cairo_jpg.c
File diff suppressed because it is too large
Load Diff
|
|
@ -1,3 +0,0 @@
|
|||
[ZoneTransfer]
|
||||
ZoneId=3
|
||||
HostUrl=https://raw.githubusercontent.com/rahra/cairo_jpg/master/src/cairo_jpg.c
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
[ZoneTransfer]
|
||||
ZoneId=3
|
||||
HostUrl=https://raw.githubusercontent.com/rahra/cairo_jpg/master/src/cairo_jpg.h
|
||||
|
|
@ -3061,7 +3061,7 @@ typedef struct
|
|||
size_t size;
|
||||
} png_to_byte_closure_t;
|
||||
|
||||
static cairo_status_t png_reader(void *in_closure, unsigned char *out_data, unsigned int length)
|
||||
cairo_status_t png_reader(void *in_closure, unsigned char *out_data, unsigned int length)
|
||||
{
|
||||
png_to_byte_closure_t *closure = (png_to_byte_closure_t *) in_closure;
|
||||
if(!closure->buffer) return CAIRO_STATUS_READ_ERROR;
|
||||
|
|
@ -3133,6 +3133,7 @@ void draw_image(int dr, xRect *r, double *x1, double *y1, double *x2, double *y2
|
|||
if(filter) {
|
||||
size_t filtersize = 0;
|
||||
char *filterdata = NULL;
|
||||
dbg(1, "draw_image(): filter=%s, image_data=%s\n", filter, attr);
|
||||
closure.buffer = NULL;
|
||||
filterdata = (char *)base64_decode(attr, strlen(attr), &filtersize);
|
||||
filter_data(filterdata, filtersize, (char **)&closure.buffer, &data_size, filter);
|
||||
|
|
@ -3298,8 +3299,8 @@ void svg_embedded_graph(FILE *fd, xRect *r, double rx1, double ry1, double rx2,
|
|||
rwi = (int) (rw * scale + 1.0);
|
||||
rhi = (int) (rh * scale + 1.0);
|
||||
save_restore_zoom(1);
|
||||
set_viewport_size(rwi, rhi, 1.0);
|
||||
zoom_box(rx1, ry1, rx2, ry2, 1.0);
|
||||
set_viewport_size(rwi, rhi, xctx->lw);
|
||||
zoom_box(rx1 - xctx->lw, ry1 - xctx->lw, rx2 + xctx->lw, ry2 + xctx->lw, 1.0);
|
||||
resetwin(1, 1, 1, rwi, rhi);
|
||||
save_draw_grid = tclgetboolvar("draw_grid");
|
||||
tclsetvar("draw_grid", "0");
|
||||
|
|
|
|||
|
|
@ -1501,6 +1501,13 @@ void edit_property(int x)
|
|||
return;
|
||||
} /* if((xctx->lastsel==0 ) */
|
||||
|
||||
/* set 'preserve unchanged properties if multiple selection */
|
||||
if(xctx->lastsel > 1) {
|
||||
tclsetvar("preserve_unchanged_attrs", "1");
|
||||
} else {
|
||||
tclsetvar("preserve_unchanged_attrs", "0");
|
||||
}
|
||||
|
||||
switch(xctx->sel_array[0].type)
|
||||
{
|
||||
case ELEMENT:
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ static void check_opt(char *opt, char *optval, int type)
|
|||
} else if( (type == SHORT && *opt == 'l') || (type == LONG && !strcmp("log", opt)) ) {
|
||||
if(optval) {
|
||||
errfp = fopen(optval, "w");
|
||||
setvbuf(errfp, NULL, _IOLBF, 0); /* line (_IOLBF) or disable (_IONBF) buffering on error log */
|
||||
if(!errfp) {
|
||||
errfp=stderr;
|
||||
dbg(0, "Problems opening log file: %s\n", optval);
|
||||
|
|
|
|||
|
|
@ -24,9 +24,6 @@
|
|||
#define X_TO_PS(x) ( (x+xctx->xorigin)* xctx->mooz )
|
||||
#define Y_TO_PS(y) ( (y+xctx->yorigin)* xctx->mooz )
|
||||
|
||||
/* FIXME This must be investigated, without some fflushes the ps file is corrupted */
|
||||
//#define FFLUSH_PS
|
||||
|
||||
#if 0
|
||||
* /* FIXME: overflow check. Not used, BTW */
|
||||
* static char *strreplace(char s[], char token[], char replace[])
|
||||
|
|
@ -107,61 +104,64 @@ typedef struct
|
|||
size_t pos;
|
||||
size_t size;
|
||||
} png_to_byte_closure_t;
|
||||
|
||||
cairo_status_t png_reader(void* in_closure, unsigned char* out_data, unsigned int length)
|
||||
{
|
||||
png_to_byte_closure_t* closure = (png_to_byte_closure_t*)in_closure;
|
||||
if (!closure->buffer) return CAIRO_STATUS_READ_ERROR;
|
||||
memcpy(out_data, closure->buffer + closure->pos, length);
|
||||
closure->pos += length;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void ps_drawPNG(xRect* r, double x1, double y1, double x2, double y2, int rot, int flip)
|
||||
{
|
||||
#if defined(HAS_LIBJPEG) && defined(HAS_CAIRO)
|
||||
int i;
|
||||
size_t data_size;
|
||||
png_to_byte_closure_t closure;
|
||||
size_t data_size = 0;
|
||||
png_to_byte_closure_t closure = {NULL, 0, 0};
|
||||
char* filter = NULL;
|
||||
int png_size_x, png_size_y;
|
||||
unsigned char *png_data, BG_r, BG_g, BG_b;
|
||||
unsigned char *png_data = NULL, BG_r, BG_g, BG_b;
|
||||
int invertImage;
|
||||
/* static char str[PATH_MAX];
|
||||
* FILE* fp;
|
||||
*/
|
||||
unsigned char* ascii85EncodedJpeg;
|
||||
char* image_data64_ptr = NULL;
|
||||
cairo_surface_t* surface;
|
||||
cairo_surface_t* surface = NULL;
|
||||
unsigned char* jpgData = NULL;
|
||||
size_t fileSize = 0;
|
||||
int quality=100;
|
||||
const char *quality_attr;
|
||||
size_t image_data_len;
|
||||
|
||||
quality_attr = get_tok_value(r->prop_ptr, "jpeg_quality", 0);
|
||||
if(quality_attr[0]) quality = atoi(quality_attr);
|
||||
else {
|
||||
quality_attr = get_tok_value(r->prop_ptr, "jpg_quality", 0);
|
||||
if(quality_attr[0]) quality = atoi(quality_attr);
|
||||
}
|
||||
my_strdup(59, &filter, get_tok_value(r->prop_ptr, "filter", 0));
|
||||
image_data_len = my_strdup2(1183, &image_data64_ptr, get_tok_value(r->prop_ptr, "image_data", 0));
|
||||
|
||||
my_strdup2(1183, &image_data64_ptr, get_tok_value(r->prop_ptr, "image_data", 0));
|
||||
if (filter) {
|
||||
size_t filtersize = 0;
|
||||
char* filterdata = NULL;
|
||||
closure.buffer = NULL;
|
||||
filterdata = (char*)base64_decode(image_data64_ptr, strlen(image_data64_ptr), &filtersize);
|
||||
filterdata = (char*)base64_decode(image_data64_ptr, image_data_len, &filtersize);
|
||||
filter_data(filterdata, filtersize, (char**)&closure.buffer, &data_size, filter);
|
||||
my_free(1661, &filterdata);
|
||||
}
|
||||
else {
|
||||
closure.buffer = base64_decode(image_data64_ptr, strlen(image_data64_ptr), &data_size);
|
||||
closure.buffer = base64_decode(image_data64_ptr, image_data_len, &data_size);
|
||||
}
|
||||
my_free(1663, &filter);
|
||||
my_free(1664, &filter);
|
||||
my_free(1184, &image_data64_ptr);
|
||||
closure.pos = 0;
|
||||
closure.size = data_size; /* should not be necessary */
|
||||
surface = cairo_image_surface_create_from_png_stream(png_reader, &closure);
|
||||
my_free(1666, &closure.buffer);
|
||||
|
||||
png_size_x = cairo_image_surface_get_width(surface);
|
||||
png_size_y = cairo_image_surface_get_height(surface);
|
||||
|
||||
cairo_surface_flush(surface);
|
||||
my_free(1667, &closure.buffer);
|
||||
png_data = cairo_image_surface_get_data(surface);
|
||||
|
||||
invertImage = !strcmp(get_tok_value(r->prop_ptr, "InvertOnExport", 0), "true");
|
||||
if(!invertImage)
|
||||
invertImage = !strcmp(get_tok_value(r->prop_ptr, "ps_invert", 0), "true");
|
||||
BG_r = 0xFF; BG_g = 0xFF; BG_b = 0xFF;
|
||||
for (i = 0; i < (png_size_x * png_size_y * 4); i += 4)
|
||||
{
|
||||
|
|
@ -174,11 +174,11 @@ void ps_drawPNG(xRect* r, double x1, double y1, double x2, double y2, int rot, i
|
|||
|
||||
if(invertImage)
|
||||
{
|
||||
png_data[i + 0] = (0xFF-png_r) + (unsigned char)((double)BG_r * ainv);
|
||||
png_data[i + 1] = (0xFF-png_g) + (unsigned char)((double)BG_g * ainv);
|
||||
png_data[i + 2] = (0xFF-png_b) + (unsigned char)((double)BG_b * ainv);
|
||||
png_data[i + 0] = (unsigned char)(0xFF-png_r) + (unsigned char)((double)BG_r * ainv);
|
||||
png_data[i + 1] = (unsigned char)(0xFF-png_g) + (unsigned char)((double)BG_g * ainv);
|
||||
png_data[i + 2] = (unsigned char)(0xFF-png_b) + (unsigned char)((double)BG_b * ainv);
|
||||
png_data[i + 3] = 0xFF;
|
||||
}else
|
||||
} else
|
||||
{
|
||||
png_data[i + 0] = png_r + (unsigned char)((double)BG_r * ainv);
|
||||
png_data[i + 1] = png_g + (unsigned char)((double)BG_g * ainv);
|
||||
|
|
@ -245,15 +245,14 @@ void ps_drawPNG(xRect* r, double x1, double y1, double x2, double y2, int rot, i
|
|||
fprintf(fd, "~>\n");
|
||||
|
||||
fprintf(fd, "grestore\n");
|
||||
|
||||
cairo_surface_destroy(surface);
|
||||
my_free(1663, &ascii85EncodedJpeg);
|
||||
free(jpgData);
|
||||
}
|
||||
|
||||
|
||||
void ps_embedded_graph(xRect* r, double rx1, double ry1, double rx2, double ry2)
|
||||
{
|
||||
#if defined(HAS_CAIRO)
|
||||
#if defined(HAS_LIBJPEG) && defined(HAS_CAIRO)
|
||||
double rw, rh, scale;
|
||||
cairo_surface_t* png_sfc;
|
||||
int save_draw_window, save_draw_grid, rwi, rhi;
|
||||
|
|
@ -266,6 +265,16 @@ void ps_embedded_graph(xRect* r, double rx1, double ry1, double rx2, double ry2)
|
|||
* static char str[PATH_MAX];
|
||||
*/
|
||||
unsigned char *ascii85EncodedJpeg;
|
||||
int quality=100;
|
||||
const char *quality_attr;
|
||||
|
||||
quality_attr = get_tok_value(r->prop_ptr, "jpeg_quality", 0);
|
||||
if(quality_attr[0]) quality = atoi(quality_attr);
|
||||
else {
|
||||
quality_attr = get_tok_value(r->prop_ptr, "jpg_quality", 0);
|
||||
if(quality_attr[0]) quality = atoi(quality_attr);
|
||||
}
|
||||
if(quality_attr[0]) quality = atoi(quality_attr);
|
||||
if (!has_x) return;
|
||||
rw = fabs(rx2 - rx1);
|
||||
rh = fabs(ry2 - ry1);
|
||||
|
|
@ -279,8 +288,8 @@ void ps_embedded_graph(xRect* r, double rx1, double ry1, double rx2, double ry2)
|
|||
rwi = (int)(rw * scale + 1.0);
|
||||
rhi = (int)(rh * scale + 1.0);
|
||||
save_restore_zoom(1);
|
||||
set_viewport_size(rwi, rhi, 1.0);
|
||||
zoom_box(rx1-2, ry1-2, rx2+2, ry2+2, 1.0);
|
||||
set_viewport_size(rwi, rhi, xctx->lw);
|
||||
zoom_box(rx1 - xctx->lw, ry1 - xctx->lw, rx2 + xctx->lw, ry2 + xctx->lw, 1.0);
|
||||
resetwin(1, 1, 1, rwi, rhi);
|
||||
save_draw_grid = tclgetboolvar("draw_grid");
|
||||
tclsetvar("draw_grid", "0");
|
||||
|
|
@ -312,10 +321,11 @@ void ps_embedded_graph(xRect* r, double rx1, double ry1, double rx2, double ry2)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
cairo_image_surface_write_to_jpeg_mem(png_sfc, &jpgData, &fileSize, 100);
|
||||
cairo_image_surface_write_to_jpeg_mem(png_sfc, &jpgData, &fileSize, quality);
|
||||
|
||||
int oLength;
|
||||
ascii85EncodedJpeg = ascii85_encode(jpgData, fileSize, &oLength, 0);
|
||||
free(jpgData);
|
||||
|
||||
cairo_surface_destroy(png_sfc);
|
||||
xctx->draw_pixmap = 1;
|
||||
|
|
@ -365,9 +375,8 @@ void ps_embedded_graph(xRect* r, double rx1, double ry1, double rx2, double ry2)
|
|||
fprintf(fd, "grestore\n");
|
||||
|
||||
my_free(1666, &ascii85EncodedJpeg);
|
||||
free(jpgData);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
static void set_lw(void)
|
||||
{
|
||||
|
|
@ -383,9 +392,6 @@ static void set_ps_colors(unsigned int pixel)
|
|||
if(color_ps) fprintf(fd, "%g %g %g RGB\n",
|
||||
(double)ps_colors[pixel].red/256.0, (double)ps_colors[pixel].green/256.0,
|
||||
(double)ps_colors[pixel].blue/256.0);
|
||||
#ifdef FFLUSH_PS /* FIXME: why is this needed? */
|
||||
fflush(fd);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
95
src/save.c
95
src/save.c
|
|
@ -25,6 +25,34 @@
|
|||
#include <sys/wait.h> /* waitpid */
|
||||
#endif
|
||||
|
||||
|
||||
/* splits a command string into argv-like arguments
|
||||
* return # of args in *argc
|
||||
* argv[*argc] is always set to NULL
|
||||
* parse_cmd_string(NULL, NULL) to clear static allocated data */
|
||||
#define PARSE_SIZE 128
|
||||
char **parse_cmd_string(const char *cmd, int *argc)
|
||||
{
|
||||
static char *cmd_copy = NULL;
|
||||
static char *argv[PARSE_SIZE];
|
||||
char *cmd_ptr, *cmd_save;
|
||||
if(!cmd || !cmd[0]) {
|
||||
if(cmd_copy) my_free(1670, &cmd_copy);
|
||||
return NULL;
|
||||
}
|
||||
*argc = 0;
|
||||
my_strdup2(1669, &cmd_copy, cmd);
|
||||
cmd_ptr = cmd_copy;
|
||||
while( (argv[*argc] = my_strtok_r(cmd_ptr, " \t", "'\"", &cmd_save)) ) {
|
||||
cmd_ptr = NULL;
|
||||
dbg(1, "--> %s\n", argv[*argc]);
|
||||
(*argc)++;
|
||||
if(*argc >= PARSE_SIZE) break;
|
||||
}
|
||||
argv[*argc] = NULL; /*terminating pointer needed by execvp() */
|
||||
return argv;
|
||||
}
|
||||
|
||||
/* get an input databuffer (din[ilen]), and a shell command (cmd) that reads stdin
|
||||
* and writes stdout, return the result in dout[olen].
|
||||
* Caller must free the returned buffer.
|
||||
|
|
@ -36,7 +64,7 @@ int filter_data(const char *din, const size_t ilen,
|
|||
{
|
||||
int p1[2]; /* parent -> child, 0: read, 1: write */
|
||||
int p2[2]; /* child -> parent, 0: read, 1: write */
|
||||
int ret = 0;
|
||||
int ret = 0, wstatus;
|
||||
pid_t pid;
|
||||
size_t bufsize = 32768, oalloc = 0, n = 0;
|
||||
|
||||
|
|
@ -49,23 +77,55 @@ int filter_data(const char *din, const size_t ilen,
|
|||
dbg(1, "filter_data(): ilen=%ld, cmd=%s\n", ilen, cmd);
|
||||
pipe(p1);
|
||||
pipe(p2);
|
||||
|
||||
dbg(1, "p1[0] = %d\n", p1[0]);
|
||||
dbg(1, "p1[1] = %d\n", p1[1]);
|
||||
dbg(1, "p2[0] = %d\n", p2[0]);
|
||||
dbg(1, "p2[1] = %d\n", p2[1]);
|
||||
|
||||
|
||||
signal(SIGPIPE, SIG_IGN); /* so attempting write/read a broken pipe won't kill program */
|
||||
/*
|
||||
* p2
|
||||
* ------------------- p2[0] <--------- p2[1] -------------------
|
||||
* | Parent program | | Child filter |
|
||||
* ------------------- p1[1] ---------> p1[0] -------------------
|
||||
* p1
|
||||
*/
|
||||
fflush(NULL); /* flush all stdio streams before process forking */
|
||||
if( (pid = fork()) == 0) {
|
||||
#if 1
|
||||
char **av;
|
||||
int ac;
|
||||
#endif
|
||||
/* child */
|
||||
close(p1[1]); /* only read from p1 */
|
||||
close(p2[0]); /* only write to p2 */
|
||||
close(0); /* dup2(p1[0],0); */ /* connect read side of read pipe to stdin */
|
||||
dup(p1[0]);
|
||||
close(p1[0]);
|
||||
close(1); /* dup2(p2[1],1); */ /* connect write side of write pipe to stdout */
|
||||
dup(p2[1]);
|
||||
/* execlp("gm", "gm", "convert", "-", "-quality", "50", "jpg:-", NULL); */
|
||||
if(system(cmd)) {
|
||||
close(p2[1]);
|
||||
|
||||
#if 1
|
||||
av = parse_cmd_string(cmd, &ac);
|
||||
if(execvp(av[0], av) == -1) {
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if(execl("/bin/sh", "sh", "-c", cmd, (char *) NULL) == -1) {
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if(system(cmd) == -1) {
|
||||
#endif
|
||||
|
||||
fprintf(stderr, "error: conversion failed\n");
|
||||
ret = 1;
|
||||
}
|
||||
close(p1[0]);
|
||||
close(p2[1]);
|
||||
exit(ret);
|
||||
_exit(ret); /* childs should always use _exit() to avoid
|
||||
* flushing open stdio streams and other unwanted side effects */
|
||||
}
|
||||
/* parent */
|
||||
close(p1[0]); /*only write to p1 */
|
||||
|
|
@ -74,6 +134,7 @@ int filter_data(const char *din, const size_t ilen,
|
|||
fprintf(stderr, "filter_data() write to pipe failed or not completed\n");
|
||||
ret = 1;
|
||||
}
|
||||
fsync(p1[1]);
|
||||
close(p1[1]);
|
||||
if(!ret) {
|
||||
oalloc = bufsize + 1; /* add extra space for final '\0' */
|
||||
|
|
@ -81,6 +142,7 @@ int filter_data(const char *din, const size_t ilen,
|
|||
*olen = 0;
|
||||
while( (n = read(p2[0], *dout + *olen, bufsize)) > 0) {
|
||||
*olen += n;
|
||||
dbg(1, "filter_data(): olen=%d, oalloc=%d\n", *olen, oalloc);
|
||||
if(*olen + bufsize + 1 >= oalloc) { /* allocate for next read */
|
||||
oalloc = *olen + bufsize + 1; /* add extra space for final '\0' */
|
||||
oalloc = ((oalloc << 2) + oalloc) >> 2; /* size up 1.25x */
|
||||
|
|
@ -90,7 +152,6 @@ int filter_data(const char *din, const size_t ilen,
|
|||
}
|
||||
if(*olen) (*dout)[*olen] = '\0'; /* so (if ascii) it can be used as a string */
|
||||
}
|
||||
close(p2[0]);
|
||||
if(n < 0 || !*olen) {
|
||||
if(oalloc) {
|
||||
my_free(1483, dout);
|
||||
|
|
@ -99,11 +160,16 @@ int filter_data(const char *din, const size_t ilen,
|
|||
fprintf(stderr, "no data read\n");
|
||||
ret = 1;
|
||||
}
|
||||
waitpid(pid, NULL, 0); /* write for child process to finish and unzombie it */
|
||||
waitpid(pid, &wstatus, 0); /* write for child process to finish and unzombie it */
|
||||
close(p2[0]);
|
||||
signal(SIGPIPE, SIG_DFL); /* restore default SIGPIPE signal action */
|
||||
|
||||
if(WIFEXITED(wstatus)) dbg(1, "Child exited normally\n");
|
||||
dbg(1, "Child exit status=%d\n", WEXITSTATUS(wstatus));
|
||||
if(WIFSIGNALED(wstatus))dbg(1, "Child was terminated by signal\n");
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
#else /* anyone wanting to write a similar function for windows Welcome! */
|
||||
int filter_data(const char* din, const size_t ilen,
|
||||
char** dout, size_t* olen,
|
||||
const char* cmd)
|
||||
|
|
@ -541,6 +607,7 @@ void free_rawfile(int dr)
|
|||
int i;
|
||||
|
||||
int deleted = 0;
|
||||
dbg(1, "free_rawfile(): clearing data\n");
|
||||
if(xctx->graph_names) {
|
||||
deleted = 1;
|
||||
for(i = 0 ; i < xctx->graph_nvars; i++) {
|
||||
|
|
@ -2409,12 +2476,13 @@ void push_undo(void)
|
|||
#elif HAS_PIPE==1
|
||||
my_snprintf(diff_name, S(diff_name), "%s/undo%d", xctx->undo_dirname, xctx->cur_undo_ptr%MAX_UNDO);
|
||||
pipe(pd);
|
||||
fflush(NULL); /* flush all stdio streams before process forking */
|
||||
if((pid = fork()) ==0) { /* child process */
|
||||
close(pd[1]); /* close write side of pipe */
|
||||
if(!(diff_fd=freopen(diff_name,"w", stdout))) /* redirect stdout to file diff_name */
|
||||
{
|
||||
dbg(1, "push_undo(): problems opening file %s \n",diff_name);
|
||||
tcleval("exit");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
/* the following 2 statements are a replacement for dup2() which is not c89
|
||||
|
|
@ -2429,7 +2497,7 @@ void push_undo(void)
|
|||
execlp("gzip", "gzip", "--fast", "-c", NULL); /* replace current process with comand */
|
||||
/* never gets here */
|
||||
fprintf(errfp, "push_undo(): problems with execlp\n");
|
||||
tcleval("exit");
|
||||
_exit(1);
|
||||
}
|
||||
close(pd[0]); /* close read side of pipe */
|
||||
fd=fdopen(pd[1],"w");
|
||||
|
|
@ -2509,12 +2577,13 @@ void pop_undo(int redo, int set_modify_status)
|
|||
#elif HAS_PIPE==1
|
||||
my_snprintf(diff_name, S(diff_name), "%s/undo%d", xctx->undo_dirname, xctx->cur_undo_ptr%MAX_UNDO);
|
||||
pipe(pd);
|
||||
fflush(NULL); /* flush all stdio streams before process forking */
|
||||
if((pid = fork())==0) { /* child process */
|
||||
close(pd[0]); /* close read side of pipe */
|
||||
if(!(diff_fd=freopen(diff_name,"r", stdin))) /* redirect stdin from file name */
|
||||
{
|
||||
dbg(1, "pop_undo(): problems opening file %s \n",diff_name);
|
||||
tcleval("exit");
|
||||
_exit(1);
|
||||
}
|
||||
/* connect write side of pipe to stdout */
|
||||
#if HAS_DUP2
|
||||
|
|
@ -2526,7 +2595,7 @@ void pop_undo(int redo, int set_modify_status)
|
|||
execlp("gzip", "gzip", "-d", "-c", NULL); /* replace current process with command */
|
||||
/* never gets here */
|
||||
dbg(1, "pop_undo(): problems with execlp\n");
|
||||
tcleval("exit");
|
||||
_exit(1);
|
||||
}
|
||||
close(pd[1]); /* close write side of pipe */
|
||||
fd=fdopen(pd[0],"r");
|
||||
|
|
|
|||
|
|
@ -1875,7 +1875,19 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
else { cmd_found = 0;}
|
||||
break;
|
||||
case 'p': /*----------------------------------------------*/
|
||||
if(!strcmp(argv[1], "parselabel"))
|
||||
if(!strcmp(argv[1], "parse_cmd"))
|
||||
{
|
||||
if(argc > 2) {
|
||||
int c, i;
|
||||
char **av;
|
||||
av = parse_cmd_string(argv[2], &c);
|
||||
for(i = 0; i < c; i++) {
|
||||
dbg(0, "--> %s\n", av[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if(!strcmp(argv[1], "parselabel"))
|
||||
{
|
||||
if(argc > 2) {
|
||||
parse(argv[2]);
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ END{
|
|||
leak+= address[i]
|
||||
print " address[ " i ", " idx[i] " ]= " address[i]
|
||||
if(show_source) {
|
||||
pipe = "egrep -n 'my_(malloc|calloc|realloc|free|strdup|strdup2)\\(" idx[i] ",' *.c xschem.h"
|
||||
pipe = "egrep -n '^my_(malloc|calloc|realloc|free|strdup|strdup2)\\(" idx[i] ",' *.c xschem.h"
|
||||
while( pipe | getline a) print " " a
|
||||
close(pipe)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1703,8 +1703,7 @@ int new_schematic(const char *what, const char *win_path, const char *fname)
|
|||
|
||||
void change_linewidth(double w)
|
||||
{
|
||||
int i, changed = 0, linew;
|
||||
double oldw = xctx->lw;
|
||||
int i, linew;
|
||||
|
||||
/* choose line width automatically based on zoom */
|
||||
if(w<0. || xctx->lw == -1.0) {
|
||||
|
|
@ -1718,10 +1717,6 @@ void change_linewidth(double w)
|
|||
} else {
|
||||
xctx->lw=w;
|
||||
}
|
||||
if(xctx->lw != oldw) {
|
||||
changed = 1;
|
||||
}
|
||||
if(!changed) return;
|
||||
if(has_x) {
|
||||
linew = INT_WIDTH(xctx->lw);
|
||||
dbg(1, "Line width = %d\n", linew);
|
||||
|
|
|
|||
|
|
@ -1170,6 +1170,7 @@ extern void hash_wire(int what, int n, int incremental);
|
|||
extern void hash_instances(void); /* 20171203 insert instance bbox in spatial hash table */
|
||||
|
||||
#if HAS_CAIRO==1
|
||||
extern cairo_status_t png_reader(void* in_closure, unsigned char* out_data, unsigned int length);
|
||||
extern int text_bbox_nocairo(const char * str,double xscale, double yscale,
|
||||
short rot, short flip, int hcenter, int vcenter,
|
||||
double x1,double y1, double *rx1, double *ry1,
|
||||
|
|
@ -1361,6 +1362,7 @@ extern void my_strndup(int id, char **dest, const char *src, size_t n);
|
|||
extern size_t my_strdup2(int id, char **dest, const char *src);
|
||||
extern char *my_fgets(FILE *fd);
|
||||
extern char *my_strtok_r(char *str, const char *delim, const char *quote, char **saveptr);
|
||||
extern char **parse_cmd_string(const char *cmd, int *argc);
|
||||
extern int my_strncpy(char *d, const char *s, size_t n);
|
||||
extern int my_strcasecmp(const char *s1, const char *s2);
|
||||
extern double mylog10(double x);
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -64,7 +64,8 @@ x2=0.001
|
|||
divx=8
|
||||
node="panel
|
||||
led" unitx=m
|
||||
color="7 4"}
|
||||
color="7 4"
|
||||
jpeg_quality=20}
|
||||
B 2 1260 -390 1680 -220 {flags=graph
|
||||
y1 = 0
|
||||
y2 = 6.7
|
||||
|
|
@ -77,7 +78,8 @@ divx=8
|
|||
color="7 4 6"
|
||||
node="i(vpanel)
|
||||
i(vled)
|
||||
\\"R.Avg. I(vpanel); i(vpanel) 20u ravg()\\""}
|
||||
\\"R.Avg. I(vpanel); i(vpanel) 20u ravg()\\""
|
||||
jpeg_quality=20}
|
||||
B 2 1260 -750 1680 -560 {flags=graph
|
||||
y1 = -8.9e-05
|
||||
y2 = 100
|
||||
|
|
@ -93,7 +95,8 @@ node="\\"Panel power; i(vpanel) v(panel) *\\"
|
|||
\\"Led power; i(vled) v(led) *\\"
|
||||
\\"Avg.Pan. Pwr; i(vpanel) v(panel) * 20u ravg()\\"
|
||||
\\"SUN %; sun 100 *\\""
|
||||
hilight_wave=-1}
|
||||
hilight_wave=-1
|
||||
jpeg_quality=20}
|
||||
B 2 1260 -940 1680 -750 {flags=graph
|
||||
y1 = 0
|
||||
y2 = 1
|
||||
|
|
@ -110,7 +113,8 @@ level"
|
|||
hilight_wave=-1
|
||||
digital=0
|
||||
ypos1=0.00261891
|
||||
ypos2=0.51596}
|
||||
ypos2=0.51596
|
||||
jpeg_quality=20}
|
||||
B 2 1260 -1140 1680 -950 {flags=graph
|
||||
y1 = 0
|
||||
y2 = 1
|
||||
|
|
@ -128,7 +132,8 @@ digital=0
|
|||
ypos1=0.00261891
|
||||
ypos2=0.51596
|
||||
color=8
|
||||
node="\\"CTRL1 Duty cycle; ctrl1 20u ravg()\\""}
|
||||
node="\\"CTRL1 Duty cycle; ctrl1 20u ravg()\\""
|
||||
jpeg_quality=20}
|
||||
B 18 85 -840 340 -655 {}
|
||||
A 5 340 -840 5.590169943749475 243.434948822922 360 {fill=true}
|
||||
P 7 6 415 -655 360 -811.25 355 -825 342.5 -840 330 -845 85 -855 {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
v {xschem version=3.0.0 file_version=1.2 }
|
||||
v {xschem version=3.1.0 file_version=1.2
|
||||
}
|
||||
G {}
|
||||
K {}
|
||||
V {}
|
||||
|
|
@ -18,7 +19,8 @@ xctrl.ldprechref"
|
|||
color="12 11"
|
||||
digital=0
|
||||
ypos1=-0.0691204
|
||||
ypos2=0.68559}
|
||||
ypos2=0.68559
|
||||
jpeg_quality=30}
|
||||
B 2 580 -280 1200 -140 {flags=graph
|
||||
y1 = 0
|
||||
y2 = 1.6
|
||||
|
|
@ -33,7 +35,8 @@ xctrl.ldcpb"
|
|||
color="12 11"
|
||||
digital=0
|
||||
ypos1=0.071147
|
||||
ypos2=1.0465}
|
||||
ypos2=1.0465
|
||||
jpeg_quality=30}
|
||||
B 2 580 -400 1200 -280 {flags=graph
|
||||
y1 = 0
|
||||
y2 = 1.6
|
||||
|
|
@ -50,7 +53,8 @@ xctrl.ldoutib"
|
|||
color="12 5 11 8"
|
||||
digital=1
|
||||
ypos1=0.1572
|
||||
ypos2=0.829851}
|
||||
ypos2=0.829851
|
||||
jpeg_quality=30}
|
||||
N 360 -670 500 -670 {lab=LDCPB}
|
||||
N 240 -760 250 -760 {lab=LDCPB}
|
||||
N 240 -760 240 -670 {lab=LDCPB}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ divx=8
|
|||
node="tcleval($\{path\}ldqi
|
||||
$\{path\}ldqib
|
||||
$\{path\}ldsali)"
|
||||
color="9 6 7"}
|
||||
color="9 6 7"
|
||||
jpeg_quality=30}
|
||||
B 2 380 -940 1060 -830 {flags=graph
|
||||
y1 = 0
|
||||
y2 = 2
|
||||
|
|
@ -25,7 +26,8 @@ x2=3.4e-07
|
|||
divx=8
|
||||
node="v(ldcp)
|
||||
v(ldprech)"
|
||||
color="12 10"}
|
||||
color="12 10"
|
||||
jpeg_quality=30}
|
||||
B 2 380 -650 1060 -510 {flags=graph
|
||||
y1 = 0
|
||||
y2 = 2
|
||||
|
|
@ -36,7 +38,8 @@ divx=8
|
|||
node="tcleval($\{path\}ldqiii
|
||||
$\{path\}ldqii
|
||||
$\{path\}ldsali)"
|
||||
color="6 8 7"}
|
||||
color="6 8 7"
|
||||
jpeg_quality=30}
|
||||
T {Was:
|
||||
60/24} 1420 -310 0 0 0.4 0.4 {}
|
||||
T {was: LDCP_B} 510 -410 0 0 0.4 0.4 {}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue