Sin ttulo de diapositiva - PowerPoint PPT Presentation

About This Presentation
Title:

Sin ttulo de diapositiva

Description:

EXEC=2. union filetype switch (filekind kind) { case TEXT: void; case DATA: ... case EXEC: string interpretor MAXNAMELEN ; struct file { string filename MAXNAMELEN ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 7
Provided by: mari355
Category:
Tags: diapositiva | exec | sin | ttulo

less

Transcript and Presenter's Notes

Title: Sin ttulo de diapositiva


1
/ Descripción XDR / const
MAXUSERNAME32 const MAXFILELEN65535 const
MAXNAMELEN255 enum filekind TEXT0,
DATA1, EXEC2 union filetype switch
(filekind kind) case TEXT void
case DATA string creatorltMAXNAMELENgt
case EXEC string interpretorltMAXNAMELENgt
struct file string filenameltMAXNAMELENgt
filetype type string ownerltMAXUSERNAMEgt
opaque data ltMAXFILELENgt
fileXDR.x
2
fileXDR.h
struct filetype filekind kind union char
creator char interpretor
filetype_u typedef struct filetype
filetype bool_t xdr_filetype() struct file
char filename filetype type char
owner struct u_int data_len char
data_val data typedef struct file
file bool_t xdr_file()
include ltrpc/types.hgt define MAXUSERNAME
32 define MAXFILELEN 65535 define MAXNAMELEN
255 enum filekind TEXT 0, DATA 1, EXEC
2, typedef enum filekind filekind bool_t
xdr_filekind()
3
fileXDR_xdr.c (I)
include ltrpc/rpc.hgt include "fileXDR.h" bool_t
xdr_filekind(xdrs, objp) XDR xdrs filekind
objp if (!xdr_enum(xdrs, (enum_t )objp))
return (FALSE) return (TRUE)
4
bool_t xdr_filetype(xdrs, objp) XDR
xdrs filetype objp if
(!xdr_filekind(xdrs, objp-gtkind)) return
(FALSE) switch (objp-gtkind) case
TEXT break case DATA if
(!xdr_string(xdrs, objp-gtfiletype_u.creator,
MAXNAMELEN)) return (FALSE) break
case EXEC if (!xdr_string(xdrs,
objp-gtfiletype_u.interpretor, MAXNAMELEN))
return (FALSE) break default return
(FALSE) return (TRUE)
fileXDR_xdr.c (II)
5
fileXDR_xdr.c (III)
bool_t xdr_file(xdrs, objp) XDR xdrs file
objp if (!xdr_string(xdrs, objp-gtfilename,
MAXNAMELEN)) return (FALSE) if
(!xdr_filetype(xdrs, objp-gttype)) return
(FALSE) if (!xdr_string(xdrs, objp-gtowner,
MAXUSERNAME)) return (FALSE) if
(!xdr_bytes(xdrs, (char )objp-gtdata.data_val,
(u_int )objp-gtdata.data_len,
MAXFILELEN)) return (FALSE) return
(TRUE)
6
Escribir.c
include ltstdio.hgt include ltrpc/rpc.hgt include
"fileXDR.h" int main() XDR xdr_handle FILE
fp file fichero char data5
data0'a' data1'b' data2'c'
data3'd' data4'e' if((fpfopen("salida
","w"))!NULL) xdrstdio_create(xdr_han
dle,fp,XDR_ENCODE) fichero.filename"nomb
refichero" fichero.type.kindTEXT
fichero.owner"nombrepropietario"
fichero.data.data_len5 fichero.data.data_v
aldata xdr_file(xdr_handle,fichero)
xdr_destroy(xdr_handle)
fclose(fp)
Write a Comment
User Comments (0)
About PowerShow.com