/* ---------------------------------------------------------------------- */ void intr_enable(void) { PRINT_TIME(NOFD, &tnow, &tprev, "intr_enable new_connections_on = %d", new_connections_on); /* * If interrupts are also used to control incoming connections * then we want to enable interrupts iff: * num_idle >= 1 (actually >= options.thold) */ if (options.conn_on == OPT_CONN_WITH_SIGIO) { if (new_connections_on) { PRINT_TIME(NOFD, &tnow, &tprev, "intr_enable: new connections are on"); DEBG(MSG_INTR, "intr_enable: calling unblock_sigio()\n"); unblock_sigio(); } else { PRINT_TIME(NOFD, &tnow, &tprev, "intr_enable: should enable is false"); } } else if (options.conn_on == OPT_CONN_WITH_SEND_EVTS) { #ifdef SEND if (new_connections_on) { PRINT_TIME(NOFD, &tnow, &tprev, "intr_enable: new connections are on"); DEBG(MSG_INTR, "intr_enable: calling unblock_send_events()\n"); unblock_send_events(); } else { PRINT_TIME(NOFD, &tnow, &tprev, "intr_enable: should enable is false"); } #endif /* SEND */ } else { PRINT_TIME(NOFD, &tnow, &tprev, "intr_enable: enabling (not using SIGIO or SEND)"); } }
/* ---------------------------------------------------------------------- */ void unblock_sigio(void) { PRINT_TIME(NOFD, &tnow, &tprev, "unblock_sigio: entered sigio_blocked = %d", sigio_blocked); if (sigio_blocked == 0) { PRINT_TIME(NOFD, &tnow, &tprev, "unblock_sigio: is already unblocked returning"); return; } num_unblock_sigio++; DEBG(MSG_INTR, "unblock_sigio: unblocked = %15d blocked = %15d\n", num_unblock_sigio, num_block_sigio); /* Set this before actually unblocking because we could get */ /* after we're unblocked we could get interrupted before this gets set. */ DEBG(MSG_INTR, "unblock_sigio: setting sigio_blocked = 0\n"); sigio_blocked = 0; DEBG(MSG_INTR, "unblock_sigio: done setting sigio_blocked = 0\n"); DEBG(MSG_INTR, "unblock_sigio: unblocking\n"); do_unblock(); PRINT_TIME(NOFD, &tnow, &tprev, "unblock_sigio: returning"); }
utility_retcode_t init_rtsp_request(struct rtsp_request *request, struct rtsp_session *session) { utility_retcode_t ret; FUNC_ENTER; DEBG("initializing request structure\n"); syscalls_memset(request, 0, sizeof(*request)); request->session = session; syscalls_strncpy(request->request_line.uri, "*", sizeof(request->request_line.uri)); syscalls_strncpy(request->request_line.version, request->session->client->version, sizeof(request->request_line.version)); ret = UTILITY_SUCCESS; DEBG("done initializing request structure\n"); FUNC_RETURN; return ret; }
int main (int argc, char **argv) { int filefmt; AFfilehandle file; AFfilesetup setup; int miscids[] = {1, 2}; int result; if (argc < 3) { fprintf(stderr, "usage: %s <file format> <audio file>\n", argv[0]); exit(EXIT_FAILURE); } if (strcmp(argv[1], "aiff") == 0) filefmt = AF_FILE_AIFF; else if (strcmp(argv[1], "aifc") == 0) filefmt = AF_FILE_AIFFC; else if (strcmp(argv[1], "wave") == 0) filefmt = AF_FILE_WAVE; else { fprintf(stderr, "unrecognized file format '%s'\n", argv[1]); exit(EXIT_FAILURE); } setup = afNewFileSetup(); afInitFileFormat(setup, filefmt); afInitMiscIDs(setup, miscids, 2); afInitMiscType(setup, 1, AF_MISC_COPY); afInitMiscType(setup, 2, AF_MISC_NAME); afInitMiscSize(setup, 1, strlen(copyright)); afInitMiscSize(setup, 2, strlen(name)); file = afOpenFile(argv[2], "w", setup); if (file == NULL) { fprintf(stderr, "could not open file '%s' for writing\n", argv[2]); exit(EXIT_FAILURE); } result = afWriteMisc(file, 1, copyright, strlen(copyright)); DEBG("wrote miscellaneous data of type %d with length = %d\n", afGetMiscType(file, 1), result); result = afWriteMisc(file, 2, name, strlen(name)); DEBG("wrote miscellaneous data of type %d with length = %d\n", afGetMiscType(file, 2), result); /* Write out two token frames of sample data. */ afWriteFrames(file, AF_DEFAULT_TRACK, data, 2); afCloseFile(file); afFreeFileSetup(setup); return 0; }
void IOPrintPlane( const IORegistryPlane * plane ) { IORegistryEntry * next; IORegistryIterator * iter; OSOrderedSet * all; char format[] = "%xxxs"; IOService * service; iter = IORegistryIterator::iterateOver( plane ); assert( iter ); all = iter->iterateAll(); if( all) { DEBG("Count %d\n", all->getCount() ); all->release(); } else DEBG("Empty\n"); iter->reset(); while( (next = iter->getNextObjectRecursive())) { snprintf(format + 1, sizeof(format) - 1, "%ds", 2 * next->getDepth( plane )); DEBG( format, ""); DEBG( "\033[33m%s", next->getName( plane )); if( (next->getLocation( plane ))) DEBG("@%s", next->getLocation( plane )); DEBG("\033[0m <class %s", next->getMetaClass()->getClassName()); if( (service = OSDynamicCast(IOService, next))) DEBG(", busy %ld", (long) service->getBusyState()); DEBG( ">\n"); // IOSleep(250); } iter->release(); }
int pre_kinfo_init(void) { int zero_fd; DEBG(MSG_SEND, "pre_kinfo_init: entered\n"); zero_fd = open("/dev/zero", O_RDONLY); if (zero_fd < 0) { perror("open /dev/zero"); exit(-1); } DEBG(MSG_SEND, "pre_kinfo_init: zero_fd = %d\n", zero_fd); return (zero_fd); }
void lt_set_level_custom(struct lt_facility *facility, lt_mask_t mask_bits, lt_level_t level) { lt_level_t i; char bits[128]; FUNC_ENTER; bits_to_string((uint64_t)mask_bits, sizeof(mask_bits) * 8, bits, sizeof(bits)); DEBG("mask_bits: %s\n", bits); /* Set the requested bit in each mask up to level. */ for (i = 0 ; i <= level ; i++) { (*facility).masks[i] |= mask_bits; } /* Unset the requested bit in the rest of the masks. */ mask_bits = ~mask_bits; for ( ; i < NUM_LT_LEVELS ; i++) { (*facility).masks[i] &= mask_bits; } FUNC_RETURN; }
utility_retcode_t raopd_base64_decode(uint8_t *dst, size_t dstlen, const char *src, const size_t srclen, size_t *decoded_length) { utility_retcode_t ret = UTILITY_SUCCESS; char *begin_padding, *end_padding; FUNC_ENTER; DEBG("srclen: %d dstlen: %d\n", srclen, dstlen); *decoded_length = EVP_DecodeBlock(dst, (const uint8_t *)src, srclen); /* Adjust length to account for the somewhat broken OpenSSL API. See: http://osdir.com/ml/encryption.openssl.devel/2002-08/msg00267.html */ begin_padding = syscalls_strchr(src, '='); end_padding = syscalls_strrchr(src, '='); if (NULL != end_padding) { *decoded_length -= (end_padding - begin_padding + 1); } INFO("decoded_length: %d\n", *decoded_length); FUNC_RETURN; return ret; }
static utility_retcode_t get_header_list(struct rtsp_response *response) { utility_retcode_t ret = UTILITY_SUCCESS; FUNC_ENTER; while (more_headers(response)) { ret = utility_copy_token(response->tmpbuf, response->tmpbuflen, response->parsep, "\r\n", NULL); if (UTILITY_SUCCESS != ret) { ERRR("Header line is not terminated by \\r\\n\n"); goto failed; } DEBG("header line: \"%s\"\n", response->tmpbuf); ret = parse_one_header(response); if (UTILITY_SUCCESS != ret) { ERRR("Failed to parse header"); goto failed; } } INFO("Got blank line (\\r\\n). Finished parsing headers\n"); failed: FUNC_RETURN; return ret; }
/* ---------------------------------------------------------------------- */ void do_block(void) { int flags = 0; sigset_t set, old; int rc; int trace_fd = 0; int i; switch (options.sigio_cntl) { case OPT_SIGIO_USE_PROCMASK: #ifdef __CYGWIN__ printf("do_block: option not supported in CYGWIN version\n"); exit(1); #else PRINT_TIME(NOFD, &tnow, &tprev, "do_block: changing procmask"); if (in_handler) { DEBG(MSG_INTR, "do_block: in_handler = 1\n"); /* printf("do_block - in handler - sigaddset\n"); */ assert(uc != 0); #ifdef MACROBUG print_mask("do_block: uc_sigmask was \n", (sigset_t *) & uc->uc_sigmask); TRACE(EVT_CHANGESET, trace_fd = 0; rc = sigaddset((sigset_t *) & (uc->uc_sigmask), SIGIO);); print_mask("do_block: uc_sigmask is now\n", (sigset_t *) & uc->uc_sigmask); #else print_mask("do_block: uc_sigmask was \n", &uc->uc_sigmask); TRACE(EVT_CHANGESET, trace_fd = 0; rc = sigaddset(&(uc->uc_sigmask), SIGIO);); print_mask("do_block: uc_sigmask is now\n", &uc->uc_sigmask); #endif /* MACROBUG */ } else {
/* ---------------------------------------------------------------------- */ void intr_disable(void) { PRINT_TIME(NOFD, &tnow, &tprev, "intr_disable new_connections_on = %d", new_connections_on); /* Not true: could be blocked because there are no resources available */ /* assert(!sigio_blocked); */ if (options.conn_on == OPT_CONN_WITH_SIGIO) { DEBG(MSG_INTR, "intr_disable: calling block_sigio()\n"); block_sigio(); } else if (options.conn_on == OPT_CONN_WITH_SEND_EVTS) { #ifdef SEND DEBG(MSG_INTR, "intr_disable: calling block_send_events()\n"); block_send_events(); #endif /* SEND */ } }
static utility_retcode_t parse_public(struct rtsp_response *response) { FUNC_ENTER; DEBG("value: \"%s\"\n", response->current_header.value); FUNC_RETURN; return UTILITY_SUCCESS; }
//------------------------------------------------------------------------------------------------- void BachAssetListView::dragEnterEvent( QDragEnterEvent * event ) { if ( !mShowingCollection || !bach_editor_mode ) return; DEBG( "dragEnterEvent 1!" ); if (event->source() == this) { DEBG( "dragEnterEvent 2.1!" ); event->setDropAction(Qt::MoveAction); event->accept(); } else { DEBG( "dragEnterEvent 2.2!" ); event->acceptProposedAction(); } }
static utility_retcode_t parse_one_header(struct rtsp_response *response) { utility_retcode_t ret = UTILITY_SUCCESS; char *start_value; char *header_name = response->current_header.name; char *header_value = response->current_header.value; FUNC_ENTER; ret = utility_copy_token(header_name, MAX_HEADER_NAME_LEN, response->parsep, ": ", NULL); if (UTILITY_SUCCESS != ret) { ERRR("Failed to copy header name\n"); goto out; } start_value = begin_token(response->parsep, ": "); ret = utility_copy_token(header_value, MAX_HEADER_VALUE_LEN, start_value, "\r\n", NULL); if (UTILITY_SUCCESS != ret) { ERRR("Failed to copy header value\n"); goto out; } DEBG("Found header name: \"%s\" value: \"%s\"\n", header_name, header_value); if (0 == syscalls_strcmp(header_name, "Content-Length")) { ret = parse_content_length(response); } else if (0 == syscalls_strcmp(header_name, "Apple-Response")) { ret = parse_apple_response(response); } else if (0 == syscalls_strcmp(header_name, "Audio-Jack-Status")) { ret = parse_audio_jack_status(response); } else if (0 == syscalls_strcmp(header_name, "Session")) { ret = parse_session(response); } else if (0 == syscalls_strcmp(header_name, "Transport")) { ret = parse_transport(response); } else if (0 == syscalls_strcmp(header_name, "Public")) { ret = parse_public(response); } else { parse_unknown_header(response); } out: FUNC_RETURN; return ret; }
IOMemoryDescriptor * IOGetBootKeyStoreData(void) { IOMemoryDescriptor *memoryDescriptor; boot_args *args = (boot_args *)PE_state.bootArgs; IOOptionBits options; IOAddressRange ranges; if (!OSCompareAndSwap(0, 1, &alreadyFetched)) return (NULL); if (newData) { IOMemoryDescriptor * data = newData; newData = NULL; return (data); } DEBG("%s: data at address %u size %u\n", __func__, args->keyStoreDataStart, args->keyStoreDataSize); if (args->keyStoreDataStart == 0) return (NULL); ranges.address = args->keyStoreDataStart; ranges.length = args->keyStoreDataSize; options = kIODirectionInOut | kIOMemoryTypePhysical64; memoryDescriptor = IOMemoryDescriptor::withOptions(&ranges, 1, 0, NULL, options); DEBG("%s: memory descriptor %p\n", __func__, memoryDescriptor); return memoryDescriptor; }
void do_kinfo_init(int zero_fd) { int ret = 0; int alt_size; int size = (sizeof(struct kinfo_struct)); assert(zero_fd > 2); DEBG(MSG_SEND, "do_kinfo_init: size = %d\n", size); DEBG(MSG_SEND, "do_kinfo_init: zero_fd = %d\n", zero_fd); /* round size to next highest page size */ if (size % PAGE_SIZE != 0) { alt_size = ((size / PAGE_SIZE) * PAGE_SIZE) + PAGE_SIZE; } DEBG(MSG_SEND, "rounded up kinfo alt_size = %d\n", alt_size); assert(alt_size % PAGE_SIZE == 0); kinfo = (struct kinfo_struct *) mmap(0, alt_size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, zero_fd, 0); if (kinfo == MAP_FAILED) { printf("do_kinfo_init: - no memory\n"); close(zero_fd); exit(1); } printf("do_kinfo_init: kinfo = %p size = %d\n", kinfo, alt_size); ret = kinfo_init(kinfo, size, server_sd); PRINT_TIME(server_sd, &tnow, &tprev, "do_kinfo_init: kinfo_init " "returns %d", ret); if (ret < 0) { printf("do_kinfo_init: bad kinfo_init %i %s\n", errno, strerror(errno)); printf("do_kinfo_init: ret = %d\n", ret); close(zero_fd); exit(-1); } }
utility_retcode_t create_content_length_header(struct rtsp_request *request) { utility_retcode_t ret = UTILITY_SUCCESS; size_t len; char s[32]; FUNC_ENTER; DEBG("-->%s<--\n", request->msg_body); len = syscalls_strlen(request->msg_body); DEBG("msg_body length: %d\n", len); syscalls_snprintf(s, sizeof(s), "%lu", len); ret = add_rtsp_header(&request->headers, "Content-Length", s, "Content-Length header"); FUNC_RETURN; return ret; }
void printinstparams (int format) { int i, *iarray; long instParamCount; instParamCount = afQueryLong(AF_QUERYTYPE_INSTPARAM, AF_QUERY_ID_COUNT, format, 0, 0); DEBG("instrument parameter query: id count: %ld\n", instParamCount); iarray = afQueryPointer(AF_QUERYTYPE_INSTPARAM, AF_QUERY_IDS, format, 0, 0); if (iarray == NULL) printf("AF_QUERYTYPE_INSTPARAM failed for format %d\n", format); for (i=0; i<instParamCount; i++) { int paramType; AUpvlist defaultValue; DEBG("instrument parameter query: id: %d\n", iarray[i]); paramType = afQueryLong(AF_QUERYTYPE_INSTPARAM, AF_QUERY_TYPE, format, iarray[i], 0); DEBG("\ttype of parameter: %s\n", paramtypename(paramType)); DEBG("\tname of parameter: %s\n", (char *) afQueryPointer(AF_QUERYTYPE_INSTPARAM, AF_QUERY_NAME, format, iarray[i], 0)); defaultValue = afQuery(AF_QUERYTYPE_INSTPARAM, AF_QUERY_DEFAULT, format, iarray[i], 0); if (paramType == AU_PVTYPE_LONG) { long ldefault; AUpvgetval(defaultValue, 0, &ldefault); DEBG("\tdefault value: %ld\n", ldefault); } else if (paramType == AU_PVTYPE_DOUBLE) { double ddefault; AUpvgetval(defaultValue, 0, &ddefault); DEBG("\tdefault value: %f\n", ddefault); } else if (paramType == AU_PVTYPE_PTR) { void *vdefault; AUpvgetval(defaultValue, 0, &vdefault); DEBG("\tdefault value: %p\n", vdefault); } } free(iarray); }
static int wdt_thread(void *arg) { int ret = 0; int ms = (tmr_margin*1000)>>1; DEBG("--- enter WATCHDOG KTHREAD ---\n"); while (1) { // check whether we should exit or not if(kthread_should_stop()){ DEBG("--- WATCHDOG KTHREAD should stop ---\n"); break; } s3c2410wdt_keepalive(); DEBG("--- feed the s3c2410 watchdog before timeout = %d ---\n", tmr_margin); msleep(ms); } DEBG("--- exit WATCHDOG KTHREAD ---\n"); return ret; }
static utility_retcode_t add_blank_line(struct rtsp_request *request) { size_t len; DEBG("Adding blank line to request\n"); len = syscalls_snprintf(request->bufp, request->bytes_remaining, "\r\n"); request->bufp += len; request->bytes_remaining -= len; return UTILITY_SUCCESS; }
//------------------------------------------------------------------------------------------------- void BachAssetListView::dragMoveEvent( QDragMoveEvent * event ) { if ( !mShowingCollection || !bach_editor_mode ) return; if (event->source() == this) { QModelIndex midx = indexAt( event->pos() ); mCurrentDropTarget = model()->getRecord( midx ); DEBG( "dropEvent 2.2!"+mCurrentDropTarget.path() ); // setSelection( RecordList( mCurrentDropTarget ) ); event->acceptProposedAction(); } }
void block_sigio(void) { PRINT_TIME(NOFD, &tnow, &tprev, "block_sigio: entered sigio_blocked = %d", sigio_blocked); if (sigio_blocked == 1) { PRINT_TIME(NOFD, &tnow, &tprev, "block_sigio: is already blocked returning"); return; } DEBG(MSG_INTR, "block_sigio: blocking\n"); do_block(); num_block_sigio++; DEBG(MSG_INTR, "block_sigio: unblocked = %15d blocked = %15d\n", num_unblock_sigio, num_block_sigio); DEBG(MSG_INTR, "block_sigio: setting sigio_blocked = 1\n"); sigio_blocked = 1; DEBG(MSG_INTR, "block_sigio: done setting sigio_blocked = 1\n"); PRINT_TIME(NOFD, &tnow, &tprev, "block_sigio: returning"); }
void remove_base64_padding(char *encoded_string) { char *begin_padding; FUNC_ENTER; begin_padding = syscalls_strchr(encoded_string, '='); if (NULL != begin_padding) { DEBG("Found padding\n"); *begin_padding = '\0'; } return; }
static utility_retcode_t header_destructor(void *data) { struct key_value_pair *header = (struct key_value_pair *)data; FUNC_ENTER; DEBG("Destroying header \"%s\"\n", header->name); syscalls_free(header->value); syscalls_free(header->name); syscalls_free(header); FUNC_RETURN; return UTILITY_SUCCESS; }
static utility_retcode_t parse_session(struct rtsp_response *response) { char *value = response->current_header.value; FUNC_ENTER; DEBG("value: \"%s\"\n", value); syscalls_strncpy(response->session->identifier, value, sizeof(response->session->identifier)); INFO("Session identifier: \"%s\"\n", response->session->identifier); FUNC_RETURN; return UTILITY_SUCCESS; }
void lt_set_level_by_position_custom(struct lt_facility *facility, lt_facility_position_t position, lt_level_t level) { lt_mask_t mask_bits; FUNC_ENTER; DEBG("position: %d\n", position); mask_bits = ((lt_mask_t)0x1 << position); lt_set_level_custom(facility, mask_bits, level); FUNC_RETURN; return; }
static utility_retcode_t parse_transport(struct rtsp_response *response) { char *value = response->current_header.value; char *port_string; FUNC_ENTER; DEBG("value: \"%s\"\n", value); port_string = begin_token(value, "server_port="); response->session->port = syscalls_strtoul(port_string, NULL, 0); INFO("Session IP port: %d\n", response->session->port); FUNC_RETURN; return UTILITY_SUCCESS; }
int main (int ac, char **av) { AUpvlist formatlist; int *flist; long lvalue; int i, formatcount; formatlist = afQuery(AF_QUERYTYPE_FILEFMT, AF_QUERY_IDS, 0, 0, 0); formatcount = afQueryLong(AF_QUERYTYPE_FILEFMT, AF_QUERY_ID_COUNT, 0, 0, 0); DEBG("formatcount = %d\n", formatcount); AUpvgetval(formatlist, 0, &flist); AUpvfree(formatlist); for (i=0; i<formatcount; i++) { int format; char *formatstring; format = flist[i]; DEBG("format = %d\n", format); formatstring = afQueryPointer(AF_QUERYTYPE_FILEFMT, AF_QUERY_NAME, format, 0, 0); DEBG("format = %s\n", formatstring); lvalue = afQueryLong(AF_QUERYTYPE_INST, AF_QUERY_SUPPORTED, format, 0, 0); DEBG("instrument query: supported: %ld\n", lvalue); lvalue = afQueryLong(AF_QUERYTYPE_INST, AF_QUERY_MAX_NUMBER, format, 0, 0); DEBG("instrument query: maximum number: %ld\n", lvalue); lvalue = afQueryLong(AF_QUERYTYPE_INSTPARAM, AF_QUERY_SUPPORTED, format, 0, 0); DEBG("instrument parameter query: supported: %ld\n", lvalue); /* Print instrument parameter information only if instrument parameters are supported. */ if (lvalue) printinstparams(format); } free(flist); return 0; }
static utility_retcode_t build_one_header(void *entry_data, void *data) { struct key_value_pair *header = (struct key_value_pair *)entry_data; struct rtsp_request *request = (struct rtsp_request *)data; int written; DEBG("name: \"%s\" value: \"%s\"\n", header->name, header->value); written = syscalls_snprintf(request->bufp, request->bytes_remaining, "%s: %s\r\n", header->name, header->value); request->bufp += written; request->bytes_remaining -= written; return UTILITY_SUCCESS; }
static utility_boolean_t more_headers(struct rtsp_response *response) { utility_boolean_t ret = UTILITY_TRUE; FUNC_ENTER; if (UTILITY_SUCCESS == next_line(response)) { DEBG("Found a header line\n"); if (0 == syscalls_strncmp(response->parsep, "\r\n", sizeof("\r\n"))) { ret = UTILITY_FALSE; } } FUNC_RETURN; return ret; }