-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibnix.h
51 lines (39 loc) · 962 Bytes
/
libnix.h
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
// lib*nix
// the *nix library
//
// Copyright 2013 Haneef Mubarak
// All Rights Reserved
#pragma once
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <fcntl.h>
#pragma pack(push,1)
typedef struct {
void *addr;
size_t len;
int m_prot;
int m_flag;
int o_flag;
int lock;
int fd;
off_t offset;
} lnix_mapFileStruct;
typedef struct {
lnix_mapFileStruct *file;
size_t linecount;
char **line;
} lnix_sourceFileStruct;
#pragma pack(pop)
int lnix_mmapFile (char *filename, lnix_mapFileStruct *mapfile);
int lnix_mremapFile (off_t newSize, lnix_mapFileStruct *mapfile);
int lnix_munmapFile (lnix_mapFileStruct *mapfile);
int lnix_getlines (char *string, char ***lines, size_t *linecount);
int lnix_getSourceFile (lnix_mapFileStruct *mapfile, lnix_sourceFileStruct *sourcefile);