Database & SQL

Moderators: None (Apply to moderate this forum)
Number of threads: 1194
Number of posts: 2247

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
hierarchical multi-cursor editor Posted by d.jeffery on 12 Aug 2005 at 9:44 PM
To initiate discussion of this initial working release,
and seeing local discussion is kept to this forum
(although I think the editor may warrant its own messageboard),
here are some errata corresponding to this release:

s.cc is no longer needed, it was used to track a bug when using malloc.
the opendir() call seems to be generating errors sometimes,
perhaps malloc errors but not debugged yet: this call is superfluous
to the design of the editor as of now and may be removed from
term::expand(). start the program on different machines like this:
route add -net 224.0.0.0 netmask 224.0.0.0 dev eth0
./main 1234
(and on other machine)
route add -net 224.0.0.0 netmask 224.0.0.0 dev eth0
./main 4321
(all participants currently must start with the editor
in the initial empty state.)

further documentation or discussion should be forthcoming
with your interest.

ciao,
- D. Jeffery

Report
Re: hierarchical multi-cursor editor Posted by d.jeffery on 14 Apr 2012 at 6:28 AM
Hello,
If anyone was having trouble running this program just apply this
simple patch which uses gcc-3.3 (or try 3.4 or fix it all up); I recall
it was a working program when I had it.

ciao,
- M.Kyaeppd

diff -Naur v0.10/line.cc v0.11/line.cc
--- v0.10/line.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/line.cc 2012-04-14 00:38:50.000000000 -0700
@@ -2,6 +2,7 @@
#include "line.h"
#include "buffer.h"
#include <unistd.h>
+#include <string.h> // strlen

//buffer( 20 ); // segfault if you use 'size'

