Question: #include #include #include #include #include #include #include #include amap.h #include aux.h / * scanner.c - process directories / files , counting words in
#include
#include
#include
#include
#include
#include
#include
#include "amap.h
#include "aux.h
scanner.c process directoriesfiles counting words in each
regular text file. Accumulate counts in the amapt then pass them
along to reducers via the reducer pipes.
Each reducer collects counts for a portion of the alphabet.
Which reducer pipe a wordcount pair should be written to is
determined by the first letter of word, using the "whichpipe" global.
The definition of a "word" is a contiguous sequence of alphabetic
characters no numbers, whitespace, or punctuation.
#define FTYPEREG
#define FTYPEDIR
#define FTYPESKIP
#define SAMPLESIZE
#define NAMESIZE
Map of characters to reducer pipe #s Init'ed in driver once for all.
extern int whichpipeALPHABETLEN;
what kind of file is this? Return value indicates type via constants above.
If it's a text file to be processed, the file descriptor is passed via
the fd out parameter.
static int checktypechar name int fd
struct stat finfo;
int rv fildes;
char bufSAMPLESIZE;
rv statname&finfo;
if rv
return FTYPESKIP;
if finfostmode & SIFMT SIFREG
fildes opennameORDONLY;
if fildes
return FTYPESKIP;
Read a few characters to try to get type
if rvreadfildesbuf,SAMPLESIZE
return FTYPESKIP;
if bufxf &&
bufE &&
bufL &&
bufF executable
bufG &&
bufI &&
bufF image
bufx &&
bufP &&
bufN &&
bufG image
buf &&
bufP &&
bufD &&
bufF PDF
closefildes;
return FTYPESKIP;
for int i; i
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
