Changeset 2444
- Timestamp:
- Jun 16, 2008, 1:04:49 PM (15 years ago)
- Location:
- neercs/trunk/src
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/Makefile.am
r2431 r2444 7 7 endif 8 8 9 neercs_SOURCES = neercs.h $(grab_c) m ain.c screens.c term.c effects.c wm.c9 neercs_SOURCES = neercs.h $(grab_c) mygetopt.c main.c screens.c term.c effects.c wm.c 10 10 neercs_CFLAGS = @CACA_CFLAGS@ 11 11 neercs_LDADD = @CACA_LIBS@ @UTIL_LIBS@ -
neercs/trunk/src/grab.c
r2430 r2444 16 16 17 17 #include "neercs.h" 18 int grab_process(pid_t pid, char *ptyname, int ptyfd); 18 19 19 20 static int memcpy_from_target(pid_t pid, void* dest, void* src, size_t n) … … 125 126 regs.ebx = oldfd; 126 127 regs.ecx = newfd; 127 128 128 129 return do_syscall(pid, ®s); 129 130 } … … 149 150 150 151 /* +4 because it's trcuncated on a multiple of 4 and we need 1 */ 151 memcpy_into_target(pid, target_page, path, strlen(path)+4); 152 memcpy_into_target(pid, target_page, path, strlen(path)+4); 152 153 153 154 regs.eax = SYS_open; … … 155 156 regs.ecx = O_RDWR; 156 157 regs.edx = 0755; 157 158 158 159 if((ret = do_syscall(pid, ®s)) < 0) 159 160 { … … 309 310 } 310 311 } 311 312 312 313 kill(pid, SIGWINCH); 313 314 -
neercs/trunk/src/main.c
r2433 r2444 31 31 # include <util.h> /* for OS X */ 32 32 #endif 33 #if !defined HAVE_GETOPT_LONG 34 # include "mygetopt.h" 35 #elif defined HAVE_GETOPT_H 36 # include <getopt.h> 37 #endif 38 #if defined HAVE_GETOPT_LONG 39 # define mygetopt getopt_long 40 # define myoptind optind 41 # define myoptarg optarg 42 # define myoption option 43 #endif 33 44 #include <errno.h> 34 45 #include <cucul.h> … … 36 47 37 48 #include "neercs.h" 49 50 51 void version(void) 52 { 53 printf("%s\n", PACKAGE_STRING); 54 printf("Copyright (C) 2006, 2008 Sam Hocevar <sam@zoy.org>\n"); 55 printf(" Jean-Yves Lamoureux <jylam@lnxscene.org>\n\n"); 56 printf("This is free software. You may redistribute copies of it under the\n"); 57 printf("terms of the Do What The Fuck You Want To Public License, Version 2\n"); 58 printf("<http://sam.zoy.org/wtfpl/>.\n"); 59 printf("There is NO WARRANTY, to the extent permitted by law.\n"); 60 printf("\n"); 61 printf("For more informations, visit http://libcaca.zoy.org/wiki/neercs\n"); 62 } 63 38 64 39 65 int main(int argc, char **argv) … … 43 69 struct screen_list *screen_list = NULL; 44 70 char *default_shell = NULL; 45 int i, w, h, args ;71 int i, w, h, args, s=0; 46 72 int eof = 0, refresh = 1, command = 0; 47 73 … … 65 91 caca_set_cursor(dp, 1); 66 92 67 68 93 w = cucul_get_canvas_width(cv); 69 94 h = cucul_get_canvas_height(cv); 70 71 95 72 96 … … 94 118 screen_list->pty = screen_list->prevpty = 0; 95 119 96 for(i = 0; i < args; i++) 97 { 98 struct screen *tmp; 99 if(argc < 2) 100 tmp = create_screen(w, h, default_shell); 101 else 102 { 103 if(!strcmp(argv[i + 1], "-P")) 120 for(;;) 121 { 122 int option_index = 0; 123 static struct myoption long_options[] = 104 124 { 105 125 #ifdef USE_GRAB 106 if(i + 2 > argc) 107 { 108 fprintf(stderr, "-P needs a parameter !\n"); 109 exit(1); 110 } 111 tmp = create_screen_grab(w, h, atoi(argv[i + 2])); 112 i++; 113 #else 114 fprintf(stderr, "Grabbing process is not supported, sorry\n"); 115 exit(1); 116 #endif 117 } 118 else 119 tmp = create_screen(w, h, argv[i + 1]); 120 } 121 122 if(tmp) 123 { 124 if(add_screen(screen_list, tmp) < 0) 125 { 126 fprintf(stderr, "Can't add %p to %p\n", tmp, screen_list); 127 } 128 } 129 else 130 { 131 fprintf(stderr, "Can't create screen\n"); 132 } 133 } 126 { "pid", 1, NULL, 'P' }, 127 #endif 128 { "help", 0, NULL, 'h' }, 129 { "version", 0, NULL, 'v' }, 130 }; 131 int c = mygetopt(argc, argv, "P:hv", long_options, &option_index); 132 if(c == -1) 133 break; 134 135 switch(c) 136 { 137 #ifdef USE_GRAB 138 case 'P': /* --pid */ 139 add_screen(screen_list,create_screen_grab(w, h, atoi(myoptarg))); 140 s+=2; 141 break; 142 #endif 143 case 'h': /* --help */ 144 // usage(argc, argv); 145 return 0; 146 break; 147 case 'v': /* --version */ 148 version(); 149 goto end; 150 break; 151 default: 152 fprintf(stderr, "Unknow argument #%d\n", myoptind); 153 return -1; 154 break; 155 } 156 } 157 158 159 if(s == 0 && argc<2) 160 { 161 add_screen(screen_list, create_screen(w, h, default_shell)); 162 } 163 164 /* Launch command line processes */ 165 for(i=0; i<(argc-1) - s; i++) 166 { 167 add_screen(screen_list, create_screen(w, h, argv[i+s+1])); 168 } 169 134 170 135 171 /* Windows are in a temporary state, resize them to the right dimensions */ … … 262 298 } 263 299 300 end: 264 301 /* Clean up */ 265 302 caca_free_display(dp); -
neercs/trunk/src/neercs.h
r2431 r2444 16 16 #include <stdint.h> 17 17 #include <caca.h> 18 19 #define CURRENTSCREEN screen_list->screen[screen_list->pty]20 21 18 22 19 enum wm_types … … 74 71 75 72 73 void version(void); 74 75 76 76 77 int create_pty(char *cmd, unsigned int w, unsigned int h, int *cpid); 77 78 #ifdef USE_GRAB -
neercs/trunk/src/term.c
r2431 r2444 167 167 * ECMA-48 5.4: Control sequences, and the code definitions are 168 168 * given in ECMA-48 8.3: Definition of control functions. */ 169 169 debug("Got command '%c'\n", buffer[i + final]); 170 170 switch(buffer[i + final]) 171 171 { … … 256 256 break; 257 257 case 'r': /* SS (0x72) - Scroll Screen FIXME */ 258 258 if(scrolled) break; 259 259 if((argv[0]==0 && argv[1]==0) || scrolled) break; 260 260 for(j = argv[0]-1; j < argv[1]-1; j++)
Note: See TracChangeset
for help on using the changeset viewer.