set savefile name in OS-dependent manner from pre-existing svp.plname, * avoiding troublesome characters */
| 1017 | /* set savefile name in OS-dependent manner from pre-existing svp.plname, |
| 1018 | * avoiding troublesome characters */ |
| 1019 | void |
| 1020 | set_savefile_name(boolean regularize_it) |
| 1021 | { |
| 1022 | int regoffset = 0, overflow = 0, |
| 1023 | indicator_spot = 0; /* 0=no indicator, 1=before ext, 2=after ext */ |
| 1024 | const char *postappend = (const char *) 0, |
| 1025 | *sfindicator = (const char *) 0; |
| 1026 | #if defined(WIN32) |
| 1027 | char tmp[BUFSZ]; |
| 1028 | #endif |
| 1029 | |
| 1030 | #ifdef VMS |
| 1031 | Sprintf(gs.SAVEF, "[.save]%d%s", getuid(), svp.plname); |
| 1032 | regoffset = 7; |
| 1033 | indicator_spot = 1; |
| 1034 | postappend = ";1"; |
| 1035 | #endif |
| 1036 | #if defined(WIN32) |
| 1037 | if (regularize_it) { |
| 1038 | static const char okchars[] |
| 1039 | = "*ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-."; |
| 1040 | const char *legal = okchars; |
| 1041 | |
| 1042 | ++legal; /* skip '*' wildcard character */ |
| 1043 | (void) fname_encode(legal, '%', svp.plname, tmp, sizeof tmp); |
| 1044 | } else { |
| 1045 | Sprintf(tmp, "%s", svp.plname); |
| 1046 | } |
| 1047 | if (strlen(tmp) < (SAVESIZE - 1)) |
| 1048 | Strcpy(gs.SAVEF, tmp); |
| 1049 | else |
| 1050 | overflow = 1; |
| 1051 | indicator_spot = 1; |
| 1052 | regularize_it = FALSE; |
| 1053 | #endif |
| 1054 | #ifdef UNIX |
| 1055 | Sprintf(gs.SAVEF, "save/%d%s", (int) getuid(), svp.plname); |
| 1056 | regoffset = 5; |
| 1057 | indicator_spot = 2; |
| 1058 | #endif |
| 1059 | #if defined(MSDOS) |
| 1060 | if (strlen(gs.SAVEP) < (SAVESIZE - 1)) |
| 1061 | Strcpy(gs.SAVEF, gs.SAVEP); |
| 1062 | if (strlen(gs.SAVEF) < (SAVESIZE - 1)) |
| 1063 | (void) strncat(gs.SAVEF, svp.plname, (SAVESIZE - strlen(gs.SAVEF))); |
| 1064 | #endif |
| 1065 | #if defined(MICRO) && !defined(WIN32) && !defined(MSDOS) |
| 1066 | if (strlen(gs.SAVEP) < (SAVESIZE - 1)) |
| 1067 | Strcpy(gs.SAVEF, gs.SAVEP); |
| 1068 | else |
| 1069 | #ifdef AMIGA |
| 1070 | if (strlen(gs.SAVEP) + strlen(bbs_id) < (SAVESIZE - 1)) |
| 1071 | strncat(gs.SAVEF, bbs_id, PATHLEN); |
| 1072 | #endif |
| 1073 | { |
| 1074 | int i = strlen(gs.SAVEP); |
| 1075 | #ifdef AMIGA |
| 1076 | /* svp.plname has to share space with gs.SAVEP and ".sav" */ |
no test coverage detected