-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker.h
More file actions
39 lines (32 loc) · 849 Bytes
/
Copy pathworker.h
File metadata and controls
39 lines (32 loc) · 849 Bytes
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
#ifndef _WORKER_H
#define _WORKER_H
#include "read_line.h"
typedef enum {
ABORT, // child should exit
ABORTING, // child got error
GET_LINK, // child should get link
GOT_LINK, // child got link
FAIL_LINK, // child cannot get link
PUT_LINK, // master should add the link to queue
PUT_TXT, // master should do something with text
} msg_t;
extern char *msgs[];
typedef enum {
AVAILABLE,
RES_HOST, // resolving hostname
FETCHING, // getting webpage
PROCESSING, // processing webpage
} worker_status_t;
typedef struct {
//int sfd;
cbuf_t *cbuf;
int pid;
worker_status_t status;
} worker_t;
void worker(worker_t *self);
worker_t *worker_new();
void worker_del(worker_t *w);
worker_status_t getType(char *str);
int sendMsg(cbuf_t *cbuf, worker_status_t type, char *str);
int trim(char *buf);
#endif