1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 2000-2001 by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 #ifndef _PAYLOADREADER_H 28 #define _PAYLOADREADER_H 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 #ifdef __cplusplus 35 } 36 #endif 37 38 #include "Parser.h" 39 40 #define NORMAL_READ 0 41 #define ITER_THERE_ONLY 1 42 43 struct PayloadReader 44 { 45 // will send the data back in (data,dataLen) 46 static fru_errno_t readData(PathDef *path, Ancestor *curDef, 47 int instWICur, 48 uint8_t *payload, size_t payloadLen, 49 void **data, size_t *dataLen); 50 51 // will update the data in payload which can then be written back. 52 static fru_errno_t updateData(PathDef *path, Ancestor *curDef, 53 int instWICur, 54 uint8_t *payload, size_t payloadLen, 55 void *data, size_t dataLen); 56 57 // will return the nuber of iterations actually there. 58 static fru_errno_t findIterThere(PathDef *path, Ancestor *curDef, 59 int instWICur, 60 uint8_t *payload, size_t payloadLen, 61 int *numThere); 62 63 private: 64 static int getIterationOffset(uint8_t *iter, int iterLen, 65 PathDef *path, int *rcIterThere, 66 fru_errno_t *err, 67 int onlyFindingIterThereFlag); 68 static int calcOffset(int iterType, 69 uint8_t head, uint8_t tail, 70 uint8_t iterThere, uint8_t iterPoss, 71 size_t length, int index, 72 fru_errno_t *err); 73 74 static fru_errno_t readRecurse(PathDef *path, 75 uint8_t *cur, size_t curLen, 76 void **data, size_t *dataLen, 77 int onlyFindingIterThereFlag); 78 79 static fru_errno_t updateRecurse(PathDef *path, 80 uint8_t *cur, size_t curLen, 81 void *data, size_t dataLen); 82 83 static int getOffsetIntoRecord(fru_regdef_t *recDef, 84 fru_regdef_t *elemDef); 85 86 PayloadReader(); 87 ~PayloadReader(); 88 PayloadReader(const PayloadReader&); 89 void operator=(const PayloadReader&); 90 }; 91 92 #ifdef __cplusplus 93 extern "C" { 94 #endif 95 96 #ifdef __cplusplus 97 } 98 #endif 99 100 #endif /* _PAYLOADREADER_H */ 101