/* $NetBSD: setproctitle.c,v 1.14 1998/11/13 12:31:52 christos Exp $ */ /* * Copyright (c) 1994, 1995 Christopher G. Demetriou * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Christopher G. Demetriou * for the NetBSD Project. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #if defined(LIBC_SCCS) && !defined(lint) __RCSID("$NetBSD: setproctitle.c,v 1.14 1998/11/13 12:31:52 christos Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" #include #include #include #include #include #include #include #ifdef __STDC__ #include #else #include #endif #ifdef __weak_alias __weak_alias(setproctitle,_setproctitle); #endif #define MAX_PROCTITLE 2048 extern char *__progname; /* Program name, from crt0. */ /* * For compatibility with old versions of crt0 that didn't define __ps_strings, * define it as a common here. */ struct ps_strings *__ps_strings; void #if __STDC__ setproctitle(const char *fmt, ...) #else setproctitle(fmt, va_alist) const char *fmt; va_dcl #endif { va_list ap; static char buf[MAX_PROCTITLE], *bufp; int used; #if __STDC__ va_start(ap, fmt); #else va_start(ap); #endif if (fmt != NULL) { used = snprintf(buf, (size_t)MAX_PROCTITLE, "%s: ", __progname); (void)vsnprintf(buf + used, (size_t)(MAX_PROCTITLE - used), fmt, ap); } else (void)snprintf(buf, MAX_PROCTITLE, "%s", __progname); va_end(ap); bufp = buf; #ifdef USRSTACK /* * For compatibility with old versions of crt0 and old kernels, set * __ps_strings to a default value if it's null. * But only if USRSTACK is defined. It might not be defined if * user-level code can not assume it's a constant (i.e. m68k). */ if (__ps_strings == 0) __ps_strings = PS_STRINGS; #endif /* USRSTACK */ if (__ps_strings != 0) { __ps_strings->ps_nargvstr = 1; __ps_strings->ps_argvstr = &bufp; } } f958e2fcee7d0709a753c62dcad'>Add TABSIZE, which is derived from terminfo init_tabs.roy 2011-07-01Fix memset usage.joerg 2010-12-16Observe the following spelling:wiz 2010-11-23to initialize mbstate_t, use memset instead mbrtowc.tnozaki 2010-02-23misc fixes and improvements:drochner 2009-07-22Prepare curses for the possibility of changing from termcap to terminfo.roy 2008-07-04use mbrtowc() instead of mbtowc().tnozaki 2007-11-08Fix the handling for added carriage return characters.jdc 2007-05-28Merge in wide curses code done as a Summer of Code project byblymn 2007-01-21Add debug "areas" that allow selective debugging by setting thejdc 2006-01-15Background characters and attributes don't need to be kept per characterjdc 2003-08-10Revert most of rev 1.27 of addbytes.c and associated changes.dsl 2003-08-07Move UCB-licensed code from 4-clause to 3-clause licence.agc 2003-07-31Do something more sensible for waddbytes(..., "\r\n", ...);dsl 2003-06-26Stop blank line being added when newline is processed with __ISPASTEOL set.dsl 2003-02-17Fix resize of windows with subwins.dsl 2002-12-23Always update the change pointers. Otherwise, we could end up notjdc 2002-07-19* Added new function idcok - this closes PR 10802blymn 2001-04-20Implement scrolling regions :jdc 2000-12-19Rename variables refering to termcap capabilities from NN to __tc_nn. Casejdc 2000-04-28Massively simplify some logic.mycroft 2000-04-18Set background character and attributes for added characters.jdc 2000-04-15Don't reset firstchp and lastchp even if this line was not dirty.jdc 2000-04-15Added functions to replace what were previously macros in curses.hblymn 2000-04-12Add color attribute manipulation.jdc 2000-04-11Made data structures opaqueblymn 1999-06-28Get rid of the evil trailing spaces and tabs.simonb 1999-04-13Upgrades the standard NetBSD curses library to provide somemrg 1998-02-03remove obsolete register declarationsperry 1997-07-22RCSid police, fix warningsmikel