NetSurf
clipboard.c
Go to the documentation of this file.
1/*
2 * Copyright 2013 Ole Loots <ole@monochrom.net>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Module Description:
19 *
20 *
21 *
22 */
23
24#include <stdlib.h>
25#include <stdint.h>
26#include <string.h>
27#include <stdio.h>
28#include <mint/osbind.h>
29#include <cflib.h>
30#include "atari/clipboard.h"
31#include "atari/gemtk/gemtk.h"
32
33
34static int filesize(char * path)
35{
36 FILE *f;
37 int fs;
38
39 f = fopen( path, "r+b");
40 if(!f)
41 return(-1);
42
43 fseek(f, 0L, SEEK_END);
44 fs = ftell(f);
45 fclose(f);
46
47 return(fs);
48}
49
50int scrap_txt_write(char *str)
51{
52 scrap_wtxt(str);
53
54
55 // Send SC_CHANGED message:
56 gemtk_send_msg(SC_CHANGED, 0, 2, 0, 0, 0, 0);
57
58 return(0);
59
60}
61
62char *scrap_txt_read(void)
63{
64 char * buf = NULL;
65 char path[80];
66
67 if (get_scrapdir (path))
68 {
69 int len;
70 strcat (path, "scrap.txt");
71 len = filesize(path);
72 if(len > 0){
73 int file;
74 if ((file = (int) Fopen (path, 0)) >= 0)
75 {
76 buf = malloc(len);
77 if(buf){
78 len = Fread (file, len, buf);
79 Fclose (file);
80 buf[len] = '\0';
81 return buf;
82 }
83 }
84 }
85 }
86 return buf;
87}
88
int scrap_txt_write(char *str)
Definition: clipboard.c:50
static int filesize(char *path)
Definition: clipboard.c:34
char * scrap_txt_read(void)
Definition: clipboard.c:62
Interface to utility string handling.
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
Definition: plot.c:821