branches/kale/3rdparty/mongoose/mongoose.c
| r244605 | r244606 | |
| 124 | 124 | #include <sys/socket.h> |
| 125 | 125 | #include <sys/select.h> |
| 126 | 126 | #define closesocket(x) close(x) |
| 127 | #ifndef __OS2__ |
| 127 | 128 | #define __cdecl |
| 129 | #else |
| 130 | #include <sys/time.h> |
| 131 | typedef int socklen_t; |
| 132 | #endif |
| 128 | 133 | #define INVALID_SOCKET (-1) |
| 129 | 134 | #define to64(x) strtoll(x, NULL, 10) |
| 130 | 135 | typedef int sock_t; |
| r244605 | r244606 | |
| 1554 | 1559 | #define MAP_FAILED NULL |
| 1555 | 1560 | #define MAP_PRIVATE 0 |
| 1556 | 1561 | #define PROT_READ 0 |
| 1562 | #elif defined(__OS2__) |
| 1563 | static void *mmap(void *addr, int64_t len, int prot, int flags, int fd, |
| 1564 | int offset) { |
| 1565 | void *p; |
| 1566 | |
| 1567 | int pos = lseek( fd, 0, SEEK_CUR ); /* Get a current position */ |
| 1568 | |
| 1569 | if (pos == -1) |
| 1570 | return NULL; |
| 1571 | |
| 1572 | /* Seek to offset offset */ |
| 1573 | if (lseek( fd, offset, SEEK_SET) == -1) |
| 1574 | return NULL; |
| 1575 | |
| 1576 | p = malloc(len); |
| 1577 | |
| 1578 | /* Read in a file */ |
| 1579 | if (!p || read(fd, p, len) == -1) { |
| 1580 | free(p); |
| 1581 | p = NULL; |
| 1582 | } |
| 1583 | |
| 1584 | /* Restore the position */ |
| 1585 | lseek(fd, pos, SEEK_SET); |
| 1586 | |
| 1587 | return p; |
| 1588 | } |
| 1589 | #define munmap(x, y) free(x) |
| 1590 | #define MAP_FAILED NULL |
| 1591 | #define MAP_PRIVATE 0 |
| 1592 | #define PROT_READ 0 |
| 1557 | 1593 | #else |
| 1558 | 1594 | #include <sys/mman.h> |
| 1559 | 1595 | #endif |
branches/kale/src/osd/sdl/sdlos_os2.c
| r244605 | r244606 | |
| 23 | 23 | |
| 24 | 24 | // MAME headers |
| 25 | 25 | #include "osdcore.h" |
| 26 | | #include "osdlib.h" |
| 27 | 26 | |
| 28 | 27 | //============================================================ |
| 29 | 28 | // osd_get_clipboard_text |
| r244605 | r244606 | |
| 36 | 35 | |
| 37 | 36 | return result; |
| 38 | 37 | } |
| 39 | | |
| 40 | | //============================================================ |
| 41 | | // osd_stat |
| 42 | | //============================================================ |
| 43 | | |
| 44 | | osd_directory_entry *osd_stat(const char *path) |
| 45 | | { |
| 46 | | int err; |
| 47 | | osd_directory_entry *result = NULL; |
| 48 | | struct stat st; |
| 49 | | |
| 50 | | err = stat(path, &st); |
| 51 | | |
| 52 | | if( err == -1) return NULL; |
| 53 | | |
| 54 | | // create an osd_directory_entry; be sure to make sure that the caller can |
| 55 | | // free all resources by just freeing the resulting osd_directory_entry |
| 56 | | result = (osd_directory_entry *) osd_malloc_array(sizeof(*result) + strlen(path) + 1); |
| 57 | | strcpy(((char *) result) + sizeof(*result), path); |
| 58 | | result->name = ((char *) result) + sizeof(*result); |
| 59 | | result->type = S_ISDIR(st.st_mode) ? ENTTYPE_DIR : ENTTYPE_FILE; |
| 60 | | result->size = (UINT64)st.st_size; |
| 61 | | |
| 62 | | return result; |
| 63 | | } |
| 64 | | |
| 65 | | //============================================================ |
| 66 | | // osd_get_volume_name |
| 67 | | //============================================================ |
| 68 | | |
| 69 | | const char *osd_get_volume_name(int idx) |
| 70 | | { |
| 71 | | static char szDrive[] = "A:\\"; |
| 72 | | |
| 73 | | ULONG ulCurDisk; |
| 74 | | ULONG ulDriveMap; |
| 75 | | |
| 76 | | DosQueryCurrentDisk(&ulCurDisk, &ulDriveMap); |
| 77 | | |
| 78 | | szDrive[ 0 ] = 'A'; |
| 79 | | while(idx--) { |
| 80 | | do |
| 81 | | { |
| 82 | | ulDriveMap >>= 1; |
| 83 | | szDrive[ 0 ]++; |
| 84 | | } while(ulDriveMap && (ulDriveMap & 1) == 0); |
| 85 | | if (!ulDriveMap) return NULL; |
| 86 | | } |
| 87 | | |
| 88 | | return szDrive; |
| 89 | | } |
| 90 | | |
| 91 | | //============================================================ |
| 92 | | // osd_get_full_path |
| 93 | | //============================================================ |
| 94 | | |
| 95 | | file_error osd_get_full_path(char **dst, const char *path) |
| 96 | | { |
| 97 | | *dst = (char *)osd_malloc_array(CCHMAXPATH + 1); |
| 98 | | if (*dst == NULL) |
| 99 | | return FILERR_OUT_OF_MEMORY; |
| 100 | | |
| 101 | | _abspath(*dst, path, CCHMAXPATH + 1); |
| 102 | | return FILERR_NONE; |
| 103 | | } |