void google(const char *str) { assert(str); const char *channel = natural_channel_name(); if (!channel) { io_out("don't use fgoogle till your in a channel!\n"); return; } #define google "http://www.google.com/search?query=" #define GOOGLE_SIZE (sizeof(google) - 1) char *search = urlize(str); assert(search); size_t len = GOOGLE_SIZE; len += strlen(search); char *url = malloc(len + 1); strcpy(url, google); strcpy(&url[GOOGLE_SIZE], search); irc_say(url); free(search); free(url); #undef google #undef GOOGLE_SIZE }
static int generic_trace_hook(int argc, char *argv[]) { int i; cio_out("%s", argv[3]); for (i = 4; i < argc; i++) { cio_out(" %s", argv[i]); } io_out("\n"); return 0; }
/* * Port modify */ static void do_port(char *s) { register BYTE port; static char nv[LENCMD]; extern BYTE io_out(), io_in(); while (isspace((int)*s)) s++; port = exatoi(s); printf("%02x = %02x : ", port, io_in(port)); fgets(nv, sizeof(nv), stdin); if (isxdigit((int)*nv)) io_out(port, (BYTE) exatoi(nv)); }
int main(){ io_out(LED); i2c_init(); while(1){ io_high(LED); _delay_ms(1000); io_low(LED); _delay_ms(1000); } }
int io_out(struct io_file *f,int pos,const void *o,int len) { int end = pos + len; if (0 == len) return pos; if (NULL == f || -1 == pos) return -1; if (NULL == o) return pos + len; if (remap(f,pos,len)) return -1; if (pos < f->file_size) { assert(pos >= f->map_offset); if (pos >= f->buffer_offset && unbuffer(f)) return -1; if (end > (int)(f->map_offset + f->map_size)) end = f->map_offset + f->map_size; if (end > f->file_size) end = f->file_size; memcpy(pos - f->map_offset + (char *) f->map,o,end - pos); } else { if (pos < f->buffer_offset || pos > (int)(f->buffer_offset + f->buffer_size)) { if (unbuffer(f)) return -1; if (lseek(f->fd,pos,SEEK_SET) == (off_t) -1) { perror("lseek"); return -1; } assert(0 == f->buffer_size); f->buffer_offset = pos; } else if (pos == (int)(f->buffer_offset + sizeof f->buffer)) if (unbuffer(f)) return -1; assert(pos >= f->buffer_offset && pos <= (int)(f->buffer_offset + f->buffer_size)); if (end > (int)(f->buffer_offset + sizeof f->buffer)) end = f->buffer_offset + sizeof f->buffer; memcpy(&f->buffer[pos - f->buffer_offset],o,end - pos); if ((int)(end - f->buffer_offset) > (int)f->buffer_size) f->buffer_size = end - f->buffer_offset; } return io_out(f,end,end - pos + (char *) o,len + pos - end); }
int putchar(int c) { io_out(SERIAL_IO_DEV, c); return c; }