Bug 1887774 convert from MediaEnginePrefs to AudioProcessing config in AudioInputProc...
[gecko.git] / toolkit / crashreporter / linux_utils.cc
blobcfddecf084e19df94b45a2c2838e7e092ba4e30c
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "common/linux/linux_libc_support.h"
7 #include "linux_utils.h"
9 bool ElfFileSoVersion(const char* mapping_name, uint32_t* version_components) {
10 if (!version_components) {
11 return false;
14 // We found no version so just report 0
15 const char* so_version = my_strstr(mapping_name, ".so.");
16 if (so_version == nullptr) {
17 return true;
20 char tmp[12]; // 11 for maximum representation of UINT32T_MAX + \0 ?
21 size_t current_position = 0;
22 size_t next_tmp = 0;
23 tmp[0] = '\0';
24 for (size_t so_version_pos = 0; so_version_pos <= my_strlen(so_version);
25 ++so_version_pos) {
26 // We can't have more than four: MAJOR.minor.release.patch
27 if (current_position == 4) {
28 break;
31 char c = so_version[so_version_pos];
32 if (c != '.') {
33 if ((c <= '9' && c >= '0')) {
34 tmp[next_tmp] = c;
35 tmp[next_tmp + 1] = '\0';
36 ++next_tmp;
39 if (so_version[so_version_pos + 1] != '\0') {
40 continue;
44 if (my_strlen(tmp) > 0) {
45 int t;
46 if (!my_strtoui(&t, tmp)) {
47 return false;
49 uint32_t casted_tmp = (uint32_t)t;
50 version_components[current_position] = casted_tmp;
51 ++current_position;
54 tmp[0] = '\0';
55 next_tmp = 0;
58 return true;