tc.func.c (69408) | tc.func.c (83098) |
---|---|
1/* $Header: /src/pub/tcsh/tc.func.c,v 3.94 2000/11/12 02:18:06 christos Exp $ */ | 1/* $Header: /src/pub/tcsh/tc.func.c,v 3.97 2001/08/28 23:13:44 christos Exp $ */ |
2/* 3 * tc.func.c: New tcsh builtins. 4 */ 5/*- 6 * Copyright (c) 1980, 1991 The Regents of the University of California. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without --- 21 unchanged lines hidden (view full) --- 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 */ 37#include "sh.h" 38 | 2/* 3 * tc.func.c: New tcsh builtins. 4 */ 5/*- 6 * Copyright (c) 1980, 1991 The Regents of the University of California. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without --- 21 unchanged lines hidden (view full) --- 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 */ 37#include "sh.h" 38 |
39RCSID("$Id: tc.func.c,v 3.94 2000/11/12 02:18:06 christos Exp $") | 39RCSID("$Id: tc.func.c,v 3.97 2001/08/28 23:13:44 christos Exp $") |
40 41#include "ed.h" 42#include "ed.defns.h" /* for the function names */ 43#include "tw.h" 44#include "tc.h" 45#ifdef WINNT_NATIVE 46#include "nt.const.h" 47#endif /* WINNT_NATIVE */ --- 10 unchanged lines hidden (view full) --- 58#endif /* AFS */ 59 60#ifdef TESLA 61extern int do_logout; 62#endif /* TESLA */ 63extern time_t t_period; 64extern int just_signaled; 65static bool precmd_active = 0; | 40 41#include "ed.h" 42#include "ed.defns.h" /* for the function names */ 43#include "tw.h" 44#include "tc.h" 45#ifdef WINNT_NATIVE 46#include "nt.const.h" 47#endif /* WINNT_NATIVE */ --- 10 unchanged lines hidden (view full) --- 58#endif /* AFS */ 59 60#ifdef TESLA 61extern int do_logout; 62#endif /* TESLA */ 63extern time_t t_period; 64extern int just_signaled; 65static bool precmd_active = 0; |
66static bool jobcmd_active = 0; /* GrP */ |
|
66static bool postcmd_active = 0; 67static bool periodic_active = 0; 68static bool cwdcmd_active = 0; /* PWP: for cwd_cmd */ 69static bool beepcmd_active = 0; 70static signalfun_t alm_fun = NULL; 71 72static void auto_logout __P((int)); 73static char *xgetpass __P((char *)); --- 964 unchanged lines hidden (view full) --- 1038 periodic_active = 0; 1039#ifdef BSDSIGS 1040 (void) sigsetmask(omask); 1041#else /* !BSDSIGS */ 1042 (void) sigrelse(SIGINT); 1043#endif /* BSDSIGS */ 1044} 1045 | 67static bool postcmd_active = 0; 68static bool periodic_active = 0; 69static bool cwdcmd_active = 0; /* PWP: for cwd_cmd */ 70static bool beepcmd_active = 0; 71static signalfun_t alm_fun = NULL; 72 73static void auto_logout __P((int)); 74static char *xgetpass __P((char *)); --- 964 unchanged lines hidden (view full) --- 1039 periodic_active = 0; 1040#ifdef BSDSIGS 1041 (void) sigsetmask(omask); 1042#else /* !BSDSIGS */ 1043 (void) sigrelse(SIGINT); 1044#endif /* BSDSIGS */ 1045} 1046 |
1047 1048/* 1049 * GrP Greg Parker May 2001 1050 * Added job_cmd(), which is run every time a job is started or 1051 * foregrounded. The command is passed a single argument, the string 1052 * used to start the job originally. With precmd, useful for setting 1053 * xterm titles. 1054 * Cloned from cwd_cmd(). 1055 */ 1056void 1057job_cmd(args) 1058 Char *args; 1059{ 1060#ifdef BSDSIGS 1061 sigmask_t omask; 1062 1063 omask = sigblock(sigmask(SIGINT)); 1064#else /* !BSDSIGS */ 1065 (void) sighold(SIGINT); 1066#endif /* BSDSIGS */ 1067 if (jobcmd_active) { /* an error must have been caught */ 1068 aliasrun(2, STRunalias, STRjobcmd); 1069 xprintf(CGETS(22, 14, "Faulty alias 'jobcmd' removed.\n")); 1070 goto leave; 1071 } 1072 jobcmd_active = 1; 1073 if (!whyles && adrof1(STRjobcmd, &aliases)) 1074 aliasrun(2, STRjobcmd, args); 1075leave: 1076 jobcmd_active = 0; 1077#ifdef BSDSIGS 1078 (void) sigsetmask(omask); 1079#else /* !BSDSIGS */ 1080 (void) sigrelse(SIGINT); 1081#endif /* BSDSIGS */ 1082} 1083 1084 |
|
1046/* 1047 * Karl Kleinpaste, 21oct1983. 1048 * Set up a one-word alias command, for use for special things. 1049 * This code is based on the mainline of process(). 1050 */ 1051void 1052aliasrun(cnt, s1, s2) 1053 int cnt; --- 198 unchanged lines hidden (view full) --- 1252 tmp = tmp->next; 1253 xfree((ptr_t) del); 1254 } 1255 if (*tmp->word == ';') { 1256 tmp->prev->next = tmp->next; 1257 tmp->next->prev = tmp->prev; 1258 xfree((ptr_t) tmp->word); 1259 del = tmp; | 1085/* 1086 * Karl Kleinpaste, 21oct1983. 1087 * Set up a one-word alias command, for use for special things. 1088 * This code is based on the mainline of process(). 1089 */ 1090void 1091aliasrun(cnt, s1, s2) 1092 int cnt; --- 198 unchanged lines hidden (view full) --- 1291 tmp = tmp->next; 1292 xfree((ptr_t) del); 1293 } 1294 if (*tmp->word == ';') { 1295 tmp->prev->next = tmp->next; 1296 tmp->next->prev = tmp->prev; 1297 xfree((ptr_t) tmp->word); 1298 del = tmp; |
1299 tmp = tmp->next; |
|
1260 xfree((ptr_t) del); 1261 } | 1300 xfree((ptr_t) del); 1301 } |
1302 we = tmp; 1303 continue; |
|
1262 } 1263 } 1264 } 1265 } 1266 for (we = we->next; 1267 *we->word != ';' && we != cp; 1268 we = we->next) 1269 continue; --- 257 unchanged lines hidden (view full) --- 1527 char **res, **res1, *cp; 1528 Char *rp; 1529#endif /* HESIOD */ 1530 1531 pp = getpwnam(short2str(us)); 1532#ifdef YPBUGS 1533 fix_yp_bugs(); 1534#endif /* YPBUGS */ | 1304 } 1305 } 1306 } 1307 } 1308 for (we = we->next; 1309 *we->word != ';' && we != cp; 1310 we = we->next) 1311 continue; --- 257 unchanged lines hidden (view full) --- 1569 char **res, **res1, *cp; 1570 Char *rp; 1571#endif /* HESIOD */ 1572 1573 pp = getpwnam(short2str(us)); 1574#ifdef YPBUGS 1575 fix_yp_bugs(); 1576#endif /* YPBUGS */ |
1535 if (pp != NULL) 1536 return Strsave(str2short(pp->pw_dir)); | 1577 if (pp != NULL) { 1578 /* Don't return if root */ 1579 if (pp->pw_dir[0] == '/' && pp->pw_dir[1] == '\0') 1580 return NULL; 1581 else 1582 return Strsave(str2short(pp->pw_dir)); 1583 } |
1537#ifdef HESIOD 1538 res = hes_resolve(short2str(us), "filsys"); | 1584#ifdef HESIOD 1585 res = hes_resolve(short2str(us), "filsys"); |
1539 rp = 0; 1540 if (res != 0) { 1541 extern char *strtok(); 1542 if ((*res) != 0) { | 1586 rp = NULL; 1587 if (res != NULL) { 1588 if ((*res) != NULL) { |
1543 /* 1544 * Look at the first token to determine how to interpret 1545 * the rest of it. 1546 * Yes, strtok is evil (it's not thread-safe), but it's also 1547 * easy to use. 1548 */ 1549 cp = strtok(*res, " "); 1550 if (strcmp(cp, "AFS") == 0) { --- 8 unchanged lines hidden (view full) --- 1559 (strtok(NULL, " ")) && /* skip mode */ 1560 (cp = strtok(NULL, " "))) { 1561 rp = Strsave(str2short(cp)); 1562 } 1563 } 1564 } 1565 for (res1 = res; *res1; res1++) 1566 free(*res1); | 1589 /* 1590 * Look at the first token to determine how to interpret 1591 * the rest of it. 1592 * Yes, strtok is evil (it's not thread-safe), but it's also 1593 * easy to use. 1594 */ 1595 cp = strtok(*res, " "); 1596 if (strcmp(cp, "AFS") == 0) { --- 8 unchanged lines hidden (view full) --- 1605 (strtok(NULL, " ")) && /* skip mode */ 1606 (cp = strtok(NULL, " "))) { 1607 rp = Strsave(str2short(cp)); 1608 } 1609 } 1610 } 1611 for (res1 = res; *res1; res1++) 1612 free(*res1); |
1613 if (rp != NULL && rp[0] == '/' && rp[1] == '\0') { 1614 xfree((ptr_t)rp); 1615 rp = NULL; 1616 } |
|
1567 return rp; 1568 } 1569#endif /* HESIOD */ 1570 return NULL; 1571} 1572 1573Char * 1574gettilde(us) --- 640 unchanged lines hidden --- | 1617 return rp; 1618 } 1619#endif /* HESIOD */ 1620 return NULL; 1621} 1622 1623Char * 1624gettilde(us) --- 640 unchanged lines hidden --- |