FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
repmmapcheck.c
Go to the documentation of this file.
1 /****************************************************************
2 repmmapcheck: Check if mmap() works.
3 
4 Copyright (C) 2007-2011 Hewlett-Packard Development Company, L.P.
5 
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License version 2.1 as published by the Free Software Foundation.
9 
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14 
15 You should have received a copy of the GNU Lesser General Public License
16 along with this library; if not, write to the Free Software Foundation, Inc.0
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 ****************************************************************/
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include "libfossrepo.h"
27 
28 #ifdef COMMIT_HASH
29 char BuildVersion[]="Build version: " COMMIT_HASH ".\n";
30 #endif
31 
32 int main(int argc, char* argv[])
33 {
34  RepMmapStruct* M;
35 
36  if (argc != 3)
37  {
38  fprintf(stderr, "Usage: %s type filename > output\n", argv[0]);
39  exit(-1);
40  }
41 
42  M = fo_RepMmap(argv[1], argv[2]);
43  if (!M)
44  {
45  fprintf(stderr, "ERROR: failed to mmap file.\n");
46  return (-1);
47  }
48 
49  printf("Successfully mapped %ld bytes\n", (long) (M->MmapSize));
50 
51  fo_RepMunmap(M);
52  return (0);
53 } /* main() */
54 
char BuildVersion[]
Definition: buckets.c:79
RepMmapStruct * fo_RepMmap(char *Type, char *Filename)
Perform a mmap.
Definition: libfossrepo.c:798
uint32_t MmapSize
Size of file mmap.
Definition: libfossrepo.h:104
void fo_RepMunmap(RepMmapStruct *M)
Perform a munmap.
Definition: libfossrepo.c:733