Clean up libpsl-native headers

This commit is contained in:
Andrew Schwartzmeyer 2016-09-28 18:17:03 -07:00
parent 001f6ecf72
commit b0cd7ba3dc
30 changed files with 70 additions and 41 deletions

View file

@ -2,10 +2,11 @@
//! @author George FLeming <v-geflem@microsoft.com> //! @author George FLeming <v-geflem@microsoft.com>
//! @brief create new hard link //! @brief create new hard link
#include "createhardlink.h"
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <string> #include <string>
#include "createhardlink.h"
//! @brief Createhardlink create new symbolic link //! @brief Createhardlink create new symbolic link
//! //!

View file

@ -2,10 +2,11 @@
//! @author George FLeming <v-geflem@microsoft.com> //! @author George FLeming <v-geflem@microsoft.com>
//! @brief create new symbolic link //! @brief create new symbolic link
#include "createsymlink.h"
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <string> #include <string>
#include "createsymlink.h"
//! @brief Createsymlink create new symbolic link //! @brief Createsymlink create new symbolic link
//! //!

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "pal.h" #include "pal.h"
#include <stdbool.h> #include <stdbool.h>
PAL_BEGIN_EXTERNC PAL_BEGIN_EXTERNC

View file

@ -2,12 +2,13 @@
//! @author George FLeming <v-geflem@microsoft.com> //! @author George FLeming <v-geflem@microsoft.com>
//! @brief returns whether a path is a symbolic link //! @brief returns whether a path is a symbolic link
#include "followsymlink.h"
#include "issymlink.h"
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <string> #include <string>
#include <iostream> #include <iostream>
#include "followsymlink.h"
#include "issymlink.h"
//! @brief Followsymlink determines target path of a sym link //! @brief Followsymlink determines target path of a sym link
//! //!

View file

@ -2,10 +2,11 @@
//! @author George Fleming <v-geflem@microsoft> //! @author George Fleming <v-geflem@microsoft>
//! @brief Implements GetComputerName Win32 API //! @brief Implements GetComputerName Win32 API
#include "getcomputername.h"
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <string> #include <string>
#include "getcomputername.h"
//! @brief GetComputerName retrieves the name of the host associated with //! @brief GetComputerName retrieves the name of the host associated with
//! the current thread. //! the current thread.

View file

@ -1,9 +1,8 @@
#include "getcurrentprocessorid.h" #include "getcurrentprocessorid.h"
#include <unistd.h> #include <unistd.h>
int32_t GetCurrentProcessId() pid_t GetCurrentProcessId()
{ {
pid_t pid = getpid(); return getpid();
return static_cast<int32_t>(pid);
} }

View file

@ -1,10 +1,11 @@
#pragma once #pragma once
#include "pal.h" #include "pal.h"
#include <sys/types.h>
PAL_BEGIN_EXTERNC PAL_BEGIN_EXTERNC
int32_t GetCurrentProcessId(); pid_t GetCurrentProcessId();
PAL_END_EXTERNC PAL_END_EXTERNC

View file

@ -1,9 +1,9 @@
#include "getcurrentthreadid.h" #include "getcurrentthreadid.h"
#include <unistd.h> #include <unistd.h>
#include <pthread.h> #include <pthread.h>
HANDLE GetCurrentThreadId() pid_t GetCurrentThreadId()
{ {
pid_t tid = pthread_self(); return pthread_self();
return reinterpret_cast<HANDLE>(tid);
} }

View file

@ -2,9 +2,11 @@
#include "pal.h" #include "pal.h"
#include <sys/types.h>
PAL_BEGIN_EXTERNC PAL_BEGIN_EXTERNC
HANDLE GetCurrentThreadId(); pid_t GetCurrentThreadId();
PAL_END_EXTERNC PAL_END_EXTERNC

View file

@ -2,15 +2,16 @@
//! @author Andrew Schwartzmeyer <andschwa@microsoft.com> //! @author Andrew Schwartzmeyer <andschwa@microsoft.com>
//! @brief returns the owner of a file //! @brief returns the owner of a file
#include "getstat.h"
#include "getpwuid.h"
#include "getfileowner.h"
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <pwd.h> #include <pwd.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "getstat.h"
#include "getpwuid.h"
#include "getfileowner.h"
//! @brief GetFileOwner returns the owner of a file //! @brief GetFileOwner returns the owner of a file
//! //!

View file

