bool DBusCommunicator::initDBusComm(string strDbusPath/*=""*/,string strInterfaceName/*=""*/, string strPrinterURI/*=""*/, string strPrinterName/*= ""*/, int iJobId/*=0*/, string strUser/*=""*/) { #ifdef HAVE_DBUS DBusError objError; DBusError * pDBusError=&objError; m_strPrinterURI = strPrinterURI; m_strPrinterName = strPrinterName; m_strDbusInterface = strInterfaceName; m_strDbusPath = strDbusPath; m_strUser = strUser; m_iJobId = iJobId; dbus_error_init(pDBusError); m_DbusConnPtr = dbus_bus_get(DBUS_BUS_SYSTEM, pDBusError); if(dbus_error_is_set(pDBusError)) { dbglog("Error: dBus Connection Error (%s)!\n", pDBusError->message); dbus_error_free(pDBusError); } if(m_DbusConnPtr == NULL) { dbglog("Error: dBus Connection Error (%s)!\n", pDBusError->message); return false; } #endif return true; }
/* Common code for both fat_read and fat_write */ static int vmdfs_fat_read(const char *vmdfile, vmd_root_t * root, uint16 * fat_buf) { uint16 fat_block, fat_size; /* Find the FAT starting block and length */ fat_block = root->fat_loc; fat_size = root->fat_size; /* We can't reliably handle VMDs with a larger FAT... */ if(fat_size > 1) { dbglog(DBG_ERROR, "vmdfs_fat_read: VMD has >1 (%d) FAT blocks\n",(int)fat_size); return -1; } file_t f = fs_open(vmdfile,O_RDONLY); fs_seek(f,fat_block*BLOCK_SIZE,SEEK_SET); fs_read(f,(uint8 *)fat_buf,BLOCK_SIZE); fs_close(f); if(!*fat_buf) { dbglog(DBG_ERROR, "vmdfs_fat_read: can't read block %d\n",(int)fat_block); return -2; } return 0; }
static int pybackend_allowed_address(u_int32_t addr) { int result = 0; PyObject *ret = NULL; PyObject *arg0 = NULL; dbglog("pybackend plugin: allowed_address_hook(addr = %d)", addr); arg0 = PyInt_FromSize_t(addr); ret = pybackend_call_function("allowed_address_hook", 1, arg0); if (ret == NULL || ret == Py_None) { goto Exit; } if (!PyBool_Check(ret)) { warn("pybackend plugin: allowed_address_hook() did not return a boolean value"); goto Exit; } if (ret == Py_True) { result = 1; } Exit: Py_CLEAR(arg0); Py_CLEAR(ret); dbglog("pybackend plugin: allowed_address_hook: %d", result); return result; }
static int check_gdi_image(file_t fd) { char line[MAX_FN_LEN]; uint32 track_count; fs_seek(fd, 0, SEEK_SET); if(fs_gets(fd, line, MAX_FN_LEN) == NULL) { #ifdef DEBUG dbglog(DBG_DEBUG, "%s: Not a GDI image\n", __func__); #endif return -1; } track_count = strtoul(line, NULL, 0); if(track_count == 0 || track_count > 99) { #ifdef DEBUG dbglog(DBG_DEBUG, "%s: Invalid GDI image\n", __func__); #endif return -1; } return (int)track_count; }
/** * ポート番号設定 * * @param[out] addr sockaddr_in構造体 * @param[in] port ポート番号またはサービス名 * @retval EX_NG エラー */ int set_port(struct sockaddr_in *addr, const char *port) { struct servent *sp = NULL; /* サービス情報構造体 */ uint16_t portno = 0; /* ポート番号 */ const int base = 10; /* 基数 */ dbglog("start: addr=%p, port=%s", addr, port); if (!addr || !port) return EX_NG; if (isdigit(port[0])) { /* 先頭が数字 */ portno = (uint16_t)strtol(port, NULL, base); dbglog("portno=%"PRIu16", 0x%"PRIx16"", portno, portno); if (portno <= 0 || 65535 <= portno) { outlog("portno=%d", portno); return EX_NG; } dbglog("portno=0x%"PRIx16"", htons(portno)); addr->sin_port = (u_short)htons(portno); } else { sp = getservbyname(port, "tcp"); if (!sp) { outlog("getservbyname: port=%s", port); return EX_NG; } addr->sin_port = sp->s_port; } dbglog("port=%"PRIu16"", ntohs((uint16_t)addr->sin_port)); return EX_OK; }
/** * データ送信 * * @param[in] sock ソケット * @param[in] sdata データ * @param[in,out] length データ長 * @retval EX_NG エラー */ int send_data(const int sock, const void *sdata, size_t *length) { ssize_t len = 0; /* send戻り値 */ size_t left = 0; /* 残りのバイト数 */ const unsigned char *ptr = NULL; /* ポインタ */ dbglog("start: sdata=%p, length=%zu", sdata, *length); ptr = (unsigned char *)sdata; left = *length; while (left > 0) { len = send(sock, sdata, *length, 0); dbglog("send=%zd, ptr=%p, left=%zu", len, ptr, left); if (len <= 0) { if ((errno == EINTR) || (errno == EAGAIN) || (errno == EWOULDBLOCK)) len = 0; else goto error_handler; } left -= len; ptr += len; } *length -= left; dbglog("send=%zd, sock=%d, ptr=%p, left=%zu, length=%zu", len, sock, ptr, left, *length); return EX_OK; error_handler: *length -= left; outlog("send=%zd, sock=%d, ptr=%p, left=%zu, length=%zu", len, sock, ptr, left, *length); return EX_NG; }
static FFTHDCALL int gui_worker(void *param) { ffui_init(); ffui_wnd_initstyle(); if (0 != load_ui()) goto err; wmain_init(); wabout_init(); wuri_init(); if (gg->conf.autosave_playlists) corecmd_add(LOADLISTS, NULL); FF_WRITEONCE(gg->state, 1); dbglog("entering UI loop"); ffui_run(); dbglog("exited UI loop"); corecmd_add(A_ONCLOSE, NULL); goto done; err: FF_WRITEONCE(gg->state, 1); gg->load_err = 1; done: ffui_uninit(); return 0; }
/** * 文字数取得 * * @param[in] val 値 * @param[in] fmt フォーマット * @return 文字数 * @retval 0 fopenエラー * @retval -1 fprintfエラー */ static int get_strlen(const dbl val, const char *fmt) { FILE *fp = NULL; /* ファイルポインタ */ int retval = 0; /* fclose戻り値 */ int length = 0; /* 文字数 */ dbglog("start: fmt=%s", fmt); dbglog(fmt, val); fp = fopen("/dev/null", "w"); if (!fp) { /* fopen エラー */ outlog("fopen"); } else { length = fprintf(fp, fmt, val); if (length < 0) outlog("fprintf: fp=%p, fmt=%s, val=%g", fp, fmt, val); retval = fclose(fp); if (retval == EOF) /* fclose エラー */ outlog("fclose: fp=%p", fp); } dbglog("length=%d", length); return length; }
int flashrom_get_region_only() { int start, size; uint8 region[6] = { 0 }; region[2] = *(uint8*)0x0021A002; /* Find the partition */ if(flashrom_info(FLASHROM_PT_SYSTEM, &start, &size) < 0) { dbglog(DBG_ERROR, "%s: can't find partition %d\n", __func__, FLASHROM_PT_SYSTEM); } else { /* Read the first 5 characters of that partition */ if(flashrom_read(start, region, 5) < 0) { dbglog(DBG_ERROR, "%s: can't read partition %d\n", __func__, FLASHROM_PT_SYSTEM); } } if(region[2] == 0x58 || region[2] == 0x30) { return FLASHROM_REGION_JAPAN; } else if(region[2] == 0x59 || region[2] == 0x31) { return FLASHROM_REGION_US; } else if(region[2] == 0x5A || region[2] == 0x32) { return FLASHROM_REGION_EUROPE; } else { dbglog(DBG_ERROR, "%s: Unknown region code %02x\n", __func__, region[2]); return FLASHROM_REGION_UNKNOWN; } }
static ssize_t tcpfs_read(void *h, void *buffer, size_t size) { int len = 0; TCPContext *s = (TCPContext *)h; uint8 *buf = (uint8 *)buffer; do { int l; #ifdef DEBUG dbglog(DBG_DEBUG, "TCPFS: reading size %d -->", size); #endif l = read(s->socket, buf, size); #ifdef DEBUG dbglog(DBG_DEBUG, " %d\n", l); #endif if (l >= 0) { len += l; s->pos += l; buf += l; size -= l; } else if (len == 0) return l; else return len; } while(s->stream && 0 < size); return len; }
/** * 因子 * * @param[in] calc calcinfo構造体 * @return 値 */ static dbl factor(calcinfo *calc) { dbl x = 0.0; /* 値 */ dbglog("start"); if (is_error(calc)) return EX_ERROR; if (calc->ch != '(') return token(calc); readch(calc); x = expression(calc); if (calc->ch != ')') { /* シンタックスエラー */ set_errorcode(calc, E_SYNTAX); return EX_ERROR; } readch(calc); dbglog(calc->fmt, x); return x; }
static void pybackend_ip_choose(u_int32_t *addr) { PyObject *ret = NULL; PyObject *arg0 = NULL; dbglog("pybackend plugin: ip_choose_hook(addr = %d)", *addr); arg0 = PyInt_FromSize_t(*addr); ret = pybackend_call_function("ip_choose_hook", 1, arg0); if (ret == NULL || ret == Py_None) { goto Exit; } if (!PyInt_Check(ret)) { warn("pybackend plugin: return value of ip_choose_hook() is not an int"); goto Exit; } // // No failure. // *addr = PyInt_AsUnsignedLongMask(ret); Exit: Py_CLEAR(arg0); Py_CLEAR(ret); dbglog("pybackend plugin: ip_choose_hook: %d", *addr); return; }
static int pybackend_chap_check(void) { int result = 0; PyObject *ret = NULL; dbglog("pybackend plugin: chap_check_hook()"); ret = pybackend_call_function("chap_check_hook", 0); if (ret == NULL || ret == Py_None) { goto Exit; } if (!PyBool_Check(ret)) { warn("pybackend plugin: chap_check_hook() did not return a boolean value"); goto Exit; } if (ret == Py_True) { result = 1; } Exit: Py_CLEAR(ret); dbglog("pybackend plugin: chap_check_hook: %d", result); return result; }
static void ChallengeResponse(u_char *challenge, u_char PasswordHash[MD4_SIGNATURE_SIZE], u_char response[24]) { u_char ZPasswordHash[21]; BZERO(ZPasswordHash, sizeof(ZPasswordHash)); BCOPY(PasswordHash, ZPasswordHash, MD4_SIGNATURE_SIZE); #if 0 dbglog("ChallengeResponse - ZPasswordHash %.*B", sizeof(ZPasswordHash), ZPasswordHash); #endif (void) DesSetkey(ZPasswordHash + 0); DesEncrypt(challenge, response + 0); (void) DesSetkey(ZPasswordHash + 7); DesEncrypt(challenge, response + 8); (void) DesSetkey(ZPasswordHash + 14); DesEncrypt(challenge, response + 16); #if 0 dbglog("ChallengeResponse - response %.24B", response); #endif }
void ySafeTrace(const char *file,u32 line,void *ptr) { u32 i; YMEM_ENTRY *entry; yEnterCriticalSection(&yMapCS); for(i=0, entry=yMap; i< yMapUsed ; i++,entry++){ YASSERT(entry->state != YMEM_NOT_USED); if(entry->ptr == ptr) break; } if(i == yMapUsed){ dbglog("Update trace of unallocated pointer 0x%x at %s:%d\n\n",ptr,file,line); ymemdump(); YASSERT(0); } if(entry->state == YMEM_FREED){ dbglog("Update trace of allready freed pointer (0x%x) at %s:%d\n",ptr,file,line); dbglog("was allocated at %s:%d size =%d freed at %s:%d\n\n", entry->malloc_file, entry->malloc_line, entry->malloc_size, entry->free_file,entry->free_line); ymemdump(); YASSERT(0); } ymemdumpentry(entry,"trace"); entry->malloc_file = file; entry->malloc_line = line; yLeaveCriticalSection(&yMapCS); }
/** * 式 * * @param[in] calc calcinfo構造体 * @return 値 */ static dbl expression(calcinfo *calc) { dbl x = 0.0; /* 値 */ dbglog("start"); if (is_error(calc)) return EX_ERROR; x = term(calc); dbglog(calc->fmt, x); while (true) { if (calc->ch == '+') { readch(calc); x += term(calc); } else if (calc->ch == '-') { readch(calc); x -= term(calc); } else { break; } } dbglog(calc->fmt, x); return x; }
/** * ブロッキングモードの設定 * * @param[in] fd ファイルディスクリプタ * @param[in] mode ブロッキングモード * @retval EX_NG エラー */ int set_block(int fd, blockmode mode) { int flags = 0; /* fcntl戻り値(F_GETFL) */ int retval = 0; /* fcntl戻り値(F_SETFL) */ flags = fcntl(fd, F_GETFL, 0); if (flags < 0) { outlog("fcntl=0x%x", flags); return EX_NG; } dbglog("fcntl=0x%x", flags); if (mode == NONBLOCK) { /* ノンブロッキング */ retval = fcntl(fd, F_SETFL, flags | O_NONBLOCK); if (retval < 0) outlog("fcntl=%d", retval); } else if (mode == BLOCKING) { /* ブロッキング */ retval = fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); if (retval < 0) outlog("fcntl=%d", retval); } else { /* no mode */ outlog("mode=%d", mode); return EX_NG; } #ifdef _DEBUG flags = fcntl(fd, F_GETFL, 0); if (flags < 0) dbglog("fcntl=0x%x", flags); dbglog("fcntl=0x%x", flags); #endif /* _DEBUG */ return EX_OK; }
/** * オプション引数 * * オプション引数ごとに処理を分岐する. * @param[in] argc 引数の数 * @param[in] argv コマンド引数・オプション引数 * @return なし */ static void parse_args(int argc, char *argv[]) { int opt = 0; /* オプション */ const int base = 10; /* 基数 */ dbglog("start"); /* デフォルトのポート番号を設定 */ if (set_port_string(DEFAULT_PORTNO) < 0) exit(EXIT_FAILURE); /* デフォルトのIPアドレスを設定 */ if (set_host_string(DEFAULT_IPADDR) < 0) exit(EXIT_FAILURE); /* デフォルトのスレッド数を設定 */ threads = MAX_THREADS; while ((opt = getopt_long(argc, argv, shortopts, longopts, NULL)) != EOF) { dbglog("opt=%c, optarg=%s", opt, optarg); switch (opt) { case 'i': /* IPアドレス指定 */ if (set_host_string(optarg) < 0) { fprintf(stderr, "Hostname string length %d", (HOST_SIZE - 1)); exit(EXIT_FAILURE); } break; case 'p': /* ポート番号指定 */ if (set_port_string(optarg) < 0) { fprintf(stderr, "Portno string length %d", (PORT_SIZE - 1)); exit(EXIT_FAILURE); } break; case 't': /* スレッド数設定 */ threads = (int)strtol(optarg, NULL, base); break; case 'h': /* ヘルプ表示 */ print_help(get_progname()); exit(EXIT_SUCCESS); case 'V': /* バージョン情報表示 */ print_version(get_progname()); exit(EXIT_SUCCESS); case '?': case ':': parse_error(opt, NULL); exit(EXIT_FAILURE); default: parse_error(opt, "internal error"); exit(EXIT_FAILURE); } } if (optind < argc) { (void)printf("non-option ARGV-elements: "); while (optind < argc) (void)printf("%s ", argv[optind++]); (void)printf("\n"); } }
/*** call the call manager main ***********************************************/ static void launch_callmgr(int call_id,struct in_addr inetaddr, char *phonenr,int window) { dbglog("pptp: call manager for %s\n", inet_ntoa(inetaddr)); dbglog("window size:\t%d\n",window); if (phonenr) dbglog("phone number:\t'%s'\n",phonenr); dbglog("call id:\t%d\n",call_id); exit(callmgr_main(inetaddr, phonenr, window, call_id)); }
/** * test_server_loop() 関数テスト * * @return なし */ void test_server_loop(void) { pid_t cpid = 0; /* 子プロセスID */ pid_t w = 0; /* wait戻り値 */ int status = 0; /* wait引数 */ int retval = 0; /* 戻り値 */ int count = 1; /* ループカウント */ if (set_port_string(port) < 0) cut_error("set_port_string"); ssock = server_sock(); cpid = fork(); if (cpid < 0) { cut_error("fork(%d)", errno); return; } if (cpid == 0) { dbglog("child"); count = 2; g_sig_handled = 1; while (count--) server_loop(ssock); exit(EXIT_SUCCESS); } else { dbglog("parent: cpid=%d", (int)cpid); csock = inet_sock_client(); if (csock < 0) return; /* 送信 */ retval = send_client(csock, expr, sizeof(expr)); if (retval < 0) { cut_error("send_client: csock=%d(%d)", csock, errno); return; } /* 受信 */ retval = recv_client(csock, readbuf); if (retval < 0) { cut_error("recv_client: csock=%d(%d)", csock, errno); return; } cut_assert_equal_string((char *)expected, (char *)readbuf); w = wait(&status); if (w < 0) cut_notify("wait(%d)", errno); dbglog("w=%d", (int)w); } }
static uint8 send_slow_cmd ( uint8 cmd, /* Command byte */ uint32 arg /* Argument */ ) { uint8 n, res; uint8 cb[6]; int i; (void)spi_slow_sr_byte(0xff); i = 0; do { res = spi_slow_sr_byte(0xff); i++; } while ((res != 0xFF) && i < 100000); if (res != 0xff) { #ifdef SD_DEBUG dbglog(DBG_DEBUG, "%s: CMD 0x%02x error\n", __func__, cmd); #endif return(0xff); } cb[0] = cmd; cb[1] = (uint8)(arg >> 24); cb[2] = (uint8)(arg >> 16); cb[3] = (uint8)(arg >> 8); cb[4] = (uint8)arg; cb[5] = sd_crc7(cb, 5, 0); /* Send command packet */ spi_slow_sr_byte(cmd); /* Command */ spi_slow_sr_byte(cb[1]); /* Argument[31..24] */ spi_slow_sr_byte(cb[2]); /* Argument[23..16] */ spi_slow_sr_byte(cb[3]); /* Argument[15..8] */ spi_slow_sr_byte(cb[4]); /* Argument[7..0] */ spi_slow_sr_byte(cb[5]); // CRC7 /* Receive command response */ if (cmd == CMD12) (void)spi_slow_sr_byte(0xff);/* Skip a stuff byte when stop reading */ n = 20; /* Wait for a valid response in timeout of 10 attempts */ do { res = spi_slow_sr_byte(0xff); } while ((res & 0x80) && --n); #ifdef SD_DEBUG dbglog(DBG_DEBUG, "%s: CMD 0x%02x response 0x%02x\n", __func__, cmd, res); #endif return res; /* Return with the response value */ }
bool DBusCommunicator::sendEvent(string strDbusPath,string strInterfaceName, string strDeviceURI, string strPrinterName, int iEvent, string strTitle/*=""*/, int iJobId/*=0*/, string strUser/*=""*/) { #ifdef HAVE_DBUS if(NULL == m_DbusConnPtr ) { dbglog("Error: dBus connection ptr is NULL.\n"); return false; } if(true == strDbusPath.empty() || true == strInterfaceName.empty() || 0 == iEvent) { dbglog("Error: dBus service Name can't be empty. DBus Path(%s) DBus Interface (%s) Event(%d)!\n", strDbusPath.c_str(), strInterfaceName.c_str(), iEvent); return false; } DBusMessage * msg = dbus_message_new_signal(strDbusPath.c_str(), strInterfaceName.c_str(), "Event"); if (NULL == msg) { dbglog("Error: dBus dbus_message_new_signal returned error. DBus Interface (%s) Event(%d)!\n", strInterfaceName.c_str(), iEvent); return false; } if (NULL == msg) { dbglog("dbus message is NULL!\n"); return false; } const char * stURI=strDeviceURI.c_str(); const char * stPRNTNM=strPrinterName.c_str(); const char * stUSR=strUser.c_str(); const char * stTtl=strTitle.c_str(); dbus_message_append_args(msg, DBUS_TYPE_STRING, &stURI, DBUS_TYPE_STRING, &stPRNTNM, DBUS_TYPE_UINT32, &iEvent, DBUS_TYPE_STRING, &stUSR, DBUS_TYPE_UINT32, &iJobId, DBUS_TYPE_STRING, &stTtl, DBUS_TYPE_INVALID); if (!dbus_connection_send(m_DbusConnPtr , msg, NULL)) { dbglog("dbus message send failed!\n"); return false; } dbus_connection_flush(m_DbusConnPtr ); dbus_message_unref(msg); #endif return true; }
/** * stop_timer() 関数テスト * * @return なし */ void test_stop_timer(void) { unsigned int t = 0, time = 0; /* タイマ用変数 */ start_timer(&t); dbglog("t=%u", t); time = stop_timer(&t); dbglog("time=%u", time); cut_assert_operator(time, >, 0); }
static int process_line(HTTPContext *s, char *line, int line_count) { char *tag, *p; /* end of header */ if (line[0] == '\0') return 0; p = line; if (line_count == 0) { while (!isspace(*p) && *p != '\0') p++; while (isspace(*p)) p++; s->http_code = strtol(p, NULL, 10); #ifdef DEBUG dbglog(DBG_DEBUG, "http_code=%d\n", s->http_code); #endif } else { while (*p != '\0' && *p != ':') p++; if (*p != ':') return 1; *p = '\0'; tag = line; p++; while (isspace(*p)) p++; if (!strcmp(tag, "Location")) { strcpy(s->location, p); } if (!strcmp(tag, "Content-Length")) { s->len = strtol(p, NULL, 10); #ifdef DEBUG dbglog(DBG_DEBUG, "len=%d\n", s->len); #endif } } return 1; }
static int pybackend_chap_verify(char *name, char *ourname, int id, struct chap_digest_type *digest, unsigned char *challenge, unsigned char *response, char *message, int message_space) { int result = 0; PyObject *ret = NULL; PyObject *arg0 = NULL; PyObject *arg1 = NULL; PyObject *arg2 = NULL; char *secret = NULL; size_t secret_len = 0; dbglog("pybackend plugin: chap_verify_hook(name = %s, ourname = %s, id = %d, ipparm = %s)", name, ourname, id, ipparam); arg0 = PyString_FromString(name); arg1 = PyString_FromString(ourname); arg2 = PyString_FromString(ipparam); ret = pybackend_call_function("chap_verify_hook", 3, arg0, arg1, arg2); if (ret == NULL || ret == Py_None) { goto Exit; } if (!PyString_Check(ret)) { warn("pybackend plugin: return value of chap_verify_hook() is not a string"); goto Exit; } secret = PyString_AsString(ret); secret_len = strlen(secret); dbglog("pybackend plugin: chap_verify_hook: %s, %d", secret, secret_len); if (!digest->verify_response(id, name, (unsigned char *)secret, secret_len, challenge, response, message, message_space)) { goto Exit; } // // No failure. // result = 1; Exit: Py_CLEAR(arg0); Py_CLEAR(arg1); Py_CLEAR(arg2); Py_CLEAR(ret); dbglog("pybackend plugin: chap_verify_hook: %d", result); return result; }
/** * バッファ読込 * * バッファから一文字読み込む. * 空白, タブは読み飛ばす. * * @param[in] calc calcinfo構造体 * @return なし */ static void readch(calcinfo *calc) { dbglog("start"); do { calc->ch = (int)*calc->ptr; dbglog("ptr=%p, ch=%c", calc->ptr, calc->ch); if (calc->ch == '\0') break; calc->ptr++; } while (isblank(calc->ch)); }
/** Display to output debug statcked error messages. */ static void spool_error_message(void) { char *s; if (s = SC68error_get(), s) { dbglog(DBG_DEBUG, "sc68 : Stacked Error Message:\n"); do { dbglog(DBG_DEBUG, " --> %s\n", s); } while (s = SC68error_get(), s); } else { dbglog(DBG_DEBUG, "sc68 : No stacked error message\n"); } }
/* Poll for responses from the AICA. We assume here that we're not running in an interrupt handler (thread perhaps, of whoever is using us). */ void snd_poll_resp() { int rv; uint32 pkt[AICA_CMD_MAX_SIZE]; aica_cmd_t * pktcmd; pktcmd = (aica_cmd_t *)pkt; while ( (rv = snd_aica_to_sh4(pkt)) > 0 ) { dbglog(DBG_DEBUG, "snd_poll_resp(): Received packet id %08lx, ts %08lx from AICA\n", pktcmd->cmd, pktcmd->timestamp); } if (rv < 0) dbglog(DBG_ERROR, "snd_poll_resp(): snd_aica_to_sh4 failed, giving up\n"); }
/** * ターミナル属性文字列取得 * * @param[in] fd ファイルディスクリプタ * @param[in] mode termios構造体 * @return ターミナル属性文字列 * @attention 戻り値ポインタは解放しなければならない */ static char * get_termattr(const int fd, struct termios *mode) { tcflag_t *bitsp = NULL; /* ビット */ unsigned long mask = 0; /* マスク */ char buf[BUF_SIZE]; /* バッファ */ char *ptr = NULL; /* 戻り値ポインタ */ char *endp = NULL; /* strrchr戻り値 */ int retval = 0; /* 戻り値 */ dbglog("start: fd=%d", fd); if (fd < 0) { outlog("tcgetattr: fd=%d, mode=%p", fd, mode); return NULL; } dbglog("c_cflag=0x%x, c_iflag=0x%x, c_oflag=0x%x, c_lflag=0x%x", mode->c_cflag, mode->c_iflag, mode->c_oflag, mode->c_lflag); retval = tcgetattr(fd, mode); if (retval < 0) return NULL; (void)memset(buf, 0, sizeof(buf)); (void)snprintf(buf, sizeof(buf), "tcgetattr("); int i; for (i = 0; mode_info[i].name != NULL; i++) { bitsp = mode_type_flag(mode_info[i].type, mode); mask = mode_info[i].mask ? : mode_info[i].bits; if ((*bitsp & mask) == mode_info[i].bits) { (void)strncat(buf, mode_info[i].name, sizeof(buf) - strlen(buf) - 1); (void)strncat(buf, ", ", sizeof(buf) - strlen(buf) - 1); } } endp = strrchr(buf, ','); if (endp) *endp = '\0'; (void)strncat(buf, ")", sizeof(buf) - strlen(buf) - 1); ptr = strdup(buf); if (!ptr) { outlog("strdup: buf=%p", buf); return NULL; } return ptr; }
/* #if 0 */ int arch_auto_init() { dbgio_init(); /* Init debug IO and print a banner */ fs_ps2load_init_console(); dbglog(DBG_INFO, "\n--\n"); dbglog(DBG_INFO, banner); timer_init(); /* Timers */ irq_init(); /* IRQs */ syscall_init(); /* System call interface */ #if 0 hardware_init(); /* DC Hardware init */ #endif /* Threads */ #if 0 if (__kos_init_flags & INIT_THD_PREEMPT) thd_init(THD_MODE_PREEMPT); else #endif thd_init(THD_MODE_COOP); fs_init(); /* VFS */ fs_ramdisk_init(); /* Ramdisk */ fs_romdisk_init(); /* Romdisk */ if (__kos_romdisk != NULL) { fs_romdisk_mount("/rd", __kos_romdisk, 0); } if (fs_ps2load_init() >= 0) { dbglog(DBG_INFO, "ps2-load console support enabled\n"); } #if 0 fs_iso9660_init(); fs_vmu_init(); /* Now comes the optional stuff */ if (__kos_init_flags & INIT_IRQ) { irq_enable(); /* Turn on IRQs */ maple_wait_scan(); /* Wait for the maple scan to complete */ } if (__kos_init_flags & INIT_NET) { net_init(); /* Enable networking (and drivers) */ } /* And one more mandatory thing */ timer_ms_enable(); #endif return 0; }