Solaris compatibility fixes.

This commit is contained in:
rakshasa
2012-03-26 23:18:10 +09:00
parent bb75f06c6d
commit d1ff1fe77c
6 changed files with 39 additions and 4 deletions
+3 -2
View File
@@ -36,10 +36,11 @@
#include "config.h" #include "config.h"
#include <ncurses.h>
#include "input_event.h" #include "input_event.h"
//ncurses.h must be included last since sys/mman.h on Solaris munges ERR.
#include <ncurses.h>
namespace input { namespace input {
void void
+11 -1
View File
@@ -42,7 +42,13 @@
#include <rak/path.h> #include <rak/path.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/dir.h>
#ifdef __sun__
#include <dirent.h>
#include <sys/stat.h>
#else
#include <sys/dir.h>
#endif
#include "path_input.h" #include "path_input.h"
@@ -72,7 +78,11 @@ PathInput::pressed(int key) {
struct _transform_filename { struct _transform_filename {
void operator () (utils::directory_entry& entry) { void operator () (utils::directory_entry& entry) {
#ifdef __sun__
if (entry.d_type & S_IFDIR)
#else
if (entry.d_type == DT_DIR) if (entry.d_type == DT_DIR)
#endif
entry.d_name += '/'; entry.d_name += '/';
} }
}; };
+5
View File
@@ -88,7 +88,12 @@ SCgi::open_named(const std::string& filename) {
char buffer[sizeof(sockaddr_un) + filename.size()]; char buffer[sizeof(sockaddr_un) + filename.size()];
sockaddr_un* sa = reinterpret_cast<sockaddr_un*>(buffer); sockaddr_un* sa = reinterpret_cast<sockaddr_un*>(buffer);
#ifdef __sun__
sa->sun_family = AF_UNIX;
#else
sa->sun_family = AF_LOCAL; sa->sun_family = AF_LOCAL;
#endif
std::memcpy(sa->sun_path, filename.c_str(), filename.size() + 1); std::memcpy(sa->sun_path, filename.c_str(), filename.size() + 1);
if (!get_fd().open_local()) if (!get_fd().open_local())
+5
View File
@@ -41,6 +41,11 @@
#include "rak/error_number.h" #include "rak/error_number.h"
#include "signal_handler.h" #include "signal_handler.h"
#ifdef __sun__
#include <iso/signal_iso.h>
//extern "C" void (*signal (int sig, void (*disp)(int)))(int);
#endif
SignalHandler::Slot SignalHandler::m_handlers[HIGHEST_SIGNAL]; SignalHandler::Slot SignalHandler::m_handlers[HIGHEST_SIGNAL];
void void
+14
View File
@@ -42,6 +42,10 @@
#include <rak/path.h> #include <rak/path.h>
#include <torrent/exceptions.h> #include <torrent/exceptions.h>
#ifdef __sun__
#include <sys/stat.h>
#endif
#include "directory.h" #include "directory.h"
namespace utils { namespace utils {
@@ -69,6 +73,9 @@ Directory::update(int flags) {
return false; return false;
struct dirent* entry; struct dirent* entry;
#ifdef __sun__
struct stat s;
#endif
while ((entry = readdir(d)) != NULL) { while ((entry = readdir(d)) != NULL) {
if ((flags & update_hide_dot) && entry->d_name[0] == '.') if ((flags & update_hide_dot) && entry->d_name[0] == '.')
@@ -76,9 +83,16 @@ Directory::update(int flags) {
iterator itr = base_type::insert(end(), value_type()); iterator itr = base_type::insert(end(), value_type());
#ifdef __sun__
stat(entry->d_name, &s);
itr->d_fileno = entry->d_ino;
itr->d_reclen = 0;
itr->d_type = s.st_mode;
#else
itr->d_fileno = entry->d_fileno; itr->d_fileno = entry->d_fileno;
itr->d_reclen = entry->d_reclen; itr->d_reclen = entry->d_reclen;
itr->d_type = entry->d_type; itr->d_type = entry->d_type;
#endif
#ifdef DIRENT_NAMLEN_EXISTS_FOOBAR #ifdef DIRENT_NAMLEN_EXISTS_FOOBAR
itr->d_name = std::string(entry->d_name, entry->d_name + entry->d_namlen); itr->d_name = std::string(entry->d_name, entry->d_name + entry->d_namlen);
+1 -1
View File
@@ -49,7 +49,7 @@ struct directory_entry {
// The name and types should match POSIX. // The name and types should match POSIX.
uint32_t d_fileno; uint32_t d_fileno;
uint32_t d_reclen; uint32_t d_reclen; //Not used. Messes with Solaris.
uint8_t d_type; uint8_t d_type;
std::string d_name; std::string d_name;