static void write_aino (FILE *f, a_inode *aino) { uae_u8 buf[1 + 4 + 257 + 257 + 81] = { 0 }; buf[0] = aino->needs_dbentry ? 1 : 0; do_put_mem_long ((uae_u32 *)(buf + 1), aino->amigaos_mode); ua_copy ((char*)buf + 5, 256, aino->aname); buf[5 + 256] = '\0'; ua_copy ((char*)buf + 5 + 257, 256, nname_begin (aino->nname)); buf[5 + 257 + 256] = '\0'; ua_copy ((char*)buf + 5 + 2 * 257, 80, aino->comment ? aino->comment : _T("")); buf[5 + 2 * 257 + 80] = '\0'; aino->db_offset = ftell (f); fwrite (buf, 1, sizeof buf, f); aino->has_dbentry = aino->needs_dbentry; TRACE ((_T("%d '%s' '%s' written\n"), aino->db_offset, aino->aname, aino->nname)); }
static void write_aino (FILE *f, a_inode *aino) { uae_u8 buf[1 + 4 + 257 + 257 + 81] = { 0 }; buf[0] = aino->needs_dbentry ? 1 : 0; do_put_mem_long ((uae_u32 *)(buf + 1), aino->amigaos_mode); ua_copy ((char*)buf + 5, 256, aino->aname); buf[5 + 256] = '\0'; ua_copy ((char*)buf + 5 + 257, 256, nname_begin (aino->nname)); buf[5 + 257 + 256] = '\0'; ua_copy ((char*)buf + 5 + 2 * 257, 80, aino->comment ? aino->comment : _T("")); buf[5 + 2 * 257 + 80] = '\0'; aino->db_offset = ftell (f); size_t isWritten = fwrite (buf, 1, sizeof buf, f); if (isWritten < sizeof(buf)) write_log("%s:%d [%s] - Failed to write %ld bytes (%ld/%ld)", __FILE__, __LINE__, __FUNCTION__, sizeof(buf) - isWritten, isWritten, sizeof(buf)); aino->has_dbentry = aino->needs_dbentry; TRACE ((_T("%d '%s' '%s' written\n"), aino->db_offset, aino->aname, aino->nname)); }
static void *console_thread (void *v) { uae_set_thread_priority (2); for (;;) { TCHAR wc = 0; //console_getch (); char c[2] = { 0, 0 }; write_log (_T("*")); ua_copy (c, 1, &wc); record_key_direct ((0x10 << 1) | 0); record_key_direct ((0x10 << 1) | 1); } return NULL; }
static void *console_thread (void *v) { uae_set_thread_priority (NULL, 1); for (;;) { TCHAR wc = console_getch (); char c[2]; write_log (L"*"); c[0] = 0; c[1] = 0; ua_copy (c, 1, &wc); record_key_direct ((0x10 << 1) | 0); record_key_direct ((0x10 << 1) | 1); } }
int checkIPC (void *vipc, struct uae_prefs *p) { struct uaeipc *ipc = (struct uaeipc*)vipc; BOOL ok; DWORD ret, err; if (!ipc) return 0; if (ipc->hipc == INVALID_HANDLE_VALUE) return 0; if (WaitForSingleObject(ipc->olevent, 0) != WAIT_OBJECT_0) return 0; if (!ipc->readpending && !ipc->writepending && ipc->outmessages > 0) { memset (&ipc->ol, 0, sizeof (OVERLAPPED)); ipc->ol.hEvent = ipc->olevent; if (ipc->binary) { ok = WriteFile (ipc->hipc, &ipc->outbin[ipc->outmessages][0], ipc->outbinlen[ipc->outmessages], &ret, &ipc->ol); } else { ok = WriteFile (ipc->hipc, ipc->outmsg[ipc->outmessages], (_tcslen (ipc->outmsg[ipc->outmessages]) + 1) * sizeof (TCHAR), &ret, &ipc->ol); } xfree (ipc->outmsg[ipc->outmessages--]); err = GetLastError (); if (!ok && err != ERROR_IO_PENDING) { write_log (_T("IPC: WriteFile() err=%d\n"), err); resetIPC (ipc); return 0; } ipc->writepending = TRUE; return 1; } if (ipc->readpending || ipc->writepending) { ok = GetOverlappedResult (ipc->hipc, &ipc->ol, &ret, FALSE); if (!ok) { err = GetLastError (); if (err == ERROR_IO_INCOMPLETE) return 0; write_log (_T("IPC: GetOverlappedResult error %d\n"), err); ipc->connected = TRUE; resetIPC (ipc); return 0; } if (!ipc->connected) { write_log (_T("IPC: Pipe connected\n")); ipc->connected = TRUE; return 0; } if (ipc->writepending) { ipc->writepending = FALSE; SetEvent (ipc->ol.hEvent); memset (&ipc->ol, 0, sizeof (OVERLAPPED)); ipc->ol.hEvent = ipc->olevent; return 0; } } if (!ipc->readpending) { ipc->buffer[0] = ipc->buffer[1] = 0; ipc->buffer[2] = ipc->buffer[3] = 0; ok = ReadFile (ipc->hipc, ipc->buffer, IPC_BUFFER_SIZE, &ret, &ipc->ol); err = GetLastError (); if (!ok) { if (err == ERROR_IO_PENDING) { ipc->readpending = TRUE; return 0; } else if (err == ERROR_BROKEN_PIPE) { write_log (_T("IPC: IPC client disconnected\n")); } else { write_log (_T("IPC: ReadFile() err=%d\n"), err); } resetIPC (ipc); return 0; } } ipc->readpending = FALSE; if (ipc->binary) { } else { TCHAR out[IPC_BUFFER_SIZE]; int outlen; TCHAR *msg; bool freeit = false; int type = 0; if (ipc->buffer[0] == 0xef && ipc->buffer[1] == 0xbb && ipc->buffer[2] == 0xbf) { msg = utf8u ((char*)ipc->buffer + 3); type = 1; } else if (ipc->buffer[0] == 0xff && ipc->buffer[1] == 0xfe) { msg = my_strdup ((TCHAR*)(ipc->buffer + 2)); type = 2; } else { msg = au ((uae_char*)ipc->buffer); } parsemessage (msg, p, out, sizeof out / sizeof (TCHAR)); xfree (msg); if (type == 1) { char *outp = uutf8 (out); strcpy ((char*)ipc->outbuf, outp); outlen = strlen ((char*)ipc->outbuf) + sizeof (char); xfree (outp); } else if (type == 2) { if (_tcslen (out) >= IPC_BUFFER_SIZE) out[IPC_BUFFER_SIZE - 1] = 0; _tcscpy ((TCHAR*)ipc->outbuf, out); outlen = _tcsclen ((TCHAR*)ipc->outbuf) + sizeof (TCHAR); } else { ua_copy ((uae_char*)ipc->outbuf, sizeof ipc->outbuf, out); outlen = strlen ((char*)ipc->outbuf) + sizeof (char); } memset (&ipc->ol, 0, sizeof (OVERLAPPED)); ipc->ol.hEvent = ipc->olevent; ok = WriteFile (ipc->hipc, ipc->outbuf, outlen, &ret, &ipc->ol); err = GetLastError (); if (!ok && err != ERROR_IO_PENDING) { write_log (_T("IPC: WriteFile() err=%d\n"), err); resetIPC (ipc); return 0; } ipc->writepending = TRUE; } return 1; }