NetServices: Add libnetservices2.a from dev/netservices into master

The overall design does not deviate much from my proof of concept [2] and that still makes a good read to
understanding the overall architecture. If you want to get a sense of how it is built up, the API comes with
full doxygen documentation for the public API [3], and I have also done a PoC change for HaikuDepot which is
useful as an illustration on what the impact for the user of the new library is. [4] There is also a test suite
that may give some insight into the day to day ergonomics of the API [5].

The current state is that I am fairly confident that many HTTP requests will actually work, but I do expect
rough edges with a protocol with this many diverse implementations. There is also a list of features yet to be
implemented on Trac [6]. Additionally, I still want/need to do performance testing.

The goal of merging the kit right now is to start making it available for more uses, and through that also give
a chance to shape its future. There are also some design decisions that need review, most notably I expect some
discussion around the uses of C++ 17 idioms (like std::optional and std::string_view) and around the use of
exceptions for error handling.

The impact of merging right now should be near zero: the netservices2 kit lives in its own header space, and
builds into its own static library (libnetservices2.a). It is not yet used in any of the apps in our
repository.

The branch does remove the deprecated services kit from the libnetapi.so library, though it leaves
libnetservices.a intact. After our previous announcement to remove it after beta 3, this should be expected.

[2] https://github.com/nielx/haiku-netservices-rfc/tree/exceptions
[3] https://git.haiku-os.org/haiku/tree/docs/user/netservices?h=dev/netservices
[4] https://review.haiku-os.org/c/haiku/+/5692
[5] https://git.haiku-os.org/haiku/tree/src/tests/kits/net/netservices2?h=dev/netservices
[6] https://dev.haiku-os.org/wiki/Development/NetServices2

