X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fmim%2FNominee.c;fp=src%2Fmim%2FNominee.c;h=5fd0081293970a9f98a2658ca333cc08fc2b67c1;hb=d36e7810a8b72db27a51d3239f0224a0409ed64a;hp=0000000000000000000000000000000000000000;hpb=89378ba8d749a6e772a195fdd5c7b4ce171acf3a;p=mim diff --git a/src/mim/Nominee.c b/src/mim/Nominee.c new file mode 100644 index 0000000..5fd0081 --- /dev/null +++ b/src/mim/Nominee.c @@ -0,0 +1,79 @@ +#include "Nominee.h" + +void InitNom(Nominee *N) +{ + N->top = -1; +} + +gint NomEmpty(Nominee *N) +{ + return N->top == -1; +} + +gint NomFull(Nominee *N) +{ + return N->top == NomSize-1; +} + +void push(Nominee *N,DataType d) +{ + if (NomFull(N)) + { + g_printf("Nominee is full!"); + return ; + } + N->data[++N->top] = d; +} + +DataType pop(Nominee *N) +{ + if (NomEmpty(N)) + { + g_printf("Nominee is empty!\n"); + return FALSE; + } + return(N->data[N->top--]); +} + +gint num(Nominee *N) +{ + return ++N->top; +} + +gchar* disp(Nominee *N) +{ + if (NomEmpty(N)) + { + g_printf("Nomieen is empty!\n"); + return ; + } + gint count = N->top; + + strcpy(UD_Phrase, N->data[N->top--]); + + while(N->top != -1) + { + strcat(UD_Phrase, N->data[N->top--]); + } + g_printf("%s\n",UD_Phrase); + + return UD_Phrase; +} + +gint main() +{ + Nominee *S; + S = (Nominee *)g_slice_alloc0(sizeof(Nominee)); + g_printf("Initialize the stack.\n"); + InitNom(S); + push(S,"aaa"); + push(S,"bbb"); + push(S,"ccc"); + push(S,"ddd"); + + g_printf("pop a element\n"); + DataType aa = pop(S); + + disp(S); + g_slice_free(Nominee, S); +} \ No newline at end of file