1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set tabstop=8 softtabstop=4 shiftwidth=4 expandtab: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #include "nsCUPSShim.h"
10 #include "mozilla/ArrayUtils.h"
14 // List of symbols to find in libcups. Must match symAddr[] defined in Init().
15 // Making this an array of arrays instead of pointers allows storing the
16 // whole thing in read-only memory.
17 static const char gSymName
[][sizeof("cupsPrintFile")] = {
25 static const int gSymNameCt
= mozilla::ArrayLength(gSymName
);
31 mCupsLib
= PR_LoadLibrary("libcups.so.2");
35 // List of symbol pointers. Must match gSymName[] defined above.
37 (void **)&mCupsAddOption
,
38 (void **)&mCupsFreeDests
,
39 (void **)&mCupsGetDest
,
40 (void **)&mCupsGetDests
,
41 (void **)&mCupsPrintFile
,
42 (void **)&mCupsTempFd
,
45 for (int i
= gSymNameCt
; i
--; ) {
46 *(symAddr
[i
]) = PR_FindSymbol(mCupsLib
, gSymName
[i
]);
47 if (! *(symAddr
[i
])) {
49 nsAutoCString
msg(gSymName
[i
]);
50 msg
.AppendLiteral(" not found in CUPS library");
51 NS_WARNING(msg
.get());
53 PR_UnloadLibrary(mCupsLib
);