From c1a3a46007249c6de1c461b38a03ded6297df6de Mon Sep 17 00:00:00 2001 From: tenox Date: Fri, 13 Jan 2017 01:10:48 -0800 Subject: initial git support --- dialogs.c | 15 +++++++++++++-- fileio.c | 22 +++++++++++++++------- wfm.h | 3 +++ 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/dialogs.c b/dialogs.c index 6ebad0d..7926a26 100644 --- a/dialogs.c +++ b/dialogs.c @@ -246,8 +246,11 @@ void about(void) { "Server Side RFC 1321 implementation by L. Peter Deutsch
\n" "Client Side RFC 1321 implementation by Paul Johnston
\n" "Icons by Yusuke Kamiyamane
\n" +#ifdef WFMGIT + "Uses libgit2 library
\n" +#endif "URL Encoding routines by Fred Bulback
\n" - "Copyright © 1994-2016 by Antoni Sawicki
\n" + "Copyright © 1994-2017 by Antoni Sawicki
\n" "Copyright © 1996-2011 by Thomas Boutell and Boutell.Com, Inc.
\n" "Copyright © 2002 by Aladdin Enterprises
\n" "Copyright © 1999-2009 by Paul Johnston
\n" @@ -258,6 +261,7 @@ void about(void) { "Server: %s
\n" "User Agent: %s
\n" "JavaScript Level: %d
\n" + "Git Support: %s (%s)
\n" " 

\n" " 

\n" "\n" @@ -274,7 +278,14 @@ void about(void) { " \n" "\n" "\n\n", - ICONSURL, TAGLINE, VERSION, __DATE__, __TIME__, __VERSION__, cgiServerSoftware, cgiUserAgent, js, cgiScriptName, virt_dirname, token); + ICONSURL, TAGLINE, VERSION, __DATE__, __TIME__, __VERSION__, cgiServerSoftware, cgiUserAgent, js, +#ifdef WFMGIT + "Yes" +#else + "No" +#endif + , (repo_check()) ? "Oo Repo Present" : "Repo OK", + cgiScriptName, virt_dirname, token); } diff --git a/fileio.c b/fileio.c index b5718d3..78044b0 100644 --- a/fileio.c +++ b/fileio.c @@ -81,6 +81,8 @@ void receivefile(void) { cgiFormFileClose(input); fclose(output); + + revup_commit("Receive File"); redirect("%s?highlight=%s&directory=%s&token=%s", cgiScriptName, virt_filename_urlencoded, virt_dirname_urlencoded, token); @@ -101,9 +103,10 @@ void mkfile(void) { error("Unable to create file.
%s", strerror(errno)); fclose(output); - - redirect("%s?highlight=%s&directory=%s&token=%s", cgiScriptName, virt_filename_urlencoded, virt_dirname_urlencoded - , token); + + revup_commit("New File"); + + redirect("%s?highlight=%s&directory=%s&token=%s", cgiScriptName, virt_filename_urlencoded, virt_dirname_urlencoded, token); } @@ -117,7 +120,7 @@ void newdir(void) { if(mkdir(phys_filename, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH )!=0) error("Unable to create directory.
%s", strerror(errno)); - + redirect("%s?highlight=%s&directory=%s&token=%s", cgiScriptName, virt_filename_urlencoded, virt_dirname_urlencoded, token); } @@ -202,6 +205,8 @@ void edit_save(void) { free(buff); + revup_commit("Editor Save"); + redirect("%s?highlight=%s&directory=%s&token=%s", cgiScriptName, virt_filename_urlencoded, virt_dirname_urlencoded, token); } @@ -234,7 +239,8 @@ void fileio_re_rmdir(char *dirname) { error("Unable to remove directory...
%s", strerror(errno)); } else { if(unlink(tempfullpath)!=0) - error("Unable to remove directory....
%s", strerror(errno)); + error("Unable to remove file....
%s", strerror(errno)); + delete_commit("Recursive Delete"); } } @@ -261,6 +267,7 @@ void fileio_delete(void) { else { if(unlink(phys_filename)!=0) error("Unable to remove file.
%s", strerror(errno)); + delete_commit("Delete File"); } } @@ -277,7 +284,7 @@ void delete(void) { // Single if(cgiFormStringMultiple("multiselect_filename", &responses) == cgiFormNotFound) { checkfilename(NULL); - fileio_delete(); + fileio_delete(); } // Multi else { @@ -339,7 +346,8 @@ void move(void) { // // Recursive Dir Size // -// WARNING: will not count directories starting with . +// NOTE: will not count directories starting with . (dot) +// so size of git repo will not show here... off_t du(char *pdir) { DIR *dir; struct dirent *direntry; diff --git a/wfm.h b/wfm.h index 55fefaf..aa43724 100644 --- a/wfm.h +++ b/wfm.h @@ -149,3 +149,6 @@ void html_title(char *); void singleprompt_ui(char *); char *url_encode(char *); char *url_decode(char *); +int revup_commit(char *); +int delete_commit(char *); +int repo_check(void); \ No newline at end of file -- cgit v1.2.3