Category : Batch File Utilities - mostly for DOS
Archive   : RBSETENV.ZIP
Filename : DELPATH.C
* delpath.c
*
* Returned status:
* 0 OK (including case where nothing needs to be done)
* 1 bad arguments
*
*/
#include
#include
#include
void exit(int status) { _exit(status); }
#define writes(s,i) write(i,s,strlen(s));
main(int argc, char *argv[])
{
int len;
char *path, *pathname, *str;
if( argc != 2) {
writes("Usage: delpath pathname\n",2);
exit(1);
} else {
pathname = strupr(argv[1]);
len = strlen(pathname);
/* strip off a trailing ";" and upper-case */
if( *(pathname+len-1) == ';') *(pathname+len-1) = '\0';
path = getenv("PATH");
str = strupr(path);
while (str) {
str = strstr(str, pathname);
if(!str) {
/* not present in path - nothing to do */
writes(path,1);
break;
} else if (*(str+len) == ';') {
/* appears at middle - write out the two parts */
*str = '\0';
writes(path,1);
writes(str+len+1,1);
break;
} else if (*(str+len) == '\0') {
/* appears at end - truncate */
*(str-1) = '\0';
writes(path,1);
break;
} else {
/* incorrect match found - keep looking */
str += len;
}
}
}
return(0);
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/