summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorb0ric <b0risov.alexandr@rambler.ru>2009-08-08 20:18:38 +0300
committerb0ric <b0risov.alexandr@rambler.ru>2009-08-08 20:18:38 +0300
commit343357ed1e7907cf4b488058053df280ae63c7bb (patch)
tree201915ed25612180af3745131be66ce19edf1a0b /main.c
parent88db5cdceabf042f5e5d5695bf984900f8396225 (diff)
Now words are shown in alphabetical order
Diffstat (limited to 'main.c')
-rw-r--r--main.c61
1 files changed, 9 insertions, 52 deletions
diff --git a/main.c b/main.c
index 79c744f..e5d9439 100644
--- a/main.c
+++ b/main.c
@@ -16,79 +16,36 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "interface.h"
-#include "subtitle.h"
+#include "main.h"
+#include "mainwin.h"
#include "dict.h"
-#define PROGNAME "wordextract"
-#define OPT_FOLDER "/.wordextract"
-#define PATH_LENGTH 50
-
+char optpath[PATH_LENGTH] = {0};
+char dictfile[PATH_LENGTH] = {0};
Language lang;
-static void create_dict_file(char *);
-static void open_and_load_dict();
+static void fill_vars();
int main(int argc, char *argv[])
{
-
gtk_init(&argc, &argv);
- open_and_load_dict();
+ fill_vars();
+ dict = load_dict();
lang = ENG;
create_main_window();
gtk_widget_show(main_window);
gtk_main();
-
- free_words(dict);
+ free_words(dict); /*Where to put?*/
return 0;
}
-void create_dict_file(char *path)
-{
- mode_t mode_0755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
- struct stat st;
- FILE *fdict;
- char file[PATH_LENGTH] = {0};
-
- if (stat(path, &st)) {
- fprintf(stderr, "%s: Creating directory\n", path);
- if (mkdir(path, mode_0755)) {
- perror(path);
- exit(1);
- }
- }
- strcat(file, path);
- strcat(file, DICT_FILE);
- fprintf(stderr, "%s: Creating blank dictionary file\n", file);
- if (!(fdict = fopen(file, "w"))) {
- perror(file);
- exit(1);
- }
- fclose(fdict);
-}
-
-void open_and_load_dict()
+void fill_vars()
{
- FILE *fdict;
- char optpath[PATH_LENGTH] = {0};
- char dictfile[PATH_LENGTH] = {0};
-
strcpy(optpath, getenv("HOME"));
strcat(optpath, OPT_FOLDER);
strcat(dictfile, optpath);
strcat(dictfile, DICT_FILE);
- if (!(fdict = fopen(dictfile, "r"))) {
- perror(dictfile);
- create_dict_file(optpath);
- if (!(fdict = fopen(dictfile, "r"))) {
- perror(dictfile);
- exit(1);
- }
- }
- dict = load_dict(fdict);
- fclose(fdict);
}