diff --git a/PracticingC/.gitignore b/PracticingC/.gitignore new file mode 100644 index 0000000..640ef7a --- /dev/null +++ b/PracticingC/.gitignore @@ -0,0 +1,6 @@ +* +!gowrikumar/bin +!gdbtut/bin +!*.i +!*.s +!*.c diff --git a/PracticingC/Makefile b/PracticingC/Makefile new file mode 100644 index 0000000..03c063e --- /dev/null +++ b/PracticingC/Makefile @@ -0,0 +1,21 @@ +CD = cd +RM = rm -v + +CC := gcc +CFLAGS := -std=c99 -Wall -g + +ALL_TARGETS := $(patsubst %.c,%,$(wildcard *.c)) + +export CD RM CFLAGS + + +all: $(ALL_TARGETS) + $(CD) gowrikumar && $(MAKE) + $(CD) gdbtut && $(MAKE) + +clean: + $(CD) gowrikumar && $(MAKE) clean + $(CD) gdbtut && $(MAKE) clean + + +.PHONY: all clean diff --git a/PracticingC/README b/PracticingC/README new file mode 100644 index 0000000..52b53eb --- /dev/null +++ b/PracticingC/README @@ -0,0 +1,3 @@ +I don't get paid to write C for a living, so I have to sneak in practice here +and there. Maybe once the kiddo goes to college I can become a kernel hacker +:-P (assuming there's still such a thing as a kernel.) diff --git a/PracticingC/gdbtut/Makefile b/PracticingC/gdbtut/Makefile new file mode 100644 index 0000000..d7d488d --- /dev/null +++ b/PracticingC/gdbtut/Makefile @@ -0,0 +1,14 @@ +# tutorial exercises from http://www.unknownroad.com/rtfm/gdbtut/ + +BINDIR := $(PWD)/bin +export BINDIR + + +all: + $(CD) src && $(MAKE) + +clean: + $(RM) $(BINDIR)/* + + +.PHONY: all clean diff --git a/PracticingC/gdbtut/bin/.keep b/PracticingC/gdbtut/bin/.keep new file mode 100644 index 0000000..e69de29 diff --git a/PracticingC/gdbtut/src/Makefile b/PracticingC/gdbtut/src/Makefile new file mode 100644 index 0000000..854655b --- /dev/null +++ b/PracticingC/gdbtut/src/Makefile @@ -0,0 +1,12 @@ +# tutorial exercises from http://www.unknownroad.com/rtfm/gdbtut/ + +ALL_BIN := $(patsubst %.c,$(BINDIR)/%,$(wildcard *.c)) + + +$(BINDIR)/%: %.c + $(CC) $(CFLAGS) -o $@ $< + +all: $(ALL_BIN) + + +.PHONY: all diff --git a/PracticingC/gdbtut/src/segfault.c b/PracticingC/gdbtut/src/segfault.c new file mode 100644 index 0000000..11e93a1 --- /dev/null +++ b/PracticingC/gdbtut/src/segfault.c @@ -0,0 +1,28 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include +#include + +int main(int argc, char **argv) +{ + char *buf; + long long huge = 8000000000000000000; + /* Okay, so this is *not* going to segfault because + * the way memory is allocated has changed since + * the tutorial was written. The segfault is supposed + * to happen when more memory is allocated than is + * available on the machine. So much for that exercise. + */ + + buf = malloc(huge); + + fgets(buf, 1024, stdin); + printf("%s\n", buf); + + return 1; +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/Makefile b/PracticingC/gowrikumar/Makefile new file mode 100644 index 0000000..37177b9 --- /dev/null +++ b/PracticingC/gowrikumar/Makefile @@ -0,0 +1,14 @@ +# puzzles from http://www.gowrikumar.com/c/ + +BINDIR := $(PWD)/bin +export BINDIR + + +all: + $(CD) src && $(MAKE) + +clean: + $(RM) $(BINDIR)/* + + +.PHONY: all clean diff --git a/PracticingC/gowrikumar/bin/.keep b/PracticingC/gowrikumar/bin/.keep new file mode 100644 index 0000000..e69de29 diff --git a/PracticingC/gowrikumar/src/00-sizeof.c b/PracticingC/gowrikumar/src/00-sizeof.c new file mode 100644 index 0000000..8981bfe --- /dev/null +++ b/PracticingC/gowrikumar/src/00-sizeof.c @@ -0,0 +1,23 @@ +#include + + +int array[] = {23, 34, 12, 17, 204, 99, 16}; +#define TOTAL_ELEMENTS sizeof(array) / sizeof(array[0]) + + +int main() +{ + int d; + +#ifdef DEBUG + printf("sizeof(array) = %d\n", TOTAL_ELEMENTS); +#endif + + for (d = 0; d < TOTAL_ELEMENTS ; d++) + printf("%d\n", array[d]); + + return 0; +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/02-dowhile.c b/PracticingC/gowrikumar/src/02-dowhile.c new file mode 100644 index 0000000..eba0649 --- /dev/null +++ b/PracticingC/gowrikumar/src/02-dowhile.c @@ -0,0 +1,20 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include + +int main() +{ + int i = 1; + do + { + printf("%d\n", i); + } while(++i < 15); + return 0; +} + + + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/03-stdoutbuf.c b/PracticingC/gowrikumar/src/03-stdoutbuf.c new file mode 100644 index 0000000..4cf1fb1 --- /dev/null +++ b/PracticingC/gowrikumar/src/03-stdoutbuf.c @@ -0,0 +1,22 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include +#include + +int main() +{ + printf("(Hit ^C to stop the madness.)\n"); + while(1) + { + fprintf(stdout, "hello-out "); + fprintf(stderr, "hello-err "); + sleep(1); + } + return 0; +} + + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/03b-stdoutbuf.c b/PracticingC/gowrikumar/src/03b-stdoutbuf.c new file mode 100644 index 0000000..deb9800 --- /dev/null +++ b/PracticingC/gowrikumar/src/03b-stdoutbuf.c @@ -0,0 +1,23 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include +#include + +int main() +{ + printf("This time we'll include \\n!\n"); + printf("(Hit ^C to stop the madness.)\n"); + while(1) + { + fprintf(stdout, "hello-out\n"); + fprintf(stderr, "hello-err\n"); + sleep(1); + } + return 0; +} + + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/03c-stdoutbuf.c b/PracticingC/gowrikumar/src/03c-stdoutbuf.c new file mode 100644 index 0000000..0402ec2 --- /dev/null +++ b/PracticingC/gowrikumar/src/03c-stdoutbuf.c @@ -0,0 +1,24 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include +#include + +int main() +{ + printf("This time we'll flush stdout!\n"); + printf("(Hit ^C to stop the madness.)\n"); + while(1) + { + fprintf(stdout, "hello-out "); + fprintf(stderr, "hello-err "); + fflush(stdout); + sleep(1); + } + return 0; +} + + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/04-macrodef.c b/PracticingC/gowrikumar/src/04-macrodef.c new file mode 100644 index 0000000..30b641f --- /dev/null +++ b/PracticingC/gowrikumar/src/04-macrodef.c @@ -0,0 +1,19 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include + +#define f(a, b) a##b +#define g(a) #a +#define h(a) g(a) + +int main() +{ + printf("%s\n", h(f(1, 2))); + printf("%s\n", g(f(1, 2))); + return 0; +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/04b-macrodef.c b/PracticingC/gowrikumar/src/04b-macrodef.c new file mode 100644 index 0000000..3dd0bc4 --- /dev/null +++ b/PracticingC/gowrikumar/src/04b-macrodef.c @@ -0,0 +1,42 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include + +#define f(a, b) a##b +#define g(a) #a +#define h(a) g(a) +#define border(c) \ + for (int i = 0; i < 60; i++) { \ + printf(c); \ + } \ + printf("\n"); + +int main() +{ + printf("%s\n", h(f(1, 2))); + printf("%s\n", g(f(1, 2))); + + printf("%s\n", g(printf("dogs rule cats drool\n"))); + + char * hambones = "Cats! " g(ham); + char * bonesham = "Meats! " g(bones); + char * tmp; + + border("-"); + printf("bonesham = %s\n", bonesham); + printf("hambones = %s\n", hambones); + + border("-"); + tmp = f(ham, bones); + f(ham, bones) = f(bones, ham); + f(bones, ham) = tmp; + + printf("bonesham = %s\n", bonesham); + printf("hambones = %s\n", hambones); + return 0; +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/05-switchint.c b/PracticingC/gowrikumar/src/05-switchint.c new file mode 100644 index 0000000..6a5b568 --- /dev/null +++ b/PracticingC/gowrikumar/src/05-switchint.c @@ -0,0 +1,24 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include +int main() +{ + int a=10; + switch(a) + { + case '1': + printf("ONE\n"); + break; + case '2': + printf("TWO\n"); + break; + defa1ut: + printf("NONE\n"); + } + return 0; +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/05b-switchint.c b/PracticingC/gowrikumar/src/05b-switchint.c new file mode 100644 index 0000000..99368be --- /dev/null +++ b/PracticingC/gowrikumar/src/05b-switchint.c @@ -0,0 +1,32 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#define MAGIC_NUMBER 10 + +#include +int main() +{ + int a = MAGIC_NUMBER; + switch(a) + { + case '1': + printf("ONE\n"); + break; + case '2': + printf("TWO\n"); + break; + defalut: + printf("NO CAN SPELL\n"); + break; + defau1t: + printf("SO CLOSE, YET SO FAR\n"); + break; + default: + printf("NONE\n"); + } + return 0; +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/06-ia64segfault.c b/PracticingC/gowrikumar/src/06-ia64segfault.c new file mode 100644 index 0000000..6e35d74 --- /dev/null +++ b/PracticingC/gowrikumar/src/06-ia64segfault.c @@ -0,0 +1,16 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include + +int main() +{ + int* p; + p = (int*)malloc(sizeof(int)); + *p = 10; + return 0; +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/06b-ia64segfault.c b/PracticingC/gowrikumar/src/06b-ia64segfault.c new file mode 100644 index 0000000..57bc6f2 --- /dev/null +++ b/PracticingC/gowrikumar/src/06b-ia64segfault.c @@ -0,0 +1,29 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include +#include + +int main() +{ + int* p; + + size_t size_of_int = sizeof(int); + printf("sizeof(int) = %d\n", size_of_int); + + p = (int*)malloc(sizeof(int)); + + size_t size_of_p = sizeof(p); + printf("sizeof(p) = %d\n", size_of_p); + + *p = 10; + + size_t size_of_ptr_p = sizeof(*p); + printf("sizeof(*p) = %d\n", size_of_ptr_p); + + return 0; +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/07-countbits.c b/PracticingC/gowrikumar/src/07-countbits.c new file mode 100644 index 0000000..aad54a4 --- /dev/null +++ b/PracticingC/gowrikumar/src/07-countbits.c @@ -0,0 +1,40 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include + +static unsigned int mask[] = { + 0x55555555, + 0x33333333, + 0x0F0F0F0F, + 0x00FF00FF, + 0x0000FFFF +}; + + +int get_bit_count(unsigned int x) +{ + + int i; + int shift; /* Number of positions to shift to right*/ + for (i = 0, shift = 1; i < 5; i++, shift *= 2) { + x = (x & mask[i]) + ((x >> shift) & mask[i]); + } + return x; +} + + +int main() +{ + int to_test[] = {0, 5, 7}; + int current; + + for (int i = 0; i < 3 ; i++) { + current = to_test[i]; + printf("get_bit_count(%d) = %d\n", current, get_bit_count(current)); + } +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/07b-countbits.c b/PracticingC/gowrikumar/src/07b-countbits.c new file mode 100644 index 0000000..e363587 --- /dev/null +++ b/PracticingC/gowrikumar/src/07b-countbits.c @@ -0,0 +1,67 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include + +static unsigned int mask[] = { + 0x55555555, + 0x33333333, + 0x0F0F0F0F, + 0x00FF00FF, + 0x0000FFFF +}; + + +int get_bit_count(unsigned int x) +{ + printf("get_bit_count(%d)\n", x); + + int i; + int x_and_mask; + int x_shifted; + int x_shifted_and_mask; + int shift; /* Number of positions to shift to right*/ + for (i = 0, shift = 1; i < 5; i++, shift *= 2) { + printf(" START loop\n"); + printf(" i = %d, x = %d, shift = %d\n", i, x, shift); + + x_and_mask = x & mask[i]; + printf(" x & mask[i] = %d\n", x_and_mask); + + x_shifted = x >> shift; + printf(" x >> shift = %d\n", x_shifted); + + x_shifted_and_mask = x_shifted & mask[i]; + printf(" (x >> shift) & mask[i] = %d\n", x_shifted_and_mask); + + x = x_and_mask + x_shifted_and_mask; + printf(" x = %d\n", x); + printf(" END loop\n"); + } + + return x; +} + + +int main() +{ + int to_test[] = {0, 5, 7}; + int current; + + /* + size_t mask_len = sizeof(mask) / sizeof(unsigned int); + + for (int i = 0; i < mask_len; i++) { + printf("mask[%d] = %d\n", i, mask[i]); + } + */ + + for (int i = 0; i < 3 ; i++) { + current = to_test[i]; + printf("get_bit_count(%d) -> %d\n", current, get_bit_count(current)); + } +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/08-incrfloat.c b/PracticingC/gowrikumar/src/08-incrfloat.c new file mode 100644 index 0000000..cae6c20 --- /dev/null +++ b/PracticingC/gowrikumar/src/08-incrfloat.c @@ -0,0 +1,26 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include + +int main() +{ + float f = 0.0f; + int i; + + for (i = 0; i < 10; i++) { + f = f + 0.1f; + } + + if (f == 1.0f) { + printf("f is 1.0 \n"); + } else { + printf("f is NOT 1.0\n"); + } + + return 0; +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/08b-incrfloat.c b/PracticingC/gowrikumar/src/08b-incrfloat.c new file mode 100644 index 0000000..782aedb --- /dev/null +++ b/PracticingC/gowrikumar/src/08b-incrfloat.c @@ -0,0 +1,43 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include +#include + +int main() +{ + float f = 0.0f; + int i; + + for (i = 0; i < 10; i++) { + f = f + 0.1f; + } + + if (f == 1.0) { + printf("f is 1.0 \n"); + /* nope! */ + } + + if (f == 1.000000) { + printf("f is perhaps 1.000000?\n"); + /* nope again */ + } + + printf("f is neither 1.0 nor 1.000000\n"); + printf("(f is really %.24f)\n", f); + printf("OH NOES!\n"); + printf("But...\n"); + + double difference = fabs(f - 1.000000); + + if (difference < 0.00001) { + printf("f is close enough to 1.000000 (off by %.24f)\n", difference); + /* yes? */ + } + + return 0; +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/09-multipleassignment.c b/PracticingC/gowrikumar/src/09-multipleassignment.c new file mode 100644 index 0000000..3cf7b4b --- /dev/null +++ b/PracticingC/gowrikumar/src/09-multipleassignment.c @@ -0,0 +1,20 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include + +int main() +{ + /* FIXME: the comma after "a = 1" makes the compiler angry. Either the + * ", 2" should be removed or another assignment should be added. + int a = 1, 2; + */ + int a = 1, b = 2; + printf("a: %d\n", a); + printf("b: %d\n", b); + return 0; +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/10-nestedprintf.c b/PracticingC/gowrikumar/src/10-nestedprintf.c new file mode 100644 index 0000000..857741c --- /dev/null +++ b/PracticingC/gowrikumar/src/10-nestedprintf.c @@ -0,0 +1,15 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include + +int main() +{ + int i = 43; + printf("%d\n", printf("%d", printf("%d", i))); + return 0; +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/10b-nestedprintf.c b/PracticingC/gowrikumar/src/10b-nestedprintf.c new file mode 100644 index 0000000..0e0304d --- /dev/null +++ b/PracticingC/gowrikumar/src/10b-nestedprintf.c @@ -0,0 +1,17 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include + +int main() +{ + int i = 43, nprinted; + nprinted = printf("%d\n", printf("%d", printf("%d", i))); + nprinted = printf("(the last one was %d characters)\n", nprinted); + nprinted = printf("(and that was %d characters)\n", nprinted); + return 0; +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/11-duff.c b/PracticingC/gowrikumar/src/11-duff.c new file mode 100644 index 0000000..bb7dbfd --- /dev/null +++ b/PracticingC/gowrikumar/src/11-duff.c @@ -0,0 +1,37 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include + +void duff(register char *to, register char *from, register int count) +{ + register int n = (count + 7) / 8; + switch (count % 8) { + case 0: do { *to++ = *from++; + case 7: *to++ = *from++; + case 6: *to++ = *from++; + case 5: *to++ = *from++; + case 4: *to++ = *from++; + case 3: *to++ = *from++; + case 2: *to++ = *from++; + case 1: *to++ = *from++; + } while (--n > 0); + } +} + +int main() +{ + char * to = "dogs cats babies"; + char * from = "monkey hat pants"; + int i = 16; + printf("to = %s\n", to); + printf("from = %s\n", from); + /* And here comes the segfault... */ + duff(to, from, i); + printf("to = %s\n", to); + printf("from = %s\n", from); +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/11b-duff.c b/PracticingC/gowrikumar/src/11b-duff.c new file mode 100644 index 0000000..3139220 --- /dev/null +++ b/PracticingC/gowrikumar/src/11b-duff.c @@ -0,0 +1,40 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include + +void duff(register char *to, register char *from, register int count) +{ + register int n; + + int remainder = count % 8; + if (remainder == 0) { + n = (count + 7) / 8; + do { + *to++ = *from++; + } while (--n > 0); + } else if (remainder <= 7 && remainder > 0) { + int i; + int c; + for (i = 0; (c = from[i] && c != EOF); i++) { + to[i] = c; + } + } +} + +int main() +{ + char * to = "dogs cats babies"; + char * from = "monkey hat pants"; + int i = 11; + printf("to = %s\n", to); + printf("from = %s\n", from); + /* And here comes the segfault... */ + duff(to, from, i); + printf("to = %s\n", to); + printf("from = %s\n", from); +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/12-countbits2.c b/PracticingC/gowrikumar/src/12-countbits2.c new file mode 100644 index 0000000..d79e1ce --- /dev/null +++ b/PracticingC/gowrikumar/src/12-countbits2.c @@ -0,0 +1,32 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include + + +int get_bit_count(unsigned int x) +{ + int count=0; + while(x) + { + count++; + x = x&(x-1); + } + return count; +} + + +int main() +{ + int to_test[] = {0, 5, 7}; + int current; + + for (int i = 0; i < 3 ; i++) { + current = to_test[i]; + printf("get_bit_count(%d) = %d\n", current, get_bit_count(current)); + } +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/PracticingC/gowrikumar/src/Makefile b/PracticingC/gowrikumar/src/Makefile new file mode 100644 index 0000000..738079a --- /dev/null +++ b/PracticingC/gowrikumar/src/Makefile @@ -0,0 +1,12 @@ +# puzzles from http://www.gowrikumar.com/c/ + +ALL_BIN := $(patsubst %.c,$(BINDIR)/%,$(wildcard *.c)) + + +$(BINDIR)/%: %.c + $(CC) $(CFLAGS) -o $@ $< + +all: $(ALL_BIN) + + +.PHONY: all diff --git a/PracticingC/socky.c b/PracticingC/socky.c new file mode 100644 index 0000000..cf27e98 --- /dev/null +++ b/PracticingC/socky.c @@ -0,0 +1,48 @@ +#include +#include +#include +#include +#include +#include + +const char *SOCKNAME = "/tmp/socky"; +int sfd; +struct sockaddr_un addr; + + +int main(int argc, char *argv[]) +{ + sfd = socket(AF_UNIX, SOCK_STREAM, 0); + if (sfd == -1) { + fprintf(stderr, "FAILED TO ALLOCATE SOCKET\n"); + goto error; + } + + memset(&addr, 0, sizeof(struct sockaddr_un)); + addr.sun_family = AF_UNIX; + strncpy(addr.sun_path, SOCKNAME, sizeof(addr.sun_path) - 1); + + if (bind(sfd, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) == -1) { + fprintf(stderr, "FAILED TO BIND SOCKET TO ADDRESS\n"); + goto error; + } + + if (listen(sfd, 128) == -1) { + fprintf(stderr, "FAILED TO LISTEN ON ADDRESS\n"); + goto error; + } + + for (;;) { + fprintf(stdout, "ATTEMPTING TO WAIT FOR REQUEST ON %s\n", SOCKNAME); + if (accept(sfd, NULL, NULL) == -1) { + fprintf(stderr, "FAILED TO ACCEPT REQUEST ON ADDRESS\n"); + goto error; + } + } + + return 0; + +error: + return 1; + +}