Newbie Question - Help with design
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Newbie Question - Help with design




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Newbie Question - Help with design  
Jamie


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:18 PM



Hello,

I am studying the C language, and I work mostly with FreeBSD at my job.
I need to write a program which will check all of the files in a
directory, and if one is over 20 megs, I need to compress it and move it
to an archive directory.

I realize that it would be very easy to do this with a shell script,
but since I am studying C, I would like to make a C program to do the job
for the coding practice.

Most of the program is simple, but I don't know what to do about the
compression part. Easy to do with gzip, but, like I say, I'd like to be
able to do this in my program.

Can anyone offer some suggestions as to how I would go about this?
Maybe it's best if I just write the shell program, though I would really
like to start doing C work at the office.


Thanks!


- Jamie






Greetings from Minneapolis, MN, United States

"A friend is someone who lets you have total freedom to be yourself."






[ Post a follow-up to this message ]



    Re: Newbie Question - Help with design  
Mike Chirico


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:18 PM


"Jamie" <jamie@gnulife.org> wrote in message
news:20031212190126.L96527-100000@floyd.gnulife.org...
quote:
> > > Hello, > > I am studying the C language, and I work mostly with FreeBSD at my job. > I need to write a program which will check all of the files in a > directory, and if one is over 20 megs, I need to compress it and move it > to an archive directory. > > I realize that it would be very easy to do this with a shell script, > but since I am studying C, I would like to make a C program to do the job > for the coding practice.
Well, for the people who have to uncompress that data, I'd recommend calling the "zlib" library from your C program. http://www.gzip.org/zlib/ Take a look at minigzip.c in the download, which does it all. It can be compiled as follows: gcc minigzip.c -lz -o minigzip And, anyone who has to use the files can just "gunzip" them; which will probably keep them happy. Regards, Mike Chirico




[ Post a follow-up to this message ]



    Re: Newbie Question - Help with design  
examnotes


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:18 PM

"Mike Chirico" <mchirico@comcast.net> writes:
quote:
> "Jamie" <jamie@gnulife.org> wrote in message > news:20031212190126.L96527-100000@floyd.gnulife.org... > > Well, for the people who have to uncompress that data, I'd recommend calli ng > the "zlib" library from your C program.
Why not just system("gzip ...")? You might want to learn zlib, of course. -- Måns Rullgård mru@kth.se




[ Post a follow-up to this message ]



    Re: Newbie Question - Help with design  
Jamie


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:18 PM

On Sat, 13 Dec 2003, [iso-8859-1] M=E5ns Rullg=E5rd wrote:
quote:
> "Mike Chirico" <mchirico@comcast.net> writes: > job.[QUOTE] it[QUOTE] ,[QUOTE] job[QUOTE] lling[QUOTE] > > Why not just system("gzip ...")? You might want to learn zlib, of course=
=2E
quote:
>
I considered it, but I'd like to try including the compression library in my program for the experience. I am going to take a look at the info Mike Chirico sent and see if I can use some of that code in my program. Thanks for the suggestion, - Jamie Greetings from Minneapolis, MN, United States "A friend is someone who lets you have total freedom to be yourself."




[ Post a follow-up to this message ]



    Re: Newbie Question - Help with design  
Konstantinos Peletidis


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:18 PM

On Sat, 13 Dec 2003 03:21:12 +0100
mru@kth.se (M=E5ns Rullg=E5rd) wrote:
quote:
> "Mike Chirico" <mchirico@comcast.net> writes: >=20 >=20 > Why not just system("gzip ...")? You might want to learn zlib, of > course.
Hello, I don't think using system(3) is a good idea. Especially if there is a chance the program you are writing is going to be given suid or sgid privileges. Quoting from the Linux man page of system(3): <QUOTE> Do not use system() from a program with suid or sgid priv- ileges, because strange values for some environment vari- ables might be used to subvert system integrity. Use the exec(3) family of functions instead, but not execlp(3) or execvp(3). </QUOTE> Just my 2 eurocents --=20 Konstantinos Peletidis Electronic & Computer Engineer Please remove strings "foo" and "bar" from my address before sending me mail.




[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:25 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register