aboutsummaryrefslogtreecommitdiff
path: root/tst
diff options
context:
space:
mode:
authorbeber <beber>2006-01-12 02:53:35 +0000
committerbeber <beber>2006-01-12 02:53:35 +0000
commitae70eb8b8f4e47a062422144bdb1549d03d5e149 (patch)
tree99506d85ab568bb844f0d9257175bc69cdd9862a /tst
parentcomment and unused code (diff)
downloadespik-ae70eb8b8f4e47a062422144bdb1549d03d5e149.tar.xz
Missing files for git-import
Diffstat (limited to 'tst')
-rw-r--r--tst/Makefile27
-rw-r--r--tst/bordure.c39
-rw-r--r--tst/conf.c35
-rw-r--r--tst/kb.c118
-rw-r--r--tst/net.c263
-rw-r--r--tst/upper.c28
6 files changed, 510 insertions, 0 deletions
diff --git a/tst/Makefile b/tst/Makefile
new file mode 100644
index 0000000..a58221e
--- /dev/null
+++ b/tst/Makefile
@@ -0,0 +1,27 @@
+SRC = upper.c
+NAME = upper
+
+CFLAGS += -W -Wall -g
+LDFLAGS +=
+OBJ = $(SRC:c=o)
+RM = rm -f
+CC = gcc
+
+$(NAME): $(OBJ)
+ $(CC) -o $(NAME) $(CFLAGS) $(LDFLAGS) $(OBJ)
+ chmod u+x $(NAME)
+ cp $(NAME) ~/bin
+
+clean:
+ $(RM) *.swp
+ $(RM) $(OBJ)
+ $(RM) *.c~ *.h~
+
+pdfclean:
+ $(RM) *.pdf
+ $(RM) *.ps
+
+fclean: clean pdfclean
+ $(RM) $(NAME)
+
+re: fclean $(NAME) clean
diff --git a/tst/bordure.c b/tst/bordure.c
new file mode 100644
index 0000000..d41e553
--- /dev/null
+++ b/tst/bordure.c
@@ -0,0 +1,39 @@
+#include <Ecore_Evas.h>
+#include <Ecore.h>
+
+#define WIDTH 400
+#define HEIGHT 400
+
+Ecore_Evas * ee;
+Evas * evas;
+Evas_Object * base_rect;
+
+int main(int argc, char** argv){
+
+ if (argc < 2)
+ exit (-1);
+
+ ecore_init();
+
+ ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, WIDTH, HEIGHT);
+
+ ecore_evas_title_set(ee, "Ecore_Evas Template");
+ ecore_evas_borderless_set(ee, atoi (argv[1]));
+ ecore_evas_show(ee);
+
+
+ evas = ecore_evas_get(ee);
+ evas_font_path_append(evas, "fonts/");
+
+
+ base_rect = evas_object_rectangle_add(evas);
+ evas_object_resize(base_rect, (double)WIDTH, (double)HEIGHT);
+ evas_object_color_set(base_rect, 244, 243, 242, 255);
+ evas_object_show(base_rect);
+
+ /* Insert Object Here */
+
+ ecore_main_loop_begin();
+
+ return 0;
+}
diff --git a/tst/conf.c b/tst/conf.c
new file mode 100644
index 0000000..381ec40
--- /dev/null
+++ b/tst/conf.c
@@ -0,0 +1,35 @@
+#include <Ecore_Config.h>
+
+int main(int argc, char ** argv)
+{
+ int i;
+ float j;
+ char *str;
+
+ if (ecore_config_init("foo") != ECORE_CONFIG_ERR_SUCC) {
+ printf("Cannot init Ecore_Config");
+ return 1;
+ }
+
+ ecore_config_int_default("/int_example", 1);
+ ecore_config_int_default("/int_example", 2);
+ ecore_config_string_default("/this/is/a/string/example", "String");
+ ecore_config_float_default("/float/example", 2.22);
+
+ ecore_config_load();
+
+ i = ecore_config_int_get("/int_example");
+ str = ecore_config_string_get("/this/is/a/string/example");
+ j = ecore_config_float_get("/float/example");
+
+ printf("str is (%s)\n", str);
+ printf("i is (%d)\n", i);
+ printf("j is (%f)\n", j);
+
+ free(str);
+
+ ecore_config_shutdown();
+ return 0;
+}
+
+
diff --git a/tst/kb.c b/tst/kb.c
new file mode 100644
index 0000000..45e6dc5
--- /dev/null
+++ b/tst/kb.c
@@ -0,0 +1,118 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+
+/* EFL Stuff */
+#include <Ecore.h>
+
+#define __UNUSED__ __attribute__((unused))
+
+char *_priv (char *msg, char *var)
+{
+ char *out;
+
+ printf ("> _priv\n");
+
+ out = calloc (sizeof (char), strlen ("PRIV") + 1 /* space */
+ + strlen (var) + 2 /* space: */
+ + strlen (msg) + 3 /* \r\n\0 */
+ );
+
+ sprintf (out, "PRIV %s :%s\r\n", var, msg);
+ printf ("< _priv:%s\n******\n", out);
+
+ return (out);
+}
+
+int del_backslash (char *msg)
+{
+ int i, count;
+
+ for (i = 0, count = 0; msg[i]; i++)
+ {
+ if (msg[i] == '\n')
+ {
+ msg[i] = '\0';
+ count++;
+ }
+ }
+
+ return (count);
+}
+
+
+int _kb_get (void __UNUSED__ * data, Ecore_Fd_Handler * fd_handler)
+{
+ char *kb;
+ char *tmp;
+ int count;
+
+ printf ("> _kb_get\n");
+
+ printf ("calloc\n");
+ kb = calloc (sizeof (char), 200);
+ if (kb == NULL)
+ {
+ fprintf (stderr, "fuck\n");
+ exit (-1);
+ }
+
+ fflush (stdin); /* Uh ? */
+ fflush (stdout); /* Uh ? */
+
+ do
+ {
+ printf ("memset\n");
+ memset (kb, 0, 200);
+ printf (">read\n");
+ count = read (ecore_main_fd_handler_fd_get (fd_handler), kb, 198);
+ printf ("<read(%d)\n", count);
+
+ if (count > 0)
+ {
+ del_backslash (kb);
+
+ tmp = _priv (kb, "test");
+
+ /* for (i=0; i < strlen(tmp) ; i++)
+ * {
+ * printf ("%d\t: %c\t%c\n", i, kb[i], tmp[i]);
+ * }
+ */
+
+ printf ("%s\n", tmp);
+ }
+ }
+ while (count >= 198);
+
+ if (count == -1)
+ perror ("read");
+
+ if (count == 0)
+ {
+ printf ("EOF, quit\n");
+ ecore_main_loop_quit ();
+ }
+
+ printf ("< _kb_get\n");
+
+ free (kb);
+ free (tmp);
+
+ return (1);
+}
+
+int main ()
+{
+ Ecore_Fd_Handler *fd_kb;
+
+ ecore_init ();
+
+ fd_kb = ecore_main_fd_handler_add (STDIN_FILENO, ECORE_FD_READ, _kb_get, NULL, NULL, NULL);
+
+ ecore_main_loop_begin ();
+
+ exit (0);
+
+}
diff --git a/tst/net.c b/tst/net.c
new file mode 100644
index 0000000..eec6788
--- /dev/null
+++ b/tst/net.c
@@ -0,0 +1,263 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/select.h>
+#include <sys/time.h>
+
+#include <errno.h>
+
+#include <string.h>
+#include <strings.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+
+#include <Ecore_Config.h>
+
+#define NB_MAX 10
+#define ___NICK "ddero"
+
+#define _EOF "\r\n"
+
+typedef struct
+{
+ char *host;
+ int port;
+
+} t_servinfo;
+
+char *
+format_send(char *msg)
+{
+ char *tosend;
+
+ /*unsigned int i; */
+
+ tosend = malloc((strlen(msg) + 2) * sizeof(char));
+ if (tosend == NULL)
+ {
+ fprintf(stderr, "Memory fault\n");
+ exit(-2);
+ }
+
+ strcpy(tosend, msg);
+ strcat(tosend, _EOF);
+
+ /*
+ for (i = 0 ; i < strlen(msg) + 2 ; i++)
+ {
+ fprintf (stderr, "[%d] %X %c\n", i, tosend[i], tosend[i]);
+ }
+ */
+ return (tosend);
+}
+
+unsigned short
+sendmsg_len(char *msg)
+{
+ return (strlen(msg) + 2);
+}
+
+void
+sendtoserv(int fd, char *msg)
+{
+ printf("send: %s\n", msg);
+ if ((send(fd, format_send(msg), sendmsg_len(msg), 0)) == -1)
+ {
+ perror("send");
+ exit(-3);
+ }
+}
+
+/*char* dir_from_path (char* path)
+{
+ char* dir;
+ unsigned int i;
+
+ for ( i = strlen (path) -1 ; i != 0 ; i-- )
+ {
+ if ( path[i] == '/')
+ break;
+ }
+
+ dir = strndup (path, i);
+ dir [i] = '\0';
+
+ printf ("dir: %s\n", dir);
+
+ return (dir);
+}*/
+
+void
+loadconfig(t_servinfo * s_info)
+{
+ if (ecore_config_init("ebic") != ECORE_CONFIG_ERR_SUCC)
+ {
+ printf("Cannot init Ecore_Config");
+ exit(-1);
+ }
+
+ ecore_config_string_default("/config/server/host", "beber.melee");
+ ecore_config_int_default("/config/server/port", 6667);
+
+ ecore_config_load();
+
+ s_info->host = ecore_config_string_get("/config/server/host");
+ s_info->port = ecore_config_int_get("/config/server/port");
+
+ ecore_config_shutdown();
+ ecore_config_save();
+
+ printf("sinfo->host : %s\n", s_info->host);
+ printf("sinfo->port : %d\n", s_info->port);
+}
+
+int
+get_max(int *tab)
+{
+ int i, max;
+
+ max = -1;
+
+ for (i = 0; tab[i]; i++)
+ {
+ if (tab[i] > max)
+ max = tab[i];
+ }
+
+ return (max);
+}
+
+int
+main(int argc, char **argv)
+{
+ int sock;
+ struct sockaddr_in dest_host;
+ struct hostent *hostent;
+
+ struct timeval wait_time;
+
+ int count;
+ int std;
+ char buff[NB_MAX];
+ char *tmp;
+
+ int r_sel;
+
+ fd_set fds_r;
+ fd_set fds_w;
+
+ int i = 0;
+
+ t_servinfo serveur;
+
+ loadconfig(&serveur);
+
+ if (argc < 3)
+ {
+ fprintf(stderr, "Loading from conf ...\n");
+ }
+ else
+ {
+ printf("connecting to %s:%s\n", argv[1], argv[2]);
+ }
+
+/* serveur.host = argv[1];
+ serveur.port = atoi (argv[2]); */
+
+ printf("host: %s\n", serveur.host);
+ printf("port: %d\n", serveur.port);
+
+ printf("gethostbyname (%s)\n", serveur.host);
+ if ((hostent = gethostbyname(serveur.host)) == NULL)
+ {
+ fprintf(stderr, "%s could not be found\n", serveur.host);
+ exit(-1);
+ }
+
+ memset(&dest_host, 0, sizeof(struct sockaddr_in));
+
+ dest_host.sin_family = AF_INET;
+ dest_host.sin_addr.s_addr = ((struct in_addr *)hostent->h_addr)->s_addr;
+ dest_host.sin_port = htons((short)serveur.port);
+
+ printf("socket\n");
+ if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+ {
+ perror("socket");
+ exit(-1);
+ }
+
+ printf("connect\n");
+ if ((connect(sock, (struct sockaddr *)&dest_host, sizeof(dest_host))) == -1)
+ {
+ perror("connect");
+ exit(-1);
+ }
+
+ std = open("/dev/input", O_RDONLY);
+ perror("open");
+
+ printf("%d\n", std);
+
+ FD_ZERO(&fds_r);
+ FD_ZERO(&fds_w);
+ FD_SET(std, &fds_r);
+ FD_SET(sock, &fds_r);
+ FD_SET(std, &fds_w);
+ FD_SET(sock, &fds_w);
+
+// wait_time.tv_sec = 1000000 / 1000000;*/ /* Nb sec */
+// wait_time.tv_usec = 1000000 % 1000000; /* Nb µsec */
+
+ do
+ {
+ memset(buff, 0, NB_MAX - 1);
+
+ r_sel = select(FD_SETSIZE, &fds_r, &fds_w, NULL, 0);
+
+ if (FD_ISSET(std, &fds_r))
+ printf("fds_r: clavier\n");
+ if (FD_ISSET(sock, &fds_r))
+ printf("fds_r: reseau\n");
+ if (FD_ISSET(std, &fds_w))
+ printf("fds_w: clavier\n");
+ if (FD_ISSET(sock, &fds_w))
+ printf("fds_w: reseau\n");
+
+ count = recv(sock, buff, NB_MAX - 1, 0);
+ printf("%d: %s", i, buff);
+ if (i == 1)
+ sendtoserv(sock, "NICK " ___NICK);
+ if (i == 2)
+ sendtoserv(sock, "USER beber beber guybrush.melee :Ronnie Reagan");
+ if (i == 3)
+ sendtoserv(sock, "OPER beber beber");
+ if (i == 3)
+ sendtoserv(sock, "JOIN #opers");
+
+ if (i > 45)
+ {
+ tmp =
+ malloc(sizeof(char) * (strlen(buff) + strlen("PRIVMSG #opers :")));
+ sprintf(tmp, "%s %s", "PRIVMSG #opers :", buff);
+ sendtoserv(sock, tmp);
+ free(tmp);
+ }
+
+ //sleep (1);
+ i++;
+ }
+ while (count != 0);
+
+ close(sock);
+
+ return (0);
+}
diff --git a/tst/upper.c b/tst/upper.c
new file mode 100644
index 0000000..1d2d71f
--- /dev/null
+++ b/tst/upper.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <string.h>
+
+void string_upper(char* str)
+{
+ unsigned int len, i;
+
+ len = strlen (str);
+
+ for (i = 0 ; i < len ; i++)
+ {
+ if (str[i] >= 0x61 && str[i] <= 0x7A)
+ str[i] -= 0x20;
+ }
+}
+
+int main()
+{
+ char in[] = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ}}{''é""";
+
+ string_upper (in);
+
+ printf ("%s\n", in);
+
+ return 0;
+}