/*
 * test.c - Example program using libuniquecheck
 *
 * Copyright (C) 1995-2026  Artyomov Alexander
 * http://self-made-free.ru/
 * aralni@mail.ru
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#include <stdio.h>
#include <unistd.h>
#include "uniquecheck.h"

int main(int argc, char *argv[]) {
    /* Initialize the library */
    uniquecheck_init(argc, argv);
    
    printf("Program: %s\n", uniquecheck_get_program_name());
    printf("PID: %d\n", uniquecheck_get_pid());
    
    /* Check system-wide */
    if (uniquecheck_is_running_system()) {
        fprintf(stderr, "Another instance is running (system-wide)!\n");
        return 1;
    }
    
    /* Check user-specific */
    if (uniquecheck_is_running_user()) {
        fprintf(stderr, "Another instance is running (same user)!\n");
        return 1;
    }
    
    printf("No other instances found. Running...\n");
    
    /* Your program logic here */
    printf("Press Enter to exit...\n");
    getchar();
    
    return 0;
}