示例#1
0
/* wrapper for inet_ntop function */
const char*
Inet_ntop (int family,
           const void *addrptr,
           char *strptr,
           size_t len)
{
    const char* ptr;

    if (strptr == NULL)
     {
         sd_journal_perror ("NULL destination pointer.");
         return NULL;
     }
    ptr = inet_ntop (family, addrptr, strptr, len);
    if (ptr == NULL) sd_journal_print (LOG_DEBUG, "inet_ntop returned NULL.");
    return ptr;                                           /* may return NULL */
}
示例#2
0
int main(int argc, char *argv[])
{
    std::string id_wanted;
    std::string value;
    char *argv0;
    bool newline = false;

    ARGBEGIN
    {
        case 'n':
            newline = true;
            break;
    }
    ARGEND

    // this prevents us from going on if we don't know what password
    if(argv == NULL || *argv == NULL)
        exit(EXIT_FAILURE);

    id_wanted = std::string(*argv);

    try
    {
        value = get_password(id_wanted);
    }
    catch(std::system_error& e)
    {
        errno = e.code().value();
        sd_journal_perror("Unable to read key");
        exit(EXIT_FAILURE);
    }
    catch(std::runtime_error& e)
    {
        sd_journal_print(LOG_INFO, e.what());
        exit(EXIT_FAILURE);
    }
    std::cout << value;
    if(newline)
        std::cout << "\n";
    exit(EXIT_SUCCESS);
}
示例#3
0
static int _perror (lua_State *L) {
	const char *message = luaL_checkstring(L, 1);
	return handle_log_result(L, sd_journal_perror(message));
}