14887Schin /*********************************************************************** 24887Schin * * 34887Schin * This software is part of the ast package * 4*8462SApril.Chin@Sun.COM * Copyright (c) 1985-2008 AT&T Intellectual Property * 54887Schin * and is licensed under the * 64887Schin * Common Public License, Version 1.0 * 7*8462SApril.Chin@Sun.COM * by AT&T Intellectual Property * 84887Schin * * 94887Schin * A copy of the License is available at * 104887Schin * http://www.opensource.org/licenses/cpl1.0.txt * 114887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 124887Schin * * 134887Schin * Information and Software Systems Research * 144887Schin * AT&T Research * 154887Schin * Florham Park NJ * 164887Schin * * 174887Schin * Glenn Fowler <gsf@research.att.com> * 184887Schin * David Korn <dgk@research.att.com> * 194887Schin * Phong Vo <kpv@research.att.com> * 204887Schin * * 214887Schin ***********************************************************************/ 224887Schin #pragma prototyped 234887Schin /* 244887Schin * Glenn Fowler 254887Schin * AT&T Research 264887Schin * 274887Schin * Time_t conversion support 284887Schin */ 294887Schin 304887Schin #include <tmx.h> 314887Schin #include <tv.h> 324887Schin 334887Schin /* 344887Schin * touch path <atime,mtime,ctime> 354887Schin * (flags&PATH_TOUCH_VERBATIM) treats times verbatim, otherwise: 364887Schin * Time_t==0 current time 374887Schin * Time_t==TMX_NOTIME retains path value 384887Schin */ 394887Schin 404887Schin int 414887Schin tmxtouch(const char* path, Time_t at, Time_t mt, Time_t ct, int flags) 424887Schin { 434887Schin Tv_t av; 444887Schin Tv_t mv; 454887Schin Tv_t cv; 464887Schin Tv_t* ap; 474887Schin Tv_t* mp; 484887Schin Tv_t* cp; 494887Schin 504887Schin if (at == TMX_NOTIME && !(flags & PATH_TOUCH_VERBATIM)) 514887Schin ap = TV_TOUCH_RETAIN; 524887Schin else if (!at && !(flags & PATH_TOUCH_VERBATIM)) 534887Schin ap = 0; 544887Schin else 554887Schin { 564887Schin av.tv_sec = tmxsec(at); 574887Schin av.tv_nsec = tmxnsec(at); 584887Schin ap = &av; 594887Schin } 604887Schin if (mt == TMX_NOTIME && !(flags & PATH_TOUCH_VERBATIM)) 614887Schin mp = TV_TOUCH_RETAIN; 624887Schin else if (!mt && !(flags & PATH_TOUCH_VERBATIM)) 634887Schin mp = 0; 644887Schin else 654887Schin { 664887Schin mv.tv_sec = tmxsec(mt); 674887Schin mv.tv_nsec = tmxnsec(mt); 684887Schin mp = &mv; 694887Schin } 704887Schin if (ct == TMX_NOTIME && !(flags & PATH_TOUCH_VERBATIM)) 714887Schin cp = TV_TOUCH_RETAIN; 724887Schin else if (!ct && !(flags & PATH_TOUCH_VERBATIM)) 734887Schin cp = 0; 744887Schin else 754887Schin { 764887Schin cv.tv_sec = tmxsec(ct); 774887Schin cv.tv_nsec = tmxnsec(ct); 784887Schin cp = &cv; 794887Schin } 804887Schin return tvtouch(path, ap, mp, cp, flags & 1); 814887Schin } 82