Fossil SCM

Added --as FILENAME option to the (chat send) command, which uses FILENAME as the attachment name for the file specified by the --file flag. Mimetype guessing for the attachment is based on the --as name.

stephan 2022-01-01 12:50 trunk
Commit 2bb3c76ad9e78e44f02b9d8d67914cd258800ec2f0bf7c422edf714c97043caa
1 file changed +5 -2
+5 -2
--- src/chat.c
+++ src/chat.c
@@ -834,10 +834,12 @@
834834
**
835835
** This command sends a new message to the chatroom. The message
836836
** to be sent is determined by arguments as follows:
837837
**
838838
** -f|--file FILENAME File to attach to the message
839
+** --as FILENAME2 Causes --file FILENAME to be sent with
840
+** the attachment name FILENAME2
839841
** -m|--message TEXT Text of the chat message
840842
** --remote URL Send to this remote URL
841843
** --unsafe Allow the use of unencrypted http://
842844
**
843845
** > fossil chat url
@@ -891,10 +893,11 @@
891893
zCmd = mprintf("%s \"%s/chat?cli\" &", zBrowser, zUrl);
892894
#endif
893895
fossil_system(zCmd);
894896
}else if( strcmp(g.argv[2],"send")==0 ){
895897
const char *zFilename = find_option("file","r",1);
898
+ const char *zAs = find_option("as",0,1);
896899
const char *zMsg = find_option("message","m",1);
897900
int allowUnsafe = find_option("unsafe",0,0)!=0;
898901
const int mFlags = HTTP_GENERIC | HTTP_QUIET | HTTP_NOCOMPRESS;
899902
int i;
900903
const char *zPw;
@@ -940,13 +943,13 @@
940943
if( zMsg && zMsg[0] ){
941944
blob_appendf(&up,"\r\nContent-Disposition: form-data; name=\"msg\"\r\n"
942945
"\r\n%s\r\n%s", zMsg, zBoundary);
943946
}
944947
if( zFilename && blob_read_from_file(&fcontent, zFilename, ExtFILE)>0 ){
945
- char *zFN = mprintf("%s", file_tail(zFilename));
948
+ char *zFN = mprintf("%s", file_tail(zAs ? zAs : zFilename));
946949
int i;
947
- const char *zMime = mimetype_from_name(zFilename);
950
+ const char *zMime = mimetype_from_name(zFN);
948951
for(i=0; zFN[i]; i++){
949952
char c = zFN[i];
950953
if( fossil_isalnum(c) ) continue;
951954
if( c=='.' ) continue;
952955
if( c=='-' ) continue;
953956
--- src/chat.c
+++ src/chat.c
@@ -834,10 +834,12 @@
834 **
835 ** This command sends a new message to the chatroom. The message
836 ** to be sent is determined by arguments as follows:
837 **
838 ** -f|--file FILENAME File to attach to the message
 
 
839 ** -m|--message TEXT Text of the chat message
840 ** --remote URL Send to this remote URL
841 ** --unsafe Allow the use of unencrypted http://
842 **
843 ** > fossil chat url
@@ -891,10 +893,11 @@
891 zCmd = mprintf("%s \"%s/chat?cli\" &", zBrowser, zUrl);
892 #endif
893 fossil_system(zCmd);
894 }else if( strcmp(g.argv[2],"send")==0 ){
895 const char *zFilename = find_option("file","r",1);
 
896 const char *zMsg = find_option("message","m",1);
897 int allowUnsafe = find_option("unsafe",0,0)!=0;
898 const int mFlags = HTTP_GENERIC | HTTP_QUIET | HTTP_NOCOMPRESS;
899 int i;
900 const char *zPw;
@@ -940,13 +943,13 @@
940 if( zMsg && zMsg[0] ){
941 blob_appendf(&up,"\r\nContent-Disposition: form-data; name=\"msg\"\r\n"
942 "\r\n%s\r\n%s", zMsg, zBoundary);
943 }
944 if( zFilename && blob_read_from_file(&fcontent, zFilename, ExtFILE)>0 ){
945 char *zFN = mprintf("%s", file_tail(zFilename));
946 int i;
947 const char *zMime = mimetype_from_name(zFilename);
948 for(i=0; zFN[i]; i++){
949 char c = zFN[i];
950 if( fossil_isalnum(c) ) continue;
951 if( c=='.' ) continue;
952 if( c=='-' ) continue;
953
--- src/chat.c
+++ src/chat.c
@@ -834,10 +834,12 @@
834 **
835 ** This command sends a new message to the chatroom. The message
836 ** to be sent is determined by arguments as follows:
837 **
838 ** -f|--file FILENAME File to attach to the message
839 ** --as FILENAME2 Causes --file FILENAME to be sent with
840 ** the attachment name FILENAME2
841 ** -m|--message TEXT Text of the chat message
842 ** --remote URL Send to this remote URL
843 ** --unsafe Allow the use of unencrypted http://
844 **
845 ** > fossil chat url
@@ -891,10 +893,11 @@
893 zCmd = mprintf("%s \"%s/chat?cli\" &", zBrowser, zUrl);
894 #endif
895 fossil_system(zCmd);
896 }else if( strcmp(g.argv[2],"send")==0 ){
897 const char *zFilename = find_option("file","r",1);
898 const char *zAs = find_option("as",0,1);
899 const char *zMsg = find_option("message","m",1);
900 int allowUnsafe = find_option("unsafe",0,0)!=0;
901 const int mFlags = HTTP_GENERIC | HTTP_QUIET | HTTP_NOCOMPRESS;
902 int i;
903 const char *zPw;
@@ -940,13 +943,13 @@
943 if( zMsg && zMsg[0] ){
944 blob_appendf(&up,"\r\nContent-Disposition: form-data; name=\"msg\"\r\n"
945 "\r\n%s\r\n%s", zMsg, zBoundary);
946 }
947 if( zFilename && blob_read_from_file(&fcontent, zFilename, ExtFILE)>0 ){
948 char *zFN = mprintf("%s", file_tail(zAs ? zAs : zFilename));
949 int i;
950 const char *zMime = mimetype_from_name(zFN);
951 for(i=0; zFN[i]; i++){
952 char c = zFN[i];
953 if( fossil_isalnum(c) ) continue;
954 if( c=='.' ) continue;
955 if( c=='-' ) continue;
956

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button