void Zone::printCards() { std::cout << " - Cards in " << getZoneName() << std::endl; for ( std::vector< Card* >::iterator it = cards.begin(); it != cards.end(); ++it ) { std::cout << (*it)->getName() << std::endl; } }
void ZoneImplementation::startManagers() { planetManager->initialize(); creatureManager->initialize(); StructureManager::instance()->loadPlayerStructures(getZoneName()); ObjectDatabaseManager::instance()->commitLocalTransaction(); managersStarted = true; }
void ZoneServer::handleWMReady() { _updateDBServerList(2); gLogger->logMsg("ZoneServer::Startup Complete"); //gLogger->printLogo(); // std::string BuildString(GetBuildString()); gLogger->logMsgF("ZoneServer:%s %s",MSG_NORMAL,getZoneName().getAnsi(),ConfigManager::getBuildString().c_str()); gLogger->logMsg("Welcome to your SWGANH Experience!"); // Connect to the ConnectionServer; _connectToConnectionServer(); }
/* * Performs Linux specific mapping and returns a zone ID * if found. Otherwise, NULL is returned. */ static char * getPlatformTimeZoneID() { struct stat statbuf; char *tz = NULL; FILE *fp; int fd; char *buf; size_t size; #if defined(__linux__) /* * Try reading the /etc/timezone file for Debian distros. There's * no spec of the file format available. This parsing assumes that * there's one line of an Olson tzid followed by a '\n', no * leading or trailing spaces, no comments. */ if ((fp = fopen(ETC_TIMEZONE_FILE, "r")) != NULL) { char line[256]; if (fgets(line, sizeof(line), fp) != NULL) { char *p = strchr(line, '\n'); if (p != NULL) { *p = '\0'; } if (strlen(line) > 0) { tz = strdup(line); } } (void) fclose(fp); if (tz != NULL) { return tz; } } #endif /* defined(__linux__) */ /* * Next, try /etc/localtime to find the zone ID. */ if (lstat(DEFAULT_ZONEINFO_FILE, &statbuf) == -1) { return NULL; } /* * If it's a symlink, get the link name and its zone ID part. (The * older versions of timeconfig created a symlink as described in * the Red Hat man page. It was changed in 1999 to create a copy * of a zoneinfo file. It's no longer possible to get the zone ID * from /etc/localtime.) */ if (S_ISLNK(statbuf.st_mode)) { char linkbuf[PATH_MAX+1]; int len; if ((len = readlink(DEFAULT_ZONEINFO_FILE, linkbuf, sizeof(linkbuf)-1)) == -1) { jio_fprintf(stderr, (const char *) "can't get a symlink of %s\n", DEFAULT_ZONEINFO_FILE); return NULL; } linkbuf[len] = '\0'; tz = getZoneName(linkbuf); if (tz != NULL) { tz = strdup(tz); return tz; } } /* * If it's a regular file, we need to find out the same zoneinfo file * that has been copied as /etc/localtime. * If initial symbolic link resolution failed, we should treat target * file as a regular file. */ if ((fd = open(DEFAULT_ZONEINFO_FILE, O_RDONLY)) == -1) { return NULL; } if (fstat(fd, &statbuf) == -1) { (void) close(fd); return NULL; } size = (size_t) statbuf.st_size; buf = (char *) malloc(size); if (buf == NULL) { (void) close(fd); return NULL; } if (read(fd, buf, size) != (ssize_t) size) { (void) close(fd); free((void *) buf); return NULL; } (void) close(fd); tz = findZoneinfoFile(buf, size, ZONEINFO_DIR); free((void *) buf); return tz; }
/* * Scans the specified directory and its subdirectories to find a * zoneinfo file which has the same content as /etc/localtime on Linux * or /usr/share/lib/zoneinfo/localtime on Solaris given in 'buf'. * If file is symbolic link, then the contents it points to are in buf. * Returns a zone ID if found, otherwise, NULL is returned. */ static char * findZoneinfoFile(char *buf, size_t size, const char *dir) { DIR *dirp = NULL; struct stat statbuf; struct dirent64 *dp = NULL; struct dirent64 *entry = NULL; char *pathname = NULL; int fd = -1; char *dbuf = NULL; char *tz = NULL; dirp = opendir(dir); if (dirp == NULL) { return NULL; } entry = (struct dirent64 *) malloc((size_t) pathconf(dir, _PC_NAME_MAX)); if (entry == NULL) { (void) closedir(dirp); return NULL; } while (readdir64_r(dirp, entry, &dp) == 0 && dp != NULL) { /* * Skip '.' and '..' (and possibly other .* files) */ if (dp->d_name[0] == '.') { continue; } /* * Skip "ROC", "posixrules", and "localtime". */ if ((strcmp(dp->d_name, "ROC") == 0) || (strcmp(dp->d_name, "posixrules") == 0) #if defined(__solaris__) /* * Skip the "src" and "tab" directories on Solaris. */ || (strcmp(dp->d_name, "src") == 0) || (strcmp(dp->d_name, "tab") == 0) #endif || (strcmp(dp->d_name, "localtime") == 0)) { continue; } pathname = getPathName(dir, dp->d_name); if (pathname == NULL) { break; } if (stat(pathname, &statbuf) == -1) { break; } if (S_ISDIR(statbuf.st_mode)) { tz = findZoneinfoFile(buf, size, pathname); if (tz != NULL) { break; } } else if (S_ISREG(statbuf.st_mode) && (size_t)statbuf.st_size == size) { dbuf = (char *) malloc(size); if (dbuf == NULL) { break; } if ((fd = open(pathname, O_RDONLY)) == -1) { break; } if (read(fd, dbuf, size) != (ssize_t) size) { break; } if (memcmp(buf, dbuf, size) == 0) { tz = getZoneName(pathname); if (tz != NULL) { tz = strdup(tz); } break; } free((void *) dbuf); dbuf = NULL; (void) close(fd); fd = -1; } free((void *) pathname); pathname = NULL; } if (entry != NULL) { free((void *) entry); } if (dirp != NULL) { (void) closedir(dirp); } if (pathname != NULL) { free((void *) pathname); } if (fd != -1) { (void) close(fd); } if (dbuf != NULL) { free((void *) dbuf); } return tz; }
/* * Scans the specified directory and its subdirectories to find a * zoneinfo file which has the same content as /etc/localtime on Linux * or /usr/share/lib/zoneinfo/localtime on Solaris given in 'buf'. * If file is symbolic link, then the contents it points to are in buf. * Returns a zone ID if found, otherwise, NULL is returned. */ static char * findZoneinfoFile(char *buf, size_t size, const char *dir) { DIR *dirp = NULL; struct stat statbuf; struct dirent *dp = NULL; struct dirent *entry = NULL; char *pathname = NULL; int fd = -1; char *dbuf = NULL; char *tz = NULL; dirp = opendir(dir); if (dirp == NULL) { return NULL; } entry = (struct dirent *) malloc((size_t) pathconf(dir, _PC_NAME_MAX)); if (entry == NULL) { (void) closedir(dirp); return NULL; } #if defined(__linux__) || defined(MACOSX) || (defined(__solaris__) \ && (defined(_POSIX_PTHREAD_SEMANTICS) || defined(_LP64))) while (readdir_r(dirp, entry, &dp) == 0 && dp != NULL) { #else while ((dp = readdir_r(dirp, entry)) != NULL) { #endif /* * Skip '.' and '..' (and possibly other .* files) */ if (dp->d_name[0] == '.') { continue; } /* * Skip "ROC", "posixrules", and "localtime". */ if ((strcmp(dp->d_name, "ROC") == 0) || (strcmp(dp->d_name, "posixrules") == 0) #ifdef __solaris__ /* * Skip the "src" and "tab" directories on Solaris. */ || (strcmp(dp->d_name, "src") == 0) || (strcmp(dp->d_name, "tab") == 0) #endif || (strcmp(dp->d_name, "localtime") == 0)) { continue; } pathname = getPathName(dir, dp->d_name); if (pathname == NULL) { break; } if (stat(pathname, &statbuf) == -1) { break; } if (S_ISDIR(statbuf.st_mode)) { tz = findZoneinfoFile(buf, size, pathname); if (tz != NULL) { break; } } else if (S_ISREG(statbuf.st_mode) && (size_t)statbuf.st_size == size) { dbuf = (char *) malloc(size); if (dbuf == NULL) { break; } if ((fd = open(pathname, O_RDONLY)) == -1) { fd = 0; break; } if (read(fd, dbuf, size) != (ssize_t) size) { break; } if (memcmp(buf, dbuf, size) == 0) { tz = getZoneName(pathname); if (tz != NULL) { tz = strdup(tz); } break; } free((void *) dbuf); dbuf = NULL; (void) close(fd); fd = 0; } free((void *) pathname); pathname = NULL; } if (entry != NULL) { free((void *) entry); } if (dirp != NULL) { (void) closedir(dirp); } if (pathname != NULL) { free((void *) pathname); } if (fd != 0) { (void) close(fd); } if (dbuf != NULL) { free((void *) dbuf); } return tz; } #if defined(__linux__) || defined(MACOSX) /* * Performs Linux specific mapping and returns a zone ID * if found. Otherwise, NULL is returned. */ static char * getPlatformTimeZoneID() { struct stat statbuf; char *tz = NULL; FILE *fp; int fd; char *buf; size_t size; #ifdef __linux__ /* * Try reading the /etc/timezone file for Debian distros. There's * no spec of the file format available. This parsing assumes that * there's one line of an Olson tzid followed by a '\n', no * leading or trailing spaces, no comments. */ if ((fp = fopen(ETC_TIMEZONE_FILE, "r")) != NULL) { char line[256]; if (fgets(line, sizeof(line), fp) != NULL) { char *p = strchr(line, '\n'); if (p != NULL) { *p = '\0'; } if (strlen(line) > 0) { tz = strdup(line); } } (void) fclose(fp); if (tz != NULL) { return tz; } } #endif /* __linux__ */ /* * Next, try /etc/localtime to find the zone ID. */ if (lstat(DEFAULT_ZONEINFO_FILE, &statbuf) == -1) { return NULL; } /* * If it's a symlink, get the link name and its zone ID part. (The * older versions of timeconfig created a symlink as described in * the Red Hat man page. It was changed in 1999 to create a copy * of a zoneinfo file. It's no longer possible to get the zone ID * from /etc/localtime.) */ if (S_ISLNK(statbuf.st_mode)) { char linkbuf[PATH_MAX+1]; int len; if ((len = readlink(DEFAULT_ZONEINFO_FILE, linkbuf, sizeof(linkbuf)-1)) == -1) { jio_fprintf(stderr, (const char *) "can't get a symlink of %s\n", DEFAULT_ZONEINFO_FILE); return NULL; } linkbuf[len] = '\0'; tz = getZoneName(linkbuf); if (tz != NULL) { tz = strdup(tz); return tz; } } /* * If it's a regular file, we need to find out the same zoneinfo file * that has been copied as /etc/localtime. * If initial symbolic link resolution failed, we should treat target * file as a regular file. */ if ((fd = open(DEFAULT_ZONEINFO_FILE, O_RDONLY)) == -1) { return NULL; } if (fstat(fd, &statbuf) == -1) { (void) close(fd); return NULL; } size = (size_t) statbuf.st_size; buf = (char *) malloc(size); if (buf == NULL) { (void) close(fd); return NULL; } if (read(fd, buf, size) != (ssize_t) size) { (void) close(fd); free((void *) buf); return NULL; } (void) close(fd); tz = findZoneinfoFile(buf, size, ZONEINFO_DIR); free((void *) buf); return tz; } #else #ifdef __solaris__ #if !defined(__sparcv9) && !defined(amd64) /* * Those file* functions mimic the UNIX stream io functions. This is * because of the limitation of the number of open files on Solaris * (32-bit mode only) due to the System V ABI. */ #define BUFFER_SIZE 4096 static struct iobuffer { int magic; /* -1 to distinguish from the real FILE */ int fd; /* file descriptor */ char *buffer; /* pointer to buffer */ char *ptr; /* current read pointer */ char *endptr; /* end pointer */ }; static int fileclose(FILE *stream) { struct iobuffer *iop = (struct iobuffer *) stream; if (iop->magic != -1) { return fclose(stream); } if (iop == NULL) { return 0; } close(iop->fd); free((void *)iop->buffer); free((void *)iop); return 0; } static FILE * fileopen(const char *fname, const char *fmode) { FILE *fp; int fd; struct iobuffer *iop; if ((fp = fopen(fname, fmode)) != NULL) { return fp; } /* * It assumes read open. */ if ((fd = open(fname, O_RDONLY)) == -1) { return NULL; } /* * Allocate struct iobuffer and its buffer */ iop = malloc(sizeof(struct iobuffer)); if (iop == NULL) { (void) close(fd); errno = ENOMEM; return NULL; } iop->magic = -1; iop->fd = fd; iop->buffer = malloc(BUFFER_SIZE); if (iop->buffer == NULL) { (void) close(fd); free((void *) iop); errno = ENOMEM; return NULL; } iop->ptr = iop->buffer; iop->endptr = iop->buffer; return (FILE *)iop; }
/* * Scans the specified directory and its subdirectories to find a * zoneinfo file which has the same content as /etc/localtime given in * 'buf'. Returns a zone ID if found, otherwise, NULL is returned. */ static char * findZoneinfoFile(char *buf, size_t size, const char *dir) { DIR *dirp = NULL; struct stat statbuf; struct dirent *dp; char *pathname = NULL; int fd = -1; char *dbuf = NULL; char *tz = NULL; dirp = opendir(dir); if (dirp == NULL) { return NULL; } while ((dp = readdir(dirp)) != NULL) { /* * Skip '.' and '..' (and possibly other .* files) */ if (dp->d_name[0] == '.') { continue; } pathname = getPathName(dir, dp->d_name); if (pathname == NULL) { break; } if (stat(pathname, &statbuf) == -1) { break; } if (S_ISDIR(statbuf.st_mode)) { tz = findZoneinfoFile(buf, size, pathname); if (tz != NULL) { break; } } else if (S_ISREG(statbuf.st_mode) && (size_t)statbuf.st_size == size) { dbuf = (char *) malloc(size); if (dbuf == NULL) { break; } if ((fd = open(pathname, O_RDONLY)) == -1) { fd = 0; break; } if (read(fd, dbuf, size) != (ssize_t) size) { break; } if (memcmp(buf, dbuf, size) == 0) { tz = getZoneName(pathname); if (tz != NULL) { tz = strdup(tz); } break; } free((void *) dbuf); dbuf = NULL; (void) close(fd); fd = 0; } free((void *) pathname); pathname = NULL; } if (dirp != NULL) { (void) closedir(dirp); } if (pathname != NULL) { free((void *) pathname); } if (fd != 0) { (void) close(fd); } if (dbuf != NULL) { free((void *) dbuf); } return tz; }
/* * Performs libc implementation specific mapping and returns a zone ID * if found. Otherwise, NULL is returned. */ static char * getPlatformTimeZoneID() { struct stat statbuf; char *tz = NULL; FILE *fp; int fd; char *buf; size_t size; /* * First, try the ZONE entry in /etc/sysconfig/clock. However, the * ZONE entry is not set up after initial Red Hat Linux * installation. In case that /etc/localtime is set up without * using timeconfig, there might be inconsistency between * /etc/localtime and the ZONE entry. The inconsistency between * timeconfig and linuxconf is reported as a bug in the Red Hat * web page as of May 1, 2000. */ if ((fp = fopen(sysconfig_clock_file, "r")) != NULL) { char line[256]; while (fgets(line, sizeof(line), fp) != NULL) { char *p = line; char *s; SKIP_SPACE(p); if (*p != 'Z') { continue; } if (strncmp(p, "ZONE=\"", 6) == 0) { p += 6; } else { /* * In case we need to parse it token by token. */ if (strncmp(p, "ZONE", 4) != 0) { continue; } p += 4; SKIP_SPACE(p); if (*p++ != '=') { break; } SKIP_SPACE(p); if (*p++ != '"') { break; } } for (s = p; *s && *s != '"'; s++) ; if (*s != '"') { /* this ZONE entry is broken. */ break; } *s = '\0'; tz = strdup(p); break; } (void) fclose(fp); if (tz != NULL) { return tz; } } /* * Next, try /etc/localtime to find the zone ID. */ if (lstat(defailt_zoneinfo_file, &statbuf) == -1) { return NULL; } /* * If it's a symlink, get the link name and its zone ID part. (The * older versions of timeconfig created a symlink as described in * the Red Hat man page. It was changed in 1999 to create a copy * of a zoneinfo file. It's no longer possible to get the zone ID * from /etc/localtime.) */ if (S_ISLNK(statbuf.st_mode)) { char linkbuf[PATH_MAX+1]; int len; if ((len = readlink(defailt_zoneinfo_file, linkbuf, sizeof(linkbuf)-1)) == -1) { jio_fprintf(stderr, (const char *) "can't get a symlink of %s\n", defailt_zoneinfo_file); return NULL; } linkbuf[len] = '\0'; tz = getZoneName(linkbuf); if (tz != NULL) { tz = strdup(tz); } return tz; } /* * If it's a regular file, we need to find out the same zoneinfo file * that has been copied as /etc/localtime. */ size = (size_t) statbuf.st_size; buf = (char *) malloc(size); if (buf == NULL) { return NULL; } if ((fd = open(defailt_zoneinfo_file, O_RDONLY)) == -1) { free((void *) buf); return NULL; } if (read(fd, buf, size) != (ssize_t) size) { (void) close(fd); free((void *) buf); return NULL; } (void) close(fd); tz = findZoneinfoFile(buf, size, zoneinfo_dir); free((void *) buf); return tz; }
void Zone::addCard( Card* card ) { std::cout << "Added " << card->getName() << " to " << getZoneName() << std::endl; cards.push_back( card ); }