예제 #1
0
int
main()
{
    k5_response_items *ri;

    check(k5_response_items_new(&ri));
    check_pred(k5_response_items_empty(ri));

    check(k5_response_items_ask_question(ri, TEST_STR1, TEST_STR1));
    check(k5_response_items_ask_question(ri, TEST_STR2, NULL));
    check_pred(nstrcmp(k5_response_items_get_challenge(ri, TEST_STR1),
                       TEST_STR1) == 0);
    check_pred(nstrcmp(k5_response_items_get_challenge(ri, TEST_STR2),
                       NULL) == 0);
    check_pred(!k5_response_items_empty(ri));

    k5_response_items_reset(ri);
    check_pred(k5_response_items_empty(ri));
    check_pred(k5_response_items_get_challenge(ri, TEST_STR1) == NULL);
    check_pred(k5_response_items_get_challenge(ri, TEST_STR2) == NULL);

    check(k5_response_items_ask_question(ri, TEST_STR1, TEST_STR1));
    check_pred(nstrcmp(k5_response_items_get_challenge(ri, TEST_STR1),
                       TEST_STR1) == 0);
    check(k5_response_items_set_answer(ri, TEST_STR1, TEST_STR1));
    check_pred(nstrcmp(k5_response_items_get_answer(ri, TEST_STR1),
                       TEST_STR1) == 0);

    k5_response_items_free(ri);

    return 0;
}
예제 #2
0
int dotest(char* a, char* b, int exp)
{
	int res = nstrcmp(a, b);
	int err = (cs(res) != cs(exp));
	printf("nstrcmp(\"%s\", \"%s\")=%d %d %s\n", a, b, res, exp, err?"WRONG":"OK");
	return err;
}
예제 #3
0
/**
 * ulfius_send_http_request
 * Send a HTTP request and store the result into a _u_response
 * return U_OK on success
 */
