void process(struct processor *p_uncast, const char *filename, struct stack *s, struct makefile *m) { struct processor_pdfcrop *p; void *c; int cachedir_index; char *cachedir; char *infile; /* We need access to the real structure, get it safely */ p = talloc_get_type(p_uncast, struct processor_pdfcrop); /* Makes a new context */ c = talloc_new(p); /* Finds the original filename */ cachedir_index = string_index(filename, ".tek_cache/"); if (cachedir_index == -1) { fprintf(stderr, "Bad cachedir for image\n"); return; } cachedir = talloc_strdup(c, filename); cachedir[cachedir_index + strlen(".tex_cache/")] = '\0'; infile = talloc_strdup(c, filename); infile[cachedir_index] = '\0'; strcat(infile, filename + strlen(cachedir)); infile[strlen(infile) - 4] = '\0'; TALLOC_FREE(cachedir); cachedir = talloc_strndup(c, filename, basename_len(filename)); /* Creates the target to build the image */ makefile_create_target(m, filename); makefile_start_deps(m); makefile_add_dep(m, infile); makefile_end_deps(m); makefile_start_cmds(m); makefile_nam_cmd(m, "echo -e \"PDFCROP\\t%s\"", infile); makefile_add_cmd(m, "mkdir -p \"%s\" >& /dev/null || true", cachedir); makefile_add_cmd(m, "pdfcrop \"%s\" \"%s\" >& /dev/null", infile, filename); makefile_end_cmds(m); /* Cleans up all the memory allocated by this code. */ TALLOC_FREE(c); }
CryptoContextWrapper( get_hmac_key_prototype * hmac_fn, get_trace_key_prototype * trace_fn, bool with_encryption, bool with_checksum, bool old_encryption_scheme, bool one_shot_encryption_scheme, char const * filename_derivatator) { cctx.set_get_hmac_key_cb(hmac_fn); cctx.set_get_trace_key_cb(trace_fn); cctx.set_trace_type( with_encryption ? TraceType::cryptofile : with_checksum ? TraceType::localfile_hashed : TraceType::localfile); cctx.old_encryption_scheme = old_encryption_scheme; cctx.one_shot_encryption_scheme = one_shot_encryption_scheme; size_t base_len = 0; char const * base = basename_len(filename_derivatator, base_len); cctx.set_master_derivator({base, base_len}); }
void process(struct processor *p_uncast, const char *filename, struct stack *s, struct makefile *m) { struct processor_svgtex *p; void *c; int cachedir_index; char *cachedir; char *infile; char *cachename; char *origfile; /* We need access to the real structure, get it safely */ p = talloc_get_type(p_uncast, struct processor_svgtex); /* Makes a new context */ c = talloc_new(p); /* Finds the original filename */ cachedir_index = string_index(filename, ".tek_cache/"); if (cachedir_index == -1) { fprintf(stderr, "Bad cachedir for image\n"); return; } cachedir = talloc_strdup(c, filename); cachedir[cachedir_index + strlen(".tex_cache/")] = '\0'; infile = talloc_strdup(c, filename); infile[cachedir_index] = '\0'; strcat(infile, filename + strlen(cachedir)); infile[strlen(infile) - 8] = '\0'; TALLOC_FREE(cachedir); cachedir = talloc_strndup(c, filename, basename_len(filename)); cachename = talloc_strndup(c, filename, strlen(filename) - 8); origfile = infile; while (strstr(infile, "/") != NULL) infile = infile + 1; /* Creates the target to build the LaTeX file for importing. */ makefile_create_target(m, filename); makefile_start_deps(m); makefile_add_dep(m, cachename); makefile_end_deps(m); makefile_start_cmds(m); makefile_nam_cmd(m, "echo -e \"SVGTEX\\t%s\"", infile); makefile_add_cmd(m, "mkdir -p \"%s\" >& /dev/null || true", cachedir); makefile_add_cmd(m, "cd .tek_cache; svgtexpp \"%s/%s\" > /dev/null", strstr(cachedir, "/")+1, infile); makefile_end_cmds(m); /* This one is necessary for pandoc. */ makefile_create_target(m, cachename); makefile_start_deps(m); makefile_add_dep(m, origfile); makefile_end_deps(m); makefile_start_cmds(m); makefile_nam_cmd(m, "echo -e \"IMGCP\\t%s\"", origfile); makefile_add_cmd(m, "mkdir -p \"%s\" >& /dev/null || true", cachedir); makefile_add_cmd(m, "cp \"%s\" \"%s\"", origfile, cachename); makefile_end_cmds(m); /* Also generate the relevant PDF */ { char *outname; outname = talloc_asprintf(c, "%.*s.svg.pdf", (int)(strlen(cachename)-8), cachename); makefile_create_target(m, outname); makefile_start_deps(m); makefile_add_dep(m, cachename); makefile_end_deps(m); makefile_start_cmds(m); makefile_nam_cmd(m, "echo -e \"RSVGC\\t%s\"", infile); makefile_add_cmd(m, "mkdir -p \"%s\" >& /dev/null || true", cachedir); makefile_add_cmd(m, "rsvg-convert \"%s\" -f pdf -o \"%s\"", infile, outname); makefile_end_cmds(m); } /* Cleans up all the memory allocated by this code. */ TALLOC_FREE(c); }
void process(struct processor *p_uncast, const char *filename, struct stack *s, struct makefile *m) { struct processor_pdfcopy *p; void *c; int cachedir_index; char *cachedir; char *infile; char *procfile; /* We need access to the real structure, get it safely */ p = talloc_get_type(p_uncast, struct processor_pdfcopy); /* Makes a new context */ c = talloc_new(p); /* Finds the original filename */ cachedir_index = string_index(filename, ".tek_cache/"); if (cachedir_index == -1) { fprintf(stderr, "Bad cachedir for image\n"); return; } cachedir = talloc_strdup(c, filename); cachedir[cachedir_index + strlen(".tex_cache/")] = '\0'; infile = talloc_strdup(c, filename); infile[cachedir_index] = '\0'; strcat(infile, filename + strlen(cachedir)); infile[strlen(infile) - 4] = '\0'; TALLOC_FREE(cachedir); cachedir = talloc_strndup(c, filename, basename_len(filename)); /* Figure out if we're supposed to copy the file or we're supposed * to generate it. */ procfile = talloc_asprintf(c, "%s.proc", infile); if (access(procfile, X_OK) == 0) { /* Generate the file manually. */ makefile_create_target(m, filename); makefile_start_deps(m); makefile_add_dep(m, procfile); makefile_end_deps(m); makefile_start_cmds(m); makefile_nam_cmd(m, "echo -e \"PDFGEN\\t%s\"", infile); makefile_add_cmd(m, "mkdir -p \"%s\" >& /dev/null || true", cachedir); makefile_add_cmd(m, "./\"%s\" > \"%s\"", procfile, filename); makefile_end_cmds(m); } else { /* Just copy the file over. */ makefile_create_target(m, filename); makefile_start_deps(m); makefile_add_dep(m, infile); makefile_end_deps(m); makefile_start_cmds(m); makefile_nam_cmd(m, "echo -e \"PDFCOPY\\t%s\"", infile); makefile_add_cmd(m, "mkdir -p \"%s\" >& /dev/null || true", cachedir); makefile_add_cmd(m, "cp \"%s\" \"%s\" >& /dev/null", infile, filename); makefile_end_cmds(m); } /* Cleans up all the memory allocated by this code. */ TALLOC_FREE(c); }