2009-02-09 21:15:56 +00:00
|
|
|
/* USBnull
|
|
|
|
* Copyright (C) 2002-2004 USBnull Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <pthread.h>
|
2009-02-22 12:08:05 +00:00
|
|
|
#include <unistd.h>
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-02-22 12:08:05 +00:00
|
|
|
#include "USB.h"
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-02-22 12:08:05 +00:00
|
|
|
int ExecCfg(char *arg)
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
char cfg[256];
|
|
|
|
struct stat buf;
|
|
|
|
|
|
|
|
strcpy(cfg, "./cfgUSBnull");
|
2009-02-22 12:08:05 +00:00
|
|
|
if (stat(cfg, &buf) != -1)
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
sprintf(cfg, "%s %s", cfg, arg);
|
|
|
|
return system(cfg);
|
|
|
|
}
|
|
|
|
|
2009-02-22 12:08:05 +00:00
|
|
|
strcpy(cfg, "./plugins/cfgUSBnull");
|
|
|
|
if (stat(cfg, &buf) != -1)
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
sprintf(cfg, "%s %s", cfg, arg);
|
|
|
|
return system(cfg);
|
|
|
|
}
|
2009-02-22 12:08:05 +00:00
|
|
|
|
|
|
|
strcpy(cfg, "./cfg/cfgUSBnull");
|
|
|
|
if (stat(cfg, &buf) != -1)
|
|
|
|
|
|
|
|
{ sprintf(cfg, "%s %s", cfg, arg);
|
|
|
|
return system(cfg);
|
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
sprintf(cfg, "%s/cfgUSBnull", getenv("HOME"));
|
2009-02-22 12:08:05 +00:00
|
|
|
if (stat(cfg, &buf) != -1)
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
sprintf(cfg, "%s %s", cfg, arg);
|
|
|
|
return system(cfg);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("cfgUSBnull file not found!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-02-22 12:08:05 +00:00
|
|
|
void SysMessage(char *fmt, ...)
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
va_list list;
|
|
|
|
char msg[512];
|
|
|
|
char cmd[512];
|
|
|
|
|
|
|
|
va_start(list, fmt);
|
|
|
|
vsprintf(msg, fmt, list);
|
|
|
|
va_end(list);
|
|
|
|
|
|
|
|
sprintf(cmd, "message \"%s\"", msg);
|
|
|
|
ExecCfg(cmd);
|
|
|
|
}
|
|
|
|
|
2009-02-22 12:08:05 +00:00
|
|
|
void USBconfigure()
|
|
|
|
{
|
|
|
|
char *file;
|
2009-03-06 15:09:42 +00:00
|
|
|
getcwd(file, ArraySize(file));
|
2009-02-22 12:08:05 +00:00
|
|
|
chdir("plugins");
|
2009-02-09 21:15:56 +00:00
|
|
|
ExecCfg("configure");
|
2009-02-22 12:08:05 +00:00
|
|
|
chdir(file);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2009-02-22 12:08:05 +00:00
|
|
|
void USBabout()
|
|
|
|
{
|
|
|
|
char *file;
|
2009-03-06 15:09:42 +00:00
|
|
|
getcwd(file, ArraySize(file));
|
2009-02-22 12:08:05 +00:00
|
|
|
chdir("plugins");
|
2009-02-09 21:15:56 +00:00
|
|
|
ExecCfg("about");
|
2009-02-22 12:08:05 +00:00
|
|
|
chdir(file);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|