<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic some questions about a C program in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994877#M718503</link>
    <description>here is a short C program to return the boot_string from the running kernel. &lt;BR /&gt;&lt;BR /&gt;1) being I'm not a C programmer, I'm looking for suggestions for improvements. &lt;BR /&gt;&lt;BR /&gt;2) &lt;BR /&gt;&lt;BR /&gt;a) how would i implement the ioctl statement if I had defined FILE *fp; instead of int fp; and used fopen and fclose. ie ioctl takes an int fildes. &lt;BR /&gt;&lt;BR /&gt;b) how do you assign values using a pointer to a structure, ie how would you correctly do what I was trying to do in the comments. &lt;BR /&gt;&lt;BR /&gt;3) my boot string is disk(8/0/19/0.6.0.0.0.0.0;0)/stand/vmunix. in C code how would i just get the "/stand/vmunix" portion. &lt;BR /&gt;&lt;BR /&gt;4) can some whizbang perl wizard do this using perl?  shouldn't be too hard. define a structure, assign vaules to the structure, open kmem, call ioctl, close kmem, parse the results, print out the kernel file name.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt; &lt;BR /&gt;#include &lt;SYS&gt; &lt;BR /&gt;#include &lt;SYS&gt; &lt;BR /&gt;#include &lt;LIBELF.H&gt; &lt;BR /&gt;&lt;BR /&gt;int main(void){ &lt;BR /&gt;struct mioc_rksym abc, *rks = &amp;amp;abc; &lt;BR /&gt;char buf[1024]; &lt;BR /&gt;int fp; &lt;BR /&gt;&lt;BR /&gt;if (( fp = open("/dev/kmem",O_RDONLY)) == NULL ) { &lt;BR /&gt;printf("kmem could not be opened\n); &lt;BR /&gt;exit(1); &lt;BR /&gt;} &lt;BR /&gt;abc.mirk_modname=NULL; &lt;BR /&gt;abc.mirk_sysname="boot_string"; &lt;BR /&gt;abc.mirk_buf=buf; &lt;BR /&gt;abc.mirk_buflen=1023; &lt;BR /&gt;/* &lt;BR /&gt;rks-&amp;gt;mirk_modename=NULL; &lt;BR /&gt;rks-&amp;gt;mirk_sysname="boot_string"; &lt;BR /&gt;rks-&amp;gt;mirk_buf=buf; &lt;BR /&gt;rks-&amp;gt;mirk_buflen=1023; &lt;BR /&gt;*/ &lt;BR /&gt;&lt;BR /&gt;if ( ioctl( fp, MIOC_READKSYM, *rks) != 0 ) { &lt;BR /&gt;perror("ioctl"); &lt;BR /&gt;return -1; &lt;BR /&gt;} &lt;BR /&gt;printf("%s"\n",rks-&amp;gt;mirk_buf); &lt;BR /&gt;if (close(fp) == EOF) &lt;BR /&gt;printf("kmem could not be closed\n"); &lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;to compile &lt;BR /&gt;&lt;BR /&gt;cc file.c -o ofile&lt;/LIBELF.H&gt;&lt;/SYS&gt;&lt;/SYS&gt;&lt;/STDIO.H&gt;</description>
    <pubDate>Wed, 11 Jun 2003 15:33:25 GMT</pubDate>
    <dc:creator>curt larson_1</dc:creator>
    <dc:date>2003-06-11T15:33:25Z</dc:date>
    <item>
      <title>some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994877#M718503</link>
      <description>here is a short C program to return the boot_string from the running kernel. &lt;BR /&gt;&lt;BR /&gt;1) being I'm not a C programmer, I'm looking for suggestions for improvements. &lt;BR /&gt;&lt;BR /&gt;2) &lt;BR /&gt;&lt;BR /&gt;a) how would i implement the ioctl statement if I had defined FILE *fp; instead of int fp; and used fopen and fclose. ie ioctl takes an int fildes. &lt;BR /&gt;&lt;BR /&gt;b) how do you assign values using a pointer to a structure, ie how would you correctly do what I was trying to do in the comments. &lt;BR /&gt;&lt;BR /&gt;3) my boot string is disk(8/0/19/0.6.0.0.0.0.0;0)/stand/vmunix. in C code how would i just get the "/stand/vmunix" portion. &lt;BR /&gt;&lt;BR /&gt;4) can some whizbang perl wizard do this using perl?  shouldn't be too hard. define a structure, assign vaules to the structure, open kmem, call ioctl, close kmem, parse the results, print out the kernel file name.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt; &lt;BR /&gt;#include &lt;SYS&gt; &lt;BR /&gt;#include &lt;SYS&gt; &lt;BR /&gt;#include &lt;LIBELF.H&gt; &lt;BR /&gt;&lt;BR /&gt;int main(void){ &lt;BR /&gt;struct mioc_rksym abc, *rks = &amp;amp;abc; &lt;BR /&gt;char buf[1024]; &lt;BR /&gt;int fp; &lt;BR /&gt;&lt;BR /&gt;if (( fp = open("/dev/kmem",O_RDONLY)) == NULL ) { &lt;BR /&gt;printf("kmem could not be opened\n); &lt;BR /&gt;exit(1); &lt;BR /&gt;} &lt;BR /&gt;abc.mirk_modname=NULL; &lt;BR /&gt;abc.mirk_sysname="boot_string"; &lt;BR /&gt;abc.mirk_buf=buf; &lt;BR /&gt;abc.mirk_buflen=1023; &lt;BR /&gt;/* &lt;BR /&gt;rks-&amp;gt;mirk_modename=NULL; &lt;BR /&gt;rks-&amp;gt;mirk_sysname="boot_string"; &lt;BR /&gt;rks-&amp;gt;mirk_buf=buf; &lt;BR /&gt;rks-&amp;gt;mirk_buflen=1023; &lt;BR /&gt;*/ &lt;BR /&gt;&lt;BR /&gt;if ( ioctl( fp, MIOC_READKSYM, *rks) != 0 ) { &lt;BR /&gt;perror("ioctl"); &lt;BR /&gt;return -1; &lt;BR /&gt;} &lt;BR /&gt;printf("%s"\n",rks-&amp;gt;mirk_buf); &lt;BR /&gt;if (close(fp) == EOF) &lt;BR /&gt;printf("kmem could not be closed\n"); &lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;to compile &lt;BR /&gt;&lt;BR /&gt;cc file.c -o ofile&lt;/LIBELF.H&gt;&lt;/SYS&gt;&lt;/SYS&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Wed, 11 Jun 2003 15:33:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994877#M718503</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-06-11T15:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994878#M718504</link>
      <description>Hi Curt:&lt;BR /&gt;&lt;BR /&gt;Why not(?):&lt;BR /&gt;&lt;BR /&gt;# echo boot_string/S|adb /stand/vmunix /dev/mem&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 11 Jun 2003 15:39:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994878#M718504</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-06-11T15:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994879#M718505</link>
      <description>2a) use fileno() on a file&lt;BR /&gt;pointer to get the&lt;BR /&gt;associated file descriptor:&lt;BR /&gt;&lt;BR /&gt;FILE *fp;&lt;BR /&gt;fd = fileno(fp);&lt;BR /&gt;&lt;BR /&gt;Then you can pass fd to&lt;BR /&gt;ioctl().&lt;BR /&gt;&lt;BR /&gt;2b) AFAICT your commented&lt;BR /&gt;code should work, except&lt;BR /&gt;that you wrote "modename"&lt;BR /&gt;instead of "modname".  You&lt;BR /&gt;also appear to be missing&lt;BR /&gt;some quotation marks here&lt;BR /&gt;and there, but I assume&lt;BR /&gt;those are transmission&lt;BR /&gt;errors.&lt;BR /&gt;&lt;BR /&gt;3) Unless there's a more&lt;BR /&gt;precise way to get the&lt;BR /&gt;kernel file, perhaps you&lt;BR /&gt;could use strchr() to find&lt;BR /&gt;the ')' and do some string&lt;BR /&gt;ops on it:&lt;BR /&gt;&lt;BR /&gt;c = strchr(mirk_buf, ')');&lt;BR /&gt;c = '\0';&lt;BR /&gt;c++;&lt;BR /&gt;printf("kernel is %s\n", c);&lt;BR /&gt;&lt;BR /&gt;4) Unless there's a Perl&lt;BR /&gt;module that provides a nice high-level method for&lt;BR /&gt;doing what you want, the&lt;BR /&gt;equivalent Perl code won't&lt;BR /&gt;be any easier than the C&lt;BR /&gt;code.  You'll still have to&lt;BR /&gt;do the ioctl() stuff, but&lt;BR /&gt;with the added complication&lt;BR /&gt;of having to use pack() and&lt;BR /&gt;unpack() to write and read&lt;BR /&gt;(respectively) the elements&lt;BR /&gt;of the struct.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Jun 2003 16:10:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994879#M718505</guid>
      <dc:creator>Gregory Fruth</dc:creator>
      <dc:date>2003-06-11T16:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994880#M718506</link>
      <description>Oops, part 3 should be more&lt;BR /&gt;like this:&lt;BR /&gt;&lt;BR /&gt;char *c;&lt;BR /&gt;c = strchr(mirk_buf, ')');&lt;BR /&gt;c++;&lt;BR /&gt;printf("kernel is %s\n", c);</description>
      <pubDate>Wed, 11 Jun 2003 16:18:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994880#M718506</guid>
      <dc:creator>Gregory Fruth</dc:creator>
      <dc:date>2003-06-11T16:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994881#M718507</link>
      <description>james,&lt;BR /&gt;&lt;BR /&gt;because I want to know the name of the file that is the currently running kerenl.&lt;BR /&gt;&lt;BR /&gt;your method only works if /stand/vmunix is the current kernel. And, if i already knew that /stand/vmunix was the kernel, I wouldn't need to do it at all.</description>
      <pubDate>Wed, 11 Jun 2003 16:33:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994881#M718507</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-06-11T16:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994882#M718508</link>
      <description>Mr. Fruth,&lt;BR /&gt;&lt;BR /&gt;thanks for all the feedback.&lt;BR /&gt;&lt;BR /&gt;AFAICT? i'm not sure what that means.&lt;BR /&gt;&lt;BR /&gt;2b) modename was a typo.&lt;BR /&gt;&lt;BR /&gt;there is an extra " typo in one of the printfs but other then that this is it.  it does compile. but if you think some are missing, I'd like to know.&lt;BR /&gt;&lt;BR /&gt;if&lt;BR /&gt;struct mioc_rksym abc, *rks = &amp;amp;abc; &lt;BR /&gt;becomes just&lt;BR /&gt;struct mioc_rksym *rks; &lt;BR /&gt;take out all the abc stuff&lt;BR /&gt;and just do &lt;BR /&gt;rks-&amp;gt;mirk_sysname="boot_string"; &lt;BR /&gt;the program gets a bus error coredump at the assignment.&lt;BR /&gt;&lt;BR /&gt;thanks again&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Jun 2003 16:53:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994882#M718508</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-06-11T16:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994883#M718509</link>
      <description>Mr. Fruth,&lt;BR /&gt;&lt;BR /&gt;added your&lt;BR /&gt;&lt;BR /&gt;char *c; &lt;BR /&gt;c = strchr(mirk_buf, ')'); &lt;BR /&gt;c++; &lt;BR /&gt;printf("kernel is %s\n", c); &lt;BR /&gt;&lt;BR /&gt;code and it works very well.&lt;BR /&gt;&lt;BR /&gt;I do get one of those pesky Integral value implictly converted to a pointer in assignment compiler warnings for the pointer arithmetic. &lt;BR /&gt;&lt;BR /&gt;if it isn't too much trouble, how would I do this such that there isn't a warning message?&lt;BR /&gt;&lt;BR /&gt;and i do hope you reply, as with 4 questions you should get 4x the points</description>
      <pubDate>Wed, 11 Jun 2003 17:22:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994883#M718509</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-06-11T17:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994884#M718510</link>
      <description>You had a few problems:&lt;BR /&gt;&lt;BR /&gt;open() == NULL could be a good result because 0 is a valid file descrirptor.&lt;BR /&gt;&lt;BR /&gt;Your pointer assignments should work but you really don't need a pointer - just pass the address of abc into the function. The hard coding of the size is VERY BAD FORM - that's what sizeof is for -  so that buf and it's size always track each other.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;fileno(fp) will return the file descriptor but real C programmers don't use *FILE's but instead use the file descriptors (at least for ioctl() stuff)&lt;BR /&gt;&lt;BR /&gt;I spent about 3 minutes cleaning up your code and returning everything past the ')' - if found.&lt;BR /&gt;&lt;BR /&gt;You might look at CPAN to see if theres a module but I wouldn't use Perl to a walking through kmem; it would be much to easy to accidently incude a print and write to /dev/kmem with possibly disasterous results.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Jun 2003 17:34:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994884#M718510</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-06-11T17:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994885#M718511</link>
      <description>Thanks a lot for the rewrite Clay.  that is a 50 point answer if there was one. 3 minutes, that is some fast typing.&lt;BR /&gt;&lt;BR /&gt;would you happen to have a recomendation on the size to use for buf, ie what is the maximum length that the boot string can be?</description>
      <pubDate>Wed, 11 Jun 2003 19:36:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994885#M718511</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-06-11T19:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994886#M718512</link>
      <description>The correct answer is to replace your 1024 with MAXSYMNMLEN (which is acually 1024 undex 11.x but might change with a patch or OS upgrade) define found in sys/ksym.h.&lt;BR /&gt;&lt;BR /&gt;The only other change (and this is nit-picky) is to add an #include &lt;UNISTD.H&gt; so that close() has a prototype.&lt;BR /&gt;It will make lint a little happier.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/UNISTD.H&gt;</description>
      <pubDate>Wed, 11 Jun 2003 20:00:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994886#M718512</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-06-11T20:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994887#M718513</link>
      <description>one last question.  how would you print out the value of a kernel symbol that was a number?   such as iticks_per_tick, which ends up in the first 4 elements of the array buf. buf is an character array. iticks_per_tick is a 32 bit integer.&lt;BR /&gt;&lt;BR /&gt;what i did was&lt;BR /&gt;long * lg = (long *) buf;&lt;BR /&gt;printf("%d\n",*lg);&lt;BR /&gt;&lt;BR /&gt;is there a better method of doing this?</description>
      <pubDate>Thu, 12 Jun 2003 07:54:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994887#M718513</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-06-12T07:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994888#M718514</link>
      <description>Well, your method works but it wouldn't work in all cases.&lt;BR /&gt;&lt;BR /&gt;The ioctl call places the data into buf - which fortunately starts on a word boundary. You assignment method works fine in that case but if you had to move from starting at buf[1] to an int or a double then you might have problems. In that case, you would use memcpy.&lt;BR /&gt;&lt;BR /&gt;Note the mirk_buf is really a void * - meaning that it can accept any type. Rigorously,&lt;BR /&gt;you should have&lt;BR /&gt;&lt;BR /&gt;abc.mirk_buf = (void *) buf;&lt;BR /&gt;abc.mirk_buflen = sizeof(buf);&lt;BR /&gt;/* you don't really need to subtract 1 because the terminal '\0' is taken into account. */&lt;BR /&gt;&lt;BR /&gt;For a long;&lt;BR /&gt;long tmp_long = 0L;&lt;BR /&gt;abc.mirk_buf = (void *) &amp;amp;tmp_long;&lt;BR /&gt;abc.mirk_buflen = sizeof(tmp_long);&lt;BR /&gt;&lt;BR /&gt;Ideally, you should modify your code to accept command line args which identify the desired variable and it's type and then you have a flexible solution with a switch{ } to handle the various variable types.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Jun 2003 15:01:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994888#M718514</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-06-12T15:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994889#M718515</link>
      <description>Well, your method works but it wouldn't work in all cases.&lt;BR /&gt;&lt;BR /&gt;The ioctl call places the data into buf - which fortunately starts on a word boundary. You assignment method works fine in that case but if you had to move from starting at buf[1] to an int or a double then you might have problems. In that case, you would use memcpy.&lt;BR /&gt;&lt;BR /&gt;Note the mirk_buf is really a void * - meaning that it can accept any type. Rigorously,&lt;BR /&gt;you should have&lt;BR /&gt;&lt;BR /&gt;abc.mirk_buf = (void *) buf;&lt;BR /&gt;abc.mirk_buflen = sizeof(buf);&lt;BR /&gt;/* you don't really need to subtract 1 because the terminal '\0' is taken into account. */&lt;BR /&gt;&lt;BR /&gt;For a long;&lt;BR /&gt;long tmp_long = 0L;&lt;BR /&gt;abc.mirk_buf = (void *) &amp;amp;tmp_long;&lt;BR /&gt;abc.mirk_buflen = sizeof(tmp_long);&lt;BR /&gt;&lt;BR /&gt;Ideally, you should modify your code to accept command line args which identify the desired variable and it's type and then you have a flexible solution with a switch{ } to handle the various variable types.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Jun 2003 15:01:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994889#M718515</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-06-12T15:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994890#M718516</link>
      <description>Well, your method works but it wouldn't work in all cases.&lt;BR /&gt;&lt;BR /&gt;The ioctl call places the data into buf - which fortunately starts on a word boundary. You assignment method works fine in that case but if you had to move from starting at buf[1] to an int or a double then you might have problems. In that case, you would use memcpy.&lt;BR /&gt;&lt;BR /&gt;Note the mirk_buf is really a void * - meaning that it can accept any type. Rigorously,&lt;BR /&gt;you should have&lt;BR /&gt;&lt;BR /&gt;abc.mirk_buf = (void *) buf;&lt;BR /&gt;abc.mirk_buflen = sizeof(buf);&lt;BR /&gt;/* you don't really need to subtract 1 because the terminal '\0' is taken into account. */&lt;BR /&gt;&lt;BR /&gt;For a long;&lt;BR /&gt;long tmp_long = 0L;&lt;BR /&gt;abc.mirk_buf = (void *) &amp;amp;tmp_long;&lt;BR /&gt;abc.mirk_buflen = sizeof(tmp_long);&lt;BR /&gt;&lt;BR /&gt;Ideally, you should modify your code to accept command line args which identify the desired variable and it's type and then you have a flexible solution with a switch{ } to handle the various variable types.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Jun 2003 15:01:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994890#M718516</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-06-12T15:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994891#M718517</link>
      <description>AFAICT = As Far As I Can Tell&lt;BR /&gt;&lt;BR /&gt;2b) The first printf() is&lt;BR /&gt;missing a ", while the second&lt;BR /&gt;printf() has an extra one:&lt;BR /&gt;&lt;BR /&gt;printf("kmem could not be opened\n);&lt;BR /&gt;&lt;BR /&gt;printf("%s"\n",rks-&amp;gt;mirk_buf); &lt;BR /&gt;&lt;BR /&gt;Sounds like you figured out&lt;BR /&gt;how to handle the buffer&lt;BR /&gt;pointers &amp;amp; such.&lt;BR /&gt;&lt;BR /&gt;As for the "integral value&lt;BR /&gt;converted to pointer" error,&lt;BR /&gt;you need to #include&lt;BR /&gt;&lt;STRING.H&gt; to get the proto&lt;BR /&gt;for strchr().  The error&lt;BR /&gt;occurs because in the absence&lt;BR /&gt;of a prototype the compiler&lt;BR /&gt;assumes functions return&lt;BR /&gt;an int.  So in the statement&lt;BR /&gt;c = strchr(...) the lhs is&lt;BR /&gt;a pointer while the rhs is&lt;BR /&gt;(incorrectly assumed to be)&lt;BR /&gt;an int, resulting in the&lt;BR /&gt;warning.&lt;BR /&gt;&lt;BR /&gt;HTH (Hope That Helps)&lt;BR /&gt;&lt;/STRING.H&gt;</description>
      <pubDate>Thu, 12 Jun 2003 15:44:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994891#M718517</guid>
      <dc:creator>Gregory Fruth</dc:creator>
      <dc:date>2003-06-12T15:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994892#M718518</link>
      <description>Thanks very much for all the assistance fellows.  I certainly appreciate it.  attached is the lastest version.&lt;BR /&gt;&lt;BR /&gt;one more question though,&lt;BR /&gt;for my kernel maxdsiz is 0X10000000&lt;BR /&gt;&lt;BR /&gt;doing a echo "maxdsiz/X" | adb ... returns&lt;BR /&gt;10000&lt;BR /&gt;&lt;BR /&gt;kmtune returns the appropriate value, but how would i get the value using adb?&lt;BR /&gt;&lt;BR /&gt;thanks alot again&lt;BR /&gt;curt</description>
      <pubDate>Fri, 13 Jun 2003 07:51:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994892#M718518</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-06-13T07:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994893#M718519</link>
      <description>noticed a couple of mistakes in the previous post.  here is corrected version</description>
      <pubDate>Fri, 13 Jun 2003 07:59:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994893#M718519</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-06-13T07:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: some questions about a C program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994894#M718520</link>
      <description>Hi Curt:&lt;BR /&gt;&lt;BR /&gt;You asked, '...one more question though, for my kernel maxdsiz is 0X10000000 [but] doing a echo "maxdsiz/X" | adb " ... returns &lt;BR /&gt;10000' ...&lt;BR /&gt;&lt;BR /&gt;That is correct.  The 'maxdsize' value returned is in *pages*.  In your case the PAGE_SIZE is undoubtedly 4096, although you can verify this by doing:&lt;BR /&gt;&lt;BR /&gt;# getconf PAGE_SIZE&lt;BR /&gt;&lt;BR /&gt;...4096 decimal is 0x1000 so:&lt;BR /&gt;&lt;BR /&gt;...'adb' returned: 0x10000 pages &lt;BR /&gt;&lt;BR /&gt;...or: 0x10000 * 0x1000 = 0x10000000&lt;BR /&gt;&lt;BR /&gt;...as reported by 'kmtune', or in decimal: 268435456&lt;BR /&gt;                  &lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 13 Jun 2003 10:27:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/some-questions-about-a-c-program/m-p/2994894#M718520</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-06-13T10:27:49Z</dc:date>
    </item>
  </channel>
</rss>