@ -2,12 +2,13 @@
//! @author George Fleming <v-geflem@microsoft.com> //! @author George Fleming <v-geflem@microsoft.com>
//! @brief Implements GetFullyQualifiedName on Linux //! @brief Implements GetFullyQualifiedName on Linux
#include "getcomputername.h"
#include "getfullyqualifiedname.h"
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netdb.h> #include <netdb.h>
#include "getcomputername.h"
#include "getfullyqualifiedname.h"
//! @brief GetFullyQualifiedName retrieves the fully qualified dns name of the host //! @brief GetFullyQualifiedName retrieves the fully qualified dns name of the host
//! //!

View file

@ -2,13 +2,14 @@
//! @author George FLeming <v-geflem@microsoft.com> //! @author George FLeming <v-geflem@microsoft.com>
//! @brief Retrieve link count of a file //! @brief Retrieve link count of a file
#include "getlinkcount.h"
#include <errno.h> #include <errno.h>
#include <locale.h> #include <locale.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <string> #include <string>
#include "getlinkcount.h"
//! @brief GetLinkCount retrieves the file link count (number of hard links) //! @brief GetLinkCount retrieves the file link count (number of hard links)
//! for the given file //! for the given file

View file

@ -2,13 +2,14 @@
//! @author Andrew Schwartzmeyer <andschwa@microsoft.com> //! @author Andrew Schwartzmeyer <andschwa@microsoft.com>
//! @brief returns the lstat of a file //! @brief returns the lstat of a file
#include "getlstat.h"
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <pwd.h> #include <pwd.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "getlstat.h"
//! @brief GetLStat returns the lstat of a file. This simply delegates to the //! @brief GetLStat returns the lstat of a file. This simply delegates to the
//! lstat() system call and maps errno to the expected values for GetLastError. //! lstat() system call and maps errno to the expected values for GetLastError.

View file

@ -1,8 +1,9 @@
#pragma once #pragma once
#include <sys/stat.h>
#include "pal.h" #include "pal.h"
#include <sys/stat.h>
PAL_BEGIN_EXTERNC PAL_BEGIN_EXTERNC
int32_t GetLStat(const char* path, struct stat* buf); int32_t GetLStat(const char* path, struct stat* buf);

View file

@ -2,13 +2,14 @@
//! @author Andrew Schwartzmeyer <andschwa@microsoft.com> //! @author Andrew Schwartzmeyer <andschwa@microsoft.com>
//! @brief returns the username for a uid //! @brief returns the username for a uid
#include "getpwuid.h"
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <pwd.h> #include <pwd.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "getpwuid.h"
//! @brief GetPwUid returns the username for a uid //! @brief GetPwUid returns the username for a uid
//! //!

View file

@ -1,8 +1,9 @@
#pragma once #pragma once
#include <sys/types.h>
#include "pal.h" #include "pal.h"
#include <sys/types.h>
PAL_BEGIN_EXTERNC PAL_BEGIN_EXTERNC
char* GetPwUid(uid_t uid); char* GetPwUid(uid_t uid);

View file

@ -2,13 +2,14 @@
//! @author Andrew Schwartzmeyer <andschwa@microsoft.com> //! @author Andrew Schwartzmeyer <andschwa@microsoft.com>
//! @brief returns the stat of a file //! @brief returns the stat of a file
#include "getstat.h"
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <pwd.h> #include <pwd.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "getstat.h"
//! @brief GetStat returns the stat of a file. This simply delegates to the //! @brief GetStat returns the stat of a file. This simply delegates to the
//! stat() system call and maps errno to the expected values for GetLastError. //! stat() system call and maps errno to the expected values for GetLastError.

View file

@ -1,8 +1,9 @@
#pragma once #pragma once
#include <sys/stat.h>
#include "pal.h" #include "pal.h"
#include <sys/stat.h>
PAL_BEGIN_EXTERNC PAL_BEGIN_EXTERNC
int32_t GetStat(const char* path, struct stat* buf); int32_t GetStat(const char* path, struct stat* buf);

View file

