예제 #1
0
파일: main.c 프로젝트: ofilin/remcam2
int WINAPI WinMain(HINSTANCE inst, HINSTANCE unused, char *cmd, int show)
{
	WSADATA wsa;
	HANDLE mutex;
	HWND hwnd;

	if((mutex = CreateMutex(NULL, FALSE, "remcam2_started")))
	{
		if(GetLastError() != ERROR_ALREADY_EXISTS)
		{
			if(!WSAStartup(MAKEWORD(1,1), &wsa))
			{
				InitCommonControls();
				sett_init();
				hwnd = phonebook(inst, NULL, show);
				msgloop(inst, hwnd);
				sett_save();
				WSACleanup();
			}
		}
		else
		{
			if((hwnd = FindWindow(NULL, "RemCam 2")))
			{
				ShowWindow(hwnd, SW_SHOW);
				SetForegroundWindow(hwnd);
			}
		}
		CloseHandle(mutex);
	}
	return 0;
}
예제 #2
0
static int parse_telmon()
{
    static int telmond_fd = -2;
    static char oldanswer[128];
    int age;

    /* reread every 1 sec only */
    age = hash_age(&TELMON, NULL);
    if (age > 0 && age <= 1000)
	return 0;

    if (telmond_fd != -1) {
	char telbuf[128];

	telmond_fd = service_connect(thost, tport);
	if (telmond_fd >= 0) {
	    int l = read(telmond_fd, telbuf, 127);
	    if ((l > 0) && (strcmp(telbuf, oldanswer))) {
		char date[11];
		char time[11];
		char number[256];
		char msn[256];
		sscanf(telbuf, "%s %s %s %s", date, time, number, msn);
		hash_put(&TELMON, "time", time);
		date[4] = '\0';
		date[7] = '\0';
		qprintf(time, sizeof(time), "%s.%s.%s", date + 8, date + 5, date);
		hash_put(&TELMON, "number", number);
		hash_put(&TELMON, "msn", msn);
		hash_put(&TELMON, "date", time);
		phonebook(number);
		phonebook(msn);
		hash_put(&TELMON, "name", number);
		hash_put(&TELMON, "msnname", msn);
	    }
	    close(telmond_fd);
	    strcpy(oldanswer, telbuf);
	}
    }
    return 0;
}