Changeset f36222f
- Timestamp:
- Dec 6, 2003, 9:13:39 PM (21 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 88ca489
- Parents:
- a68f05d
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
ra68f05d rf36222f 8 8 Command line arg -D turns on debugging and deletes previous 9 9 debugging file 10 Do ~ expansion in 'dump' command. 10 11 11 12 2.0.13 -
commands.c
rc1be0c6 rf36222f 1083 1083 char *owl_command_dump(int argc, char **argv, char *buff) 1084 1084 { 1085 char *filename; 1086 1085 1087 if (argc!=2) { 1086 1088 owl_function_makemsg("usage: dump <filename>"); 1087 1089 return(NULL); 1088 1090 } 1089 1090 owl_function_dump(argv[1]); 1091 filename=owl_util_makepath(argv[1]); 1092 owl_function_dump(filename); 1093 owl_free(filename); 1091 1094 return(NULL); 1092 1095 } -
functions.c
rd9b0b972 rf36222f 3120 3120 } 3121 3121 3122 /* Dump messages in the current view to the file 'filename'. */ 3122 3123 void owl_function_dump(char *filename) 3123 3124 { … … 3126 3127 owl_view *v; 3127 3128 FILE *file; 3129 3128 3130 /* struct stat sbuf; */ 3129 3131 … … 3152 3154 } 3153 3155 fclose(file); 3156 owl_function_makemsg("Messages dumped to %s", filename); 3154 3157 } 3155 3158 -
util.c
r12c35df rf36222f 4 4 #include <unistd.h> 5 5 #include <ctype.h> 6 #include <pwd.h> 6 7 7 8 static const char fileIdent[] = "$Id$"; … … 175 176 } 176 177 return buff; 178 } 179 180 /* Return a "nice" version of the path. Tilde expansion is done, and 181 * duplicate slashes are removed. Caller must free the return. 182 */ 183 char *owl_util_makepath(char *in) 184 { 185 int i, j, x; 186 char *out, user[MAXPATHLEN]; 187 struct passwd *pw; 188 189 out=owl_malloc(MAXPATHLEN+1); 190 out[0]='\0'; 191 j=strlen(in); 192 x=0; 193 for (i=0; i<j; i++) { 194 if (in[i]=='~') { 195 if ( (i==(j-1)) || /* last character */ 196 (in[i+1]=='/') ) { /* ~/ */ 197 /* use my homedir */ 198 pw=getpwuid(getuid()); 199 if (!pw) { 200 out[x]=in[i]; 201 } else { 202 out[x]='\0'; 203 strcat(out, pw->pw_dir); 204 x+=strlen(pw->pw_dir); 205 } 206 } else { 207 /* another user homedir */ 208 int a, b; 209 b=0; 210 for (a=i+1; i<j; a++) { 211 if (in[a]==' ' || in[a]=='/') { 212 break; 213 } else { 214 user[b]=in[a]; 215 i++; 216 b++; 217 } 218 } 219 user[b]='\0'; 220 pw=getpwnam(user); 221 if (!pw) { 222 out[x]==in[i]; 223 } else { 224 out[x]='\0'; 225 strcat(out, pw->pw_dir); 226 x+=strlen(pw->pw_dir); 227 } 228 } 229 } else if (in[i]=='/') { 230 /* check for a double / */ 231 if (i<(j-1) && (in[i+1]=='/')) { 232 /* do nothing */ 233 } else { 234 out[x]=in[i]; 235 x++; 236 } 237 } else { 238 out[x]=in[i]; 239 x++; 240 } 241 } 242 out[x]='\0'; 243 return(out); 177 244 } 178 245
Note: See TracChangeset
for help on using the changeset viewer.