Change-Id: I5d0b7e2619699f39a2506588417b57391f0f5cc2
This commit is contained in:
Niels Sascha Reedijk
2022-11-02 01:37:17 +00:00
18 changed files with 115 additions and 101 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ Branch
**Time:** ~ 1 week **Time:** ~ 1 week
* Update the version constants in master (example: hrev52295) * Update the version constants in master (`example: hrev52295 <https://git.haiku-os.org/haiku/commit/?h=hrev52295>`_)
* Branch haiku and buildtools (git push origin master:r1beta1) * Branch haiku and buildtools (git push origin master:r1beta1)
* Update the version constants in the branch (`example <https://git.haiku-os.org/haiku/commit/?h=r1beta1&id=b5c9e6620ee731bd33d8cb3ef6ac01749122b6b3>`_) * Update the version constants in the branch (`example <https://git.haiku-os.org/haiku/commit/?h=r1beta1&id=b5c9e6620ee731bd33d8cb3ef6ac01749122b6b3>`_)
* Update copyright years in the `bootloader menu <https://git.haiku-os.org/haiku/tree/src/system/boot/platform/generic/text_menu.cpp#n212>`_ * Update copyright years in the `bootloader menu <https://git.haiku-os.org/haiku/tree/src/system/boot/platform/generic/text_menu.cpp#n212>`_
+20 -19
View File
@@ -200,10 +200,10 @@
There are two different cases where you must or could use these blocks: There are two different cases where you must or could use these blocks:
1. For non-public API of a <em>public header file</em>, you must always -# For non-public API of a <em>public header file</em>, you must always
add the classes and other elements to the documentation (even if they) add the classes and other elements to the documentation even if they
are placeholders, and put them in the conditional block. are placeholders, and put them in the conditional block.
2. For parts of the non-public API that is in a <em>private header -# For parts of the non-public API that is in a <em>private header
file</em>, you could put the documentation in a conditional block. If file</em>, you could put the documentation in a conditional block. If
you choose to do so, you must document all elements in that header you choose to do so, you must document all elements in that header
file. file.
@@ -226,13 +226,13 @@
- \<single_word\> - The argument is a single word. - \<single_word\> - The argument is a single word.
- (until the end of the line) - The argument runs until the end of the line. - (until the end of the line) - The argument runs until the end of the line.
- {paragraph} - The argument runs for an entire paragraph. A paragraph is - {paragraph} - The argument runs for an entire paragraph. A paragraph is
ended by an empty line, or if another command that defines a \ref ended by an empty line, or if another command that defines a \link
commands_sections sections is found. Note that if you use commands that commands_sections section \endlink is found. Note that if you use
work on a paragraph and you split it over multiple lines (because of the commands that work on a paragraph and you split it over multiple lines
maximum line width of 80 characters or because it looks better), you (because of the maximum line width of 80 characters or because it looks
will have to indent subsequent lines that belong to the paragraph with better), you will have to indent subsequent lines that belong to the
two more spaces, making the total of four. This is to visually paragraph with two more spaces, making the total of four. This is to
distinguish paragraphs for other documenters. visually distinguish paragraphs for other documenters.
\subsection commands_definitions Block Definitions \subsection commands_definitions Block Definitions
@@ -273,8 +273,8 @@
If you have a look at the output that Doxygen generates, you can see that If you have a look at the output that Doxygen generates, you can see that
there are recurring sections in the documentation. Documentation that there are recurring sections in the documentation. Documentation that
belongs to a certain section should be placed after a command that marks the belongs to a certain section should be placed after a command that marks the
start of that section. All the commands take a paragraph as answer. A start of that section. All the commands take a paragraph as argument. A
paragraph ends with a whitespace, or with a command that marks a new paragraph ends with an empty line, or with a command that marks a new
section. Note that this list only shows the syntax of the commands. For the section. Note that this list only shows the syntax of the commands. For the
semantics, have a look at the next section on style. In member documentation semantics, have a look at the next section on style. In member documentation
you can use the following: you can use the following:
@@ -423,7 +423,7 @@
you will end up using every now and then. This section will describe those you will end up using every now and then. This section will describe those
commands. commands.
The first one is \c \\n. This commands sort of belongs to the category of The first one is \c \\n. This command sort of belongs to the category of
markup commands. It basically forces a newline. Because Doxygen parses markup commands. It basically forces a newline. Because Doxygen parses
paragraphs as a single contiguous entity, it's not possible to mark up the paragraphs as a single contiguous entity, it's not possible to mark up the
text using carriage returns in the documentation. \c \\n forces a newline in text using carriage returns in the documentation. \c \\n forces a newline in
@@ -453,8 +453,8 @@
Finally, it is a good idea to link between parts of the documentation. There Finally, it is a good idea to link between parts of the documentation. There
are two commands for that. The first one is \c \\ref, which enable you to are two commands for that. The first one is \c \\ref, which enable you to
refer to pages, sections, etc. that you created yourself. The second one is refer to pages, sections, etc. that you created yourself. The second one is
\c \\link which refers to members. The first one is takes one word as an \c \\link which refers to members. The first one takes one word as an
argument, the name of the section, and it inserts a link with the name of argument, the name of the section, and it inserts a link with the text of
the title. \c \\link is more complex. It should always be accompanied by \c the title. \c \\link is more complex. It should always be accompanied by \c
\\endlink. The first word between the two commands is the object that is \\endlink. The first word between the two commands is the object that is
referred to, and the rest is the link text. referred to, and the rest is the link text.
@@ -595,7 +595,7 @@
-# End with a list of references to other classes, functions, pages, etc. -# End with a list of references to other classes, functions, pages, etc.
that might be of interest to the reader. that might be of interest to the reader.
When documenting classes, don't be to exhaustive. Avoid becoming a tutorial When documenting classes, don't be too exhaustive. Avoid becoming a tutorial
or a complete guide. This documentation is for reference only. If you want or a complete guide. This documentation is for reference only. If you want
to enlighten the reader on bigger subjects, consider writing a separate to enlighten the reader on bigger subjects, consider writing a separate
documentation page that connects the different points you want to make. documentation page that connects the different points you want to make.
@@ -623,7 +623,8 @@
clear description. The description starts with a capital letter and ends clear description. The description starts with a capital letter and ends
with a dot. Don't write the description saying what the method does, with a dot. Don't write the description saying what the method does,
like "Starts the timer", but rather as what it will do: "Start the like "Starts the timer", but rather as what it will do: "Start the
timer." -# If the brief description doesn't cover all of what the method timer."
-# If the brief description doesn't cover all of what the method
or function does, then you can add a few paragraphs that explain it in or function does, then you can add a few paragraphs that explain it in
more depth. Don't be too verbose, and use an example to illustrate more depth. Don't be too verbose, and use an example to illustrate
points. Point out any potential misunderstandings or problems you expect points. Point out any potential misunderstandings or problems you expect
@@ -646,7 +647,7 @@
In case of overloaded members, you'll need to make a decision. If you need In case of overloaded members, you'll need to make a decision. If you need
to copy too much information, you might resort to putting it in one to copy too much information, you might resort to putting it in one
paragraph with the text "This is an overloaded member function, and differs paragraph with the text "This is an overloaded member function, and differs
from \<name\> only by the type of parameter it takes." That will keep the from <name> only by the type of parameter it takes." That will keep the
copying down and will point developers right to the place where they can get copying down and will point developers right to the place where they can get
more documentation. more documentation.
@@ -693,7 +694,7 @@
depend on this variable. depend on this variable.
Defines are usually used as message constants. Give a short description of Defines are usually used as message constants. Give a short description of
what the message constant stands for, and where it might be send from and what the message constant stands for, and where it might be sent from and
where it might be received. where it might be received.
Enumerations can either be anonymous or named. In case of the latter, you Enumerations can either be anonymous or named. In case of the latter, you
+6 -6
View File
@@ -502,13 +502,13 @@ snooze_until(time - Latency(), B_SYSTEM_TIMEBASE);
prevent this, Haiku implements a \"locking\" mechanism, allowing one prevent this, Haiku implements a \"locking\" mechanism, allowing one
thread to \"lock out\" other threads from executing code that might thread to \"lock out\" other threads from executing code that might
modify the same data. modify the same data.
- \b Archiving \b and \b IO. These classes allow a programmer to - \b Archiving \b and \b IO. These classes allow a programmer to
convert objects into a form that can more easily be transferred to convert objects into a form that can more easily be transferred to
other applications or stored to disk, as well as performing basic other applications or stored to disk, as well as performing basic
input and output operations. input and output operations.
- \b Memory \b Allocation. This class allows a programmer to hand off - \b Memory \b Allocation. This class allows a programmer to hand off
some of the duties of memory accounting and management. some of the duties of memory accounting and management.
- \b Common \b Datatypes. To avoid unnecessary duplication of code - \b Common \b Datatypes. To avoid unnecessary duplication of code
and to make life easier for programmers, Haiku includes classes that and to make life easier for programmers, Haiku includes classes that
handle management of ordered lists and strings. handle management of ordered lists and strings.
@@ -551,9 +551,9 @@ snooze_until(time - Latency(), B_SYSTEM_TIMEBASE);
- BString allows strings and provides common access, modification, - BString allows strings and provides common access, modification,
and comparison functions. and comparison functions.
- BStopWatch allows an application to measure the time an action takes. - BStopWatch allows an application to measure the time an action takes.
- \ref support_globals "Global functions" - \ref support_globals "Global functions"
- \ref TypeConstants.h "Common types and constants" - \ref TypeConstants.h "Common types and constants"
- Error codes for all kits - Error codes for all kits
\defgroup translation Translation Kit \defgroup translation Translation Kit
+1 -1
View File
@@ -43,7 +43,7 @@
The initial coordinate space, from which all others are derived, is the The initial coordinate space, from which all others are derived, is the
screen space. Its origin is at the center of the screen's top-left pixel. screen space. Its origin is at the center of the screen's top-left pixel.
Coordinates can be converted between this and a specific window or view Coordinates can be converted between this and a specific window or view
space is done using the ConvertToScreen and ConvertFromScreen methods of space using the ConvertToScreen and ConvertFromScreen methods of
the corresponding object. the corresponding object.
Each BWindow has its own coordinate space. Its origin is at the center of Each BWindow has its own coordinate space. Its origin is at the center of
+5 -1
View File
@@ -239,8 +239,12 @@ enum {
B_USE_WINDOW_INSETS = B_USE_WINDOW_SPACING, B_USE_WINDOW_INSETS = B_USE_WINDOW_SPACING,
B_USE_SMALL_SPACING = -1006, B_USE_SMALL_SPACING = -1006,
B_USE_SMALL_INSETS = B_USE_SMALL_SPACING, B_USE_SMALL_INSETS = B_USE_SMALL_SPACING,
B_USE_BIG_SPACING = -1007, B_USE_CORNER_SPACING = -1007,
B_USE_CORNER_INSETS = B_USE_CORNER_SPACING,
B_USE_BIG_SPACING = -1008,
B_USE_BIG_INSETS = B_USE_BIG_SPACING, B_USE_BIG_INSETS = B_USE_BIG_SPACING,
B_USE_BORDER_SPACING = -1009,
B_USE_BORDER_INSETS = B_USE_BORDER_SPACING,
}; };
@@ -337,8 +337,6 @@ public:
uint32 flags = 0, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS, uint32 borders = B_ALL_BORDERS,
orientation orientation = B_HORIZONTAL); orientation orientation = B_HORIZONTAL);
virtual float GetScrollBarWidth(
orientation orientation = B_VERTICAL);
protected: protected:
void _DrawButtonFrame(BView* view, BRect& rect, void _DrawButtonFrame(BView* view, BRect& rect,
@@ -356,8 +356,8 @@ public:
inline Element* RemoveHead(); inline Element* RemoveHead();
inline Element* RemoveTail(); inline Element* RemoveTail();
inline Element* GetPrevious(Element* element) const; static inline Element* GetPrevious(Element* element);
inline Element* GetNext(Element* element) const; static inline Element* GetNext(Element* element);
inline bool Contains(Element* element) const; inline bool Contains(Element* element) const;
// O(n)! // O(n)!
@@ -605,7 +605,7 @@ DOUBLY_LINKED_LIST_CLASS_NAME::RemoveTail()
// GetPrevious // GetPrevious
DOUBLY_LINKED_LIST_TEMPLATE_LIST DOUBLY_LINKED_LIST_TEMPLATE_LIST
Element* Element*
DOUBLY_LINKED_LIST_CLASS_NAME::GetPrevious(Element* element) const DOUBLY_LINKED_LIST_CLASS_NAME::GetPrevious(Element* element)
{ {
Element* result = NULL; Element* result = NULL;
if (element) if (element)
@@ -616,7 +616,7 @@ DOUBLY_LINKED_LIST_CLASS_NAME::GetPrevious(Element* element) const
// GetNext // GetNext
DOUBLY_LINKED_LIST_TEMPLATE_LIST DOUBLY_LINKED_LIST_TEMPLATE_LIST
Element* Element*
DOUBLY_LINKED_LIST_CLASS_NAME::GetNext(Element* element) const DOUBLY_LINKED_LIST_CLASS_NAME::GetNext(Element* element)
{ {
Element* result = NULL; Element* result = NULL;
if (element) if (element)
@@ -430,6 +430,13 @@ HIDParser::ReportAt(uint8 type, uint8 index)
size_t size_t
HIDParser::MaxReportSize() HIDParser::MaxReportSize()
{
return MaxReportSize(HID_REPORT_TYPE_ANY);
}
size_t
HIDParser::MaxReportSize(uint8 type)
{ {
size_t maxSize = 0; size_t maxSize = 0;
for (int32 i = 0; i < fReports.Count(); i++) { for (int32 i = 0; i < fReports.Count(); i++) {
@@ -437,6 +444,9 @@ HIDParser::MaxReportSize()
if (report == NULL) if (report == NULL)
continue; continue;
if (type != HID_REPORT_TYPE_ANY && report->Type() != type)
continue;
if (report->ReportSize() > maxSize) if (report->ReportSize() > maxSize)
maxSize = report->ReportSize(); maxSize = report->ReportSize();
} }
@@ -30,6 +30,7 @@ public:
uint8 CountReports(uint8 type); uint8 CountReports(uint8 type);
HIDReport * ReportAt(uint8 type, uint8 index); HIDReport * ReportAt(uint8 type, uint8 index);
size_t MaxReportSize(); size_t MaxReportSize();
size_t MaxReportSize(uint8 type);
HIDCollection * RootCollection() { return fRootCollection; }; HIDCollection * RootCollection() { return fRootCollection; };
@@ -110,7 +110,8 @@ KeyboardProtocolHandler::KeyboardProtocolHandler(HIDReport &inputReport,
#ifdef USB_KDL #ifdef USB_KDL
sDebugKeyboardPipe = fInputReport.Device()->InterruptPipe(); sDebugKeyboardPipe = fInputReport.Device()->InterruptPipe();
#endif #endif
sDebugKeyboardReportSize = fInputReport.Parser()->MaxReportSize(); sDebugKeyboardReportSize =
fInputReport.Parser()->MaxReportSize(HID_REPORT_TYPE_INPUT);
if (outputReport != NULL) if (outputReport != NULL)
sDebugKeyboardFound = true; sDebugKeyboardFound = true;
} }
@@ -794,7 +795,7 @@ KeyboardProtocolHandler::_ReadReport(bigtime_t timeout, uint32 *cookie)
= fInputReport.Device()->InterruptPipe(); = fInputReport.Device()->InterruptPipe();
#endif #endif
sDebugKeyboardReportSize sDebugKeyboardReportSize
= fInputReport.Parser()->MaxReportSize(); = fInputReport.Parser()->MaxReportSize(HID_REPORT_TYPE_INPUT);
#endif #endif
char letter = current[i] - 4 + 'a'; char letter = current[i] - 4 + 'a';
@@ -192,6 +192,8 @@ usb_hid_device_removed(void *cookie)
int32 parentCookie = (int32)(addr_t)cookie; int32 parentCookie = (int32)(addr_t)cookie;
TRACE("device_removed(%" B_PRId32 ")\n", parentCookie); TRACE("device_removed(%" B_PRId32 ")\n", parentCookie);
// removed device may contain multiple HID devices on multiple interfaces
// we must go through all published devices and remove all that belong to this parent
for (int32 i = 0; i < gDeviceList->CountDevices(); i++) { for (int32 i = 0; i < gDeviceList->CountDevices(); i++) {
ProtocolHandler *handler = (ProtocolHandler *)gDeviceList->DeviceAt(i); ProtocolHandler *handler = (ProtocolHandler *)gDeviceList->DeviceAt(i);
if (!handler) if (!handler)
@@ -202,12 +204,13 @@ usb_hid_device_removed(void *cookie)
continue; continue;
// remove all the handlers // remove all the handlers
for (uint32 i = 0;; i++) { for (uint32 j = 0;; j++) {
handler = device->ProtocolHandlerAt(i); handler = device->ProtocolHandlerAt(j);
if (handler == NULL) if (handler == NULL)
break; break;
gDeviceList->RemoveDevice(NULL, handler); gDeviceList->RemoveDevice(NULL, handler);
i--; // device count changed, adjust index
} }
// this handler's device belongs to the one removed // this handler's device belongs to the one removed
@@ -216,8 +219,6 @@ usb_hid_device_removed(void *cookie)
device->Removed(); device->Removed();
} else } else
delete device; delete device;
break;
} }
mutex_unlock(&sDriverLock); mutex_unlock(&sDriverLock);
@@ -181,7 +181,7 @@ HIDDevice::HIDDevice(usb_device device, const usb_configuration_info *config,
return; return;
} }
fTransferBufferSize = fParser.MaxReportSize(); fTransferBufferSize = fParser.MaxReportSize(HID_REPORT_TYPE_INPUT);
if (fTransferBufferSize == 0) { if (fTransferBufferSize == 0) {
TRACE_ALWAYS("report claims a report size of 0\n"); TRACE_ALWAYS("report claims a report size of 0\n");
return; return;
+28 -20
View File
@@ -2725,19 +2725,19 @@ ls( httpd_conn* hc )
int namlen; int namlen;
/*static*/int maxnames = 0; /*static*/int maxnames = 0;
int nnames; int nnames;
/*static*/char* names; /*static*/char* names = NULL;
/*static*/char** nameptrs; /*static*/char** nameptrs = NULL;
/*static*/char* name; /*static*/char* name = NULL;
/*static*/size_t maxname = 0; /*static*/size_t maxname = 0;
/*static*/char* rname; /*static*/char* rname = NULL;
/*static*/size_t maxrname = 0; /*static*/size_t maxrname = 0;
/*static*/char* encrname; /*static*/char* encrname = NULL;
/*static*/size_t maxencrname = 0; /*static*/size_t maxencrname = 0;
FILE* fp; FILE* fp;
int i/*, r*/; int i/*, r*/;
struct stat sb; struct stat sb;
struct stat lsb; struct stat lsb;
//char modestr[20]; char modestr[20];
char* linkprefix; char* linkprefix;
char lnk[MAXPATHLEN+1]; char lnk[MAXPATHLEN+1];
int linklen; int linklen;
@@ -2763,6 +2763,7 @@ ls( httpd_conn* hc )
send_mime( send_mime(
hc, 200, ok200title, "", "", "text/html; charset=%s", (off_t) -1, hc, 200, ok200title, "", "", "text/html; charset=%s", (off_t) -1,
hc->sb.st_mtime ); hc->sb.st_mtime );
httpd_write_response( hc );
} }
else if ( hc->method == METHOD_GET ) else if ( hc->method == METHOD_GET )
{ {
@@ -2856,7 +2857,8 @@ mode links bytes last-changed name\n\
if ( names == (char*) 0 || nameptrs == (char**) 0 ) if ( names == (char*) 0 || nameptrs == (char**) 0 )
{ {
// syslog( LOG_ERR, "out of memory reallocating directory names" ); // syslog( LOG_ERR, "out of memory reallocating directory names" );
exit( 1 ); closedir( dirp );
return -1;
} }
for ( i = 0; i < maxnames; ++i ) for ( i = 0; i < maxnames; ++i )
nameptrs[i] = &names[i * ( MAXPATHLEN + 1 )]; nameptrs[i] = &names[i * ( MAXPATHLEN + 1 )];
@@ -2909,13 +2911,13 @@ mode links bytes last-changed name\n\
/* Break down mode word. First the file type. */ /* Break down mode word. First the file type. */
switch ( lsb.st_mode & S_IFMT ) switch ( lsb.st_mode & S_IFMT )
{ {
/*case S_IFIFO: modestr[0] = 'p'; break; case S_IFIFO: modestr[0] = 'p'; break;
case S_IFCHR: modestr[0] = 'c'; break; case S_IFCHR: modestr[0] = 'c'; break;
case S_IFDIR: modestr[0] = 'd'; break; case S_IFDIR: modestr[0] = 'd'; break;
case S_IFBLK: modestr[0] = 'b'; break; case S_IFBLK: modestr[0] = 'b'; break;
case S_IFREG: modestr[0] = '-'; break; case S_IFREG: modestr[0] = '-'; break;
case S_IFSOCK: modestr[0] = 's'; break;*/ case S_IFSOCK: modestr[0] = 's'; break;
case S_IFLNK: //modestr[0] = 'l'; case S_IFLNK: modestr[0] = 'l';
linklen = readlink( name, lnk, sizeof(lnk) - 1 ); linklen = readlink( name, lnk, sizeof(lnk) - 1 );
if ( linklen != -1 ) if ( linklen != -1 )
{ {
@@ -2923,15 +2925,15 @@ mode links bytes last-changed name\n\
linkprefix = " -&gt; "; linkprefix = " -&gt; ";
} }
break; break;
//default: modestr[0] = '?'; break; default: modestr[0] = '?'; break;
} }
/* Now the world permissions. Owner and group permissions /* Now the world permissions. Owner and group permissions
** are not of interest to web clients. ** are not of interest to web clients.
*/ */
/*modestr[1] = ( lsb.st_mode & S_IROTH ) ? 'r' : '-'; modestr[1] = ( lsb.st_mode & S_IROTH ) ? 'r' : '-';
modestr[2] = ( lsb.st_mode & S_IWOTH ) ? 'w' : '-'; modestr[2] = ( lsb.st_mode & S_IWOTH ) ? 'w' : '-';
modestr[3] = ( lsb.st_mode & S_IXOTH ) ? 'x' : '-'; modestr[3] = ( lsb.st_mode & S_IXOTH ) ? 'x' : '-';
modestr[4] = '\0';*/ modestr[4] = '\0';
/* We also leave out the owner and group name, they are /* We also leave out the owner and group name, they are
** also not of interest to web clients. Plus if we're ** also not of interest to web clients. Plus if we're
@@ -2971,28 +2973,25 @@ mode links bytes last-changed name\n\
switch ( sb.st_mode & S_IFMT ) switch ( sb.st_mode & S_IFMT )
{ {
case S_IFDIR: fileclass = "/"; break; case S_IFDIR: fileclass = "/"; break;
//case S_IFSOCK: fileclass = "="; break; case S_IFSOCK: fileclass = "="; break;
//case S_IFLNK: fileclass = "@"; break; case S_IFLNK: fileclass = "@"; break;
default: default:
fileclass = "";//( sb.st_mode & S_IXOTH ) ? "*" : ""; fileclass = ( sb.st_mode & S_IXOTH ) ? "*" : "";
break; break;
} }
/* And print. */ /* And print. */
(void) fprintf( fp, (void) fprintf( fp,
"%s %3ld %10lld %s <a href=\"/%.500s%s\">%.80s</a>%s%s%s\n", "%s %3ld %10lld %s <a href=\"/%.500s%s\">%.80s</a>%s%s%s\n",
/*modestr,*/ (long) lsb.st_nlink, (long long) lsb.st_size, modestr, (long) lsb.st_nlink, (long long) lsb.st_size,
timestr, encrname, S_ISDIR(sb.st_mode) ? "/" : "", timestr, encrname, S_ISDIR(sb.st_mode) ? "/" : "",
nameptrs[i], linkprefix, lnk, fileclass ); nameptrs[i], linkprefix, lnk, fileclass );
} }
(void) fprintf( fp, " </pre>\n </body>\n</html>\n" ); (void) fprintf( fp, " </pre>\n </body>\n</html>\n" );
(void) fclose( fp ); (void) fclose( fp );
exit( 0 );
// } // }
/* Parent process. */
closedir( dirp );
// syslog( LOG_DEBUG, "spawned indexing process %d for directory '%.200s'", r, hc->expnfilename ); // syslog( LOG_DEBUG, "spawned indexing process %d for directory '%.200s'", r, hc->expnfilename );
#ifdef CGI_TIMELIMIT #ifdef CGI_TIMELIMIT
/* Schedule a kill for the child process, in case it runs too long */ /* Schedule a kill for the child process, in case it runs too long */
@@ -3006,6 +3005,12 @@ mode links bytes last-changed name\n\
hc->status = 200; hc->status = 200;
hc->bytes_sent = CGI_BYTECOUNT; hc->bytes_sent = CGI_BYTECOUNT;
hc->should_linger = 0; hc->should_linger = 0;
free(names);
free(nameptrs);
free(name);
free(rname);
free(encrname);
} }
else else
{ {
@@ -3730,6 +3735,7 @@ really_start_request( httpd_conn* hc, struct timeval* nowP )
free(indexname); free(indexname);
/* Nope, no index file, so it's an actual directory request. */ /* Nope, no index file, so it's an actual directory request. */
#ifdef GENERATE_INDEXES #ifdef GENERATE_INDEXES
if(hc->hs->do_list_dir){
/* Directories must be readable for indexing. */ /* Directories must be readable for indexing. */
if ( ! ( hc->sb.st_mode & S_IROTH ) ) if ( ! ( hc->sb.st_mode & S_IROTH ) )
{ {
@@ -3754,6 +3760,7 @@ free(indexname);
/* Ok, generate an index. */ /* Ok, generate an index. */
return ls( hc ); return ls( hc );
//#else /* GENERATE_INDEXES */ //#else /* GENERATE_INDEXES */
} else {
// syslog( // syslog(
// LOG_INFO, "%.80s URL \"%.80s\" tried to index a directory", // LOG_INFO, "%.80s URL \"%.80s\" tried to index a directory",
// httpd_ntoa( &hc->client_addr ), hc->encodedurl ); // httpd_ntoa( &hc->client_addr ), hc->encodedurl );
@@ -3762,6 +3769,7 @@ free(indexname);
ERROR_FORM( err403form, "The requested URL '%.80s' is a directory, and directory indexing is disabled on this server.\n" ), ERROR_FORM( err403form, "The requested URL '%.80s' is a directory, and directory indexing is disabled on this server.\n" ),
hc->encodedurl ); hc->encodedurl );
return -1; return -1;
}
#endif /* GENERATE_INDEXES */ #endif /* GENERATE_INDEXES */
got_one: ; got_one: ;
+8 -6
View File
@@ -3,9 +3,9 @@
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include <ControlLook.h> #include <ControlLook.h>
#include <algorithm>
#include <binary_compatibility/Interface.h> #include <binary_compatibility/Interface.h>
@@ -37,8 +37,13 @@ BControlLook::ComposeSpacing(float spacing)
return be_control_look->DefaultItemSpacing(); return be_control_look->DefaultItemSpacing();
case B_USE_SMALL_SPACING: case B_USE_SMALL_SPACING:
return ceilf(be_control_look->DefaultItemSpacing() * 0.7f); return ceilf(be_control_look->DefaultItemSpacing() * 0.7f);
case B_USE_CORNER_SPACING:
return ceilf(be_control_look->DefaultItemSpacing() * 1.273f);
case B_USE_BIG_SPACING: case B_USE_BIG_SPACING:
return ceilf(be_control_look->DefaultItemSpacing() * 1.3f); return ceilf(be_control_look->DefaultItemSpacing() * 1.8f);
case B_USE_BORDER_SPACING:
return std::max(1.0f, floorf(be_control_look->DefaultItemSpacing() / 11.0f));
} }
return spacing; return spacing;
@@ -86,10 +91,7 @@ BControlLook::GetInsets(frame_type frameType, background_type backgroundType,
float float
BControlLook::GetScrollBarWidth(orientation orientation) BControlLook::GetScrollBarWidth(orientation orientation)
{ {
// this matches HaikuControlLook.cpp currently return ComposeSpacing(B_USE_CORNER_SPACING);
if (be_plain_font->Size() <= 12.0f)
return 14.0f;
return be_plain_font->Size() / 12.0f * 14.0f;
} }
-11
View File
@@ -3840,17 +3840,6 @@ HaikuControlLook::_FillGlossyGradient(BView* view, const BRect& rect,
} }
float
HaikuControlLook::GetScrollBarWidth(orientation orientation)
{
// HaikuControlLook does not make a distinction between the
// width and height of the scrollbar, but other controllooks may
if (be_plain_font->Size() <= 12.0f)
return 14.0f;
return be_plain_font->Size() / 12.0f * 14.0f;
}
void void
HaikuControlLook::_MakeGradient(BGradientLinear& gradient, const BRect& rect, HaikuControlLook::_MakeGradient(BGradientLinear& gradient, const BRect& rect,
const rgb_color& base, float topTint, float bottomTint, const rgb_color& base, float topTint, float bottomTint,
+1 -1
View File
@@ -224,7 +224,7 @@ GenerateThumbnailJob::Execute()
thumbnailWritten = (status == B_OK); thumbnailWritten = (status == B_OK);
// write thumbnail creation time into an attribute // write thumbnail creation time into an attribute
bigtime_t created = system_time(); bigtime_t created = real_time_clock_usecs();
fFile->WriteAttr(kAttrThumbnailCreationTime, B_TIME_TYPE, fFile->WriteAttr(kAttrThumbnailCreationTime, B_TIME_TYPE,
0, &created, sizeof(bigtime_t)); 0, &created, sizeof(bigtime_t));
} }
+3 -4
View File
@@ -210,10 +210,9 @@ MountVisitor::_WasPreviouslyMounted(const BPath& path,
// We only check the legacy config data here; the current method // We only check the legacy config data here; the current method
// is implemented in ArchivedVolumeVisitor -- this can be removed // is implemented in ArchivedVolumeVisitor -- this can be removed
// some day. // some day.
const char* volumeName = NULL; BString volumeName;
if (partition->ContentName() == NULL if (fPrevious.FindString(path.Path(), &volumeName) != B_OK
|| fPrevious.FindString(path.Path(), &volumeName) != B_OK || volumeName != partition->ContentName())
|| strcmp(volumeName, partition->ContentName()) != 0)
return false; return false;
return true; return true;
+18 -18
View File
@@ -81,7 +81,7 @@ public:
pathString = path.Path(); pathString = path.Path();
else else
pathString = strerror(error); pathString = strerror(error);
printf("device %ld: \"%s\"\n", device->ID(), pathString); printf("device %" B_PRId32 ": \"%s\"\n", device->ID(), pathString);
printf(" has media: %d\n", device->HasMedia()); printf(" has media: %d\n", device->HasMedia());
printf(" removable: %d\n", device->IsRemovableMedia()); printf(" removable: %d\n", device->IsRemovableMedia());
printf(" read only: %d\n", device->IsReadOnlyMedia()); printf(" read only: %d\n", device->IsReadOnlyMedia());
@@ -103,14 +103,14 @@ public:
pathString = path.Path(); pathString = path.Path();
else else
pathString = strerror(error); pathString = strerror(error);
printf("%spartition %ld: \"%s\"\n", prefix, partition->ID(), printf("%spartition %" B_PRId32 ": \"%s\"\n", prefix, partition->ID(),
pathString); pathString);
} }
printf("%s offset: %lld\n", prefix, partition->Offset()); printf("%s offset: %" B_PRId64 "\n", prefix, partition->Offset());
printf("%s size: %lld\n", prefix, partition->Size()); printf("%s size: %" B_PRId64 "\n", prefix, partition->Size());
printf("%s block size: %lu\n", prefix, partition->BlockSize()); printf("%s block size: %" B_PRIu32 "\n", prefix, partition->BlockSize());
printf("%s index: %ld\n", prefix, partition->Index()); printf("%s index: %" B_PRId32 "\n", prefix, partition->Index());
printf("%s status: %lu\n", prefix, partition->Status()); printf("%s status: %" B_PRIu32 "\n", prefix, partition->Status());
printf("%s file system: %d\n", prefix, printf("%s file system: %d\n", prefix,
partition->ContainsFileSystem()); partition->ContainsFileSystem());
printf("%s part. system: %d\n", prefix, printf("%s part. system: %d\n", prefix,
@@ -118,10 +118,10 @@ public:
printf("%s device: %d\n", prefix, partition->IsDevice()); printf("%s device: %d\n", prefix, partition->IsDevice());
printf("%s read only: %d\n", prefix, partition->IsReadOnly()); printf("%s read only: %d\n", prefix, partition->IsReadOnly());
printf("%s mounted: %d\n", prefix, partition->IsMounted()); printf("%s mounted: %d\n", prefix, partition->IsMounted());
printf("%s flags: %lx\n", prefix, partition->Flags()); printf("%s flags: %" B_PRIx32 "\n", prefix, partition->Flags());
printf("%s name: \"%s\"\n", prefix, partition->Name()); printf("%s name: \"%s\"\n", prefix, partition->Name());
printf("%s content name: \"%s\"\n", prefix, printf("%s content name: \"%s\"\n", prefix,
partition->ContentName()); partition->ContentName().String());
printf("%s type: \"%s\"\n", prefix, partition->Type()); printf("%s type: \"%s\"\n", prefix, partition->Type());
printf("%s content type: \"%s\"\n", prefix, printf("%s content type: \"%s\"\n", prefix,
partition->ContentType()); partition->ContentType());
@@ -156,7 +156,7 @@ print_partition(BPartition* partition, int level, int index)
2 * max_c(3 - level, 0), "", 2 * max_c(3 - level, 0), "",
offset.String(), size.String(), offset.String(), size.String(),
(partition->ContentType() ? partition->ContentType() : "-"), (partition->ContentType() ? partition->ContentType() : "-"),
(partition->ContentName() ? partition->ContentName() : "")); partition->ContentName().String());
} }
@@ -198,7 +198,7 @@ public:
readWrite = ""; readWrite = "";
} }
printf("\ndevice %ld: \"%s\": %s%s\n\n", device->ID(), pathString, printf("\ndevice %" B_PRId32 ": \"%s\": %s%s\n\n", device->ID(), pathString,
media, readWrite); media, readWrite);
print_partition_table_header(); print_partition_table_header();
@@ -360,7 +360,7 @@ private:
// print the available disk systems // print the available disk systems
printf("\ndisk systems that can initialize the selected partition:\n"); printf("\ndisk systems that can initialize the selected partition:\n");
for (int32 i = 0; BDiskSystem* diskSystem = diskSystems.ItemAt(i); i++) for (int32 i = 0; BDiskSystem* diskSystem = diskSystems.ItemAt(i); i++)
printf("%2ld %s\n", i, diskSystem->PrettyName()); printf("%2" B_PRId32 " %s\n", i, diskSystem->PrettyName());
printf("\n"); printf("\n");
@@ -378,7 +378,7 @@ private:
BString parameters; BString parameters;
while (true) { while (true) {
// let the user enter name and parameters // let the user enter name and parameters
if (supportsName && !_ReadLine("partition name: ", name) if ((supportsName && !_ReadLine("partition name: ", name))
|| !_ReadLine("partition parameters: ", parameters)) { || !_ReadLine("partition parameters: ", parameters)) {
return; return;
} }
@@ -497,7 +497,7 @@ private:
// list them // list them
printf("Possible partition types:\n"); printf("Possible partition types:\n");
for (int32 i = 0; i < supportedTypesCount; i++) for (int32 i = 0; i < supportedTypesCount; i++)
printf("%2ld %s\n", i, supportedTypes.ItemAt(i)->String()); printf("%2" B_PRId32 " %s\n", i, supportedTypes.ItemAt(i)->String());
if (!_ReadNumber("supported type index [-1 to abort]: ", 0, if (!_ReadNumber("supported type index [-1 to abort]: ", 0,
supportedTypesCount - 1, -1, "invalid index", typeIndex)) { supportedTypesCount - 1, -1, "invalid index", typeIndex)) {
@@ -516,7 +516,7 @@ private:
BString offset, size; BString offset, size;
get_size_string(_offset, offset); get_size_string(_offset, offset);
get_size_string(_size, size); get_size_string(_size, size);
printf("%2ld start: %8s, size: %8s\n", i, offset.String(), printf("%2" B_PRId32 " start: %8s, size: %8s\n", i, offset.String(),
size.String()); size.String());
} }
@@ -594,7 +594,7 @@ private:
get_size_string(validatedStart, startString); get_size_string(validatedStart, startString);
get_size_string(validatedSize, sizeString); get_size_string(validatedSize, sizeString);
printf("The disk system adjusted the partition start and " printf("The disk system adjusted the partition start and "
"size to %lld (%s) and %lld (%s).\n", "size to %" B_PRIdOFF " (%s) and %" B_PRIdOFF " (%s).\n",
validatedStart, startString.String(), validatedSize, validatedStart, startString.String(), validatedSize,
sizeString.String()); sizeString.String());
start = validatedStart; start = validatedStart;
@@ -713,7 +713,7 @@ private:
return false; return false;
char buffer[256]; char buffer[256];
if (sscanf(line.String(), "%lld%s", &number, buffer) == 1) if (sscanf(line.String(), "%" B_PRId64 "%s", &number, buffer) == 1)
return true; return true;
printf("invalid input\n"); printf("invalid input\n");
@@ -729,7 +729,7 @@ private:
return false; return false;
char buffer[256]; char buffer[256];
if (sscanf(line.String(), "%lld%s", &number, buffer) != 1) { if (sscanf(line.String(), "%" B_PRId64 "%s", &number, buffer) != 1) {
printf("invalid input\n"); printf("invalid input\n");
continue; continue;
} }