int ulfius_send_http_request(const struct _u_request * request, struct _u_response * response) {
  body body_data;
  body_data.size = 0;
  body_data.data = NULL;
  int res;
  const char * content_type;
  
  res = ulfius_send_http_streaming_request(request, response, ulfius_write_body, (void *)&body_data);
  
  if (res == U_OK && response != NULL) {
    if (body_data.data != NULL && body_data.size > 0) {
      response->string_body = nstrdup(body_data.data);
      response->binary_body = malloc(body_data.size);
      if (response->binary_body == NULL || response->string_body == NULL) {
        y_log_message(Y_LOG_LEVEL_ERROR, "Ulfius - Error allocating memory for response->binary_body");
        free(body_data.data);
        return U_ERROR_MEMORY;
      }
      memcpy(response->binary_body, body_data.data, body_data.size);
      response->binary_body_length = body_data.size;
      
      content_type = u_map_get_case(response->map_header, ULFIUS_HTTP_HEADER_CONTENT);
      if (content_type != NULL && 0 == nstrcmp(content_type, ULFIUS_HTTP_ENCODING_JSON)) {
        // Parsing json content
        response->json_body = json_loads(body_data.data, JSON_DECODE_ANY, NULL);
      }
    }
    free(body_data.data);
    return U_OK;
  } else {
    free(body_data.data);
    return res;
  }
}
예제 #4
0
파일: WOREWAAN.C 프로젝트: MegaGod/TW
unsigned char *WoreWaanRtn( register unsigned char *TempIndx ) {
	register unsigned char *plus1 = TempIndx + 1, *minus3 = TempIndx - 3;

	if ( istcon( *( TempIndx - 1 ) ) ) {
		if ( istlvwl( *( TempIndx - 2 ) ) ) {
			return( minus3 );
		} else if ( istcon( *( TempIndx - 2 ) ) && istcon( *plus1 ) ) {
			switch ( *( TempIndx + 1 ) ) {
			case OrAng:
				return( FAIL );
			case RoreReo:
				if ( *( TempIndx + 2 ) == RoreReo ) {
					return( FAIL );
				}
			default:
				if ( plus1 <= RightMargin ) {
					if ( *( TempIndx + 3 ) == Karan ) {
						return( FAIL );
					} else {
						return( !istrvwl( *( TempIndx + 2 ) ) ? plus1 : FAIL );
					}
				} else {
					return( FAIL );
				}
			}
		} else if ( isttnl( *( TempIndx - 1 ) ) && istcon( *( TempIndx - 2 ) ) && istcon( *minus3 ) ) {

			if ( plus1 <= RightMargin ) {
				return( plus1 );
			} else if ( !nstrcmp( "¡Ã", minus3 ) || !nstrcmp( "¡Å", minus3 ) || !nstrcmp( "˹", minus3 ) || !nstrcmp( "ËÂ", minus3 ) ) {
				return( TempIndx - 4 );
			} else {
				return( minus3 );
			}
		}
	}
	return( FAIL );
}
예제 #5
0
파일: service.c 프로젝트: FMNSSun/NoOS
NUSHORT srvc_get_id(NPCHAR name) { 
  NUSHORT i;
  for(i=0;i<SRVC_SIZE;i++) {
    
    if(nstrlen(srvc_entries[i].name) != nstrlen(name)) continue;
    if(nstrcmp(srvc_entries[i].name,name) != 1) continue;
#ifdef DEBUG_LVL_TWO
    vid_print("[ SRVC ] Found as: ",0x0A);
    vid_print(nitoa((int)srvc_entries[i].sid,10),0x0A);
    vid_print("\r\n",0x07);
    vid_print(srvc_entries[i].name,0x08);
    vid_print(" /SRVC\r\n",0x08);
#endif
    return srvc_entries[i].sid;
  }
#ifdef DEBUG_LVL_TWO
  vid_print("[ SRVC ] srvc_get_id could not find this service :(\r\n",0x04);
  vid_print(name,0x4);
#endif
  //kstop();
  return 0;
}
예제 #6
0
static int
check ()
{
  struct GNUNET_CONTAINER_Heap *myHeap;
  struct GNUNET_CONTAINER_HeapNode *n1;
  struct GNUNET_CONTAINER_HeapNode *n2;
  struct GNUNET_CONTAINER_HeapNode *n3;
  struct GNUNET_CONTAINER_HeapNode *n4;
  struct GNUNET_CONTAINER_HeapNode *n5;
  struct GNUNET_CONTAINER_HeapNode *n6;
  struct GNUNET_CONTAINER_HeapNode *n7;
  struct GNUNET_CONTAINER_HeapNode *n8;
  const char *r;

  myHeap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);

  // GNUNET_CONTAINER_heap_remove_root heap empty, taking if-branch
  n1 = GNUNET_CONTAINER_heap_remove_root (myHeap);
  GNUNET_assert (NULL == n1);

  // GNUNET_CONTAINER_heap_peek heap empty, taking if-branch
  n1 = GNUNET_CONTAINER_heap_peek (myHeap);
  GNUNET_assert (NULL == n1);

  // GNUNET_CONTAINER_heap_walk_get_next: heap empty, taking if-branch
  n1 = GNUNET_CONTAINER_heap_walk_get_next (myHeap);
  GNUNET_assert (NULL == n1);

  n1 = GNUNET_CONTAINER_heap_insert (myHeap, "11", 11);
  GNUNET_assert (NULL != n1);


  // GNUNET_CONTAINER_heap_peek not empty, taking if-branch
  n2 = NULL;
  n2 = GNUNET_CONTAINER_heap_peek (myHeap);
  GNUNET_assert (NULL != n2);

  // GNUNET_CONTAINER_heap_walk_get_next: 1 element
  n1 = NULL;
  n1 = GNUNET_CONTAINER_heap_walk_get_next (myHeap);
  GNUNET_assert (NULL != n1);

  GNUNET_CONTAINER_heap_iterate (myHeap, &iterator_callback, NULL);
  GNUNET_assert (1 == GNUNET_CONTAINER_heap_get_size (myHeap));
  n2 = GNUNET_CONTAINER_heap_insert (myHeap, "78", 78);
  GNUNET_assert (2 == GNUNET_CONTAINER_heap_get_size (myHeap));
  GNUNET_assert (0 == strcmp ("78", GNUNET_CONTAINER_heap_remove_node (n2)));
  GNUNET_assert (1 == GNUNET_CONTAINER_heap_get_size (myHeap));
  GNUNET_CONTAINER_heap_iterate (myHeap, &iterator_callback, NULL);

  n3 = GNUNET_CONTAINER_heap_insert (myHeap, "15", 5);
  GNUNET_CONTAINER_heap_update_cost (myHeap, n3, 15);
  GNUNET_assert (2 == GNUNET_CONTAINER_heap_get_size (myHeap));
  GNUNET_CONTAINER_heap_iterate (myHeap, &iterator_callback, NULL);

  n4 = GNUNET_CONTAINER_heap_insert (myHeap, "50", 50);
  GNUNET_CONTAINER_heap_update_cost (myHeap, n4, 50);
  GNUNET_assert (3 == GNUNET_CONTAINER_heap_get_size (myHeap));
  GNUNET_CONTAINER_heap_iterate (myHeap, &iterator_callback, NULL);

  n5 = GNUNET_CONTAINER_heap_insert (myHeap, "100", 100);
  n6 = GNUNET_CONTAINER_heap_insert (myHeap, "30/200", 30);
  GNUNET_assert (5 == GNUNET_CONTAINER_heap_get_size (myHeap));
  GNUNET_CONTAINER_heap_remove_node (n5);
  r = GNUNET_CONTAINER_heap_remove_root (myHeap);       /* n1 */
  GNUNET_assert (NULL != r);
  GNUNET_assert (0 == strcmp ("11", r));
  GNUNET_CONTAINER_heap_update_cost (myHeap, n6, 200);
  GNUNET_CONTAINER_heap_remove_node (n3);
  r = GNUNET_CONTAINER_heap_remove_root (myHeap);       /* n4 */
  GNUNET_assert (NULL != r);
  GNUNET_assert (0 == strcmp ("50", r));
  r = GNUNET_CONTAINER_heap_remove_root (myHeap);       /* n6 */
  GNUNET_assert (NULL != r);
  GNUNET_assert (0 == strcmp ("30/200", r));
  GNUNET_assert (0 == GNUNET_CONTAINER_heap_get_size (myHeap));

  GNUNET_CONTAINER_heap_destroy (myHeap);

  // My additions to a complete testcase
  // Testing a GNUNET_CONTAINER_HEAP_ORDER_MIN
  // Testing remove_node

  myHeap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);

  n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
  GNUNET_CONTAINER_heap_update_cost (myHeap, n1, 15);

  r = GNUNET_CONTAINER_heap_remove_node (n1);
  GNUNET_assert (NULL != r);
  GNUNET_assert (0 == strcmp ("10", r));

  n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
  n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);

  GNUNET_CONTAINER_heap_walk_get_next (myHeap);
  r = GNUNET_CONTAINER_heap_remove_node (n2);
  GNUNET_assert (NULL != r);
  GNUNET_assert (0 == strcmp ("20", r));
  r = GNUNET_CONTAINER_heap_remove_node (n1);
  GNUNET_assert (NULL != r);
  GNUNET_assert (0 == strcmp ("10", r));

  n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
  n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
  n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 10);

  GNUNET_CONTAINER_heap_remove_node (n2);
  GNUNET_CONTAINER_heap_remove_node (n1);
  r = GNUNET_CONTAINER_heap_remove_root (myHeap);
  GNUNET_assert (NULL != r);
  GNUNET_assert (0 == strcmp ("30", r));

  n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
  n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
  n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 10);

  GNUNET_CONTAINER_heap_remove_node (n2);
  GNUNET_CONTAINER_heap_remove_node (n1);
  r = GNUNET_CONTAINER_heap_remove_node (n3);
  GNUNET_assert (NULL != r);
  GNUNET_assert (0 == strcmp ("30", r));

  n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
  n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 20);
  n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 30);

  GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (n2)));
  GNUNET_assert (0 ==
                 nstrcmp ("10", GNUNET_CONTAINER_heap_remove_root (myHeap)));
  GNUNET_assert (0 ==
                 nstrcmp ("30", GNUNET_CONTAINER_heap_remove_root (myHeap)));

  n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
  n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 20);
  n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 30);
  n4 = GNUNET_CONTAINER_heap_insert (myHeap, "40", 40);
  n5 = GNUNET_CONTAINER_heap_insert (myHeap, "50", 50);
  n6 = GNUNET_CONTAINER_heap_insert (myHeap, "60", 60);

  // Inserting nodes deeper in the tree with lower costs
  n7 = GNUNET_CONTAINER_heap_insert (myHeap, "70", 10);
  n8 = GNUNET_CONTAINER_heap_insert (myHeap, "80", 10);

  GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (n3)));

  // Cleaning up...
  GNUNET_assert (0 == nstrcmp ("60", GNUNET_CONTAINER_heap_remove_node (n6)));
  GNUNET_assert (0 == nstrcmp ("50", GNUNET_CONTAINER_heap_remove_node (n5)));

  // Testing heap_walk_get_next
  GNUNET_CONTAINER_heap_walk_get_next (myHeap);
  GNUNET_CONTAINER_heap_walk_get_next (myHeap);
  GNUNET_CONTAINER_heap_walk_get_next (myHeap);;
  GNUNET_CONTAINER_heap_walk_get_next (myHeap);
  GNUNET_CONTAINER_heap_walk_get_next (myHeap);

  GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (n1)));
  GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (n2)));
  GNUNET_assert (0 == nstrcmp ("40", GNUNET_CONTAINER_heap_remove_node (n4)));
  GNUNET_assert (0 == nstrcmp ("70", GNUNET_CONTAINER_heap_remove_node (n7)));
  GNUNET_assert (0 == nstrcmp ("80", GNUNET_CONTAINER_heap_remove_node (n8)));

  // End Testing remove_node

  // Testing a GNUNET_CONTAINER_HEAP_ORDER_MAX
  GNUNET_CONTAINER_heap_destroy (myHeap);

  myHeap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MAX);

  n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
  GNUNET_CONTAINER_heap_update_cost (myHeap, n1, 15);

  GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (n1)));

  n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
  n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);

  GNUNET_CONTAINER_heap_walk_get_next (myHeap);
  GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (n2)));
  GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (n1)));

  n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
  n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
  n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 10);

  GNUNET_CONTAINER_heap_remove_node (n2);
  GNUNET_CONTAINER_heap_remove_node (n1);
  GNUNET_assert (0 ==
                 nstrcmp ("30", GNUNET_CONTAINER_heap_remove_root (myHeap)));

  n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
  n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
  n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 10);

  GNUNET_CONTAINER_heap_remove_node (n2);
  GNUNET_CONTAINER_heap_remove_node (n1);
  GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (n3)));

  n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
  n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 20);
  n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 30);
  n4 = GNUNET_CONTAINER_heap_insert (myHeap, "40", 40);
  n5 = GNUNET_CONTAINER_heap_insert (myHeap, "50", 50);
  n6 = GNUNET_CONTAINER_heap_insert (myHeap, "60", 60);

  // Inserting nodes deeper in the tree with lower costs
  n7 = GNUNET_CONTAINER_heap_insert (myHeap, "70", 10);
  n8 = GNUNET_CONTAINER_heap_insert (myHeap, "80", 10);

  GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (n3)));

  // Cleaning up...
  GNUNET_assert (0 == nstrcmp ("60", GNUNET_CONTAINER_heap_remove_node (n6)));
  GNUNET_assert (0 == nstrcmp ("50", GNUNET_CONTAINER_heap_remove_node (n5)));

  // Testing heap_walk_get_next
  GNUNET_CONTAINER_heap_walk_get_next (myHeap);
  GNUNET_CONTAINER_heap_walk_get_next (myHeap);
  GNUNET_CONTAINER_heap_walk_get_next (myHeap);;
  GNUNET_CONTAINER_heap_walk_get_next (myHeap);
  GNUNET_CONTAINER_heap_walk_get_next (myHeap);

  GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (n1)));
  GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (n2)));
  GNUNET_assert (0 == nstrcmp ("40", GNUNET_CONTAINER_heap_remove_node (n4)));
  GNUNET_assert (0 == nstrcmp ("70", GNUNET_CONTAINER_heap_remove_node (n7)));
  GNUNET_assert (0 == nstrcmp ("80", GNUNET_CONTAINER_heap_remove_node (n8)));

  // End Testing remove_node

  GNUNET_CONTAINER_heap_destroy (myHeap);

  return 0;
}
int main(int argc, char *argv[])
{
    XCBConnection *c;
    int scrn;
    char *display_name = NULL;
    char *name = NULL;
    XCBWINDOW root_window = {0};
    XCBSCREEN *screen;
    XCBXvQueryExtensionRep *query_ext;
    XCBXvQueryAdaptorsRep *adaptors_rep;
    XCBXvAdaptorInfoIter adaptors_iter;
    XCBXvAdaptorInfo *ainfo;
    XCBXvFormat *format;
    XCBXvQueryPortAttributesRep *attr_rep;
    XCBXvAttributeInfoIter attr_iter;
    XCBXvAttributeInfo *attribute;

    int nscreens, nattr, i, j, k;

    if ((argc != 1) && (argc != 3))
        PrintUsage();

    if (argc != 1) {
        if (strcmp(argv[1], "-display"))
            PrintUsage();
        display_name = argv[2];
    }

    if (!display_name) display_name = getenv("DISPLAY");
    if (!(c = XCBConnect(display_name, &scrn)))
    {
        fprintf(stderr, "xcbxvinfo: Unable to open display %s\n", display_name);
        exit(1);
    }

    if (!(query_ext = XCBXvQueryExtensionReply(c, XCBXvQueryExtension(c), NULL)))
    {
        fprintf(stderr, "xvinfo: No X-Video extension on %s\n", display_name);
        exit(0);
    }
    else
    {
        fprintf(stdout, "X-Video Extension version %i.%i\n", query_ext->major, query_ext->minor);
    }

    free(query_ext);

    nscreens = XCBConnSetupSuccessRepRootsIter(XCBGetSetup(c)).rem;

    for (i = 0; i < nscreens; i++)
    {
        fprintf(stdout, "screen #%i\n", i);

        screen = ScreenOfDisplay(c, scrn);
        if (screen) root_window = screen->root;

        adaptors_rep = XCBXvQueryAdaptorsReply(c, XCBXvQueryAdaptors(c, root_window), NULL);
        if (!adaptors_rep->num_adaptors) {
            fprintf(stdout, " no adaptors present.\n");
            continue;
        }

        adaptors_iter = XCBXvQueryAdaptorsInfoIter(adaptors_rep);

        for (j = 0; j < adaptors_rep->num_adaptors; j++)
        {
            ainfo = adaptors_iter.data;
            name = ExtractString(XCBXvAdaptorInfoName(ainfo), XCBXvAdaptorInfoNameLength(ainfo));
            fprintf(stdout, "  Adaptor #%i: \"%s\"\n", j, name);
            fprintf(stdout, "    number of ports: %i\n", ainfo->num_ports);
            fprintf(stdout, "    port base: %li\n", ainfo->base_id.xid);
            fprintf(stdout, "    operations supported: ");
            free(name);

            switch(ainfo->type & (XCBXvTypeInputMask | XCBXvTypeOutputMask)) {
                case XCBXvTypeInputMask:
                    if (ainfo->type & XCBXvTypeVideoMask)
                        fprintf(stdout, "PutVideo ");
                    if (ainfo->type & XCBXvTypeStillMask)
                        fprintf(stdout, "PutStill ");
                    if (ainfo->type & XCBXvTypeImageMask)
                        fprintf(stdout, "PutImage ");
                    break;
                case XCBXvTypeOutputMask:
                    if (ainfo->type & XCBXvTypeVideoMask)
                        fprintf(stdout, "GetVideo ");
                    if (ainfo->type & XCBXvTypeStillMask)
                        fprintf(stdout, "GetStill ");
                    break;
                default:
                    fprintf(stdout, "none ");
                    break;
            }
            fprintf(stdout, "\n");

            format = XCBXvAdaptorInfoFormats(ainfo);

            fprintf(stdout, "    supported visuals:\n");
            for (k=0; k < ainfo->num_formats; k++, format++)
                fprintf(stdout, "      depth %i, visualID 0x%2lx\n",
                        format->depth, format->visual.id);

            attr_rep = XCBXvQueryPortAttributesReply(c,
                    XCBXvQueryPortAttributes(c, ainfo->base_id), NULL);
            nattr = attr_rep->num_attributes;
            attr_iter = XCBXvQueryPortAttributesAttributesIter(attr_rep);

            if (nattr) {            
                fprintf(stdout, "    number of attributes: %i\n", nattr);

                for (k = 0; k < nattr; k++) {
                    attribute = attr_iter.data;
                    fprintf(stdout, "      \"%s\" (range %li to %li)\n",
                            XCBXvAttributeInfoName(attribute),
                            attribute->min,
                            attribute->max);

                    if (attribute->flags & XCBXvAttributeFlagSettable)
                        fprintf(stdout, "              client settable attribute\n");

                    if (attribute->flags & XCBXvAttributeFlagGettable) {
                        XCBATOM the_atom;
                        XCBInternAtomRep *atom_rep;

                        fprintf(stdout, "              client gettable attribute");

                        atom_rep = XCBInternAtomReply(c,
                                XCBInternAtom(c,
                                    1, 
                                    /*XCBXvAttributeInfoNameLength(attribute),*/
                                    strlen(XCBXvAttributeInfoName(attribute)),
                                    XCBXvAttributeInfoName(attribute)),
                                NULL);
                        the_atom = atom_rep->atom;

                        if (the_atom.xid != 0) {
                            XCBXvGetPortAttributeRep *pattr_rep =
                                XCBXvGetPortAttributeReply(c,
                                        XCBXvGetPortAttribute(c, ainfo->base_id, the_atom),
                                        NULL);
                            if (pattr_rep) fprintf(stdout, " (current value is %li)", pattr_rep->value);
                            free(pattr_rep);
                        }
                        fprintf(stdout, "\n");
                        free(atom_rep);
                    }
                    XCBXvAttributeInfoNext(&attr_iter);
                }
            }
            else {
                fprintf(stdout, "    no port attributes defined\n");
            }

            XCBXvQueryEncodingsRep *qencodings_rep;
            qencodings_rep = XCBXvQueryEncodingsReply(c, XCBXvQueryEncodings(c, ainfo->base_id), NULL);
            int nencode = qencodings_rep->num_encodings;
            XCBXvEncodingInfoIter encoding_iter = XCBXvQueryEncodingsInfoIter(qencodings_rep);
            XCBXvEncodingInfo *encoding;

            int ImageEncodings = 0;
            if (nencode) {
                int n;
                for (n = 0; n < nencode; n++) {
                    encoding = encoding_iter.data;
                    name = ExtractString(XCBXvEncodingInfoName(encoding), XCBXvEncodingInfoNameLength(encoding));
                    if (!nstrcmp(name, strlen(name), "XV_IMAGE"))
                        ImageEncodings++;
                    XCBXvEncodingInfoNext(&encoding_iter);
                    free(name);
                }

                if(nencode - ImageEncodings) {
                    fprintf(stdout, "    number of encodings: %i\n", nencode - ImageEncodings);

                    /* Reset the iter. */
                    encoding_iter = XCBXvQueryEncodingsInfoIter(qencodings_rep);
                    for(n = 0; n < nencode; n++) {
                        encoding = encoding_iter.data;
                        name = ExtractString(XCBXvEncodingInfoName(encoding), XCBXvEncodingInfoNameLength(encoding));
                        if(nstrcmp(name, strlen(name), "XV_IMAGE")) {
                            fprintf(stdout,
                                    "      encoding ID #%li: \"%*s\"\n",
                                    encoding->encoding.xid,
                                    strlen(name),
                                    name);
                            fprintf(stdout, "        size: %i x %i\n",
                                    encoding->width,
                                    encoding->height);
                            fprintf(stdout, "        rate: %f\n",
                                    (float)encoding->rate.numerator/
                                    (float)encoding->rate.denominator);
                            free(name);
                        }
                        XCBXvEncodingInfoNext(&encoding_iter);
                    }
                }

                if(ImageEncodings && (ainfo->type & XCBXvTypeImageMask)) {
                    char imageName[5] = {0, 0, 0, 0, 0};
                    encoding_iter = XCBXvQueryEncodingsInfoIter(qencodings_rep);
                    for(n = 0; n < nencode; n++) {
                        encoding = encoding_iter.data;
                        name = ExtractString(XCBXvEncodingInfoName(encoding), XCBXvEncodingInfoNameLength(encoding));
                        if(!nstrcmp(name, strlen(name), "XV_IMAGE")) {
                            fprintf(stdout, 
                                    "    maximum XvImage size: %i x %i\n",	
                                    encoding->width, encoding->height);
                            break;
                        }
                        free(name);
                    }
                    XCBXvListImageFormatsRep *formats_rep;
                    formats_rep = XCBXvListImageFormatsReply(c,
                            XCBXvListImageFormats(c, ainfo->base_id),
                            NULL);

                    int numImages = formats_rep->num_formats;
                    XCBXvImageFormatInfo *format;
                    XCBXvImageFormatInfoIter formats_iter = XCBXvListImageFormatsFormatIter(formats_rep);
                    fprintf(stdout, "    Number of image formats: %i\n",
                            numImages);

                    for(n = 0; n < numImages; n++) {
                        format = formats_iter.data;
                        memcpy(imageName, &(format->id), 4);
                        fprintf(stdout, "      id: 0x%lx", format->id);
                        if(isprint(imageName[0]) && isprint(imageName[1]) &&
                                isprint(imageName[2]) && isprint(imageName[3])) 
                        {
                            fprintf(stdout, " (%s)\n", imageName);
                        } else {
                            fprintf(stdout, "\n");
                        }
                        fprintf(stdout, "        guid: ");
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[0]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[1]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[2]);
                        fprintf(stdout, "%02x-", (unsigned char) 
                                format->guid[3]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[4]);
                        fprintf(stdout, "%02x-", (unsigned char) 
                                format->guid[5]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[6]);
                        fprintf(stdout, "%02x-", (unsigned char) 
                                format->guid[7]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[8]);
                        fprintf(stdout, "%02x-", (unsigned char) 
                                format->guid[9]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[10]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[11]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[12]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[13]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[14]);
                        fprintf(stdout, "%02x\n", (unsigned char) 
                                format->guid[15]);

                        fprintf(stdout, "        bits per pixel: %i\n",
                                format->bpp);
                        fprintf(stdout, "        number of planes: %i\n",
                                format->num_planes);
                        fprintf(stdout, "        type: %s (%s)\n", 
                                (format->type == XCBXvImageFormatInfoTypeRGB) ? "RGB" : "YUV",
                                (format->format == XCBXvImageFormatInfoFormatPacked) ? "packed" : "planar");

                        if(format->type == XCBXvImageFormatInfoTypeRGB) {
                            fprintf(stdout, "        depth: %i\n", 
                                    format->depth);

                            fprintf(stdout, "        red, green, blue masks: " 
                                    "0x%lx, 0x%lx, 0x%lx\n", 
                                    format->red_mask,
                                    format->green_mask,
                                    format->blue_mask);
                        } else {

                        }
                        XCBXvImageFormatInfoNext(&formats_iter);
                    }
                    free(formats_rep);
                }
            }
            free(qencodings_rep);
            XCBXvAdaptorInfoNext(&adaptors_iter);
        }
    }

    free(adaptors_rep);
    adaptors_rep = NULL;

    return 1;
}
예제 #8
0
uint8_t Nordic::term_complete() {

  uint8_t ret_val = _SENTENCE_NONE;

  // the first term determines the sentence type
  if (_term_number == 0) {
    if (!nstrcmp(_term, _LOC_TERM))
      _sentence_type = _SENTENCE_LOC;
    else if (!nstrcmp(_term, _HRM_TERM))
      _sentence_type = _SENTENCE_HRM;
    else if (!nstrcmp(_term, _CAD_TERM))
      _sentence_type = _SENTENCE_CAD;
    else if (!nstrcmp(_term, _ANCS_TERM))
      _sentence_type = _SENTENCE_ANCS;
    else if (!nstrcmp(_term, _PC_TERM))
      _sentence_type = _SENTENCE_PC;
    else if (!nstrcmp(_term, _BTN_TERM))
      _sentence_type = _SENTENCE_BTN;
    else if (!nstrcmp(_term, _DBG_TERM))
      _sentence_type = _SENTENCE_DBG;
    else
      _sentence_type = _SENTENCE_OTHER;
    return false;
  }

  if (_sentence_type != _SENTENCE_OTHER && _term[0]) {
    // on doit parser l'info (_term)
    switch (COMBINE(_sentence_type, _term_number)) {
      case COMBINE(_SENTENCE_LOC, 1):
        _sec_jour = natol(_term);
        break;
	  case COMBINE(_SENTENCE_LOC, 2):
        _lat = parse_sint();
        break;
      case COMBINE(_SENTENCE_LOC, 3):
        _lon = parse_sint();
        break;
	  case COMBINE(_SENTENCE_LOC, 4):
        _ele = parse_sint();
        break;
	  case COMBINE(_SENTENCE_LOC, 5):
        _gps_speed = parse_sint();
        ret_val = _SENTENCE_LOC;
        break;

      case COMBINE(_SENTENCE_HRM, 1):
        _bpm = natol(_term);
        break;
      case COMBINE(_SENTENCE_HRM, 2):
        _rr = natol(_term);
        ret_val = _SENTENCE_HRM;
        break;

      case COMBINE(_SENTENCE_CAD, 1):
        _rpm = natol(_term);
        break;
      case COMBINE(_SENTENCE_CAD, 2):
        _cad_speed = natol(_term);
        ret_val = _SENTENCE_CAD;
        break;

      case COMBINE(_SENTENCE_ANCS, 1):
        _ancs_type = natol(_term);
        break;
      case COMBINE(_SENTENCE_ANCS, 2):
        if (_ancs_type == 0) {
          _ancs_msg = _term;
          ret_val = _SENTENCE_ANCS;
        } else {
          _ancs_title = _term;
        }
        break;
      case COMBINE(_SENTENCE_ANCS, 3):
        _ancs_msg = _term;
        ret_val = _SENTENCE_ANCS;
        break;
		
	  case COMBINE(_SENTENCE_DBG, 1):
        _dbg_type = natol(_term);
        break;
      case COMBINE(_SENTENCE_DBG, 2):
        _dbg_code = natol(_term);
        break;
	  case COMBINE(_SENTENCE_DBG, 3):
        _dbg_line = natol(_term);
		if (_dbg_type == 0) {
          ret_val = _SENTENCE_DBG;
        }
        break;
      case COMBINE(_SENTENCE_DBG, 4):
        if (_dbg_type == 1) {
          _dbg_file = _term;
          ret_val = _SENTENCE_DBG;
        }
        break;
      
	  case COMBINE(_SENTENCE_BTN, 1):
        _btn = natol(_term) + 1;
        ret_val = _SENTENCE_BTN;
        break;
		
      case COMBINE(_SENTENCE_PC, 1):
        _pc = natol(_term);
        ret_val = _SENTENCE_PC;
        break;
    }
  }

  return ret_val;
}
예제 #9
0
unsigned char *SaraORtn( register unsigned char *TempIndx ) {
	register short i;
	unsigned char *TempIndxm1 = TempIndx - 1;
	short SoreSeoTbLen = 6;									/* 7 - 1 */
	short OrAngTbLen = 8;									/* 9 - 1 */
	short MoreMarTbLen = 6;									/* 7 - 1 */
	short NoreNooTbLen = 1;									/* 2 - 1 */
	short ShoreChangTbLen = 3;								/* 4 - 1 */
	static char *SoreSeoTable[] = { "╩т┼╟ь", "╩т╣╟ь", "╩т╡├ь", "╩т┴╩├", "╩т╡╣", "╩тд╗", "╩т┼сб╣" };
	static char *OrAngTable[] = { "═т│╖╤┬", "═т├д┬╥", "═т╦╩╘", "═т╣к╥", "═т╖╩╨", "═т┴╦╨", "═т┼└╨", "═т┼╦╨", "═т╚б" };
	static char *MoreMarTable[] = { "┴т╦├╨╖╓б", "┴т╦├╩╛", "┴т╦╠╥├", "┴т╦├╒", "┴т╦╩╢", "┴т╣└╥╛", "┴т╣╕├├┴" };
	static char *NoreNooTable[] = { "╣т┬║╥┬", "╣т├┤┴" };
	static char *ShoreChangTable[] = { "кт┼║┼", "кт┼╕├", "кт┼┴", "кт┬" };
	static char ToreTaharnWord[] = "╖т┴╣";
	static char RoreReoWord[] = "├т╦░╥╣";
	static char YoreYakWord[] = "┬т╩";
	static char KorKaiWord[] = "вт┴┬";

	switch ( *( TempIndxm1 ) ) {
	case SoreSeo:											/* ╩т┼╟ь ╩т╣╟ь ╩т╡├ь ╩т┴╩├ ╩т╡╣ ╩тд╗ ╩т┼сб╣*/
		for ( i = 0; i <= SoreSeoTbLen; ++i ) {
			if ( !( nstrcmp( SoreSeoTable[i], TempIndxm1 ) ) ) {
				return( TempIndx - 2 );						/* cut before consonant that before Sara O */
			}
		}
		return( TempIndxm1 );								/* cut before sara O */

	case OrAng:												/* ═т│╖╤┬ ═т├д┬╥ ═т╦╩╘ ═т╣к╥ ═т╖╩╨ ═т┴╦╨ ═т┼└╨ ═т┼╦╨ ═т╚б*/
		for ( i = 0; i <= OrAngTbLen; ++i ) {
			if ( !( nstrcmp( OrAngTable[i], TempIndxm1 ) ) ) {
				return( TempIndx - 2 );						/* cut before consonant that before Sara O */
			}
		}
		return( TempIndxm1 );								/* cut before sara O */

	case MoreMar:											/* ┴т╦├╨╖╓б, ┴т╦├╩╛,┴т╦╠╥├,┴т╦├,┴т╦╩╢ */
		for ( i = 0; i <= MoreMarTbLen; ++i ) {
			if ( !( nstrcmp( MoreMarTable[i], TempIndxm1 ) ) ) {
				return( TempIndx - 2 );						/* cut before consonant that before Sara O */
			}
		}
		return( TempIndxm1 );								/* cut before sara O */

	case NoreNoo:											/* ╣т┬║╥┬ ╣т├┤┴ */
		if ( !( nstrcmp( "╣т┴", TempIndxm1 ) ) && !( istlvwl( *( TempIndx - 2 ) ) ) ) {
			if ( !( isttnl( *( TempIndx + 2 ) ) ) ) {
				return( TempIndx - 2 );						/*cut before NoreNoo */
			}
		}
		for ( i = 0; i <= NoreNooTbLen; ++i ) {
			if ( !( nstrcmp( NoreNooTable[i], TempIndxm1 ) ) ) {
				return( TempIndx - 2 );						/* cut before consonant that before Sara O */
			}
		}
		return( TempIndxm1 );								/* cut before sara O */

	case ShoreChang:										/* кт┼║┼ кт┼╕├ кт┼┴ кт┬ */
		for ( i = 0; i <= ShoreChangTbLen; ++i ) {
			if ( !( nstrcmp( ShoreChangTable[i], TempIndxm1 ) ) ) {
				return( TempIndx - 2 );						/* cut before consonant that before Sara O */
			}
		}
		return( TempIndxm1 );								/* cut before sara O */

	case ToreTaharn:										/* ╖т┴╣ */
		if ( nstrcmp( ToreTaharnWord, TempIndxm1 ) ) {
			return( TempIndxm1 );							/* cut before sara O */
		} else {
			return( TempIndx - 2 );							/* cut before consonant that before Sara O */
		}
		break;

	case RoreReo:											/* ├т╦░╥╣ */
		if ( nstrcmp( RoreReoWord, TempIndxm1 ) ) {
			return( TempIndxm1 );							/* cut before sara O */
		} else {
			return( TempIndx - 2 );							/* cut before consonant that before Sara O */
		}
		break;

	case YoreYak:											/* ┬т╩ */
		if ( nstrcmp( YoreYakWord, TempIndxm1 ) ) {
			return( TempIndxm1 );							/* cut before sara O */
		} else {
			return( TempIndx - 2 );							/* cut before consonant that before Sara O */
		}
		break;

	case KorKai:											/* вт┴┬ */
		if ( nstrcmp( KorKaiWord, TempIndxm1 ) ) {
			return( TempIndxm1 );							/* cut before sara O */
		} else {
			return( TempIndx - 2 );							/* cut before consonant that before Sara O */
		}
		break;
/*
	default:
		return( TempIndx - 1 );
*/
	}
	return( TempIndx - 1 );
}
예제 #10
0
파일: HUNAKAD.C 프로젝트: kytulendu/TW
unsigned char *HunAkadRtn( register unsigned char *TempIndx ) {
    register unsigned char *plus1 = TempIndx + 1;
    register unsigned char *minus2 = TempIndx - 2;

    if ( plus1 <= RightMargin ) {
        switch ( *( plus1 ) ) {
        case KoreGai:
            if ( findchar( *( TempIndx - 1 ), "¡§ª«´µ¶º»¿ÁÇË" ) ) {
                return( plus1 );
            }
            break;
        case NgorNgoo:
            switch ( *( TempIndx - 1 ) ) {
            case SoreSeo:
                if ( *( TempIndx + 2 ) != KorKai && *( TempIndx + 2 ) != KoreRakung ) {
                    return( plus1 );
                }
                break;
            case RoreReo:
                if ( !nstrcmp( "¡Ãѧ´ì", minus2 ) ) {
                    return( TempIndx - 3 );
                } else {
                    return( plus1 );
                }
            default:
                return( plus1 );
            }
            break;
        case DoreDek:
            return( plus1 );
        case NoreNoo:
            if ( *( TempIndx + 3 ) != Karan ) {
                return( plus1 );
            }
            break;
        case YoreYak:
            if ( !nstrcmp( "¹Ñ¹ì", TempIndx - 1 ) ) {
                return( minus2 );
            } else {
                return( plus1 );
            }
        case SoreSeo:
            if ( *( TempIndx + 4 ) != Karan ) {
                return( plus1 );
            }
            break;
        case WoreWaan:
            switch ( *( TempIndx + 2 ) ) {
            case SaraAh:
                if ( TempIndx + 2 <= RightMargin ) {
                    return( TempIndx + 2 );
                }
                break;
            case RoreReo:
                if ( *( TempIndx + 3 ) == Karan ) {
                    return( minus2 );
                }
                break;
            default:
                return( plus1 );
            }
            break;
        default:
            if ( isttnl( *( plus1 ) ) ) {
                if ( *( TempIndx + 4 ) == Karan ) {
                    return( minus2 );
                } else {
                    if ( TempIndx + 2 <= RightMargin ) {
                        return( TempIndx + 2 );
                    }
                }
            }
        }

        switch ( *( TempIndx - 1 ) ) {
        case NgorNgoo:
            return( plus1 );
        case NoreNoo:
            if ( !findchar( *( plus1 ), "µ¹Â" ) ) {
                return( plus1 );
            }
            break;
        case MoreMar:
            if ( !findchar( *( plus1 ), "¤¹Ç" ) ) {
                return( plus1 );
            }
            break;
        case RoreReo:
            if ( !findchar( *( plus1 ), "¡µ¾È" ) ) {
                return( plus1 );
            }
            break;
        case HorHeeb:
            if ( *( plus1 ) != ToreTao && *( plus1 ) != NoreNoo ) {
                return( plus1 );
            }
            break;
        case HorNokHook:
            return( plus1 );
        }
    }

    if ( findchar( *( TempIndx - 1 ), "¢¤¦ª«­±³¶¸»¼½¾¿ÈÊÍÎ" ) ) {
        return( minus2 );
    } else {
        switch ( *( TempIndx - 1 ) ) {
        case KoreGai:
            return( *minus2 == SoreSeo ? FAIL : minus2 );
        case NgorNgoo:
            switch ( *minus2 ) {
            case HorHeeb:
                return( TempIndx - 3 );
            case SoreSeo:
                return( FAIL );
            default:
                return( minus2 );
            }
        case JoreJarn:
            return( ( *minus2 == KorKai ) ? FAIL : minus2 );
        case DoreDek:
            return( ( *minus2 == SoreSeo ) ? FAIL : minus2 );
        case ToreTao:
            return( ( *minus2 == KoreGai ) ? FAIL : minus2 );
        case ToreTaharn:
            switch ( *minus2 ) {
            case HorHeeb:
                return( TempIndx - 3 );
            case WoreWaan:
                return( FAIL );
            default:
                return( minus2 );
            }
        case BoreBaimai:
            return( ( *minus2 == ChorChing ) ? TempIndx - 3 : minus2 );
        case PoreSumpao:
            return( ( *minus2 == OrAng ) ? FAIL : minus2 );
        case WoreWaan:
            return( findchar( *minus2, "¡¢¤¨©µ¶¸ÊË" ) ? FAIL : minus2 );
        case HorHeeb:
            return( findchar( *minus2, "ÁÃÍ" ) ? FAIL : minus2 );
        }
    }
    return( FAIL );
}
예제 #11
0
파일: inout.c 프로젝트: rossetd0/porta
int read_input_file( char *fname, FILE *outfp, int *dim, RAT **ar, int *nel_ar, 
                     char *intkey1, int **intli1, char *intkey2, int **intli2,
                     char *RATkey1, RAT **RATli1 )
