forked from mdlavin/firefox-gnome-keyring
-
Notifications
You must be signed in to change notification settings - Fork 8
/
xpcom_abi.cpp
41 lines (35 loc) · 1.12 KB
/
xpcom_abi.cpp
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
#include <stdio.h>
#include <stdint.h>
#include "nsIXULRuntime.h"
#include "nsServiceManagerUtils.h"
#include "nsStringAPI.h"
#include "nsXPCOM.h"
#include "nsXPCOMCIDInternal.h"
/**
* Print the XPCOM ABI string, e.g. Linux_x86-gcc3
*
* See:
* https://developer.mozilla.org/en/Bundles#Platform-specific_files
* https://developer.mozilla.org/en/Chrome_Registration#abi
* https://developer.mozilla.org/en/XPCOM_ABI#ABI_Naming
*
* See also:
* https://bugzilla.mozilla.org/728600
*/
int main(int argc, char **argv) {
nsresult rv;
nsCOMPtr<nsIServiceManager> servMan;
rv = NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
if (!NS_SUCCEEDED(rv)) return NS_ERROR_GET_CODE(rv);
nsCOMPtr<nsIXULRuntime> xulrun = do_GetService(XULAPPINFO_SERVICE_CONTRACTID, &rv);
if (!NS_SUCCEEDED(rv)) return NS_ERROR_GET_CODE(rv);
nsCString xpcomAbi;
nsCString xpcomOs;
rv = xulrun->GetOS(xpcomOs);
if (!NS_SUCCEEDED(rv)) return NS_ERROR_GET_CODE(rv);
rv = xulrun->GetXPCOMABI(xpcomAbi);
if (!NS_SUCCEEDED(rv)) return NS_ERROR_GET_CODE(rv);
printf("%s_%s\n", xpcomOs.get(), xpcomAbi.get());
rv = NS_ShutdownXPCOM(nullptr);
return 0;
}