Skip to content

Commit 7f5190b

Browse files
committed
Updated README
1 parent 27f9e0c commit 7f5190b

File tree

3 files changed

+95
-23
lines changed

3 files changed

+95
-23
lines changed

LIBRARY.md

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
11
<h2 align="center">CCLOC library</h2>
22

3-
CCLOC can be used as a static library. You can build the library yourself by running ```make lib```, or download the build static library from the releases section. Include the ```ccloc.h``` header.
3+
CCLOC can be used as a static library. You can build the library yourself by running ```make lib```, or download the built static library from the releases section. Include the ```ccloc.h``` header.
44

55
By default the library API exposes only the ```ccloc``` function and the required structures to use it. If you want to use the languages & extensions database use the following defines before including the header:
66
```
77
#define CCLOC_LANGS_DEFS // for the defines
88
#define CCLOC_LANGS // for the languages database
9-
#define CCLOC_EXTS // for the extensions database
9+
#define CCLOC_EXTS // for the extensions database
1010
```
1111

12+
All the [options](https://github.com/hypertensiune/ccloc/blob/master/README.md#options) that are used with the ccloc cli tool can be used with the library. The time options doesn't need to be specified, as it is used only by the cli tool to display the time stats (time is calculated regardless of this options). Options are set using the ```loc_options```:
13+
```
14+
typedef struct
15+
{
16+
int all;
17+
int time;
18+
int sort;
19+
int langs;
20+
int threads;
21+
int langs_n;
22+
char sort_method[10];
23+
char langs_array[100][20];
24+
} loc_options;
25+
```
26+
27+
The resulting report is found in the ```report``` parameter of the ```ccloc``` function. If option -a is used ccloc expects that paramter to be a ```loc_file_report``` otherwise a ```loc_report```.
28+
1229
### Example
1330

1431
```
32+
// > ccloc .
1533
#include "ccloc.h"
1634
1735
int main()
@@ -20,14 +38,49 @@ int main()
2038
loc_options options = {0, 0, 0, 0, 20}; // no extra options, 20 threads
2139
loc_report report = {.length = 0};
2240
23-
// options - https://github.com/hypertensiune/ccloc/blob/master/README.md#options
24-
// report - the final report produced by ccloc after counting
25-
int result = ccloc(path, &options, &report);
41+
int result = ccloc(path, &options, (void*)&report);
42+
43+
return 0;
44+
}
45+
```
46+
47+
```
48+
// > ccloc . -a
49+
#include "ccloc.h"
50+
51+
int main()
52+
{
53+
char* path = ".";
54+
loc_options options = {1, 0, 0, 0, 20}; // -a, 20 threads
55+
loc_file_report report = {0, 0, 0, 0, NULL};
56+
57+
int result = ccloc(path, &options, (void*)&report);
58+
59+
return 0;
60+
}
61+
62+
```
63+
```
64+
// > ccloc . -s comments -l Python
65+
#include "ccloc.h"
66+
67+
int main()
68+
{
69+
char* path = ".";
70+
loc_report report = {.length = 0};
71+
72+
loc_options options = {0, 0, 1, 1, 20}; // -s -l, 20 threads
73+
options.langs = 1;
74+
strcpy(options.langs_array[0], "Python");
75+
strcpy(options.sort_method, "comments");
76+
77+
int result = ccloc(path, &options, (void*)&report);
2678
2779
return 0;
2880
}
2981
```
82+
3083
Build the program and link the statc library:
3184
```
3285
gcc main.c -o main.exe -lccloc
33-
```
86+
```

README.md

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ You can build ccloc by yourself or you can download the availabe prebuilt binari
6565
### Options
6666

6767
```
68-
ccloc v1.0.1
68+
ccloc v1.0.2
6969
https://github.com/hypertensiune/ccloc
7070
7171
Usage:
@@ -87,36 +87,55 @@ Options:
8787
```
8888
> ccloc . -a -t
8989
---------------------------------------------------+---------------------------+------------+------------+------------
90-
File | Language | Total | Code | Comments
90+
File | Language | Total | Code | Comments
9191
---------------------------------------------------+---------------------------+------------+------------+------------
92-
~\ccloc\ccloc.c | C | 689 | 541 | 37
93-
~\ccloc\langs.h | C Header | 1927 | 1896 | 23
94-
~\generate.py | Python | 82 | 56 | 6
92+
~\src\langs.c | C | 1621 | 1594 | 23
93+
~\src\ccloc.c | C | 671 | 443 | 114
94+
~\main.c | C | 167 | 145 | 0
95+
---------------------------------------------------+---------------------------+------------+------------+------------
96+
~\include\langs.h | C Header | 335 | 306 | 23
97+
~\src\ccloc.h | C Header | 111 | 65 | 26
98+
~\include\ccloc.h | C Header | 107 | 62 | 31
99+
---------------------------------------------------+---------------------------+------------+------------+------------
100+
~\graphs\react.json | JSON | 2078 | 2078 | 0
95101
~\languages.json | JSON | 1800 | 1800 | 0
96-
~\README.md | Markdown | 479 | 431 | 0
102+
~\linux.json | JSON | 1024 | 1024 | 0
103+
~\graphs\linux.json | JSON | 1024 | 1024 | 0
104+
---------------------------------------------------+---------------------------+------------+------------+------------
105+
~\README.md | Markdown | 604 | 545 | 0
106+
~\LIBRARY.md | Markdown | 33 | 26 | 0
97107
---------------------------------------------------+---------------------------+------------+------------+------------
98-
TOTAL | | 4977 | 4724 | 66
108+
~\generate.py | Python | 82 | 56 | 6
109+
~\plot.py | Python | 33 | 21 | 0
110+
---------------------------------------------------+---------------------------+------------+------------+------------
111+
~\res.txt | Plain Text | 5746 | 5746 | 0
99112
---------------------------------------------------+---------------------------+------------+------------+------------
100-
Took: 25.00 milliseconds
101-
Parsed 5 files, files/s: 200.00
102-
Read 137208 bytes (0.14 megabytes), bytes/s: 5488320.00 (mb/s: 5.49)
113+
TOTAL 15 files | | 15436 | 14935 | 223
114+
---------------------------------------------------+---------------------------+------------+------------+------------
115+
Took: 8.00 milliseconds
116+
Parsed 15 files, files/s: 1875.00
117+
Read 1613215 bytes (1.61 megabytes), bytes/s: 201651875.00 (mb/s: 201.65)
103118
```
104119

105120
#### Process only files that contain C Header or Python source code
106121

107122
```
108123
> ccloc . -a -t -l "C Header" Python
109124
---------------------------------------------------+---------------------------+------------+------------+------------
110-
File | Language | Total | Code | Comments
125+
File | Language | Total | Code | Comments
126+
---------------------------------------------------+---------------------------+------------+------------+------------
127+
~\include\langs.h | C Header | 335 | 306 | 23
128+
~\src\ccloc.h | C Header | 111 | 65 | 26
129+
~\include\ccloc.h | C Header | 107 | 62 | 31
111130
---------------------------------------------------+---------------------------+------------+------------+------------
112-
~\ccloc\langs.h | C Header | 1927 | 1896 | 23
113131
~\generate.py | Python | 82 | 56 | 6
132+
~\plot.py | Python | 33 | 21 | 0
114133
---------------------------------------------------+---------------------------+------------+------------+------------
115-
TOTAL | | 2009 | 1952 | 29
134+
TOTAL 5 files | | 668 | 510 | 86
116135
---------------------------------------------------+---------------------------+------------+------------+------------
117-
Took: 14.00 milliseconds
118-
Parsed 2 files, files/s: 142.86
119-
Read 37087 bytes (0.04 megabytes), bytes/s: 2649071.43 (mb/s: 2.65)
136+
Took: 10.00 milliseconds
137+
Parsed 5 files, files/s: 500.00
138+
Read 17048 bytes (0.02 megabytes), bytes/s: 1704800.00 (mb/s: 1.70)
120139
```
121140

122141
#### Sort by lines of comments

main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static inline void PRINT_TIME_STATS(double time, int files, long long bytes)
6565

6666
static inline void PRINT_HELP()
6767
{
68-
printf("ccloc v1.0.1\nhttps://github.com/hypertensiune/ccloc\n\n");
68+
printf("ccloc v1.0.2\nhttps://github.com/hypertensiune/ccloc\n\n");
6969
printf("Usage:\n ccloc <directory|file> [options]\n\n");
7070
printf("Options:\n");
7171
printf(" -h, --help Print this info\n");

0 commit comments

Comments
 (0)