added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / devs / afs / error.c
blob0cf13a109732b4284e9e18bfe1db05350b73c17c
1 /*
2 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /*
7 * -date------ -name------------------- -description-----------------------------
8 * 02-jan-2008 [Tomasz Wiszkowski] added disk check option for broken disks
9 * 04-jan-2008 [Tomasz Wiszkowski] corrected tabulation
13 #include <proto/intuition.h>
14 #include <aros/debug.h>
16 #include <intuition/intuition.h>
18 #include "error.h"
19 #include "baseredef.h"
22 * showReqType matches adequate option[] in showPtrArgsText.
24 enum showReqType
26 Req_Cancel = 0,
27 Req_RetryCancel,
28 Req_CheckCancel,
29 Req_ContinueCancel,
30 Req_Continue
34 * showReqStruct: a group describing particular requester:
35 * - text - content to be displayed
36 * - type - set of buttons for the requester
38 struct showReqStruct
40 char* text;
41 enum showReqType type;
45 * displays requester on screen or puts text to the debug buffer
47 LONG showPtrArgsText(struct AFSBase *afsbase, char *string, enum showReqType type, ULONG *args)
49 char* options[] =
51 "Cancel",
52 "Retry|Cancel",
53 "Check disk|Cancel",
54 "Continue|Cancel",
55 "Continue",
56 NULL
58 struct EasyStruct es={sizeof (struct EasyStruct),0,"AFFS",0,options[type]};
60 es.es_TextFormat=string;
61 #if (AROS_FLAVOUR & AROS_FLAVOUR_STANDALONE)
62 if (IntuitionBase->FirstScreen != NULL)
64 #endif
65 return EasyRequestArgs(NULL,&es,NULL,args);
66 #if (AROS_FLAVOUR & AROS_FLAVOUR_STANDALONE)
68 else
70 #warning "kprintf for error printing when gfx.hidd is not initialized"
71 vkprintf(string, args);
72 kprintf("\n");
74 #endif
75 return 0;
78 void showText(struct AFSBase *afsbase, char *string, ...)
80 showPtrArgsText(afsbase, string, Req_Cancel, (ULONG *)(&string+1));
83 LONG showRetriableError(struct AFSBase *afsbase, TEXT *string, ...)
85 return showPtrArgsText(afsbase, string, Req_RetryCancel, (ULONG*)(&string+1));
88 LONG showError(struct AFSBase *afsbase, ULONG error, ...)
90 struct showReqStruct texts[] =
92 {NULL, Req_Cancel },
93 {"No ioport", Req_Cancel },
94 {"Couldn't open device %s", Req_Cancel },
95 {"Couldn't add disk as dosentry", Req_Cancel },
96 {"Disk is not validated!", Req_CheckCancel },
97 {"Wrong data block %lu", Req_Cancel },
98 {"Wrong checksum on block %lu", Req_CheckCancel },
99 {"Missing some more bitmap blocks", Req_Cancel },
100 {"Wrong blocktype on block %lu", Req_CheckCancel },
101 {"Read/Write Error %ld accessing block %lu", Req_Cancel },
102 {"*** This may be a non-AFS disk. ***\n"
103 "Any attempt to fix it in this case may render the original\n"
104 "file system invalid, and its contents unrecoverable.\n\n"
105 "Please select what to do", Req_ContinueCancel },
106 {"Block %lu used twice", Req_Cancel},
107 {"Block %lu is located outside volume scope\nand will be removed.", Req_Continue},
108 {"Repairing disk structure will lead to data loss.\n"
109 "It's best to make a backup before proceeding.\n\n"
110 "Please select what to do.", Req_ContinueCancel },
111 {NULL, Req_Cancel },
112 {"Unknown error", Req_Cancel}
115 if (error == ERR_ALREADY_PRINTED)
116 return 0;
117 if (error >= ERR_UNKNOWN)
119 return showPtrArgsText(afsbase, texts[ERR_UNKNOWN].text, texts[ERR_UNKNOWN].type, (ULONG *)&error);
122 return showPtrArgsText(afsbase, texts[error].text, texts[error].type, (ULONG *)(&error+1));
126 /* vim: set ts=3 noet fdm=marker fmr={,}: */