* Made libnetapi a separate library again.
* The built-in services are no longer added as resource to libnetwork, but as attribute. This removes the libbe dependency. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25485 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -64,9 +64,9 @@ BEOS_DEMOS = BSnow Chart Clock $(X86_ONLY)Cortex FontDemo
|
|||||||
Playground Pulse Sudoku
|
Playground Pulse Sudoku
|
||||||
;
|
;
|
||||||
BEOS_SYSTEM_LIBS = libbe.so $(HAIKU_LIBSTDC++) libmedia.so libtracker.so
|
BEOS_SYSTEM_LIBS = libbe.so $(HAIKU_LIBSTDC++) libmedia.so libtracker.so
|
||||||
libtranslation.so libnetwork.so libdebug.so libbsd.so libmail.so
|
libtranslation.so libnetapi.so libnetwork.so libdebug.so libbsd.so
|
||||||
libtextencoding.so libz.so libfreetype.so libpng.so libmidi.so libmidi2.so
|
libmail.so libtextencoding.so libz.so libfreetype.so libpng.so libmidi.so
|
||||||
libdevice.so libgame.so libscreensaver.so <revisioned>libroot.so
|
libmidi2.so libdevice.so libgame.so libscreensaver.so <revisioned>libroot.so
|
||||||
$(X86_ONLY)libGL.so libfluidsynth.so liblpsolve55.so liblinprog.so libalm.so
|
$(X86_ONLY)libGL.so libfluidsynth.so liblpsolve55.so liblinprog.so libalm.so
|
||||||
libilmimf.so
|
libilmimf.so
|
||||||
;
|
;
|
||||||
@@ -190,7 +190,7 @@ AddFilesToHaikuImage beos system lib : $(BEOS_SYSTEM_LIBS) ;
|
|||||||
|
|
||||||
# libnetwork.so replaces quite a few libraries
|
# libnetwork.so replaces quite a few libraries
|
||||||
BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES
|
BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES
|
||||||
= libsocket.so libbind.so libnet.so libnetapi.so libbnetapi.so ;
|
= libsocket.so libbind.so libnet.so ;
|
||||||
|
|
||||||
local lib ;
|
local lib ;
|
||||||
for lib in $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) {
|
for lib in $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) {
|
||||||
|
|||||||
@@ -3,18 +3,12 @@ SubDir HAIKU_TOP src kits network ;
|
|||||||
UsePrivateHeaders libroot net shared ;
|
UsePrivateHeaders libroot net shared ;
|
||||||
UsePrivateKernelHeaders ;
|
UsePrivateKernelHeaders ;
|
||||||
|
|
||||||
local services = [ FGristFiles services ] ;
|
|
||||||
SEARCH on $(services) = [ FDirName $(SUBDIR) dns defaults ] ;
|
|
||||||
AddFileDataResource libnetwork.so : CSTR:201:services : $(services) ;
|
|
||||||
|
|
||||||
SharedLibrary libnetwork.so :
|
SharedLibrary libnetwork.so :
|
||||||
init.cpp
|
init.cpp
|
||||||
interfaces.cpp
|
interfaces.cpp
|
||||||
socket.cpp
|
socket.cpp
|
||||||
r5_compatibility.cpp
|
r5_compatibility.cpp
|
||||||
:
|
:
|
||||||
<libnetwork_netapi>netapi.o
|
|
||||||
|
|
||||||
<libnetwork_dns>dns_dst.o
|
<libnetwork_dns>dns_dst.o
|
||||||
<libnetwork_dns>dns_inet.o
|
<libnetwork_dns>dns_inet.o
|
||||||
<libnetwork_dns>dns_irs.o
|
<libnetwork_dns>dns_irs.o
|
||||||
@@ -22,9 +16,11 @@ SharedLibrary libnetwork.so :
|
|||||||
<libnetwork_dns>dns_nameser.o
|
<libnetwork_dns>dns_nameser.o
|
||||||
<libnetwork_dns>dns_resolv.o
|
<libnetwork_dns>dns_resolv.o
|
||||||
<libnetwork_dns>dns_private.o
|
<libnetwork_dns>dns_private.o
|
||||||
|
|
||||||
be
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
local services = [ FGristFiles services ] ;
|
||||||
|
SEARCH on $(services) = [ FDirName $(SUBDIR) dns defaults ] ;
|
||||||
|
AddFileDataAttribute libnetwork.so : services : string : $(services) ;
|
||||||
|
|
||||||
SubInclude HAIKU_TOP src kits network dns ;
|
SubInclude HAIKU_TOP src kits network dns ;
|
||||||
SubInclude HAIKU_TOP src kits network libnetapi ;
|
SubInclude HAIKU_TOP src kits network libnetapi ;
|
||||||
|
|||||||
@@ -63,10 +63,6 @@
|
|||||||
|
|
||||||
#include "port_after.h"
|
#include "port_after.h"
|
||||||
|
|
||||||
#include <File.h>
|
|
||||||
#include <Resources.h>
|
|
||||||
#include <TypeConstants.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@@ -80,15 +76,16 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <fs_attr.h>
|
||||||
|
#include <image.h>
|
||||||
|
#include <TypeConstants.h>
|
||||||
|
|
||||||
|
|
||||||
#define IRS_SV_MAXALIASES 35
|
#define IRS_SV_MAXALIASES 35
|
||||||
|
|
||||||
struct service_private {
|
struct service_private {
|
||||||
FILE* file;
|
FILE* file;
|
||||||
char line[BUFSIZ+1];
|
char line[BUFSIZ+1];
|
||||||
char* resource_file;
|
|
||||||
char* resource_end;
|
|
||||||
char* resource_line;
|
|
||||||
struct servent servent;
|
struct servent servent;
|
||||||
char* aliases[IRS_SV_MAXALIASES];
|
char* aliases[IRS_SV_MAXALIASES];
|
||||||
};
|
};
|
||||||
@@ -115,26 +112,9 @@ find_own_image(image_info* _info)
|
|||||||
char *
|
char *
|
||||||
get_next_line(struct service_private* service)
|
get_next_line(struct service_private* service)
|
||||||
{
|
{
|
||||||
if (service->file != NULL)
|
if (service->file == NULL)
|
||||||
return fgets(service->line, BUFSIZ, service->file);
|
|
||||||
if (service->resource_file == NULL)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
return fgets(service->line, BUFSIZ, service->file);
|
||||||
char* line = service->resource_line;
|
|
||||||
while (line < service->resource_end
|
|
||||||
&& line[0]
|
|
||||||
&& line[0] != '\n')
|
|
||||||
line++;
|
|
||||||
|
|
||||||
if (service->resource_line >= service->resource_end
|
|
||||||
|| service->resource_line == line)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
strlcpy(service->line, service->resource_line,
|
|
||||||
min_c(line + 1 - service->resource_line, BUFSIZ));
|
|
||||||
service->resource_line = line + 1;
|
|
||||||
|
|
||||||
return service->line;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -149,7 +129,6 @@ sv_close(struct irs_sv *sv)
|
|||||||
if (service->file)
|
if (service->file)
|
||||||
fclose(service->file);
|
fclose(service->file);
|
||||||
|
|
||||||
free(service->resource_file);
|
|
||||||
memput(service, sizeof *service);
|
memput(service, sizeof *service);
|
||||||
memput(sv, sizeof *sv);
|
memput(sv, sizeof *sv);
|
||||||
}
|
}
|
||||||
@@ -168,44 +147,55 @@ sv_rewind(struct irs_sv *sv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((service->file = fopen(_PATH_SERVICES, "r")) != NULL) {
|
if ((service->file = fopen(_PATH_SERVICES, "r")) != NULL) {
|
||||||
if (fcntl(fileno(service->file), F_SETFD, 1) == 0)
|
if (fcntl(fileno(service->file), F_SETFD, FD_CLOEXEC) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fclose(service->file);
|
fclose(service->file);
|
||||||
service->file = NULL;
|
service->file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// opening the standard file has file has failed, use resources
|
// opening the standard file has file has failed, use the attribute
|
||||||
|
|
||||||
if (service->resource_file != NULL) {
|
// find our library image
|
||||||
service->resource_line = service->resource_file;
|
addr_t addressInImage = (addr_t)&sv_rewind;
|
||||||
|
const char* path = NULL;
|
||||||
|
image_info info;
|
||||||
|
int32 cookie;
|
||||||
|
|
||||||
|
while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
|
||||||
|
if (addressInImage >= (addr_t)info.text
|
||||||
|
&& addressInImage < (addr_t)info.text + info.text_size) {
|
||||||
|
path = info.name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// open the library
|
||||||
|
int libraryFD = open(path, O_RDONLY);
|
||||||
|
if (libraryFD < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// open the attribute
|
||||||
|
int attrFD = fs_open_attr(libraryFD, "services", B_STRING_TYPE, O_RDONLY);
|
||||||
|
close(libraryFD);
|
||||||
|
if (attrFD < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// attach it to a FILE
|
||||||
|
service->file = fdopen(attrFD, "r");
|
||||||
|
if (service->file == NULL) {
|
||||||
|
close(attrFD);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
image_info info;
|
if (fcntl(fileno(service->file), F_SETFD, FD_CLOEXEC) == 0)
|
||||||
if (find_own_image(&info) < B_OK)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BFile file;
|
fclose(service->file);
|
||||||
if (file.SetTo(info.name, B_READ_ONLY) < B_OK)
|
service->file = NULL;
|
||||||
return;
|
|
||||||
|
|
||||||
BResources resources(&file);
|
|
||||||
if (resources.InitCheck() < B_OK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
size_t size;
|
|
||||||
const void* data = resources.LoadResource(B_STRING_TYPE, "services", &size);
|
|
||||||
if (data == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
service->resource_file = (char *)malloc(size);
|
|
||||||
if (service->resource_file == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
memcpy(service->resource_file, data, size);
|
|
||||||
service->resource_line = service->resource_file;
|
|
||||||
service->resource_end = service->resource_file + size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -215,10 +205,10 @@ sv_next(struct irs_sv *sv)
|
|||||||
struct service_private *service = (struct service_private *)sv->private_data;
|
struct service_private *service = (struct service_private *)sv->private_data;
|
||||||
char *p, *cp, **q;
|
char *p, *cp, **q;
|
||||||
|
|
||||||
if (service->file == NULL && service->resource_file == NULL)
|
if (service->file == NULL)
|
||||||
sv_rewind(sv);
|
sv_rewind(sv);
|
||||||
|
|
||||||
if (service->file == NULL && service->resource_file == NULL)
|
if (service->file == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
again:
|
again:
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ if $(TARGET_PLATFORM) != haiku {
|
|||||||
# boot home config lib ;
|
# boot home config lib ;
|
||||||
boot home Desktop haiku-networkingkit lib ;
|
boot home Desktop haiku-networkingkit lib ;
|
||||||
} else {
|
} else {
|
||||||
MergeObject <libnetwork_netapi>netapi.o :
|
SharedLibrary libnetapi.so :
|
||||||
$(netapi_sources)
|
$(netapi_sources)
|
||||||
|
: be $(TARGET_NETWORK_LIBS)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user