2017-05-24 10:46:42 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Frank Morgner <frankmorgner@gmail.com>
|
|
|
|
*
|
|
|
|
* This file is part of OpenSC.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "ui/notify.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2017-06-08 14:10:43 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
void Sleep(unsigned int Milliseconds)
|
|
|
|
{
|
|
|
|
struct timespec req, rem;
|
|
|
|
|
|
|
|
if (Milliseconds > 999) {
|
|
|
|
req.tv_sec = Milliseconds / 1000; /* Must be Non-Negative */
|
|
|
|
req.tv_nsec = (Milliseconds - (req.tv_sec * 1000)) * 1000000; /* Must be in range of 0 to 999999999 */
|
|
|
|
} else {
|
|
|
|
req.tv_sec = 0; /* Must be Non-Negative */
|
|
|
|
req.tv_nsec = Milliseconds * 1000000; /* Must be in range of 0 to 999999999 */
|
|
|
|
}
|
|
|
|
|
|
|
|
nanosleep(&req , &rem);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-05-24 10:46:42 +00:00
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
const char *title = NULL, *text = NULL;
|
|
|
|
switch (argc) {
|
|
|
|
case 3:
|
|
|
|
text = argv[2];
|
|
|
|
/* fall through */
|
|
|
|
case 2:
|
2017-06-08 14:10:43 +00:00
|
|
|
title = argv[1];
|
2017-05-24 10:46:42 +00:00
|
|
|
/* fall through */
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
fprintf(stderr, "Usage: opensc-notify [title [text]]");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
sc_notify_init();
|
|
|
|
sc_notify(title, text);
|
2017-06-08 14:10:43 +00:00
|
|
|
Sleep(250);
|
2017-05-24 10:46:42 +00:00
|
|
|
sc_notify_close();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|