From: Armaan Bhojwani Date: Mon, 8 Mar 2021 15:31:42 +0000 (-0500) Subject: Copy css in stagit-index X-Git-Url: https://git.armaanb.net/?p=stagit.git;a=commitdiff_plain;h=70aaa5e01b2895d11b6d0dee8d600e822a199cfe Copy css in stagit-index --- diff --git a/src/cp.h b/src/cp.h new file mode 100644 index 0000000..1372b5b --- /dev/null +++ b/src/cp.h @@ -0,0 +1,25 @@ +#include +#include + +int cp(char fileSource[], char fileDestination[]) +{ + int c; + FILE *stream_R, *stream_W; + + stream_R = fopen(fileSource, "r"); + if (stream_R == NULL) + return -1; + stream_W = fopen(fileDestination, "w"); //create and write to file + if (stream_W == NULL) + { + fclose(stream_R); + return -2; + } + while ((c = fgetc(stream_R)) != EOF) + fputc(c, stream_W); + fclose(stream_R); + fclose(stream_W); + + return 0; +} + diff --git a/src/stagit-index.c b/src/stagit-index.c index 2b243ec..fa0c21a 100644 --- a/src/stagit-index.c +++ b/src/stagit-index.c @@ -8,6 +8,8 @@ #include +#include "cp.h" + static git_repository *repo; static const char *relpath = ""; @@ -69,7 +71,7 @@ writeheader(FILE *fp) "", fp); xmlencode(fp, description, strlen(description)); fprintf(fp, "\n\n", relpath); - fprintf(fp, "\n", relpath); + fprintf(fp, "\n", relpath); fputs("\n\n", fp); fprintf(fp, "\n\n" "
\"\"", relpath); @@ -212,6 +214,11 @@ main(int argc, char *argv[]) } writefooter(stdout); + /* copy css */ + char cwd[PATH_MAX]; + strcpy(cwd, getcwd(cwd, sizeof(cwd))); + cp("/usr/local/share/stagit/style.min.css", strcat(cwd, "/style.min.css")); + /* cleanup */ git_repository_free(repo); git_libgit2_shutdown(); diff --git a/src/stagit.c b/src/stagit.c index 264604e..aa99c77 100644 --- a/src/stagit.c +++ b/src/stagit.c @@ -14,6 +14,7 @@ #include +#include "cp.h" #include "compat.h" struct deltainfo { @@ -70,28 +71,6 @@ static char lastoidstr[GIT_OID_HEXSZ + 2]; /* id + newline + NUL byte */ static FILE *rcachefp, *wcachefp; static const char *cachefile; -int cp(char fileSource[], char fileDestination[]) -{ - int c; - FILE *stream_R, *stream_W; - - stream_R = fopen(fileSource, "r"); - if (stream_R == NULL) - return -1; - stream_W = fopen(fileDestination, "w"); //create and write to file - if (stream_W == NULL) - { - fclose(stream_R); - return -2; - } - while ((c = fgetc(stream_R)) != EOF) - fputc(c, stream_W); - fclose(stream_R); - fclose(stream_W); - - return 0; -} - void joinpath(char *buf, size_t bufsiz, const char *path, const char *path2) {