X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fsendfile.c;h=fbf5f1b82d70bd6a4cc4b10197bf083f9d861527;hb=cc828cb983a024b5df467a83c12e594b38b10f1e;hp=48787fdd635195838162abf9f23fb4413d20fbbf;hpb=81cfca6c6ec15e3a8f94e278f2bdfcc1249eb122;p=ashd.git diff --git a/src/sendfile.c b/src/sendfile.c index 48787fd..fbf5f1b 100644 --- a/src/sendfile.c +++ b/src/sendfile.c @@ -26,6 +26,8 @@ #include #include #include +#include +#include #ifdef HAVE_CONFIG_H #include @@ -65,11 +67,6 @@ static void passdata(int in, int out) free(buf); } -static int strrcmp(char *str, char *end) -{ - return(strcmp(str + strlen(str) - strlen(end), end)); -} - static char *attrmimetype(char *file) { #ifdef HAVE_XATTR @@ -113,6 +110,15 @@ static const char *getmimetype(char *file, struct stat *sb) return("application/octet-stream"); } +/* XXX: This could be made far better and check for other attributes + * and stuff, but not now. */ +static const char *ckctype(const char *ctype) +{ + if(!strncmp(ctype, "text/", 5) && (strchr(ctype, ';') == NULL)) + return(sprintf2("%s; charset=%s", ctype, nl_langinfo(CODESET))); + return(ctype); +} + static void checkcache(char *file, struct stat *sb) { char *hdr; @@ -141,6 +147,7 @@ int main(int argc, char **argv) int fd; const char *contype; + setlocale(LC_ALL, ""); contype = NULL; while((c = getopt(argc, argv, "c:")) >= 0) { switch(c) { @@ -172,6 +179,7 @@ int main(int argc, char **argv) } if(contype == NULL) contype = getmimetype(file, &sb); + contype = ckctype(contype); checkcache(file, &sb);