forked from getsentry/sentry-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsentry_hint.c
More file actions
106 lines (94 loc) · 2.67 KB
/
Copy pathsentry_hint.c
File metadata and controls
106 lines (94 loc) · 2.67 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "sentry_hint.h"
#include "sentry_alloc.h"
#include "sentry_attachment.h"
#include "sentry_path.h"
#include "sentry_string.h"
#include <string.h>
sentry_hint_t *
sentry_hint_new(void)
{
sentry_hint_t *hint = SENTRY_MAKE(sentry_hint_t);
if (!hint) {
return NULL;
}
return hint;
}
void
sentry__hint_free(sentry_hint_t *hint)
{
if (!hint) {
return;
}
sentry__attachments_free(hint->attachments);
sentry_free(hint);
}
sentry_attachment_t *
sentry_hint_attach_file(sentry_hint_t *hint, const char *path)
{
return sentry_hint_attach_file_n(hint, path, sentry__guarded_strlen(path));
}
sentry_attachment_t *
sentry_hint_attach_file_n(
sentry_hint_t *hint, const char *path, size_t path_len)
{
if (!hint) {
return NULL;
}
return sentry__attachments_add_path(&hint->attachments,
sentry__path_from_str_n(path, path_len), NULL, NULL);
}
sentry_attachment_t *
sentry_hint_attach_bytes(
sentry_hint_t *hint, const char *buf, size_t buf_len, const char *filename)
{
return sentry_hint_attach_bytes_n(
hint, buf, buf_len, filename, sentry__guarded_strlen(filename));
}
sentry_attachment_t *
sentry_hint_attach_bytes_n(sentry_hint_t *hint, const char *buf, size_t buf_len,
const char *filename, size_t filename_len)
{
if (!hint) {
return NULL;
}
return sentry__attachments_add(&hint->attachments,
sentry__attachment_from_buffer(
buf, buf_len, sentry__path_from_str_n(filename, filename_len)));
}
#ifdef SENTRY_PLATFORM_WINDOWS
sentry_attachment_t *
sentry_hint_attach_filew(sentry_hint_t *hint, const wchar_t *path)
{
size_t path_len = path ? wcslen(path) : 0;
return sentry_hint_attach_filew_n(hint, path, path_len);
}
sentry_attachment_t *
sentry_hint_attach_filew_n(
sentry_hint_t *hint, const wchar_t *path, size_t path_len)
{
if (!hint) {
return NULL;
}
return sentry__attachments_add_path(&hint->attachments,
sentry__path_from_wstr_n(path, path_len), NULL, NULL);
}
sentry_attachment_t *
sentry_hint_attach_bytesw(sentry_hint_t *hint, const char *buf, size_t buf_len,
const wchar_t *filename)
{
size_t filename_len = filename ? wcslen(filename) : 0;
return sentry_hint_attach_bytesw_n(
hint, buf, buf_len, filename, filename_len);
}
sentry_attachment_t *
sentry_hint_attach_bytesw_n(sentry_hint_t *hint, const char *buf,
size_t buf_len, const wchar_t *filename, size_t filename_len)
{
if (!hint) {
return NULL;
}
return sentry__attachments_add(&hint->attachments,
sentry__attachment_from_buffer(
buf, buf_len, sentry__path_from_wstr_n(filename, filename_len)));
}
#endif