17c478bd9Sstevel@tonic-gate /* 2*058561cbSjbeck * Copyright (c) 2000-2001, 2004, 2006 Sendmail, Inc. and its suppliers. 37c478bd9Sstevel@tonic-gate * All rights reserved. 47c478bd9Sstevel@tonic-gate * Copyright (c) 1990, 1993 57c478bd9Sstevel@tonic-gate * The Regents of the University of California. All rights reserved. 67c478bd9Sstevel@tonic-gate * 77c478bd9Sstevel@tonic-gate * This code is derived from software contributed to Berkeley by 87c478bd9Sstevel@tonic-gate * Chris Torek. 97c478bd9Sstevel@tonic-gate * 107c478bd9Sstevel@tonic-gate * By using this file, you agree to the terms and conditions set 117c478bd9Sstevel@tonic-gate * forth in the LICENSE file which can be found at the top level of 127c478bd9Sstevel@tonic-gate * the sendmail distribution. 137c478bd9Sstevel@tonic-gate */ 147c478bd9Sstevel@tonic-gate 157c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 167c478bd9Sstevel@tonic-gate 177c478bd9Sstevel@tonic-gate #include <sm/gen.h> 18*058561cbSjbeck SM_RCSID("@(#)$Id: flags.c,v 1.23 2006/12/19 19:44:23 ca Exp $") 197c478bd9Sstevel@tonic-gate #include <sys/types.h> 207c478bd9Sstevel@tonic-gate #include <sys/file.h> 217c478bd9Sstevel@tonic-gate #include <errno.h> 227c478bd9Sstevel@tonic-gate #include <sm/io.h> 23*058561cbSjbeck #include "local.h" 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate /* 267c478bd9Sstevel@tonic-gate ** SM_FLAGS -- translate external (user) flags into internal flags 277c478bd9Sstevel@tonic-gate ** 287c478bd9Sstevel@tonic-gate ** Paramters: 297c478bd9Sstevel@tonic-gate ** flags -- user select flags 307c478bd9Sstevel@tonic-gate ** 317c478bd9Sstevel@tonic-gate ** Returns: 327c478bd9Sstevel@tonic-gate ** Internal flag value matching user selected flags 337c478bd9Sstevel@tonic-gate */ 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate int 367c478bd9Sstevel@tonic-gate sm_flags(flags) 37*058561cbSjbeck int flags; 387c478bd9Sstevel@tonic-gate { 39*058561cbSjbeck int ret; 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate switch(SM_IO_MODE(flags)) 427c478bd9Sstevel@tonic-gate { 437c478bd9Sstevel@tonic-gate case SM_IO_RDONLY: /* open for reading */ 447c478bd9Sstevel@tonic-gate ret = SMRD; 457c478bd9Sstevel@tonic-gate break; 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate case SM_IO_WRONLY: /* open for writing */ 487c478bd9Sstevel@tonic-gate ret = SMWR; 497c478bd9Sstevel@tonic-gate break; 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate case SM_IO_APPEND: /* open for appending */ 527c478bd9Sstevel@tonic-gate ret = SMWR; 537c478bd9Sstevel@tonic-gate break; 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate case SM_IO_RDWR: /* open for read and write */ 567c478bd9Sstevel@tonic-gate ret = SMRW; 577c478bd9Sstevel@tonic-gate break; 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate default: 607c478bd9Sstevel@tonic-gate ret = 0; 617c478bd9Sstevel@tonic-gate break; 627c478bd9Sstevel@tonic-gate } 637c478bd9Sstevel@tonic-gate if (SM_IS_BINARY(flags)) 647c478bd9Sstevel@tonic-gate ret |= SM_IO_BINARY; 657c478bd9Sstevel@tonic-gate return ret; 667c478bd9Sstevel@tonic-gate } 67