diff -Naur v0.10/main.cc v0.11/main.cc
--- v0.10/main.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/main.cc 2012-04-14 05:45:20.000000000 -0700
@@ -40,6 +40,7 @@
if( FD_ISSET( fileno( stdin ), &inputs ) )
{
char inbuf;
+
for(;;)
{
rc = read( fileno( stdin ), &inbuf, 1 );
@@ -181,10 +182,11 @@
fcntl( fileno( stdin ), F_GETFL, 0 ) | O_ASYNC | O_NONBLOCK );
fcntl( fileno( stdin ), F_SETOWN, getpid() );

- init_mcast_socket();
+ ms = init_mcast_socket();
+
puck.que = q = new queue( &puck.pad, ms, to, id );

- puck.pad.clear();
+// puck.pad.clear();
#if 0
puck.pad.debug();
#endif // debug
diff -Naur v0.10/makefile v0.11/makefile
--- v0.10/makefile 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/makefile 2012-04-14 00:45:27.000000000 -0700
@@ -19,7 +19,7 @@
s.cc -version -o s.s
as -V -Qy -o s.o s.s

-%.o: %.cc; g++ -c $<
+%.o: %.cc; g++-3.3 -c $<

#main: main.cc kbd.cc kbd_tty.cc \
# term.cc note.cc script.cc line.cc buffer.cc
diff -Naur v0.10/mcast.cc v0.11/mcast.cc
--- v0.10/mcast.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/mcast.cc 2012-04-14 06:12:34.000000000 -0700
@@ -10,7 +10,7 @@
#include <netinet/udp.h> // udphdr

#include <unistd.h> // getpid
-#include <stdio.h> // printf
+#include <stdio.h> // printf, perror
/*
#include <net/if.h>
#include <sys/ioctl.h>
@@ -23,10 +23,11 @@
extern int ms; // multicast socket
extern struct sockaddr_in to;
extern u_int id;
-
+#define sin to
int init_mcast_socket()
{
- struct sockaddr_in sin; // address for bind
+ int err = 0;
+ //struct sockaddr_in sin; // address for bind
sin.sin_addr.s_addr = htonl( INADDR_ANY );
sin.sin_port = htons( 9876 );

@@ -40,7 +41,9 @@
int msock_reuse = 1;
setsockopt( ms, SOL_SOCKET, SO_REUSEADDR, &msock_reuse, sizeof( int ) );

- bind( ms, ( struct sockaddr* )&sin, sizeof( sin ) );
+ err = bind( ms, ( struct sockaddr* )&sin, sizeof( sin ) );
+ printf( "bind:%x:", err );
+ perror( "::" );

u_char msock_ttl = 4;
setsockopt( ms, IPPROTO_IP, IP_MULTICAST_TTL,
@@ -65,6 +68,8 @@

if( setsockopt( ms, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof( mreq ) )
< 0 ) printf( "failed\n" );
-
+
+ fflush( stdout );
+
return ms;
}
diff -Naur v0.10/queue.cc v0.11/queue.cc
--- v0.10/queue.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/queue.cc 2012-04-14 06:08:05.000000000 -0700
@@ -3,6 +3,8 @@
//#include <stdlib.h> // malloc, free
#include <stdio.h> // stdin, fileno
#include <unistd.h> // read
+#include <string.h> // memcpy
+#include <stdlib.h> // exit

char message[ 1500 ]; // dynamic allocation segfaults below

diff -Naur v0.10/script.cc v0.11/script.cc
--- v0.10/script.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/script.cc 2012-04-14 06:13:38.000000000 -0700
@@ -1,6 +1,7 @@
//#include "null.h"
#include "script.h"
#include <stdlib.h> // NULL
+#include <string.h> // strlen

line_s::~line_s()
{
diff -Naur v0.10/term.cc v0.11/term.cc
--- v0.10/term.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/term.cc 2012-04-14 00:37:12.000000000 -0700
@@ -1,6 +1,7 @@
#include <stdio.h>
#include "term.h"
#include <stdlib.h>
+#include <string.h> // memcpy

//#define debug_flag

Report
Re: hierarchical multi-cursor editor Posted by d.jeffery on 20 Apr 2012 at 3:05 AM
Hello,
this is a bugfix release. simply apply both patches in order to the program and compile with gcc 3.x.

diff -Naur v0.11/atom.cc b/atom.cc
--- v0.11/atom.cc 2005-07-29 17:04:22.000000000 -0700
+++ b/atom.cc 2012-04-20 03:36:09.000000000 -0700
@@ -26,6 +26,8 @@
#include <string.h> // strcat, strlen
#include <stdio.h> // snprintf

+extern FILE* _file;
+
char* atom::ptrtocx( atom* object )
{
switch( object -> id_mask )
@@ -50,13 +52,13 @@
int size;
if( it == 0 ) size = 1;
else size = ( int )log10( it ) + 1;
- _name = new char[ size + 1 + strlen( pname ) ];
+ _name = new char[ size + 1 + strlen( pname ) + 1 ];
snprintf( _name, size + 1, "%d", it );
}
else
{
int size = strlen( object -> cx -> name );
- _name = new char[ size + 1 + strlen( pname ) ];
+ _name = new char[ size + 1 + strlen( pname ) + 1 ];
strcpy( _name, object -> cx -> name );
}
if( pname[ 0 ] != '\0' ) // root
@@ -81,6 +83,7 @@
char* name,* pname;
//if( object -> parent -> parent -> id_mask == ID_SCRIPT_DIR )
pname = ptrtocx( object -> parent -> parent );
+ //pname = ptrtocx( object -> parent );
int size;
/*
if( object -> cx == NULL )
@@ -96,14 +99,14 @@
int size;
if( it == 0 ) size = 1;
else size = ( int )log10( it ) + 1;
- name = new char[ size + 1 + strlen( pname ) ];
+ name = new char[ size + 1 + strlen( pname ) + 1 ];
snprintf( name, size + 1, "%d", it );
}
*/
if( object -> cx == NULL )
{
int size = strlen( ( ( line* )( object -> parent ) ) -> text );
- name = new char[ size + 1 + strlen( pname ) ];
+ name = new char[ size + 1 + strlen( pname ) + 1 ];
strcpy( name, ( ( line_s* )( object -> parent ) ) -> text );
char* _c = strchr( name, '.' );
if( _c ) *_c = '\0';
@@ -111,7 +114,7 @@
else
{
int size = strlen( object -> cx -> name );
- name = new char[ size + 1 + strlen( pname ) ];
+ name = new char[ size + 1 + strlen( pname ) + 1 ];
strcpy( name, object -> cx -> name );
}
if( pname[ 0 ] != '\0' ) // root
diff -Naur v0.11/context.cc b/context.cc
--- v0.11/context.cc 2005-07-29 17:04:22.000000000 -0700
+++ b/context.cc 2012-04-20 03:53:34.000000000 -0700
@@ -6,12 +6,63 @@
{
}

-context::context( context* _up, atom* _a , char* _name )
+context::context( context* _up, atom* _a , char* _name ) // please new[] _name
: a( _a ), name( _name ), up( _up )
, first( NULL ), last( NULL ), prev( NULL ), next( NULL )
{
}

+#include <stdlib.h> // strchr
+#include <string.h> // strlen, strcat, bzero, memcpy
+#include <stdio.h> // debug
+#include <unistd.h> // sync()
+
+char* context::rename( char* _name )
+{
+ char* __name = NULL;
+ if( name ) __name = name;
+ name = new char[ strlen( _name ) + 1 ];
+ memcpy( name, _name, strlen( _name ) + 1 );
+ if( __name ) delete[] __name;
+ return name;
+}
+
+char* context::path()
+{
+ char* cx = a -> ptrtocx( a );
+ char* _here = NULL;
+ char* _path = new char[ strlen( cx ) + 1 ];
+ char* _name = new char[ strlen( cx ) + 1 ];
+ strcpy( _name, cx );
+ bzero( _path, strlen( _name ) + 1 );
+ for(;;)
+ {
+ _here = strrchr( _name, '.' );
+ int bah;
+ if( _here == NULL )
+ {
+ strcat( _path, _name );
+ break;
+ }
+ *_here++ = '\0'; // shortening _name
+ bah = strlen( _here ) + 1;
+
+ char* _this = new char[ bah ]; // how to, int strchr - strchr
+
+ memcpy( _this, _here, bah );
+ strcat( _path, _this );
+ strcat( _path, "/" ); // for a total of bah added to _path
+
+ delete[] _this;
+ }
+ delete[] _name;
+
+ return _path;
+}
+ //char* _this = strchr( _here, '.' );
+ //if( _this != NULL )
+ // *_this = '\0';
+
/*
atom* context::findcx( char* );
int context::possess( int );
diff -Naur v0.11/context.h b/context.h
--- v0.11/context.h 2005-07-29 17:04:22.000000000 -0700
+++ b/context.h 2012-04-18 09:12:44.000000000 -0700
@@ -14,6 +14,9 @@
~context();
context( context*, atom*, char* );

+ char* rename( char* );
+ char* path();
+
// atom* findcx( char* );
// int possess( int );
// int colorize( int );
diff -Naur v0.11/main.cc b/main.cc
--- v0.11/main.cc 2012-04-20 03:17:29.000000000 -0700
+++ b/main.cc 2012-04-20 03:50:53.000000000 -0700
@@ -169,6 +169,8 @@
signal( SIGTERM, term );
signal( SIGABRT, term );

+ sync();
+
if( argc < 2 )
{
printf( "usage: %s <id#>\r\n", argv[ 0 ] );
@@ -186,7 +188,7 @@

puck.que = q = new queue( &puck.pad, ms, to, id );

-// puck.pad.clear();
+ puck.pad.clear();
#if 0
puck.pad.debug();
#endif // debug
diff -Naur v0.11/program.cc b/program.cc
--- v0.11/program.cc 2005-07-29 17:04:22.000000000 -0700
+++ b/program.cc 2012-04-20 02:29:48.000000000 -0700
@@ -67,9 +67,17 @@

void term( int signal );

+//#include <stdio.h> // debug
+//#include <unistd.h> // sync()
+
void program::mcast( void* state )
{
// printf( "y" );
// fflush( stdout );
+//FILE* _file = fopen( "/home/mdasoh/atom.log", "a" );
+//fprintf( _file, ":for:\n" );
+//fflush( stdout );
+//fclose( _file );
+//sync();
que -> disperse();
}
diff -Naur v0.11/script.cc b/script.cc
--- v0.11/script.cc 2012-04-20 03:17:29.000000000 -0700
+++ b/script.cc 2012-04-20 03:43:17.000000000 -0700
@@ -85,15 +85,15 @@

line* script::ins( line* here )
{
- line* brand = new line( this ),
+ line* brand = new line( this ), // parent
* there = here -> next;

brand -> last = here;
brand -> next = there;
if( there != NULL ) there -> last = brand;
here -> next = brand;
- // if( bot == here )
- // bot = brand;
+ if( bot == here )
+ bot = brand;

return brand;
}
@@ -141,37 +141,32 @@
}
#endif

-FILE* _file;
+#include "context.h" // debug

int script::load( char* path )
{
-fprintf( _file, "2\n" );
-fflush( _file );
-
close( top );

bot = top = new line( this ); line* current = top;

- if( 0 != chdir( path ) )
-fprintf( _file, "2.0\n" );
-fflush( _file );
+ if( 0 == chdir( path ) ); // solved
+ else if( 0 == chdir( "./" ) );
+ else if( 0 == chdir( "/" ) );
+ else
+{
+printf( "2.0.error\n" ); // reopen output
+fflush( stdout );
+}

struct dirent** dir; int entries;

sync();

-fprintf( _file, "2.1\n" );
-fflush( _file );
-
// entries = scandir( "./", &dir, nodots, alphasort );
// entries = scandir( "./", &dir, 0, alphasort );
entries = scandir( "./", &dir, 0, 0 );

if( entries == -1 )
-fprintf( _file, "2.2.0\n" );
-
-fprintf( _file, "2.2\n" );
-fflush( _file );

sync();

@@ -192,10 +187,7 @@
}
else return 1;

-fprintf( _file, "3\n" );
-fflush( _file );
-
- return entries;
+ return entries;
}

void script::save( char* file )
diff -Naur v0.11/term.cc b/term.cc
--- v0.11/term.cc 2012-04-20 03:17:29.000000000 -0700
+++ b/term.cc 2012-04-20 03:47:21.000000000 -0700
@@ -273,8 +273,7 @@
}
}

-extern FILE* _file;
-
+#include "context.h"
// update each here for cursors within this context
void term::expand( u_int cursor )
{
@@ -297,34 +296,26 @@
} // else
if( _row == 0 ) s -> top = lines;

-// if it has a name, loop through parent contexts
-// if( strlen( lines -> text ) == 0 )
+ if(0) // uncomment if you want to browse paths beginning with root
{
lines -> scr -> id_mask = ID_SCRIPT_DIR;
atom* _a = lines -> parent;
- if( _a == NULL )
+
+ char* cx = new char[ strlen( lines -> text ) + 1 ];
+ strcpy( cx, lines -> text );
+ if( lines -> parent -> parent )
{
+ lines -> scr -> cx = new
+ context( lines -> parent -> parent -> cx, lines -> scr, cx );
}
-_file = fopen( "atom.log", "a" );
-fprintf( _file, "1\n" );
-fflush( _file );
- lines -> scr -> load( "/root/hier" );
-fprintf( _file, "4\n" );
-fflush( _file );
- char* cx; // strange bug, do investigate further
-// if( lines == s -> top || strlen( lines -> last -> text ) != 23 )
-{
- cx = lines -> ptrtocx( lines -> scr );
-}
-// else { cx = new char[ 1 ]; cx[ 0 ] = '\0'; }
- lines -> clear();
-// lines -> ins( 0, "" );
-// cx[ 40 ] = '\0';
- lines -> ins( 0, cx );
- delete[] cx;
-fprintf( _file, "5\n" );
-fflush( _file );
-fclose( _file );
+ else
+ {
+ lines -> scr -> cx = new
+ context( NULL, lines -> scr, cx );
+ }
+ char* cx_path = lines -> scr -> cx -> path();
+ lines -> scr -> load( cx_path );
+ delete[] cx_path;
}
}
if( _row > 0 )
@@ -360,6 +351,7 @@
if( _row - _orig == note::rows ) _orig++;

if( _row > xorig + note::rows || _row + count <= xorig ) return;
+
redraw();
}

diff -Naur v0.11/thread.h b/thread.h
--- v0.11/thread.h 2005-07-29 17:04:22.000000000 -0700
+++ b/thread.h 2012-04-20 03:22:13.000000000 -0700
@@ -35,13 +35,13 @@
// printf( "%%" );
// fflush( stdout );

- thread* top = new thread;
+ register thread* top = new struct thread; // malloc failure centers on this

// printf( "%%" );
// fflush( stdout );

top -> next = next;
- top -> addr = v; // failure centers on this
+ top -> addr = v; // with allegro, malloc failure centers on this
top -> state = state;

( thread* )top_thread = top;
Report
Re: hierarchical multi-cursor editor Posted by d.jeffery on 14 Apr 2012 at 6:32 AM
Hello,
If anyone was having trouble running this program just apply this
simple patch which uses gcc-3.3 (or try 3.4 or fix it all up); I recall
it was a working program when I had it.

ciao,
- M.Kyaeppd

diff -Naur v0.10/line.cc v0.11/line.cc
--- v0.10/line.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/line.cc 2012-04-14 00:38:50.000000000 -0700
@@ -2,6 +2,7 @@
#include "line.h"
#include "buffer.h"
#include <unistd.h>
+#include <string.h> // strlen

//buffer( 20 ); // segfault if you use 'size'

diff -Naur v0.10/main.cc v0.11/main.cc
--- v0.10/main.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/main.cc 2012-04-14 05:45:20.000000000 -0700
@@ -40,6 +40,7 @@
if( FD_ISSET( fileno( stdin ), &inputs ) )
{
char inbuf;
+
for(;;)
{
rc = read( fileno( stdin ), &inbuf, 1 );
@@ -181,10 +182,11 @@
fcntl( fileno( stdin ), F_GETFL, 0 ) | O_ASYNC | O_NONBLOCK );
fcntl( fileno( stdin ), F_SETOWN, getpid() );

- init_mcast_socket();
+ ms = init_mcast_socket();
+
puck.que = q = new queue( &puck.pad, ms, to, id );

- puck.pad.clear();
+// puck.pad.clear();
#if 0
puck.pad.debug();
#endif // debug
diff -Naur v0.10/makefile v0.11/makefile
--- v0.10/makefile 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/makefile 2012-04-14 00:45:27.000000000 -0700
@@ -19,7 +19,7 @@
s.cc -version -o s.s
as -V -Qy -o s.o s.s

-%.o: %.cc; g++ -c $<
+%.o: %.cc; g++-3.3 -c $<

#main: main.cc kbd.cc kbd_tty.cc \
# term.cc note.cc script.cc line.cc buffer.cc
diff -Naur v0.10/mcast.cc v0.11/mcast.cc
--- v0.10/mcast.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/mcast.cc 2012-04-14 06:12:34.000000000 -0700
@@ -10,7 +10,7 @@
#include <netinet/udp.h> // udphdr

#include <unistd.h> // getpid
-#include <stdio.h> // printf
+#include <stdio.h> // printf, perror
/*
#include <net/if.h>
#include <sys/ioctl.h>
@@ -23,10 +23,11 @@
extern int ms; // multicast socket
extern struct sockaddr_in to;
extern u_int id;
-
+#define sin to
int init_mcast_socket()
{
- struct sockaddr_in sin; // address for bind
+ int err = 0;
+ //struct sockaddr_in sin; // address for bind
sin.sin_addr.s_addr = htonl( INADDR_ANY );
sin.sin_port = htons( 9876 );

@@ -40,7 +41,9 @@
int msock_reuse = 1;
setsockopt( ms, SOL_SOCKET, SO_REUSEADDR, &msock_reuse, sizeof( int ) );

- bind( ms, ( struct sockaddr* )&sin, sizeof( sin ) );
+ err = bind( ms, ( struct sockaddr* )&sin, sizeof( sin ) );
+ printf( "bind:%x:", err );
+ perror( "::" );

u_char msock_ttl = 4;
setsockopt( ms, IPPROTO_IP, IP_MULTICAST_TTL,
@@ -65,6 +68,8 @@

if( setsockopt( ms, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof( mreq ) )
< 0 ) printf( "failed\n" );
-
+
+ fflush( stdout );
+
return ms;
}
diff -Naur v0.10/queue.cc v0.11/queue.cc
--- v0.10/queue.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/queue.cc 2012-04-14 06:08:05.000000000 -0700
@@ -3,6 +3,8 @@
//#include <stdlib.h> // malloc, free
#include <stdio.h> // stdin, fileno
#include <unistd.h> // read
+#include <string.h> // memcpy
+#include <stdlib.h> // exit

char message[ 1500 ]; // dynamic allocation segfaults below

diff -Naur v0.10/script.cc v0.11/script.cc
--- v0.10/script.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/script.cc 2012-04-14 06:13:38.000000000 -0700
@@ -1,6 +1,7 @@
//#include "null.h"
#include "script.h"
#include <stdlib.h> // NULL
+#include <string.h> // strlen

line_s::~line_s()
{
diff -Naur v0.10/term.cc v0.11/term.cc
--- v0.10/term.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/term.cc 2012-04-14 00:37:12.000000000 -0700
@@ -1,6 +1,7 @@
#include <stdio.h>
#include "term.h"
#include <stdlib.h>
+#include <string.h> // memcpy

//#define debug_flag

Report
Re: hierarchical multi-cursor editor Posted by d.jeffery on 14 Apr 2012 at 6:43 AM
Hello,
If anyone was having trouble running this program just apply this
simple patch which uses gcc-3.3 (or 3.4 or fix it all up.) I remember having
a working program when I had it before.

cheers,
- M. Kyaeppd

diff -Naur v0.10/line.cc v0.11/line.cc
--- v0.10/line.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/line.cc 2012-04-14 00:38:50.000000000 -0700
@@ -2,6 +2,7 @@
#include "line.h"
#include "buffer.h"
#include <unistd.h>
+#include <string.h> // strlen

//buffer( 20 ); // segfault if you use 'size'

diff -Naur v0.10/main.cc v0.11/main.cc
--- v0.10/main.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/main.cc 2012-04-14 05:45:20.000000000 -0700
@@ -40,6 +40,7 @@
if( FD_ISSET( fileno( stdin ), &inputs ) )
{
char inbuf;
+
for(;;)
{
rc = read( fileno( stdin ), &inbuf, 1 );
@@ -181,10 +182,11 @@
fcntl( fileno( stdin ), F_GETFL, 0 ) | O_ASYNC | O_NONBLOCK );
fcntl( fileno( stdin ), F_SETOWN, getpid() );

- init_mcast_socket();
+ ms = init_mcast_socket();
+
puck.que = q = new queue( &puck.pad, ms, to, id );

- puck.pad.clear();
+// puck.pad.clear();
#if 0
puck.pad.debug();
#endif // debug
diff -Naur v0.10/makefile v0.11/makefile
--- v0.10/makefile 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/makefile 2012-04-14 00:45:27.000000000 -0700
@@ -19,7 +19,7 @@
s.cc -version -o s.s
as -V -Qy -o s.o s.s

-%.o: %.cc; g++ -c $<
+%.o: %.cc; g++-3.3 -c $<

#main: main.cc kbd.cc kbd_tty.cc \
# term.cc note.cc script.cc line.cc buffer.cc
diff -Naur v0.10/mcast.cc v0.11/mcast.cc
--- v0.10/mcast.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/mcast.cc 2012-04-14 06:12:34.000000000 -0700
@@ -10,7 +10,7 @@
#include <netinet/udp.h> // udphdr

#include <unistd.h> // getpid
-#include <stdio.h> // printf
+#include <stdio.h> // printf, perror
/*
#include <net/if.h>
#include <sys/ioctl.h>
@@ -23,10 +23,11 @@
extern int ms; // multicast socket
extern struct sockaddr_in to;
extern u_int id;
-
+#define sin to
int init_mcast_socket()
{
- struct sockaddr_in sin; // address for bind
+ int err = 0;
+ //struct sockaddr_in sin; // address for bind
sin.sin_addr.s_addr = htonl( INADDR_ANY );
sin.sin_port = htons( 9876 );

@@ -40,7 +41,9 @@
int msock_reuse = 1;
setsockopt( ms, SOL_SOCKET, SO_REUSEADDR, &msock_reuse, sizeof( int ) );

- bind( ms, ( struct sockaddr* )&sin, sizeof( sin ) );
+ err = bind( ms, ( struct sockaddr* )&sin, sizeof( sin ) );
+ printf( "bind:%x:", err );
+ perror( "::" );

u_char msock_ttl = 4;
setsockopt( ms, IPPROTO_IP, IP_MULTICAST_TTL,
@@ -65,6 +68,8 @@

if( setsockopt( ms, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof( mreq ) )
< 0 ) printf( "failed\n" );
-
+
+ fflush( stdout );
+
return ms;
}
diff -Naur v0.10/queue.cc v0.11/queue.cc
--- v0.10/queue.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/queue.cc 2012-04-14 06:08:05.000000000 -0700
@@ -3,6 +3,8 @@
//#include <stdlib.h> // malloc, free
#include <stdio.h> // stdin, fileno
#include <unistd.h> // read
+#include <string.h> // memcpy
+#include <stdlib.h> // exit

char message[ 1500 ]; // dynamic allocation segfaults below

diff -Naur v0.10/script.cc v0.11/script.cc
--- v0.10/script.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/script.cc 2012-04-14 06:13:38.000000000 -0700
@@ -1,6 +1,7 @@
//#include "null.h"
#include "script.h"
#include <stdlib.h> // NULL
+#include <string.h> // strlen

line_s::~line_s()
{
diff -Naur v0.10/term.cc v0.11/term.cc
--- v0.10/term.cc 2005-07-29 17:04:22.000000000 -0700
+++ v0.11/term.cc 2012-04-14 00:37:12.000000000 -0700
@@ -1,6 +1,7 @@
#include <stdio.h>
#include "term.h"
#include <stdlib.h>
+#include <string.h> // memcpy

//#define debug_flag




 

Recent Jobs