int main(int argc, char *argv[]) { node *chars, *q=NULL, *root; int c; unsigned mode; double offset; /* build huffman tree */ chars = getCharCounts(argv[1]); q = orderInputQ(chars, q); root = buildTree(q); /* Display */ if(argc!=2){ fprintf(stderr, "incorrect usage, try eg" "./huffman textfile.txt"); exit(1); } printf("\nenter number for layout type:\n"); printf("0. Knuth, 1. pseudo-Reingold-Tilford\n"); printf("(1 is not 100%% correct as RT but better "); printf("than Knuth in all cases I tried) :"); while(scanf("%u", &mode)!=1 || mode > 1){ printf("invalid choice, try again\n"); do{/*clear out user input*/ c=getchar(); } while(c!='\n'); } if(mode == 0){ knuth_getCoords(root, 0); } else { rt_draw_1(root, 0); offset = rt_1_1_move_onscreen(root); root->offset = offset; root->x += offset; rt_2_petrify(root,0); } doDisplay(root); /*clear up other memory */ freeTree(root); free(chars); return 0; }
int LoginCharacterList::Lua_GetCharacterCounts(LuaPlus::LuaState* state) { state->PushInteger(getCharCounts()); return 1; }