Annotation of Gnu-Mach/mig/string.c, revision 1.1

1.1     ! root        1: /* 
        !             2:  * Mach Operating System
        !             3:  * Copyright (c) 1991,1990 Carnegie Mellon University
        !             4:  * All Rights Reserved.
        !             5:  * 
        !             6:  * Permission to use, copy, modify and distribute this software and its
        !             7:  * documentation is hereby granted, provided that both the copyright
        !             8:  * notice and this permission notice appear in all copies of the
        !             9:  * software, derivative works or modified versions, and any portions
        !            10:  * thereof, and that both notices appear in supporting documentation.
        !            11:  * 
        !            12:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS 
        !            13:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
        !            14:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            15:  * 
        !            16:  * Carnegie Mellon requests users of this software to return to
        !            17:  * 
        !            18:  *  Software Distribution Coordinator  or  [email protected]
        !            19:  *  School of Computer Science
        !            20:  *  Carnegie Mellon University
        !            21:  *  Pittsburgh PA 15213-3890
        !            22:  * 
        !            23:  * any improvements or extensions that they make and grant Carnegie the
        !            24:  * rights to redistribute these changes.
        !            25:  */
        !            26: 
        !            27: #include <sys/types.h>
        !            28: #include <stdlib.h>
        !            29: 
        !            30: #include "boolean.h"
        !            31: #include "error.h"
        !            32: #include "mig_string.h"
        !            33: 
        !            34: string_t
        !            35: strmake(const char *string)
        !            36: {
        !            37:     register string_t saved;
        !            38: 
        !            39:     saved = malloc(strlen(string) + 1);
        !            40:     if (saved == strNULL)
        !            41:        fatal("strmake('%s'): %s", string, unix_error_string(errno));
        !            42:     return strcpy(saved, string);
        !            43: }
        !            44: 
        !            45: string_t
        !            46: strconcat(const_string_t left, const_string_t right)
        !            47: {
        !            48:     register string_t saved;
        !            49: 
        !            50:     saved = malloc(strlen(left) + strlen(right) + 1);
        !            51:     if (saved == strNULL)
        !            52:        fatal("strconcat('%s', '%s'): %s",
        !            53:              left, right, unix_error_string(errno));
        !            54:     return strcat(strcpy(saved, left), right);
        !            55: }
        !            56: 
        !            57: void
        !            58: strfree(string_t string)
        !            59: {
        !            60:     free(string);
        !            61: }
        !            62: 
        !            63: const char *
        !            64: strbool(boolean_t bool)
        !            65: {
        !            66:     if (bool)
        !            67:        return "TRUE";
        !            68:     else
        !            69:        return "FALSE";
        !            70: }
        !            71: 
        !            72: const char *
        !            73: strstring(const_string_t string)
        !            74: {
        !            75:     if (string == strNULL)
        !            76:        return "NULL";
        !            77:     else
        !            78:        return string;
        !            79: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.