Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _XOPEN_SOURCE 700
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- #define max 256
- #define osErrorFatal(userMsg) osErrorFatalImpl((userMsg), __FILE__, __func__, __LINE__)
- #define osAssert(expr, userMsg) \
- do { \
- if (!(expr)) \
- osErrorFatal(userMsg); \
- } while(0)
- void osErrorFatalImpl(const char *userMsg, const char *fileName,
- const char *functionName, const int lineNum);
- _Bool osispub(const char* path);
- int main(int argc, char** argv){
- osAssert(argc==2, "Invalid num arg");
- printf("%b\n ", osispub(argv[2]));
- return 0;
- }
- _Bool osispub(const char* fpath){
- struct stat finfo;
- osAssert(-1!=stat(fpath, &finfo),"Getting info failed");
- osAssert(S_ISREG(finfo.st_mode) , "File not regular");
- if(finfo.st_mode & S_IROTH && finfo.st_mode & S_IWOTH)
- return true;
- else
- return false;
- }
- void osErrorFatalImpl(const char *userMsg, const char *fileName,
- const char *functionName, const int lineNum) {
- perror(userMsg);
- fprintf(stderr, "File: '%s'\nFunction: '%s'\nLine: '%d'\n", fileName, functionName, lineNum);
- exit(EXIT_FAILURE);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement