logoISU  

CS456 - Systems Programming

Spring 2023

Displaying ./code/h3/myls.h

/*

this is where we include all the other header files we need
we also define functions here

*/


//header files needed 
#include <stdio.h>
#include <stdlib.h> 
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <pwd.h>
#include <grp.h>

#define BUF 512   //for a buffer to put text in

//typedef structs (for cleaner code)
typedef struct dirent DIRENT;
typedef struct passwd PASSWD;
typedef struct group  GROUP;
typedef struct stat    STAT;


//defining which bit coresponds to which option (for the flags function)
#define L 	0  // for the -l option
#define A 	1  // for the -a option
#define C   2  // for the -c option

// function definitions
void processArgs(int argc, char **argv, char *opt, char *fi);
int flags(char *options);
int isHiddenFile(char *filename);
int isHiddenOption(int opt);
int setBit(int n, int bit);
int checkBit(int n, int bit);
void printHelp(void);
int isLongFormat(int opt);
void printLongFormat(STAT s);
void printPermissions(STAT s);
void printTime(STAT s);
int isCount(int opt);