@ -1,12 +1,13 @@
#include <string>
#include <sstream>
#include <errno.h>
#include <sys/sysctl.h>
#include "pal.h" #include "pal.h"
#include "getfileowner.h" #include "getfileowner.h"
#include "getpwuid.h" #include "getpwuid.h"
#include "getuserfrompid.h" #include "getuserfrompid.h"
#include <string>
#include <sstream>
#include <errno.h>
#include <sys/sysctl.h>
char* GetUserFromPid(pid_t pid) char* GetUserFromPid(pid_t pid)
{ {

View file

@ -2,6 +2,8 @@
#include "pal.h" #include "pal.h"
#include <sys/types.h>
PAL_BEGIN_EXTERNC PAL_BEGIN_EXTERNC
char* GetUserFromPid(pid_t pid); char* GetUserFromPid(pid_t pid);

View file

@ -2,10 +2,11 @@
//! @author Andrew Schwartzmeyer <andschwa@microsoft.com> //! @author Andrew Schwartzmeyer <andschwa@microsoft.com>
//! @brief Implements GetUserName for Linux //! @brief Implements GetUserName for Linux
#include <unistd.h>
#include "getpwuid.h" #include "getpwuid.h"
#include "getusername.h" #include "getusername.h"
#include <unistd.h>
//! @brief GetUserName retrieves the name of the user associated with //! @brief GetUserName retrieves the name of the user associated with
//! the current thread. //! the current thread.
//! //!

View file

@ -2,16 +2,17 @@
//! @author Andrew Schwartzmeyer <andschwa@microsoft.com> //! @author Andrew Schwartzmeyer <andschwa@microsoft.com>
//! @brief returns if the path is a directory //! @brief returns if the path is a directory
#include "getstat.h"
#include "getpwuid.h"
#include "getfileowner.h"
#include "isdirectory.h"
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <pwd.h> #include <pwd.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "getstat.h"
#include "getpwuid.h"
#include "getfileowner.h"
#include "isdirectory.h"
//! @brief returns if the path is a directory; uses stat and so follows symlinks //! @brief returns if the path is a directory; uses stat and so follows symlinks
//! //!

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "pal.h" #include "pal.h"
#include <stdbool.h> #include <stdbool.h>
PAL_BEGIN_EXTERNC PAL_BEGIN_EXTERNC

View file

@ -2,10 +2,11 @@
//! @author George Fleming <v-geflem@microsoft.com> //! @author George Fleming <v-geflem@microsoft.com>
//! @brief returns whether a file is executable //! @brief returns whether a file is executable
#include "isexecutable.h"
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <string> #include <string>
#include "isexecutable.h"
//! @brief IsExecutable determines if path is executable //! @brief IsExecutable determines if path is executable
//! //!

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "pal.h" #include "pal.h"
#include <stdbool.h> #include <stdbool.h>
PAL_BEGIN_EXTERNC PAL_BEGIN_EXTERNC

View file

@ -2,6 +2,9 @@
//! @author Andrew Schwartzmeyer <andschwa@microsoft.com> //! @author Andrew Schwartzmeyer <andschwa@microsoft.com>
//! @brief returns if the path exists //! @brief returns if the path exists
#include "getlstat.h"
#include "isfile.h"
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -9,8 +12,6 @@
#include <string.h> #include <string.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include "getlstat.h"
#include "isfile.h"
//! @brief returns if the path is a file or directory //! @brief returns if the path is a file or directory
//! //!

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "pal.h" #include "pal.h"
#include <stdbool.h> #include <stdbool.h>
PAL_BEGIN_EXTERNC PAL_BEGIN_EXTERNC

View file

@ -2,13 +2,14 @@
//! @author George FLeming <v-geflem@microsoft.com> //! @author George FLeming <v-geflem@microsoft.com>
//! @brief returns whether a path is a symbolic link //! @brief returns whether a path is a symbolic link
#include "getlstat.h"
#include "issymlink.h"
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <string> #include <string>
#include "getlstat.h"
#include "issymlink.h"
//! @brief IsSymlink determines if path is a symbolic link //! @brief IsSymlink determines if path is a symbolic link
//! //!

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "pal.h" #include "pal.h"
#include <stdbool.h> #include <stdbool.h>
PAL_BEGIN_EXTERNC PAL_BEGIN_EXTERNC

View file

@ -2,13 +2,14 @@
//! @author George FLeming <v-geflem@microsoft.com> //! @author George FLeming <v-geflem@microsoft.com>
//! @brief set local/system date and time //! @brief set local/system date and time
#include "setdate.h"
#include <errno.h> #include <errno.h>
#include <langinfo.h> #include <langinfo.h>
#include <locale.h> #include <locale.h>
#include <string> #include <string>
#include <time.h> #include <time.h>
#include <sys/time.h> #include <sys/time.h>
#include "setdate.h"
//! @brief SetDate sets the date and time on local computer. You must //! @brief SetDate sets the date and time on local computer. You must
//! be super-user to set the time. //! be super-user to set the time.