Annotation of 43BSDReno/contrib/isode-beta/dsap/common/file_str.c, revision 1.1.1.1

1.1       root        1: #include "quipu/util.h"
                      2: #include "quipu/attrvalue.h"
                      3: 
                      4: extern LLog * log_dsap;
                      5: 
                      6: str2file_aux (str,at,x)
                      7: char * str;
                      8: AttributeType at;
                      9: AttributeValue x;
                     10: {
                     11: struct file_syntax * fs;
                     12: #ifdef CHECK_FILE_ATTRIBUTES
                     13: struct stat filestat;
                     14: #endif
                     15: 
                     16:        x->av_syntax = AV_FILE;
                     17:        fs = (struct file_syntax *) smalloc (sizeof(struct file_syntax));
                     18:        fs->fs_ref = 1;
                     19:        fs->fs_attr = NULLAttrV;
                     20:        x->av_struct = (caddr_t) fs;
                     21:        if ((fs->fs_real_syntax = at->oa_syntax) >= AV_WRITE_FILE)
                     22:                fs->fs_real_syntax -= AV_WRITE_FILE; 
                     23: 
                     24:        if (*str != 0) {
                     25:                fs->fs_mode = 0;
                     26:                fs->fs_name = strdup (str);
                     27:        } else {
                     28:                if (dflt_attr_file (at,x,1) == NOTOK) 
                     29:                        return (NOTOK);
                     30:                fs->fs_mode = FS_DEFAULT;
                     31:        }
                     32: 
                     33: #ifdef CHECK_FILE_ATTRIBUTES
                     34:        /* now check the file is OK */
                     35:        if (stat(fs->fs_name,&filestat) != -1) 
                     36:                return (OK);
                     37:        else {
                     38:                parse_error ("can't find attribute file %s",fs->fs_name);
                     39:                return (NOTOK);
                     40:        }
                     41:        /* NOTREACHED */
                     42: #else
                     43:        return (OK);
                     44: #endif
                     45: 
                     46: }
                     47: 
                     48: AttributeValue str2file (str,at)
                     49: char * str;
                     50: AttributeType at;
                     51: {
                     52: AttributeValue x;
                     53: 
                     54:        x = AttrV_alloc();
                     55:        if (str2file_aux (str,at,x) == OK)
                     56:                return (x);
                     57:        free ((char *)x);
                     58:        return (NULLAttrV);
                     59: }
                     60: 
                     61: file_free (fs)
                     62: struct file_syntax * fs;
                     63: {
                     64:        if (fs == (struct file_syntax *) NULL)
                     65:                return;
                     66: 
                     67:        fs->fs_ref--;
                     68: 
                     69:        if (fs->fs_ref > 0)
                     70:                return;
                     71: 
                     72:        if (fs->fs_attr) 
                     73:                AttrV_free (fs->fs_attr);
                     74: 
                     75:        if (fs->fs_mode & FS_CREATE) {
                     76:                (void) unlink (fs->fs_name);
                     77:                DLOG (log_dsap,LLOG_DEBUG,("Removed photo file '%s'",fs->fs_name));
                     78:        }
                     79: 
                     80:        if (fs->fs_name)
                     81:                free (fs->fs_name);
                     82:                
                     83:        free ((char *) fs);
                     84: }

unix.superglobalmegacorp.com

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