summaryrefslogtreecommitdiff
path: root/main.c
blob: b0ebe5c1d5587166483c32030fa3fa2d6b0854be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#include <stdlib.h>


#include <string.h>
#include <ctype.h>

#include <readline/readline.h>

// import files for reading the current directory
#include "apue.c"
#include <dirent.h>

#define true 1
#define false 0

void err_quit(char * str) {
    printf("%s", str);
}
void err_sys(char * str) {
    printf("%s", str);
}

void PROCESS_PID(char *string) {

    printf("PID %ld\n", (long)getpid());
}

void LIST_CURRENT_DIRECTORY(int argc, char *argv[])
{
    DIR *dp;
    struct dirent *dirp;
    if (argc != 2)
        err_quit("usage: ls directory_name");
    if ((dp = opendir(argv[1])) == NULL)
        err_sys(  argv[1]);
    while ((dirp = readdir(dp)) != NULL)
        printf("%s\n", dirp->d_name);
    closedir(dp);
}


int main(int argc, char *argv[]) {

    printf("succefully started the program");
    // RUNNING THE PROGRAM ON AN ENDLESS LOOP
    // BREAKS WHEN USER ENTERS EXIT
    // ReSharper disable once CppDFAEndlessLoop

    return 0;
}