Re: Patch to add support for RFC2324 (HTCPCP)

2021-11-28 Thread Kang-Che Sung
On Mon, Nov 29, 2021 at 5:16 AM Peter Willis  wrote:
>
> Hi busybox devs, It's been a long time! About 17 years since my last 
> submission :-)
>
> I was just trying to make some coffee with busybox, and I noticed it doesn't 
> support RFC 2324 (Hyper Text Coffee Pot Control Protocol). Attached is a 
> patch that adds support for the standard. Although I should mention it's not 
> full support for the standard; I take my coffee black, so I didn't implement 
> WHEN and Accept-Additions, but I'm sure someone else can if they need creamer 
> (although some Kahlua wouldn't go amiss with this winter weather...)
>
> The patch includes a configuration file option "T" that sets if the host is a 
> teapot or not. The default is teapot mode, for portability (coffee brewing 
> operations shouldn't happen on a teapot).
>
> Sample operation:
>
> $ echo "T:1" > cgi-bin/httpd.conf
> $ curl -d 'start' -H "Content-Type: application/coffee-pot-command" -X BREW 
> http://localhost:6789/cgi-bin/coffeepot
> 418 I'm a teapot
> 418 I'm a teapot
> The web server is a teapot
> 
> $ echo "T:0" > cgi-bin/httpd.conf
> $ curl -d 'start' -H "Content-Type: application/coffee-pot-command" -X BREW 
> http://localhost:6789/cgi-bin/coffeepot
> Brewing coffee!
>
> Also note that the patch fixes a Content-Length bug I found in send_headers():
>
> The function always returns the Content-Length, which is always set to 
> the length of a file (for example, if there was a request of a file, the 
> file's size is taken - but then some error might be thrown after this point). 
> After the Content-Length is set, if infoString was set (the text of a 
> response code) the resulting HTML output's length bears no relation to the 
> file size it previously set as the Content-Length. Therefore the 
> Content-Length needs to be set to either the file size, or the length of the 
> infoString HTML message. The patch includes a change to calculate the size of 
> the infoString template and return that length if infoString was set.

Just wondering. Is this an out-of-season April Fools joke? (Sorry for
quoting that guy at Blizzcon.)

But I have a serious question here: I don't see the ".cup" file
extension or the "vessel/cup" MIME type defined anywhere in the HTCPCP
spec. Where are those keywords from?
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Patch to add support for RFC2324 (HTCPCP)

2021-11-28 Thread Peter Willis
Hi busybox devs, It's been a long time! About 17 years since my last submission 
:-)

I was just trying to make some coffee with busybox, and I noticed it doesn't 
support RFC 2324 (Hyper Text Coffee Pot Control Protocol). Attached is a patch 
that adds support for the standard. Although I should mention it's not full 
support for the standard; I take my coffee black, so I didn't implement WHEN 
and Accept-Additions, but I'm sure someone else can if they need creamer 
(although some Kahlua wouldn't go amiss with this winter weather...)

The patch includes a configuration file option "T" that sets if the host is a 
teapot or not. The default is teapot mode, for portability (coffee brewing 
operations shouldn't happen on a teapot).

Sample operation:

$ echo "T:1" > cgi-bin/httpd.conf 
$ curl -d 'start' -H "Content-Type: application/coffee-pot-command" -X BREW 
http://localhost:6789/cgi-bin/coffeepot
418 I'm a teapot
418 I'm a teapot
The web server is a teapot

$ echo "T:0" > cgi-bin/httpd.conf
$ curl -d 'start' -H "Content-Type: application/coffee-pot-command" -X BREW 
http://localhost:6789/cgi-bin/coffeepot
Brewing coffee!

Also note that the patch fixes a Content-Length bug I found in send_headers():

The function always returns the Content-Length, which is always set to the 
length of a file (for example, if there was a request of a file, the file's 
size is taken - but then some error might be thrown after this point). After 
the Content-Length is set, if infoString was set (the text of a response code) 
the resulting HTML output's length bears no relation to the file size it 
previously set as the Content-Length. Therefore the Content-Length needs to be 
set to either the file size, or the length of the infoString HTML message. The 
patch includes a change to calculate the size of the infoString template and 
return that length if infoString was set.

HTCPCP.diff.gz
Description: application/gzip
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


RE: return type demotion remarks

2021-11-28 Thread David Laight
From: Bernhard Reutner-Fischer
> Sent: 28 November 2021 19:37
> 
> On Sun, 28 Nov 2021 18:00:31 +
> David Laight  wrote:
> 
> > From: Bernhard Reutner-Fischer
> > > Sent: 27 November 2021 20:57
> > >
> > > Hi!
> > >
> > > I'm attaching a color log of some spots that may benefit of using
> > > narrower return types; See "could return".
> >
> > My mailer won't expand a .gz file .
> 
> yea, it was too big to send uncompressed, sorry for that.
> >
> > However making function arguments and return values smaller
> > than a normal cpu register (long is probably better than int!)
> > is likely to increase code size.
> 
> Arches will promote types as they see fit anyway.

The problem is that the values start needing to be masked to the
smaller type, not that they get promoted.

> I'm attaching something that i would _not_ apply since it was based off
> the user-visible fix-it not taking into account the shifts needed in
> the callers.
> Lessons learned in this v0.0:
> - iterate_on_dir callback should be void
> - find ACTF could use a narrower type
> - functors are a bit of a pain ;)
> cheers,

Try using outlook :-(
It really only wants to execute attachments, not display them.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, 
UK
Registration No: 1397386 (Wales)

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


RE: return type demotion remarks

2021-11-28 Thread David Laight
From: Bernhard Reutner-Fischer
> Sent: 27 November 2021 20:57
> 
> Hi!
> 
> I'm attaching a color log of some spots that may benefit of using
> narrower return types; See "could return".

My mailer won't expand a .gz file .

However making function arguments and return values smaller
than a normal cpu register (long is probably better than int!)
is likely to increase code size.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, 
UK
Registration No: 1397386 (Wales)
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] find: implement -samefile

2021-11-28 Thread Aaro Koskinen
Implement -samefile.

Signed-off-by: Aaro Koskinen 
---
 findutils/find.c | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/findutils/find.c b/findutils/find.c
index fdc5c152d..87fd5b9bc 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -155,6 +155,13 @@
 //config:  default y
 //config:  depends on FIND
 //config:
+//config:config FEATURE_FIND_SAMEFILE
+//config:  bool "Enable -samefile: reference file matching"
+//config:  default y
+//config:  depends on FIND
+//config:  help
+//config:Support the 'find -samefile' option for searching by a 
reference file.
+//config:
 //config:config FEATURE_FIND_EXEC
 //config:  bool "Enable -exec: execute commands"
 //config:  default y
@@ -350,6 +357,9 @@
 //usage:   IF_FEATURE_FIND_INUM(
 //usage: "\n   -inum N File has inode number N"
 //usage:   )
+//usage:   IF_FEATURE_FIND_SAMEFILE(
+//usage: "\n   -samefile FILE  File is same as FILE"
+//usage:   )
 //usage:   IF_FEATURE_FIND_USER(
 //usage: "\n   -user NAME/ID   File is owned by given user"
 //usage:   )
@@ -444,6 +454,7 @@ IF_FEATURE_FIND_MTIME(  ACTS(mtime, unsigned char 
time_type; unsigned char mtime
 IF_FEATURE_FIND_MMIN(   ACTS(mmin,  unsigned char time_type; unsigned char 
mmin_char; unsigned mmin_mins;))
 IF_FEATURE_FIND_NEWER(  ACTS(newer, time_t newer_mtime;))
 IF_FEATURE_FIND_INUM(   ACTS(inum,  ino_t inode_num;))
+IF_FEATURE_FIND_SAMEFILE(ACTS(samefile, ino_t inode_num; dev_t device;))
 IF_FEATURE_FIND_USER(   ACTS(user,  uid_t uid;))
 IF_FEATURE_FIND_SIZE(   ACTS(size,  char size_char; off_t size;))
 IF_FEATURE_FIND_CONTEXT(ACTS(context, security_context_t context;))
@@ -731,6 +742,13 @@ ACTF(inum)
return (statbuf->st_ino == ap->inode_num);
 }
 #endif
+#if ENABLE_FEATURE_FIND_SAMEFILE
+ACTF(samefile)
+{
+   return statbuf->st_ino == ap->inode_num &&
+  statbuf->st_dev == ap->device;
+}
+#endif
 #if ENABLE_FEATURE_FIND_EXEC
 static int do_exec(action_exec *ap, const char *fileName)
 {
@@ -1125,6 +1143,7 @@ static action*** parse_params(char **argv)
IF_FEATURE_FIND_CMIN(   PARM_cmin  ,)
IF_FEATURE_FIND_NEWER(  PARM_newer ,)
IF_FEATURE_FIND_INUM(   PARM_inum  ,)
+   IF_FEATURE_FIND_SAMEFILE(PARM_samefile ,)
IF_FEATURE_FIND_USER(   PARM_user  ,)
IF_FEATURE_FIND_GROUP(  PARM_group ,)
IF_FEATURE_FIND_SIZE(   PARM_size  ,)
@@ -1173,6 +1192,7 @@ static action*** parse_params(char **argv)
IF_FEATURE_FIND_CMIN(   "-cmin\0"   )
IF_FEATURE_FIND_NEWER(  "-newer\0"  )
IF_FEATURE_FIND_INUM(   "-inum\0"   )
+   IF_FEATURE_FIND_SAMEFILE("-samefile\0")
IF_FEATURE_FIND_USER(   "-user\0"   )
IF_FEATURE_FIND_GROUP(  "-group\0"  )
IF_FEATURE_FIND_SIZE(   "-size\0"   )
@@ -1511,6 +1531,21 @@ static action*** parse_params(char **argv)
ap->inode_num = xatoul(arg1);
}
 #endif
+#if ENABLE_FEATURE_FIND_SAMEFILE
+   else if (parm == PARM_samefile) {
+   action_samefile *ap;
+   struct stat stbuf;
+   dbg("%d", __LINE__);
+   if (G.recurse_flags & (ACTION_FOLLOWLINKS |
+  ACTION_FOLLOWLINKS_L0))
+   xstat(arg1, );
+   else if (lstat(arg1, ))
+   bb_perror_msg_and_die("can't stat '%s'", arg1);
+   ap = ALLOC_ACTION(samefile);
+   ap->inode_num = stbuf.st_ino;
+   ap->device = stbuf.st_dev;
+   }
+#endif
 #if ENABLE_FEATURE_FIND_USER
else if (parm == PARM_user) {
action_user *ap;
-- 
2.17.0

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox