static PyObject * chmod_channel( PyObject *self, PyObject *args ) { (void)self; PyObject *py_chan; int mode; // get arg objects if( !PyArg_ParseTuple(args, "Oi", &py_chan, &mode) ) { return NULL; } // parse channel ach_channel_t *c = parse_channel_pointer(py_chan); if( NULL == c ) { return NULL; } // make the damn call ach_status_t r = ach_chmod( c, (mode_t)mode ); // check the result if( ACH_OK != r ) { PyErr_SetString( ach_py_error, ach_result_to_string(r) ); return NULL; } // cleanup Py_RETURN_NONE; }
int ach_move_init() { // Channels int r = 0; printf("ACH: Creating Channel\n"); ach_create_attr_t attr; ach_create_attr_init(&attr); r = ach_create((char*)craftyo_chan_name, 100, IBOARDSTATE_SIZE+IMOVESTRING_SIZE, &attr); printf("ACH: %s\n", ach_result_to_string((ach_status_t)r)); printf("ACH: Opening Channel\n"); craftyo_chan = (ach_channel_t*) malloc (sizeof(ach_channel_t)); if(craftyo_chan == NULL) return 0; r = ach_open(craftyo_chan, craftyo_chan_name, NULL); if(r != ACH_OK) { printf("ACH: %s\n", ach_result_to_string((ach_status_t)r)); return 0; } ach_chmod(craftyo_chan, SOMATIC_CHANNEL_MODE ); r = ach_flush(craftyo_chan); if(r != ACH_OK) { printf("ACH: %s\n", ach_result_to_string((ach_status_t)r)); return 0; } // Data craftyo_message = (Somatic__Crafty*)malloc(sizeof(Somatic__Crafty)); if(craftyo_message == NULL) return 0; somatic__crafty__init(craftyo_message); //craftyo_message->boardstate.data = (uint8_t*) malloc(128); //craftyo_message->has_boardstate = 1; //craftyo_message->boardstate.len = 128; craftyo_message->move = (char*)malloc(10); printf("ACH: Info\n" "ACH: Name: %s\n" "ACH: Size: %d\n", craftyo_chan_name, somatic__crafty__get_packed_size(craftyo_message)); return 1; }
int cmd_chmod(void) { assert(opt_mode >=0 ); if( opt_verbosity > 0 ) { fprintf( stderr, "Changing mode of %s to %o\n", opt_chan_name, (unsigned)opt_mode ); } /* open */ ach_channel_t chan; errno = 0; ach_status_t r = ach_open( &chan, opt_chan_name, NULL ); check_status( r, "Error opening channel '%s'", opt_chan_name ); /* chmod */ r = ach_chmod( &chan, (mode_t)opt_mode ); check_status( r, "Error chmodding channel '%s'", opt_chan_name ); /* close */ r = ach_close( &chan ); check_status( r, "Error closing channel '%s'", opt_chan_name ); return r; }