static void assign_db_stat (T_CM_DB_PROC_STAT * db_stat, char *db_name, T_CM_PROC_STAT * stat) { strcpy_limit (db_stat->name, db_name, sizeof (db_stat->name)); db_stat->stat = *stat; }
//--------------------------------------------------------------------------- HRESULT __stdcall MSADPCMModule::GetSupportExts(unsigned long index, LPWSTR mediashortname, LPWSTR buf, unsigned long buflen ) { if(index >= 1) return S_FALSE; wcscpy(mediashortname, L"MS-ADPCM Wave ファイル"); strcpy_limit(buf, L".wav", buflen); return S_OK; }
/* * Convert a Unix device to a prom device and save on success, * log any ioctl/conversion error. */ static int utop(char *fs_name, char *prom_name) { union obpbuf { char buf[OBP_MAXPATHLEN + sizeof (uint_t)]; struct openpromio oppio; }; union obpbuf oppbuf; struct openpromio *opp; char *promdev = "/dev/openprom"; int fd, upval; if ((fd = open(promdev, O_RDONLY)) == -1) { mesg(MERR, open_fmt, promdev, strerror(errno)); return (NOUP); } opp = &oppbuf.oppio; opp->oprom_size = OBP_MAXPATHLEN; strcpy_limit(opp->oprom_array, fs_name, OBP_MAXPATHLEN, "statefile device"); upval = ioctl(fd, OPROMDEV2PROMNAME, opp); (void) close(fd); if (upval == OKUP) { strcpy_limit(prom_name, opp->oprom_array, OBP_MAXPATHLEN, "prom device"); } else { openlog("pmconfig", 0, LOG_DAEMON); syslog(LOG_NOTICE, gettext("cannot convert \"%s\" to prom device"), fs_name); closelog(); } return (upval); }
/* * Parse a command line to determine the name of the game file specified * by the arguments. We'll return the index of the argv element that * specifies the name of the game, or a negative number if there is no * filename argument. * * Note that our parsing will work for TADS 2 or TADS 3 interpreter * command lines, so this routine can be used to extract the filename from * an ambiguous command line in order to check the file for its type and * thereby resolve which interpreter to use. */ int vm_get_game_arg(int argc, const char *const *argv, char *buf, size_t buflen) { int i; const char *restore_file; /* presume we won't find a file to restore */ restore_file = 0; /* * Scan the arguments for the union of the TADS 2 and TADS 3 command * line options. Start at the second element of the argument vector, * since the first element is the executable name. Keep going until * we run out of options, each of which must start with a '-'. * * Note that we don't care about the meanings of the options - we * simply want to skip past them. This is more complicated than * merely looking for the first argument without a '-' prefix, because * some of the options allow arguments, and an option argument can * sometimes - depending on the argument - take the next position in * the argument vector after the option itself. So, we must determine * the meaning of each option well enough that we can tell whether or * not the next argv element after the option is part of the option. */ for (i = 1 ; i < argc && argv[i][0] == '-' ; ++i) { /* * check the first character after the hyphen to determine which * option we have */ switch(argv[i][1]) { case 'b': /* * tads 3 "-banner" (no arguments, so just consume it and * continue) */ break; case 'c': /* * tads 3 "-cs charset" or "-csl charset"; tads 2 "-ctab-" or * "-ctab tab" */ if (strcmp(argv[i], "-ctab") == 0 || strcmp(argv[i], "-cs") == 0 || strcmp(argv[i], "-csl") == 0) { /* there's another argument giving the filename */ ++i; } break; case 'd': /* tads 2 "-double[+-]" (no arguments) */ break; case 'm': /* tads 2 "-msSize", "-mhSize", "-mSize" */ switch(argv[i][2]) { case 's': case 'h': /* * argument required - if nothing follows the second * letter, consume the next vector item as the option * argument */ if (argv[i][3] == '\0') ++i; break; case '\0': /* * argument required, but nothing follows the "-m" - * consume the next vector item */ ++i; break; default: /* argument required and present */ break; } break; case 't': /* tads 2 "-tfFile", "-tsSize", "-tp[+-]", "-t[+0]" */ switch(argv[i][2]) { case 'f': case 's': /* * argument required - consume the next vector item if * nothing is attached to this item */ if (argv[i][3] == '\0') ++i; break; case 'p': /* no arguments */ break; default: /* no arguments */ break; } break; case 'u': /* * tads 2 "-uSize" - argument required, so consume the next * vector item if necessary */ if (argv[i][2] == '\0') ++i; break; case 'n': /* tads 3 "-nobanner" - no arguments */ break; case 's': /* * tads 2/3 "-s#" (#=0,1,2,3,4); in tads 2, the # can be * separated by a space from the -s, so we'll allow it this * way in general */ if (argv[i][2] == '\0') ++i; break; case 'i': /* tads 2/3 "-iFile" - consume an argument */ if (argv[i][2] == '\0') ++i; break; case 'l': /* tads 2/3 "-lFile" - consume an argument */ if (argv[i][2] == '\0') ++i; break; case 'o': /* tads 2/3 "-oFile" - consume an argument */ if (argv[i][2] == '\0') ++i; break; case 'p': /* tads 2/3 "-plain"; tads 2 "-p[+-]" - no arguments */ break; case 'R': /* tads 3 '-Rdir' - consume an argument */ if (argv[i][2] == '\0') ++i; break; case 'r': /* tads 2/3 "-rFile" - consume an argument */ if (argv[i][2] != '\0') { /* the file to be restored is appended to the "-r" */ restore_file = argv[i] + 2; } else { /* the file to be restored is the next argument */ ++i; restore_file = argv[i]; } break; } } /* * We have no more options, so the next argument is the game filename. * If we're out of argv elements, then no game filename was directly * specified, in which case we'll try looking for a file spec in the * restore file, if present. */ if (i < argc) { /* there's a game file argument - copy it to the caller's buffer */ strcpy_limit(buf, argv[i], buflen); /* return success */ return TRUE; } else if (restore_file != 0) { /* * There's no game file argument, but there is a restore file * argument. Try identifying the game file from the original game * file specification stored in the saved state file. */ return vm_get_game_file_from_savefile(restore_file, buf, buflen); } else { /* * there's no game file or restore file argument, so they've given * us nothing to go on - there's no game file */ return FALSE; } }
T_CM_DISK_PARTITION_STAT_ALL * cm_get_host_disk_partition_stat (T_CM_ERROR * err_buf) { int i, len; char buf[160] = { 0 }; ULONGLONG total_size[32], free_size[32]; char names[32][4] = { 0 }; char *token; T_CM_DISK_PARTITION_STAT_ALL *res; len = GetLogicalDriveStringsA (sizeof (buf), buf); for (i = 0; i < len; i++) { if (buf[i] == 0) { buf[i] = ';'; } } buf[len - 1] = 0; i = 0; for (token = strtok (buf, ";"); token != NULL && i < 32; token = strtok (NULL, ";")) { if (GetDriveTypeA (token) == DRIVE_FIXED) { ULARGE_INTEGER ul_total, ul_free; GetDiskFreeSpaceExA (token, &ul_free, &ul_total, NULL); total_size[i] = ul_total.QuadPart; free_size[i] = ul_free.QuadPart; strcpy_limit (names[i], token, sizeof (names[i])); i++; } } res = malloc (sizeof (T_CM_DISK_PARTITION_STAT_ALL)); if (res == NULL) { return NULL; } res->num_stat = i; res->partitions = malloc (sizeof (T_CM_DISK_PARTITION_STAT) * i); if (res->partitions == NULL) { FREE_MEM (res); return NULL; } for (i = 0; i < res->num_stat; i++) { res->partitions[i].avail = free_size[i]; res->partitions[i].size = total_size[i]; res->partitions[i].used = total_size[i] - free_size[i]; strcpy_limit (res->partitions[i].name, names[i], sizeof (res->partitions[i].name)); } return res; }
//--------------------------------------------------------------------------- HRESULT __stdcall MSADPCMModule::GetModuleDescription(LPWSTR buffer, unsigned long buflen ) { strcpy_limit(buffer, L"Microsoft ADPCM decoder (*.wav)", buflen); return S_OK; }
//--------------------------------------------------------------------------- HRESULT __stdcall MSADPCMModule::GetModuleCopyright(LPWSTR buffer, unsigned long buflen) { strcpy_limit(buffer, L"Microsft ADPCM decoder for TVP Sound System (C) 2000 W.Dee <*****@*****.**> and contributors", buflen); return S_OK; }
static int read_start_server_output (char *stdout_file, char *stderr_file, char *_dbmt_error) { FILE *fp, *fp2; char buf[1024]; char *strp; int retval = 0; if (access (stdout_file, F_OK) == 0) { fp = fopen (stdout_file, "r"); if (fp != NULL) { while (fgets (buf, sizeof (buf), fp) != NULL) { if (strncmp (buf, "++", 2) == 0) { if ((strp = strchr (buf, ':')) && strstr (strp, "fail")) { retval = -1; break; } } } fclose (fp); } } if (access (stderr_file, F_OK) == 0) { fp2 = fopen (stderr_file, "r"); if (fp2 != NULL) { int len = 0; while (fgets (buf, sizeof (buf), fp2) != NULL) { ut_trim (buf); len += (int) strlen (buf); if (len < (DBMT_ERROR_MSG_SIZE - 1)) { strcpy (_dbmt_error, buf); _dbmt_error += len; } else { strcpy_limit (_dbmt_error, buf, DBMT_ERROR_MSG_SIZE); strcpy_limit (_dbmt_error + DBMT_ERROR_MSG_SIZE - 4, "...", 4); break; } } if (len != 0 && retval != -1) { retval = 1; } fclose (fp2); } } return retval; }