Changeset 300
- Timestamp:
- 11/21/05 12:37:55
- Files:
-
- openpgpsdk/trunk/examples/packet-dump.c (modified) (1 diff)
- openpgpsdk/trunk/include/openpgpsdk/errors.h (modified) (3 diffs)
- openpgpsdk/trunk/src/Makefile.template (modified) (1 diff)
- openpgpsdk/trunk/src/errors.c (modified) (3 diffs)
- openpgpsdk/trunk/src/ops_errors.c (deleted)
- openpgpsdk/trunk/src/util.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openpgpsdk/trunk/examples/packet-dump.c
r299 r300 292 292 293 293 case OPS_PARSER_ERRCODE: 294 printf("parse error: %s (0x%x): %s\n", 295 ops_errcode(content->errcode.errcode, OPS_LANG_ENGLISH), 296 content->errcode.errcode, 297 ops_error(content->errcode.errcode, OPS_LANG_ENGLISH)); 294 printf("parse error: %s\n", 295 ops_errcode(content->errcode.errcode)); 298 296 break; 299 297 openpgpsdk/trunk/include/openpgpsdk/errors.h
r299 r300 13 13 14 14 OPS_E_FAIL=0x0001, /* general error */ 15 16 OPS_E_SYSTEM_ERROR=0x0002, /* system error, look at errno for details */ 15 17 16 18 /* reader errors */ … … 30 32 } ops_errcode_t; 31 33 32 /** ops_error_map_t */33 typedef ops_map_t ops_error_map_t;34 35 34 /** ops_errcode_name_map_t */ 36 35 typedef ops_map_t ops_errcode_name_map_t; 37 36 38 /** ops_lang_t */39 typedef enum40 {41 OPS_LANG_ENGLISH=142 } ops_lang_t;43 44 /* Function Declarations */45 46 char *ops_error(ops_errcode_t errcode, ops_lang_t lang);47 char *ops_errcode(ops_errcode_t errcode, ops_lang_t lang);48 49 /** ops_error_code_t50 \todo Not sure why we have this as well as ops_errcode_t above,51 will probably combine. RW52 */53 typedef enum54 {55 OPS_E_READ_FAILED=1,56 OPS_E_SYSTEM_ERROR=2,57 } ops_error_code_t;58 59 37 /** one entry in a linked list of errors */ 60 38 typedef struct ops_error 61 39 { 62 ops_err or_code_t errcode;40 ops_errcode_t errcode; 63 41 int errno; /*!< irrelevent unless errcode == OPS_E_SYSTEM_ERROR */ 64 42 char *comment; … … 68 46 } ops_error_t; 69 47 70 void push_error(ops_error_t **errstack,ops_error_code_t errcode,int errno, 48 char *ops_errcode(const ops_errcode_t errcode); 49 50 void push_error(ops_error_t **errstack,ops_errcode_t errcode,int errno, 71 51 const char *file,int line,const char *comment,...); 72 52 void print_error(ops_error_t *err); openpgpsdk/trunk/src/Makefile.template
r282 r300 11 11 LIBOBJS = packet-parse.o util.o openssl_crypto.o accumulate.o \ 12 12 memory.o fingerprint.o hash.o keyring.o signature.o compress.o \ 13 packet-show.o create.o validate.o lists.o ops_errors.o armour.o \ 14 errors.o 13 packet-show.o create.o validate.o lists.o armour.o errors.o 15 14 16 15 headers: openpgpsdk/trunk/src/errors.c
r299 r300 9 9 #include <stdio.h> 10 10 #include <stdlib.h> 11 12 #include "openpgpsdk/util.h" 13 14 static ops_errcode_name_map_t errcode_name_map[] = 15 { 16 { OPS_E_OK, "OPS_E_OK" }, 17 { OPS_E_FAIL, "OPS_E_FAIL" }, 18 { OPS_E_SYSTEM_ERROR, "OPS_E_SYSTEM_ERROR" }, 19 20 { OPS_E_R, "OPS_E_R" }, 21 { OPS_E_R_READ_FAILED, "OPS_E_R_READ_FAILED" }, 22 { OPS_E_R_EARLY_EOF, "OPS_E_R_EARLY_EOF" }, 23 24 { OPS_E_W, "OPS_E_W" }, 25 26 { OPS_E_P, "OPS_E_P" }, 27 { OPS_E_P_NOT_ENOUGH_DATA, "OPS_E_P_NOT_ENOUGH_DATA" }, 28 29 { OPS_E_C, "OPS_E_C" }, 30 31 { (int) NULL, (char *)NULL }, /* this is the end-of-array marker */ 32 }; 33 34 /** 35 * \ingroup Errors 36 * 37 * returns string representing error code name 38 * \param errcode 39 * \return string or "Unknown" 40 */ 41 char *ops_errcode(const ops_errcode_t errcode) 42 { 43 return(ops_str_from_map((int) errcode, (ops_map_t *) errcode_name_map)); 44 } 11 45 12 46 /** … … 22 56 */ 23 57 24 void push_error(ops_error_t **errstack,ops_err or_code_t errcode,int errno,58 void push_error(ops_error_t **errstack,ops_errcode_t errcode,int errno, 25 59 const char *file,int line,const char *fmt,...) 26 60 { … … 59 93 printf("%s:%d: ",err->file,err->line); 60 94 if (err->errcode==OPS_E_SYSTEM_ERROR) 61 printf("system error %d returned from %s \n",err->errno, err->comment);95 printf("system error %d returned from %s()\n",err->errno, err->comment); 62 96 else 63 printf("errcode=%d, errno=%d, comment=%s\n",err->errcode,err->errno,err->comment); 97 printf("%s, %s\n", 98 ops_errcode(err->errcode), 99 err->comment); 64 100 } 65 101 openpgpsdk/trunk/src/util.c
r299 r300 114 114 if(n == -1) 115 115 { 116 ops_system_error_1(&parse_info->errors,OPS_E_R EAD_FAILED,"read",116 ops_system_error_1(&parse_info->errors,OPS_E_R_READ_FAILED,"read", 117 117 "file descriptor %d",arg->fd); 118 118 return OPS_R_ERROR;
