2011-07-01 11:29:35 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "zerror.h"
|
|
|
|
|
|
|
|
void test0()
|
|
|
|
{
|
|
|
|
struct zerror_s *zs, *zs_l, *zs_cp, *zs_se = NULL, *zs_se_l = NULL, *zs_pe = NULL, *zs_pe2 = NULL;
|
|
|
|
|
|
|
|
zs = zerror_new(-12, -45, "error № %d, %s", -8752, "некая строка");
|
|
|
|
|
|
|
|
printf("zerror_new = {%d, %d, %s}\n", zs->domain, zs->code, zs->message);
|
|
|
|
|
|
|
|
zs_l = zerror_new_literal(-52, -8954, "литерал");
|
|
|
|
|
|
|
|
printf("zerror_new_literal = {%d, %d, %s}\n", zs_l->domain, zs_l->code, zs_l->message);
|
|
|
|
|
|
|
|
zs_cp = zerror_copy(zs_l);
|
|
|
|
|
|
|
|
printf("zerror_copy = {%d, %d, %s}\n", zs_cp->domain, zs_cp->code, zs_cp->message);
|
|
|
|
|
|
|
|
printf("zerror_matches(-52, -8954) = %d\n", zerror_matches(zs_cp, -52, -8954));
|
|
|
|
printf("zerror_matches(-53, -8954) = %d\n", zerror_matches(zs_cp, -53, -8954));
|
|
|
|
printf("zerror_matches(-52, -1954) = %d\n", zerror_matches(zs_cp, -52, -1954));
|
|
|
|
|
|
|
|
/* indicates error in smb's code */
|
|
|
|
z_set_error(&zs, -928, -894, "error was set by z_set_error(%d, %d)", -928, -894);
|
|
|
|
printf("ERRinSMB'sCODE: z_set_error = {%d, %d, %s}\n", zs->domain, zs->code, zs->message);
|
|
|
|
|
|
|
|
z_set_error(&zs_se, -928, -894, "error was set by z_set_error(%d, %d)", -928, -894);
|
|
|
|
printf("z_set_error = {%d, %d, %s}\n", zs_se->domain, zs_se->code, zs_se->message);
|
|
|
|
|
|
|
|
/* indicates error in smb's code */
|
|
|
|
z_set_error_literal(&zs, -928, -894, "error was set by z_set_error_literal()");
|
|
|
|
printf("ERRinSMB'sCODE: z_set_error_literal = {%d, %d, %s}\n", zs->domain, zs->code, zs->message);
|
|
|
|
|
|
|
|
z_set_error_literal(&zs_se_l, -928, -894, "error was set by z_set_error_literal()");
|
|
|
|
printf("z_set_error_literal = {%d, %d, %s}\n", zs_se_l->domain, zs_se_l->code, zs_se_l->message);
|
|
|
|
|
|
|
|
/* indicates error in smb's code */
|
|
|
|
z_propagate_error(&zs, zs_se);
|
|
|
|
printf("ERRinSMB'sCODE: z_propagate_error = {%d, %d, %s}\n", zs->domain, zs->code, zs->message);
|
|
|
|
|
|
|
|
z_propagate_error(&zs_pe, zs_se);
|
|
|
|
printf("z_propagate_error = {%d, %d, %s}\n", zs_pe->domain, zs_pe->code, zs_pe->message);
|
|
|
|
|
|
|
|
z_prefix_error(&zs_pe, "prefix(%s): ", "PREFIX");
|
|
|
|
printf("z_prefix_error = {%d, %d, %s}\n", zs_pe->domain, zs_pe->code, zs_pe->message);
|
|
|
|
|
|
|
|
z_propagate_prefixed_error(&zs_pe2, zs_se_l, "prefix_propagate(%s): ", "propagated");
|
|
|
|
printf("z_propagate_prefixed_error = {%d, %d, %s}\n", zs_pe2->domain, zs_pe2->code, zs_pe2->message);
|
|
|
|
|
|
|
|
zerror_free(zs);
|
2011-07-11 11:48:24 +04:00
|
|
|
z_clear_error(&zs_l);
|
2011-07-01 11:29:35 +04:00
|
|
|
zerror_free(zs_cp);
|
|
|
|
//~ z_clear_error(&zs_se_l); // not need clear, because zs_se_l propagated to zs_pe2
|
|
|
|
//~ z_clear_error(&zs_se); // not need clear, because zs_se propagated to zs_pe
|
|
|
|
z_clear_error(&zs_pe);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(/*int argc, char *argv[]*/)
|
|
|
|
{
|
|
|
|
test0();
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|