/*****************************************************************/
/*
 * Read the dimension "dim",
 * a table "ar" of points (in case of a .poi file), 
 * or of inequalities (in case of a .ieq file),
 * a line "intli1" of integers occurring after keyword "intkey1",
 * a line "intli2" of integers occurring after keyword "intkey2",
 * a line "RATli1" of rationals occurring after keyword "RATkey1".
 * "ar6" is a point that is output in the VALID section in the .ieq file.
 * 
 * Change by M.S. 5.6.92:
 * If "outfp" exists (e.g. if is_set(Sort)),
 * copy the input file into outfp, 
 * except for the INEQUALITIES_SECTION, the CONV_SECTION, and the CONE_SECTION,
 * and END.
 */
{
    int i,j,ieqs,nonempty,arrows=0,arrowl=0,cone = 0,conv = 0,line;
    int *hip;
    char *in,*end = "END",
    equalities[22],
    convstr[13],conestr[13],key_eli[18],key_val[6],key_low[13],key_upp[13], 
    *comm = "COMMENT" ;
    char scanned_inline[MAXLINE];
    char in_line[MAXLINE];
    RAT val;

    line = 0;
    strcpy (equalities,"INEQUALITIES_SECTION");
    strcpy (convstr,"CONV_SECTION");
    strcpy (conestr,"CONE_SECTION");
    strcpy (key_eli,"ELIMINATION_ORDER");
    strcpy (key_val,"VALID");
    strcpy (key_upp,"UPPER_BOUNDS");
    strcpy (key_low,"LOWER_BOUNDS");
    fp = fopen(fname,"r");
    if (fp == 0)
        msg( "%s : no such file", fname, 0 );
    
    /* 
     * Read the first line into string "in_line". Leading blanks are skipped.
     * In_Line should start with "DIM=".
     */
    
    do 
    {
        nonempty = get_line(fp,fname,in_line,&line );
    } 
    while (!nonempty);
    
    scan_line(&val,3,0,line,fname,in_line,scanned_inline);
    if (strncmp(scanned_inline,"DIM=",4) == 0) 
    {
        in = scanned_inline+4;
        *dim = atoi(in);
        if (*dim == 0) 
            msg("%s, line %i : dimension error",fname,line);
        if (outfp) 
        {
            fprintf(outfp,"%s",in_line);

            /* 17.01.1994: include logging on file porta.log */
            porta_log( "%s",in_line);
        }
    }
    ieqs = (strcmp(fname+strlen(fname)-4,".ieq") == 0);
    if( ieqs ) 
    {
        equa = ineq = 0;
        convstr[0] = conestr[0] = '\n';
        arrowl = *dim+2;
        if (!strcmp(intkey1,"ELIMINATION_ORDER") || !strcmp(intkey2,"ELIMINATION_ORDER"))
            key_eli[0] =  '\n'; 
        if (!strcmp(intkey1,"LOWER_BOUNDS") || !strcmp(intkey2,"LOWER_BOUNDS"))
            key_low[0] =  '\n'; 
        if (!strcmp(intkey1,"UPPER_BOUNDS") || !strcmp(intkey2,"UPPER_BOUNDS"))
            key_upp[0] =  '\n'; 
        if (!strcmp(RATkey1,"VALID"))
            key_val[0] =  '\n'; 
    }
    else 
    {
        /* 
         * key_eli, key_low, key_upp, and key_val are set to 0,
         * if they already appear as input parameters to this subroutine.
         * In this way, if e.g. the keyword "VALID" is encountered twice in the 
         * input file, an error message is produced.
         * "convstr" and "conestr" are set to "\n",
         * so that the keywords "CONV_SECTION" and "CONE_SECTION" 
         * result in an error message, if they appear in the .ieq file.
         */
        cone = conv = 0;
        key_val[0] = key_upp[0] = key_low[0] = key_eli[0] = equalities[0] = '\n';
        arrowl = *dim+1;
    }
    
    /* 
     * ar6 is initialized to 0.
     * It is overwritten by a point in the CONV_SECTION,
     * or by a point in the VALID section.
     */
    ar6 = (RAT *) RATallo(ar6,0,*dim);
    for (j = 0; j < *dim; j++) 
    {
        ar6[j].num = 0;
        ar6[j].den.i = 1;
    }
    
    /* Read the next line into string "in_line" and scan it */
    nonempty = get_line(fp,fname,in_line,&line );
    scan_line(&val,3,0,line,fname,in_line,scanned_inline);
    do 
    {
        if (!nonempty) 
        {
            if(outfp)
            {
                fprintf(outfp,"%s",in_line);
                
                /* 17.01.1994: include logging on file porta.log */
                porta_log( "%s",in_line);
            }
            nonempty = get_line(fp,fname,in_line,&line);
            scan_line(&val,3,0,line,fname,in_line,scanned_inline);
        }
        else if (strncmp(scanned_inline,comm,7) == 0) 
        {
            /*
             * Overread keyword COMMENT and all following lines,
             * until the next keyword (i.e. one of the arguments of nstrcmp() ) 
             * is encountered.
             */
            do 
            {
                if(outfp)
                { 
                    fprintf(outfp,"%s",in_line);
                    
                    /* 17.01.1994: include logging on file porta.log */
                    porta_log( "%s",in_line);
                }
                nonempty = get_line(fp,fname,in_line,&line);
                scan_line(&val,3,0,line,fname,in_line,scanned_inline);
            } 
            while (nstrcmp(scanned_inline,conestr,equalities,end,
             intkey1,intkey2,RATkey1,convstr) || !nonempty);
        }
        else if (strcmp(scanned_inline,RATkey1) == 0) 
        {
            /*
             * If the keyword RATkey1 is encountered,
             * read the next line of "dim" rationals into array RATli1.
             * RATkey1 is "VALID" for "traf *.ieq" applications.
             */
            if(outfp)
            { 
                fprintf(outfp,"%s",in_line);
            
                /* 17.01.1994: include logging on file porta.log */
                porta_log( "%s",in_line);
            }
            /*
               When calling read_input_file, RATkey1 is always
               assigned to a const argument (string).
               Therefore it isn't allowed to assign new
               values to this argument. By the way, this
               statement causes a bus error on some architectures
               like the HP!
               18.01.1994, Andreas Loebel
               RATkey1[0] = '\n';
               *RATli1 = (RAT *) RATallo(*RATkey1,0,*dim);
               */
            *RATli1 = (RAT *) RATallo(CP 0,0,*dim);
            do 
            {
                nonempty = get_line(fp,fname,in_line,&line);
                if(outfp)
                {
                    fprintf(outfp,"%s",in_line);

                    /* 17.01.1994: include logging on file porta.log */
                    porta_log( "%s",in_line);
                }
            } 
            while (!nonempty);
            scan_line(*RATli1,1,*dim,line,fname,in_line,scanned_inline);
            nonempty = get_line(fp,fname,in_line,&line);
            scan_line(&val,3,0,line,fname,in_line,scanned_inline);
        }
        else if (strcmp(scanned_inline,key_val) == 0) 
        {
            /*
             * keyval[0] == "VALID", iff
             * Ratkey1 was not "VALID" at the start of function read_input_file()
             * Otherwise keyval[0] = '\n'
             * --> "VALID" is accepted as a keyword at most once.
             */
            if(outfp)
            { 
                fprintf(outfp,"%s",in_line);
                
                /* 17.01.1994: include logging on file porta.log */
                porta_log( "%s",in_line);
            }
            key_val[0] = '\n';
            /* 
             * Change by M.S.: "ar6" was already allocated earlier,
             * and it is never freed in this loop.
             ar6 = (RAT *) RATallo(ar6,0,*dim);
             */
            do 
            {
                nonempty = get_line(fp,fname,in_line,&line);
                if(outfp)
                {
                    fprintf(outfp,"%s",in_line);

                    /* 17.01.1994: include logging on file porta.log */
                    porta_log( "%s",in_line);
                }
            } 
            while (!nonempty);
            scan_line(ar6,1,*dim,line,fname,in_line,scanned_inline);
            nonempty = get_line(fp,fname,in_line,&line);
            scan_line(&val,3,0,line,fname,in_line,scanned_inline);
            /* change by M.S. 31.5.92: 
             * "ar6" is also used when reading the CONV_SECTION, so don't free it.
             ar6 = (RAT *) RATallo(ar6,*dim,0);
             */
        }
        else if (strcmp(scanned_inline,intkey1) == 0) 
        {
            if(outfp)
            { 
                fprintf(outfp,"%s",in_line);
            
                /* 17.01.1994: include logging on file porta.log */
                porta_log( "%s",in_line);
            }
            intkey1[0] = '\n';
            *intli1 = (int *) allo(*intli1,0,*dim*sizeof(int));
            do 
            {
                nonempty = get_line(fp,fname,in_line,&line);
                if(outfp)
                { 
                    fprintf(outfp,"%s",in_line);
                
                    /* 17.01.1994: include logging on file porta.log */
                    porta_log( "%s",in_line);
                }
            } 
            while (!nonempty);
            scan_line((RAT *)*intli1,2,*dim,line,fname,in_line,scanned_inline);
            nonempty = get_line(fp,fname,in_line,&line);
            scan_line(&val,3,0,line,fname,in_line,scanned_inline);
        }
        else if (strcmp(scanned_inline,intkey2) == 0) 
        {
            if(outfp)
            { 
                fprintf(outfp,"%s",in_line);

                /* 17.01.1994: include logging on file porta.log */
                porta_log( "%s",in_line);
            }
            intkey2[0] = '\n';
            *intli2 = (int *) allo(*intli2,0,*dim*sizeof(int));
            do 
            {
                nonempty = get_line(fp,fname,in_line,&line);
                if(outfp)
                { 
                    fprintf(outfp,"%s",in_line);

                    /* 17.01.1994: include logging on file porta.log */
                    porta_log( "%s",in_line);
                }
            } 
            while (!nonempty);
            scan_line((RAT *)*intli2,2,*dim,line,fname,in_line,scanned_inline);
            nonempty = get_line(fp,fname,in_line,&line);
            scan_line(&val,3,0,line,fname,in_line,scanned_inline);
        }
        else if (!strcmp(scanned_inline,key_eli) 
                 || !strcmp(scanned_inline,key_low) 
                 || !strcmp(scanned_inline,key_upp) ) 
        {
            /*
             * array "hip" is just a temporary array.
             */
            if(outfp)
            { 
                fprintf(outfp,"%s",in_line);
                
                /* 17.01.1994: include logging on file porta.log */
                porta_log( "%s",in_line);
            }
            if (!strcmp(scanned_inline,key_eli))   key_eli[0] = '\n';
            if (!strcmp(scanned_inline,key_low))   key_low[0] = '\n';
            if (!strcmp(scanned_inline,key_upp))   key_upp[0] = '\n';
            hip = (int *) allo(CP 0,0,*dim*sizeof(int));
            do 
            {
                nonempty = get_line(fp,fname,in_line,&line);
                if(outfp)
                { 
                    fprintf(outfp,"%s",in_line);
                    
                    /* 17.01.1994: include logging on file porta.log */
                    porta_log( "%s",in_line);
                }
            } 
            while (!nonempty);
            scan_line((RAT *)hip,2,*dim,line,fname,in_line,scanned_inline);
            nonempty = get_line(fp,fname,in_line,&line);
            scan_line(&val,3,0,line,fname,in_line,scanned_inline);
            hip = (int *) allo(hip,*dim*sizeof(int),0);
        }
        else if (strcmp(scanned_inline, convstr) == 0) 
        {
            /* 
             * Read the CONV_SECTION into array "ar".
             * For all points j=1,...,conv in the CONV_SECTION, 
             * ar[j-1][dim] is set to 1.
             * "arrowl" was set to dim+1 earlier.
             */
            convstr[0] = '\n';
            *ar = (RAT *) RATallo(*ar,arrows*arrowl,
                                  (arrows+INCR_INSYS_ROW)*arrowl);
            arrows += INCR_INSYS_ROW;
            do 
            {
                nonempty = get_line(fp,fname,in_line,&line);
            } 
            while (!nonempty);
            while (scan_line(*ar+(conv+cone)*arrowl,0,*dim,line,fname,
                             in_line,scanned_inline)) 
            {
                (*ar+(conv+cone)*arrowl+*dim)->num = 1;
                if (conv+cone+2 > arrows) 
                {
                    *ar = (RAT *) RATallo(*ar,arrows*arrowl,
                                    (arrows+INCR_INSYS_ROW)*arrowl);
                    arrows += INCR_INSYS_ROW;
                }
                do 
                {
                    nonempty = get_line(fp,fname,in_line,&line);
                } 
                while (!nonempty);
                conv++;
            }
            /* repeat the last point in array "ar6" */
            for (j = 0; j < *dim; j++)
                ar6[j] = (*ar+(conv+cone-1)*arrowl)[j];
        }
        else if ((strcmp(scanned_inline, conestr) == 0)) 
        {
            /* 
             * Read the CONE_SECTION
             * ar[j-1][dim] is initialized by RATallo to 0.
             */
            conestr[0] = '\n';
            *ar = (RAT *) RATallo(*ar,arrows*arrowl,
                                  (arrows+INCR_INSYS_ROW)*arrowl);
            arrows += INCR_INSYS_ROW;
            do 
            {
                nonempty = get_line(fp,fname,in_line,&line);
            } 
            while (!nonempty);
            while (scan_line(*ar+(conv+cone)*arrowl,0,*dim,line,fname,
                             in_line,scanned_inline)) 
            {
                if (conv+cone+2 > arrows) 
                {
                    *ar = (RAT *) RATallo(*ar,arrows*arrowl,
                                          (arrows+INCR_INSYS_ROW)*arrowl);
                    arrows += INCR_INSYS_ROW;
                }
                do 
                {
                    nonempty = get_line(fp,fname,in_line,&line);
                } 
                while (!nonempty);
                cone++;
            }
        }
        else if ( (strcmp(scanned_inline, equalities) == 0)) 
        {
            /*
             * Read the INEQUALITIES_SECTION
             * "arrowl" was set to dim+2 earlier.
             */
            equalities[0] = '\n';      
            *ar = (RAT *) RATallo(*ar,arrows*arrowl,
                                  (arrows+INCR_INSYS_ROW)*arrowl);
            arrows += INCR_INSYS_ROW;
            read_eqie(ar,*dim,&equa,&ineq,&arrows,&line,
                      fname,in_line,scanned_inline);
            nonempty = 1;
        }
        else if (strcmp(scanned_inline,end) == 0)
        {
            i =  (ieqs) ? equa+ineq : conv+cone;
            
            *nel_ar = (i+1)*arrowl;
            
            *ar = (RAT *) RATallo(*ar,arrows*arrowl,*nel_ar);
            
            fclose(fp);
            
            fprintf(prt,"input file %s o.k.\n",fname);
            fprintf(prt,  "dimension              : %4i \n",*dim);

            /* 17.01.1994: include logging on file porta.log */
            porta_log( "input file %s o.k.\n",fname);
            porta_log( "dimension              : %4i \n",*dim);

            if (ieqs) 
            {
                fprintf(prt,"number of equations    : %4i \n",equa);
                fprintf(prt,"number of inequalities : %4i \n\n",ineq);

                /* 17.01.1994: include logging on file porta.log */
                porta_log( "number of equations    : %4i \n",equa);
                porta_log( "number of inequalities : %4i \n\n",ineq);
            }
            else 
            {
                fprintf(prt,"number of cone-points  : %4i \n",cone);
                fprintf(prt,"number of conv-points  : %4i \n\n",conv);

                /* 17.01.1994: include logging on file porta.log */
                porta_log( "number of cone-points  : %4i \n",cone);
                porta_log( "number of conv-points  : %4i \n\n",conv);
            }
            
            return (i);
            
        }
        
        else
            msg("%s, line %i : invalid format",fname,line);
        
    } 
    while (1);
    
}