Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _GNU_SOURCE
- #include <stdio.h>
- #include <stdlib.h>
- #include <errno.h>
- #include <pthread.h>
- #include <ctype.h>
- #include <string.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <time.h>
- #define OsErrorFatal(msg) OsErrorFatalImpl(msg, __FILE__, __func__, __LINE__)
- #define OsAssert(cond, msg) \
- do{ \
- if(!(cond)) \
- OsErrorFatal(msg); \
- }while(0);
- #define OsCheckPThread(pthreaderr, msg) \
- do{ \
- int pthread_err = pthreaderr; \
- if(pthread_err) \
- { \
- errno = pthread_err; \
- OsErrorFatal(msg); \
- } \
- }while(0);
- void OsErrorFatalImpl(char* msg, const char* file, const char* funk, int line);
- #define WR_END 1
- #define RD_END 0
- int unlocked = 0;
- int locked = 0;
- int main(int argc, char** argv)
- {
- OsAssert( argc == 2, "flmaspf");
- int pomeri = atoi(argv[1]);
- time_t trenutno = time(NULL);
- OsAssert( trenutno != -1, "vreme failed us");
- struct tm* vreme_seksi = localtime(&trenutno);
- OsAssert( vreme_seksi != NULL, "lokal fejld");
- vreme_seksi->tm_mday += pomeri;
- trenutno = mktime(vreme_seksi);
- OsAssert( trenutno != -1, "mktime failed us");
- vreme_seksi = localtime(&trenutno);
- OsAssert( vreme_seksi != NULL, "lokal again fejld");
- switch (vreme_seksi->tm_wday)
- {
- case 0:
- printf("ned");
- break;
- case 1:
- printf("pon");
- break;
- case 2:
- printf("uto");
- break;
- case 3:
- printf("sre");
- break;
- case 4:
- printf("cetv");
- break;
- case 5:
- printf("pet");
- break;
- case 6:
- printf("sub");
- break;
- default:
- break;
- }
- exit(EXIT_SUCCESS);
- }
- void OsErrorFatalImpl(char* msg, const char* file, const char* funk, int line)
- {
- perror(msg);
- fprintf(stderr, "%s:%s:%d", file, funk, line);
- exit(EXIT_FAILURE);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement